vfs: drop unnecessary cache_purge()s

2023-07-16 Thread Thordur Bjornsson
VOP_RECLAIM is only ever called from vclean() to cleanup fs dependent
data, and vclean() calls cache_purge().

Makes all of the reclaim implementations the same in this regard.

diff --git sys/isofs/cd9660/cd9660_node.c sys/isofs/cd9660/cd9660_node.c
index bce99d77c22..300277f3b37 100644
--- sys/isofs/cd9660/cd9660_node.c
+++ sys/isofs/cd9660/cd9660_node.c
@@ -218,7 +218,6 @@ cd9660_reclaim(void *v)
/*
 * Purge old data structures associated with the inode.
 */
-   cache_purge(vp);
if (ip->i_devvp) {
vrele(ip->i_devvp);
ip->i_devvp = 0;
diff --git sys/msdosfs/msdosfs_denode.c sys/msdosfs/msdosfs_denode.c
index 7a33212b648..3707c97458e 100644
--- sys/msdosfs/msdosfs_denode.c
+++ sys/msdosfs/msdosfs_denode.c
@@ -600,7 +600,6 @@ msdosfs_reclaim(void *v)
/*
 * Purge old data structures associated with the denode.
 */
-   cache_purge(vp);
if (dep->de_devvp) {
vrele(dep->de_devvp);
dep->de_devvp = 0;
diff --git sys/nfs/nfs_node.c sys/nfs/nfs_node.c
index c8ac3b9bb14..38ad5db82fc 100644
--- sys/nfs/nfs_node.c
+++ sys/nfs/nfs_node.c
@@ -237,7 +237,6 @@ nfs_reclaim(void *v)
if (np->n_wcred)
crfree(np->n_wcred);
 
-   cache_purge(vp);
pool_put(_node_pool, vp->v_data);
vp->v_data = NULL;
 
diff --git sys/ntfs/ntfs_vnops.c sys/ntfs/ntfs_vnops.c
index d239112e991..d40e3d254f6 100644
--- sys/ntfs/ntfs_vnops.c
+++ sys/ntfs/ntfs_vnops.c
@@ -221,8 +221,6 @@ ntfs_reclaim(void *v)
return (error);

/* Purge old data structures associated with the inode. */
-   cache_purge(vp);
-
ntfs_frele(fp);
ntfs_ntput(ip);
 
diff --git sys/tmpfs/tmpfs_vnops.c sys/tmpfs/tmpfs_vnops.c
index bc1390d72c9..6ec13e686b2 100644
--- sys/tmpfs/tmpfs_vnops.c
+++ sys/tmpfs/tmpfs_vnops.c
@@ -1079,8 +1079,6 @@ tmpfs_reclaim(void *v)
racing = TMPFS_NODE_RECLAIMING(node);
rw_exit_write(>tn_nlock);
 
-   cache_purge(vp);
-
/*
 * If inode is not referenced, i.e. no links, then destroy it.
 * Note: if racing - inode is about to get a new vnode, leave it.
diff --git sys/ufs/ext2fs/ext2fs_vnops.c sys/ufs/ext2fs/ext2fs_vnops.c
index 235590d7c74..006a06b0dc8 100644
--- sys/ufs/ext2fs/ext2fs_vnops.c
+++ sys/ufs/ext2fs/ext2fs_vnops.c
@@ -1247,7 +1247,6 @@ ext2fs_reclaim(void *v)
/*
 * Purge old data structures associated with the inode.
 */
-   cache_purge(vp);
if (ip->i_devvp)
vrele(ip->i_devvp);
 



Re: iked: more ibuf cleanup

2023-07-16 Thread Theo Buehler
On Sun, Jul 16, 2023 at 04:24:15PM +0200, Claudio Jeker wrote:
> Rename ibuf_get() to ibuf_getdata() by merging the two functions together.
> I want to use ibuf_get() as part of the ibuf API so this needs to move.
> Also use ibuf_add_zero() in a place of ibuf_reserve() and remove a check
> for buf->buf == NULL in ibuf_length() which has nothing to do there.

ok tb



Re: iked: more ibuf cleanup

2023-07-16 Thread Tobias Heider
On Sun, Jul 16, 2023 at 04:24:15PM +0200, Claudio Jeker wrote:
> Rename ibuf_get() to ibuf_getdata() by merging the two functions together.
> I want to use ibuf_get() as part of the ibuf API so this needs to move.
> Also use ibuf_add_zero() in a place of ibuf_reserve() and remove a check
> for buf->buf == NULL in ibuf_length() which has nothing to do there.
> 
> -- 
> :wq Claudio

ok tobhe@

> 
> Index: iked.h
> ===
> RCS file: /cvs/src/sbin/iked/iked.h,v
> retrieving revision 1.220
> diff -u -p -r1.220 iked.h
> --- iked.h28 Jun 2023 14:10:24 -  1.220
> +++ iked.h16 Jul 2023 13:45:20 -
> @@ -1271,9 +1271,8 @@ struct ibuf *
>  int   ibuf_cat(struct ibuf *, struct ibuf *);
>  size_tibuf_length(struct ibuf *);
>  int   ibuf_setsize(struct ibuf *, size_t);
> -void *ibuf_getdata(struct ibuf *, size_t);
>  struct ibuf *
> -  ibuf_get(struct ibuf *, size_t);
> +  ibuf_getdata(struct ibuf *, size_t);
>  struct ibuf *
>ibuf_dup(struct ibuf *);
>  struct ibuf *
> Index: ikev2.c
> ===
> RCS file: /cvs/src/sbin/iked/ikev2.c,v
> retrieving revision 1.372
> diff -u -p -r1.372 ikev2.c
> --- ikev2.c   28 Jun 2023 14:10:24 -  1.372
> +++ ikev2.c   16 Jul 2023 13:54:01 -
> @@ -5829,16 +5829,20 @@ ikev2_sa_keys(struct iked *env, struct i
>   goto done;
>   }
>  
> - /* ibuf_get() returns a new buffer from the next read offset */
> - if ((sa->sa_key_d = ibuf_get(t, hash_length(prf))) == NULL ||
> + /* ibuf_getdata() returns a new buffer from the next read offset */
> + if ((sa->sa_key_d = ibuf_getdata(t, hash_length(prf))) == NULL ||
>   (!isaead &&
> - (sa->sa_key_iauth = ibuf_get(t, hash_keylength(integr))) == NULL) ||
> + (sa->sa_key_iauth = ibuf_getdata(t, hash_keylength(integr))) ==
> + NULL) ||
>   (!isaead &&
> - (sa->sa_key_rauth = ibuf_get(t, hash_keylength(integr))) == NULL) ||
> - (sa->sa_key_iencr = ibuf_get(t, cipher_keylength(encr))) == NULL ||
> - (sa->sa_key_rencr = ibuf_get(t, cipher_keylength(encr))) == NULL ||
> - (sa->sa_key_iprf = ibuf_get(t, hash_length(prf))) == NULL ||
> - (sa->sa_key_rprf = ibuf_get(t, hash_length(prf))) == NULL) {
> + (sa->sa_key_rauth = ibuf_getdata(t, hash_keylength(integr))) ==
> + NULL) ||
> + (sa->sa_key_iencr = ibuf_getdata(t, cipher_keylength(encr))) ==
> + NULL ||
> + (sa->sa_key_rencr = ibuf_getdata(t, cipher_keylength(encr))) ==
> + NULL ||
> + (sa->sa_key_iprf = ibuf_getdata(t, hash_length(prf))) == NULL ||
> + (sa->sa_key_rprf = ibuf_getdata(t, hash_length(prf))) == NULL) {
>   log_debug("%s: failed to get SA keys", SPI_SA(sa, __func__));
>   goto done;
>   }
> @@ -6307,13 +6311,13 @@ ikev2_childsa_negotiate(struct iked *env
>   csa->csa_spi.spi_size = 4;
>   }
>  
> - if (encrxf && (csa->csa_encrkey = ibuf_get(keymat,
> + if (encrxf && (csa->csa_encrkey = ibuf_getdata(keymat,
>   encrxf->xform_keylength / 8)) == NULL) {
>   log_debug("%s: failed to get CHILD SA encryption key",
>   __func__);
>   goto done;
>   }
> - if (integrxf && (csa->csa_integrkey = ibuf_get(keymat,
> + if (integrxf && (csa->csa_integrkey = ibuf_getdata(keymat,
>   integrxf->xform_keylength / 8)) == NULL) {
>   log_debug("%s: failed to get CHILD SA integrity key",
>   __func__);
> @@ -6340,13 +6344,13 @@ ikev2_childsa_negotiate(struct iked *env
>   csb->csa_local = csa->csa_peer;
>   csb->csa_peer = csa->csa_local;
>  
> - if (encrxf && (csb->csa_encrkey = ibuf_get(keymat,
> + if (encrxf && (csb->csa_encrkey = ibuf_getdata(keymat,
>   encrxf->xform_keylength / 8)) == NULL) {
>   log_debug("%s: failed to get CHILD SA encryption key",
>   __func__);
>   goto done;
>   }
> - if (integrxf && (csb->csa_integrkey = ibuf_get(keymat,
> + if (integrxf && (csb->csa_integrkey = ibuf_getdata(keymat,
>   integrxf->xform_keylength / 8)) == NULL) {
>   log_debug("%s: failed to get CHILD SA integrity key",
>   __func__);
> Index: imsg_util.c
> ===
> RCS file: /cvs/src/sbin/iked/imsg_util.c,v
> retrieving revision 1.19
> diff -u -p -r1.19 imsg_util.c
> --- imsg_util.c   19 Jun 2023 17:19:50 -  1.19
> +++ imsg_util.c   16 Jul 2023 13:59:29 -
> @@ -55,7 +55,7 @@ ibuf_new(const void *data, size_t len)
>  

iked: more ibuf cleanup

2023-07-16 Thread Claudio Jeker
Rename ibuf_get() to ibuf_getdata() by merging the two functions together.
I want to use ibuf_get() as part of the ibuf API so this needs to move.
Also use ibuf_add_zero() in a place of ibuf_reserve() and remove a check
for buf->buf == NULL in ibuf_length() which has nothing to do there.

-- 
:wq Claudio

Index: iked.h
===
RCS file: /cvs/src/sbin/iked/iked.h,v
retrieving revision 1.220
diff -u -p -r1.220 iked.h
--- iked.h  28 Jun 2023 14:10:24 -  1.220
+++ iked.h  16 Jul 2023 13:45:20 -
@@ -1271,9 +1271,8 @@ struct ibuf *
 int ibuf_cat(struct ibuf *, struct ibuf *);
 size_t  ibuf_length(struct ibuf *);
 int ibuf_setsize(struct ibuf *, size_t);
-void   *ibuf_getdata(struct ibuf *, size_t);
 struct ibuf *
-ibuf_get(struct ibuf *, size_t);
+ibuf_getdata(struct ibuf *, size_t);
 struct ibuf *
 ibuf_dup(struct ibuf *);
 struct ibuf *
Index: ikev2.c
===
RCS file: /cvs/src/sbin/iked/ikev2.c,v
retrieving revision 1.372
diff -u -p -r1.372 ikev2.c
--- ikev2.c 28 Jun 2023 14:10:24 -  1.372
+++ ikev2.c 16 Jul 2023 13:54:01 -
@@ -5829,16 +5829,20 @@ ikev2_sa_keys(struct iked *env, struct i
goto done;
}
 
-   /* ibuf_get() returns a new buffer from the next read offset */
-   if ((sa->sa_key_d = ibuf_get(t, hash_length(prf))) == NULL ||
+   /* ibuf_getdata() returns a new buffer from the next read offset */
+   if ((sa->sa_key_d = ibuf_getdata(t, hash_length(prf))) == NULL ||
(!isaead &&
-   (sa->sa_key_iauth = ibuf_get(t, hash_keylength(integr))) == NULL) ||
+   (sa->sa_key_iauth = ibuf_getdata(t, hash_keylength(integr))) ==
+   NULL) ||
(!isaead &&
-   (sa->sa_key_rauth = ibuf_get(t, hash_keylength(integr))) == NULL) ||
-   (sa->sa_key_iencr = ibuf_get(t, cipher_keylength(encr))) == NULL ||
-   (sa->sa_key_rencr = ibuf_get(t, cipher_keylength(encr))) == NULL ||
-   (sa->sa_key_iprf = ibuf_get(t, hash_length(prf))) == NULL ||
-   (sa->sa_key_rprf = ibuf_get(t, hash_length(prf))) == NULL) {
+   (sa->sa_key_rauth = ibuf_getdata(t, hash_keylength(integr))) ==
+   NULL) ||
+   (sa->sa_key_iencr = ibuf_getdata(t, cipher_keylength(encr))) ==
+   NULL ||
+   (sa->sa_key_rencr = ibuf_getdata(t, cipher_keylength(encr))) ==
+   NULL ||
+   (sa->sa_key_iprf = ibuf_getdata(t, hash_length(prf))) == NULL ||
+   (sa->sa_key_rprf = ibuf_getdata(t, hash_length(prf))) == NULL) {
log_debug("%s: failed to get SA keys", SPI_SA(sa, __func__));
goto done;
}
@@ -6307,13 +6311,13 @@ ikev2_childsa_negotiate(struct iked *env
csa->csa_spi.spi_size = 4;
}
 
-   if (encrxf && (csa->csa_encrkey = ibuf_get(keymat,
+   if (encrxf && (csa->csa_encrkey = ibuf_getdata(keymat,
encrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA encryption key",
__func__);
goto done;
}
-   if (integrxf && (csa->csa_integrkey = ibuf_get(keymat,
+   if (integrxf && (csa->csa_integrkey = ibuf_getdata(keymat,
integrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA integrity key",
__func__);
@@ -6340,13 +6344,13 @@ ikev2_childsa_negotiate(struct iked *env
csb->csa_local = csa->csa_peer;
csb->csa_peer = csa->csa_local;
 
-   if (encrxf && (csb->csa_encrkey = ibuf_get(keymat,
+   if (encrxf && (csb->csa_encrkey = ibuf_getdata(keymat,
encrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA encryption key",
__func__);
goto done;
}
-   if (integrxf && (csb->csa_integrkey = ibuf_get(keymat,
+   if (integrxf && (csb->csa_integrkey = ibuf_getdata(keymat,
integrxf->xform_keylength / 8)) == NULL) {
log_debug("%s: failed to get CHILD SA integrity key",
__func__);
Index: imsg_util.c
===
RCS file: /cvs/src/sbin/iked/imsg_util.c,v
retrieving revision 1.19
diff -u -p -r1.19 imsg_util.c
--- imsg_util.c 19 Jun 2023 17:19:50 -  1.19
+++ imsg_util.c 16 Jul 2023 13:59:29 -
@@ -55,7 +55,7 @@ ibuf_new(const void *data, size_t len)
return (buf);
 
if (data == NULL) {
-   if (ibuf_reserve(buf, len) == NULL) {
+   if (ibuf_add_zero(buf, len) != 0) {