summaryrefslogtreecommitdiff
path: root/sys/fs
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2021-10-20 03:08:16 +0000
committerthorpej <thorpej@NetBSD.org>2021-10-20 03:08:16 +0000
commit8abbca48b237c9edc3ffb387e9074ddcff8b645d (patch)
tree41861906d64ee2ea60ac288b69c2b14012886108 /sys/fs
parent6ddcd84a3618d73c6acd9eb1ba9c92a563467245 (diff)
Overhaul of the EVFILT_VNODE kevent(2) filter:
- Centralize vnode kevent handling in the VOP_*() wrappers, rather than forcing each individual file system to deal with it (except VOP_RENAME(), because VOP_RENAME() is a mess and we currently have 2 different ways of handling it; at least it's reasonably well-centralized in the "new" way). - Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ, compatible with the same events in FreeBSD. - Track which kevent notifications clients are interested in receiving to avoid doing work for events no one cares about (avoiding, e.g. taking locks and traversing the klist to send a NOTE_WRITE when someone is merely watching for a file to be deleted, for example). In support of the above: - Add support in vnode_if.sh for specifying PRE- and POST-op handlers, to be invoked before and after vop_pre() and vop_post(), respectively. Basic idea from FreeBSD, but implemented differently. - Add support in vnode_if.sh for specifying CONTEXT fields in the vop_*_args structures. These context fields are used to convey information between the file system VOP function and the VOP wrapper, but do not occupy an argument slot in the VOP_*() call itself. These context fields are initialized and subsequently interpreted by PRE- and POST-op handlers. - Version VOP_REMOVE(), uses the a context field for the file system to report back the resulting link count of the target vnode. Return this in tmpfs, udf, nfs, chfs, ext2fs, lfs, and ufs. NetBSD 9.99.92.
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c19
-rw-r--r--sys/fs/nilfs/nilfs_vnops.c24
-rw-r--r--sys/fs/ptyfs/ptyfs_vnops.c5
-rw-r--r--sys/fs/puffs/puffs_vnops.c9
-rw-r--r--sys/fs/sysvbfs/sysvbfs_vnops.c13
-rw-r--r--sys/fs/tmpfs/tmpfs_rename.c24
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c22
-rw-r--r--sys/fs/tmpfs/tmpfs_vnops.c14
-rw-r--r--sys/fs/udf/udf_rename.c26
-rw-r--r--sys/fs/udf/udf_vnops.c32
-rw-r--r--sys/fs/union/union_vnops.c9
-rw-r--r--sys/fs/unionfs/unionfs_vnops.c2
-rw-r--r--sys/fs/v7fs/v7fs_vnops.c7
13 files changed, 86 insertions, 120 deletions
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index 7425b5de334..81b11648620 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vnops.c,v 1.106 2021/07/18 23:57:14 dholland Exp $ */
+/* $NetBSD: msdosfs_vnops.c,v 1.107 2021/10/20 03:08:17 thorpej Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.106 2021/07/18 23:57:14 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.107 2021/10/20 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -151,7 +151,6 @@ msdosfs_create(void *v)
DETIMES(&ndirent, NULL, NULL, NULL, pdep->de_pmp->pm_gmtoff);
if ((error = createde(&ndirent, pdep, &dep, cnp)) != 0)
goto bad;
- VN_KNOTE(ap->a_dvp, NOTE_WRITE);
*ap->a_vpp = DETOV(dep);
cache_enter(ap->a_dvp, *ap->a_vpp, cnp->cn_nameptr, cnp->cn_namelen,
cnp->cn_flags);
@@ -427,7 +426,6 @@ msdosfs_setattr(void *v)
}
if (de_changed) {
- VN_KNOTE(vp, NOTE_ATTRIB);
error = deupdat(dep, 1);
if (error)
goto bad;
@@ -545,7 +543,7 @@ msdosfs_write(void *v)
int a_ioflag;
kauth_cred_t a_cred;
} */ *ap = v;
- int resid, extended = 0;
+ int resid;
int error = 0;
int ioflag = ap->a_ioflag;
u_long osize;
@@ -625,7 +623,6 @@ msdosfs_write(void *v)
if (rem > 0)
ubc_zerorange(&vp->v_uobj, (off_t)dep->de_FileSize,
rem, UBC_VNODE_FLAGS(vp));
- extended = 1;
}
do {
@@ -664,8 +661,6 @@ msdosfs_write(void *v)
* to the size it was before the write was attempted.
*/
errexit:
- if (resid > uio->uio_resid)
- VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0));
if (error) {
detrunc(dep, osize, ioflag & IO_SYNC, NOCRED);
uio->uio_offset -= resid - uio->uio_resid;
@@ -717,10 +712,11 @@ msdosfs_update(struct vnode *vp, const struct timespec *acc,
int
msdosfs_remove(void *v)
{
- struct vop_remove_v2_args /* {
+ struct vop_remove_v3_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
+ nlink_t ctx_vp_new_nlink;
} */ *ap = v;
struct denode *dep = VTODE(ap->a_vp);
struct denode *ddep = VTODE(ap->a_dvp);
@@ -734,8 +730,6 @@ msdosfs_remove(void *v)
printf("msdosfs_remove(), dep %p, usecount %d\n",
dep, vrefcnt(ap->a_vp));
#endif
- VN_KNOTE(ap->a_vp, NOTE_DELETE);
- VN_KNOTE(ap->a_dvp, NOTE_WRITE);
if (ddep == dep)
vrele(ap->a_vp);
else
@@ -1255,7 +1249,6 @@ msdosfs_mkdir(void *v)
ndirent.de_devvp = pdep->de_devvp;
if ((error = createde(&ndirent, pdep, &dep, cnp)) != 0)
goto bad;
- VN_KNOTE(ap->a_dvp, NOTE_WRITE | NOTE_LINK);
*ap->a_vpp = DETOV(dep);
return (0);
@@ -1315,7 +1308,6 @@ msdosfs_rmdir(void *v)
* directory. Since dos filesystems don't do this we just purge
* the name cache and let go of the parent directory denode.
*/
- VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
cache_purge(dvp);
/*
* Truncate the directory that is being deleted.
@@ -1323,7 +1315,6 @@ msdosfs_rmdir(void *v)
error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred);
cache_purge(vp);
out:
- VN_KNOTE(vp, NOTE_DELETE);
vput(vp);
return (error);
}
diff --git a/sys/fs/nilfs/nilfs_vnops.c b/sys/fs/nilfs/nilfs_vnops.c
index 0a2f14d3486..9bf1aa33d03 100644
--- a/sys/fs/nilfs/nilfs_vnops.c
+++ b/sys/fs/nilfs/nilfs_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.44 2021/07/24 21:31:38 andvar Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.45 2021/10/20 03:08:17 thorpej Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.44 2021/07/24 21:31:38 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.45 2021/10/20 03:08:17 thorpej Exp $");
#endif /* not lint */
@@ -213,7 +213,7 @@ nilfs_write(void *v)
struct nilfs_node *nilfs_node = VTOI(vp);
uint64_t file_size;
vsize_t len;
- int error, resid, extended;
+ int error, resid;
DPRINTF(WRITE, ("nilfs_write called\n"));
@@ -285,10 +285,6 @@ nilfs_write(void *v)
* the superuser as a precaution against tampering.
*/
- /* if we wrote a thing, note write action on vnode */
- if (resid > uio->uio_resid)
- VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0));
-
if (error) {
/* bring back file size to its former size */
/* take notice of its errors? */
@@ -1196,9 +1192,6 @@ nilfs_link(void *v)
if (error)
VOP_ABORTOP(dvp, cnp);
- VN_KNOTE(vp, NOTE_LINK);
- VN_KNOTE(dvp, NOTE_WRITE);
-
return error;
}
@@ -1362,7 +1355,7 @@ nilfs_rename(void *v)
}
/* remove existing entry if present */
- if (tvp)
+ if (tvp)
nilfs_dir_detach(tdnode->ump, tdnode, tnode, tcnp);
/* create new directory entry for the node */
@@ -1401,10 +1394,11 @@ out_unlocked:
int
nilfs_remove(void *v)
{
- struct vop_remove_v2_args /* {
+ struct vop_remove_v3_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
+ nlink_t ctx_vp_new_nlink;
} */ *ap = v;
struct vnode *dvp = ap->a_dvp;
struct vnode *vp = ap->a_vp;
@@ -1423,11 +1417,6 @@ nilfs_remove(void *v)
error = EPERM;
}
- if (error == 0) {
- VN_KNOTE(vp, NOTE_DELETE);
- VN_KNOTE(dvp, NOTE_WRITE);
- }
-
if (dvp == vp)
vrele(vp);
else
@@ -1476,7 +1465,6 @@ nilfs_rmdir(void *v)
if (error == 0) {
cache_purge(vp);
// cache_purge(dvp); /* XXX from msdosfs, why? */
- VN_KNOTE(vp, NOTE_DELETE);
}
DPRINTFIF(NODE, error, ("\tgot error removing file\n"));
diff --git a/sys/fs/ptyfs/ptyfs_vnops.c b/sys/fs/ptyfs/ptyfs_vnops.c
index 0c007f51848..89cd5f1df7d 100644
--- a/sys/fs/ptyfs/ptyfs_vnops.c
+++ b/sys/fs/ptyfs/ptyfs_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ptyfs_vnops.c,v 1.66 2021/07/18 23:57:34 dholland Exp $ */
+/* $NetBSD: ptyfs_vnops.c,v 1.67 2021/10/20 03:08:17 thorpej Exp $ */
/*
* Copyright (c) 1993, 1995
@@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.66 2021/07/18 23:57:34 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.67 2021/10/20 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -477,7 +477,6 @@ ptyfs_setattr(void *v)
if (error)
return error;
}
- VN_KNOTE(vp, NOTE_ATTRIB);
return 0;
}
diff --git a/sys/fs/puffs/puffs_vnops.c b/sys/fs/puffs/puffs_vnops.c
index d1b6dfe9d43..8ccfd8e483e 100644
--- a/sys/fs/puffs/puffs_vnops.c
+++ b/sys/fs/puffs/puffs_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_vnops.c,v 1.222 2021/07/24 21:31:38 andvar Exp $ */
+/* $NetBSD: puffs_vnops.c,v 1.223 2021/10/20 03:08:17 thorpej Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.222 2021/07/24 21:31:38 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.223 2021/10/20 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -1796,11 +1796,12 @@ callremove(struct puffs_mount *pmp, puffs_cookie_t dck, puffs_cookie_t ck,
int
puffs_vnop_remove(void *v)
{
- struct vop_remove_v2_args /* {
+ struct vop_remove_v3_args /* {
const struct vnodeop_desc *a_desc;
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
+ nlink_t ctx_vp_new_nlink;
} */ *ap = v;
PUFFS_MSG_VARS(vn, remove);
struct vnode *dvp = ap->a_dvp;
@@ -2172,6 +2173,8 @@ puffs_vnop_rename(void *v)
if (PUFFS_USE_DOTDOTCACHE(pmp) &&
(VPTOPP(fvp)->pn_parent != tdvp))
update_parent(fvp, tdvp);
+
+ /* XXX Update ap->ctx_vp_new_nlink */
}
diff --git a/sys/fs/sysvbfs/sysvbfs_vnops.c b/sys/fs/sysvbfs/sysvbfs_vnops.c
index 5b05755cc48..2d5e3dc9353 100644
--- a/sys/fs/sysvbfs/sysvbfs_vnops.c
+++ b/sys/fs/sysvbfs/sysvbfs_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sysvbfs_vnops.c,v 1.67 2020/06/27 17:29:18 christos Exp $ */
+/* $NetBSD: sysvbfs_vnops.c,v 1.68 2021/10/20 03:08:17 thorpej Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.67 2020/06/27 17:29:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.68 2021/10/20 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -474,7 +474,6 @@ sysvbfs_write(void *arg)
struct uio *uio = a->a_uio;
int advice = IO_ADV_DECODE(a->a_ioflag);
struct sysvbfs_node *bnode = v->v_data;
- bool extended = false;
vsize_t sz;
int err = 0;
@@ -489,7 +488,6 @@ sysvbfs_write(void *arg)
if (bnode->size < uio->uio_offset + uio->uio_resid) {
sysvbfs_file_setsize(v, uio->uio_offset + uio->uio_resid);
- extended = true;
}
while (uio->uio_resid > 0) {
@@ -503,19 +501,18 @@ sysvbfs_write(void *arg)
if (err)
sysvbfs_file_setsize(v, bnode->size - uio->uio_resid);
- VN_KNOTE(v, NOTE_WRITE | (extended ? NOTE_EXTEND : 0));
-
return err;
}
int
sysvbfs_remove(void *arg)
{
- struct vop_remove_v2_args /* {
+ struct vop_remove_v3_args /* {
struct vnodeop_desc *a_desc;
struct vnode * a_dvp;
struct vnode * a_vp;
struct componentname * a_cnp;
+ nlink_t ctx_vp_new_nlink;
} */ *ap = arg;
struct vnode *vp = ap->a_vp;
struct vnode *dvp = ap->a_dvp;
@@ -534,8 +531,6 @@ sysvbfs_remove(void *arg)
if ((err = bfs_file_delete(bfs, ap->a_cnp->cn_nameptr, true)) != 0)
DPRINTF("%s: bfs_file_delete failed.\n", __func__);
- VN_KNOTE(ap->a_vp, NOTE_DELETE);
- VN_KNOTE(ap->a_dvp, NOTE_WRITE);
if (dvp == vp)
vrele(vp);
else
diff --git a/sys/fs/tmpfs/tmpfs_rename.c b/sys/fs/tmpfs/tmpfs_rename.c
index 583ee3131a1..18eb01d7c17 100644
--- a/sys/fs/tmpfs/tmpfs_rename.c
+++ b/sys/fs/tmpfs/tmpfs_rename.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_rename.c,v 1.10 2019/12/03 04:59:05 riastradh Exp $ */
+/* $NetBSD: tmpfs_rename.c,v 1.11 2021/10/20 03:08:17 thorpej Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.10 2019/12/03 04:59:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.11 2021/10/20 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@@ -264,7 +264,7 @@ tmpfs_gro_rename(struct mount *mp, kauth_cred_t cred,
struct vnode *fdvp, struct componentname *fcnp,
void *fde, struct vnode *fvp,
struct vnode *tdvp, struct componentname *tcnp,
- void *tde, struct vnode *tvp)
+ void *tde, struct vnode *tvp, nlink_t *tvp_nlinkp)
{
tmpfs_node_t *fdnode = VP_TO_TMPFS_DIR(fdvp);
tmpfs_node_t *tdnode = VP_TO_TMPFS_DIR(tdvp);
@@ -317,14 +317,6 @@ tmpfs_gro_rename(struct mount *mp, kauth_cred_t cred,
if (fdvp != tdvp) {
tmpfs_dir_detach(fdnode, *fdep);
tmpfs_dir_attach(tdnode, *fdep, VP_TO_TMPFS_NODE(fvp));
- } else if (tvp == NULL) {
- /*
- * We are changing the directory. tmpfs_dir_attach and
- * tmpfs_dir_detach note the events for us, but for
- * this case we don't call them, so we must note the
- * event explicitly.
- */
- VN_KNOTE(fdvp, NOTE_WRITE);
}
/*
@@ -350,6 +342,8 @@ tmpfs_gro_rename(struct mount *mp, kauth_cred_t cred,
}
tmpfs_dir_detach(tdnode, *tdep);
tmpfs_free_dirent(VFS_TO_TMPFS(mp), *tdep);
+
+ *tvp_nlinkp = VP_TO_TMPFS_NODE(tvp)->tn_links;
}
/*
@@ -377,8 +371,6 @@ tmpfs_gro_rename(struct mount *mp, kauth_cred_t cred,
tmpfs_update(tdvp, TMPFS_UPDATE_MTIME | TMPFS_UPDATE_CTIME);
tmpfs_update(fvp, TMPFS_UPDATE_CTIME);
- VN_KNOTE(fvp, NOTE_RENAME);
-
genfs_rename_cache_purge(fdvp, fvp, tdvp, tvp);
return 0;
@@ -390,7 +382,8 @@ tmpfs_gro_rename(struct mount *mp, kauth_cred_t cred,
*/
static int
tmpfs_gro_remove(struct mount *mp, kauth_cred_t cred,
- struct vnode *dvp, struct componentname *cnp, void *de, struct vnode *vp)
+ struct vnode *dvp, struct componentname *cnp, void *de, struct vnode *vp,
+ nlink_t *tvp_nlinkp)
{
tmpfs_node_t *dnode = VP_TO_TMPFS_DIR(dvp);
struct tmpfs_dirent **dep = de;
@@ -413,6 +406,9 @@ tmpfs_gro_remove(struct mount *mp, kauth_cred_t cred,
tmpfs_free_dirent(VFS_TO_TMPFS(mp), *dep);
tmpfs_update(dvp, TMPFS_UPDATE_MTIME | TMPFS_UPDATE_CTIME);
+ KASSERT((*dep)->td_node == VP_TO_TMPFS_NODE(vp));
+ *tvp_nlinkp = VP_TO_TMPFS_NODE(vp)->tn_links;
+
return 0;
}
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 221077f74b1..75f1b6e1d59 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_subr.c,v 1.113 2020/09/05 16:30:12 riastradh Exp $ */
+/* $NetBSD: tmpfs_subr.c,v 1.114 2021/10/20 03:08:17 thorpej Exp $ */
/*
* Copyright (c) 2005-2020 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.113 2020/09/05 16:30:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.114 2021/10/20 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/cprng.h>
@@ -537,7 +537,6 @@ tmpfs_dir_attach(tmpfs_node_t *dnode, tmpfs_dirent_t *de, tmpfs_node_t *node)
TMPFS_VALIDATE_DIR(node);
}
- VN_KNOTE(dvp, events);
}
/*
@@ -554,8 +553,7 @@ void
tmpfs_dir_detach(tmpfs_node_t *dnode, tmpfs_dirent_t *de)
{
tmpfs_node_t *node = de->td_node;
- vnode_t *vp, *dvp = dnode->tn_vnode;
- int events = NOTE_WRITE;
+ vnode_t *dvp = dnode->tn_vnode;
KASSERT(dvp == NULL || VOP_ISLOCKED(dvp));
@@ -566,11 +564,6 @@ tmpfs_dir_detach(tmpfs_node_t *dnode, tmpfs_dirent_t *de)
KASSERT(node->tn_links > 0);
node->tn_links--;
- if ((vp = node->tn_vnode) != NULL) {
- KASSERT(VOP_ISLOCKED(vp));
- VN_KNOTE(vp, node->tn_links ? NOTE_LINK : NOTE_DELETE);
- }
-
/* If directory - decrease the link count of parent. */
if (node->tn_type == VDIR) {
KASSERT(node->tn_spec.tn_dir.tn_parent == dnode);
@@ -578,7 +571,6 @@ tmpfs_dir_detach(tmpfs_node_t *dnode, tmpfs_dirent_t *de)
KASSERT(dnode->tn_links > 0);
dnode->tn_links--;
- events |= NOTE_LINK;
}
}
de->td_node = NULL;
@@ -593,7 +585,6 @@ tmpfs_dir_detach(tmpfs_node_t *dnode, tmpfs_dirent_t *de)
if (dvp) {
uvm_vnp_setsize(dvp, dnode->tn_size);
- VN_KNOTE(dvp, events);
}
}
@@ -952,9 +943,6 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize)
/* Decrease the used-memory counter. */
tmpfs_mem_decr(tmp, (oldpages - newpages) << PAGE_SHIFT);
}
- if (newsize > oldsize) {
- VN_KNOTE(vp, NOTE_EXTEND);
- }
return 0;
}
@@ -1014,7 +1002,6 @@ tmpfs_chflags(vnode_t *vp, int flags, kauth_cred_t cred, lwp_t *l)
node->tn_flags = flags;
}
tmpfs_update(vp, TMPFS_UPDATE_CTIME);
- VN_KNOTE(vp, NOTE_ATTRIB);
return 0;
}
@@ -1044,7 +1031,6 @@ tmpfs_chmod(vnode_t *vp, mode_t mode, kauth_cred_t cred, lwp_t *l)
}
node->tn_mode = (mode & ALLPERMS);
tmpfs_update(vp, TMPFS_UPDATE_CTIME);
- VN_KNOTE(vp, NOTE_ATTRIB);
cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true);
return 0;
}
@@ -1089,7 +1075,6 @@ tmpfs_chown(vnode_t *vp, uid_t uid, gid_t gid, kauth_cred_t cred, lwp_t *l)
node->tn_uid = uid;
node->tn_gid = gid;
tmpfs_update(vp, TMPFS_UPDATE_CTIME);
- VN_KNOTE(vp, NOTE_ATTRIB);
cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true);
return 0;
}
@@ -1185,7 +1170,6 @@ tmpfs_chtimes(vnode_t *vp, const struct timespec *atime,
node->tn_birthtime = *btime;
}
mutex_exit(&node->tn_timelock);
- VN_KNOTE(vp, NOTE_ATTRIB);
return 0;
}
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index 9c8df3b4639..210545fbe67 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_vnops.c,v 1.147 2021/07/18 23:57:14 dholland Exp $ */
+/* $NetBSD: tmpfs_vnops.c,v 1.148 2021/10/20 03:08:17 thorpej Exp $ */
/*
* Copyright (c) 2005, 2006, 2007, 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.147 2021/07/18 23:57:14 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.148 2021/10/20 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@@ -648,7 +648,6 @@ tmpfs_write(void *v)
}
tmpfs_update(vp, TMPFS_UPDATE_MTIME | TMPFS_UPDATE_CTIME);
- VN_KNOTE(vp, NOTE_WRITE);
out:
if (error) {
KASSERT(oldsize == node->tn_size);
@@ -685,10 +684,11 @@ tmpfs_fsync(void *v)
int
tmpfs_remove(void *v)
{
- struct vop_remove_v2_args /* {
+ struct vop_remove_v3_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
+ nlink_t ctx_vp_new_nlink;
} */ *ap = v;
vnode_t *dvp = ap->a_dvp, *vp = ap->a_vp;
tmpfs_node_t *dnode, *node;
@@ -747,6 +747,7 @@ tmpfs_remove(void *v)
/* We removed a hard link. */
tflags |= TMPFS_UPDATE_CTIME;
}
+ ap->ctx_vp_new_nlink = node->tn_links;
tmpfs_update(dvp, tflags);
error = 0;
out:
@@ -814,10 +815,7 @@ tmpfs_link(void *v)
tmpfs_dir_attach(dnode, de, node);
tmpfs_update(dvp, TMPFS_UPDATE_MTIME | TMPFS_UPDATE_CTIME);
- /* Update the timestamps and trigger the event. */
- if (node->tn_vnode) {
- VN_KNOTE(node->tn_vnode, NOTE_LINK);
- }
+ /* Update the timestamps. */
tmpfs_update(vp, TMPFS_UPDATE_CTIME);
error = 0;
out:
diff --git a/sys/fs/udf/udf_rename.c b/sys/fs/udf/udf_rename.c
index a7be766eb92..5be685d676c 100644
--- a/sys/fs/udf/udf_rename.c
+++ b/sys/fs/udf/udf_rename.c
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_rename.c,v 1.13 2020/01/17 20:08:08 ad Exp $ */
+/* $NetBSD: udf_rename.c,v 1.14 2021/10/20 03:08:17 thorpej Exp $ */
/*
* Copyright (c) 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udf_rename.c,v 1.13 2020/01/17 20:08:08 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_rename.c,v 1.14 2021/10/20 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@@ -322,7 +322,7 @@ udf_gro_rename(struct mount *mp, kauth_cred_t cred,
struct vnode *fdvp, struct componentname *fcnp,
void *fde, struct vnode *fvp,
struct vnode *tdvp, struct componentname *tcnp,
- void *tde, struct vnode *tvp)
+ void *tde, struct vnode *tvp, nlink_t *tvp_nlinkp)
{
struct udf_node *fnode, *fdnode, *tnode, *tdnode;
struct vattr fvap;
@@ -364,8 +364,15 @@ udf_gro_rename(struct mount *mp, kauth_cred_t cred,
return error;
/* remove existing entry if present */
- if (tvp)
+ if (tvp) {
udf_dir_detach(tdnode->ump, tdnode, tnode, tcnp);
+ if (tnode->fe) {
+ *tvp_nlinkp = udf_rw16(tnode->fe->link_cnt);
+ } else {
+ KASSERT(tnode->efe != NULL);
+ *tvp_nlinkp = udf_rw16(tnode->efe->link_cnt);
+ }
+ }
/* create new directory entry for the node */
error = udf_dir_attach(tdnode->ump, tdnode, fnode, &fvap, tcnp);
@@ -384,7 +391,6 @@ udf_gro_rename(struct mount *mp, kauth_cred_t cred,
goto rollback;
}
- VN_KNOTE(fvp, NOTE_RENAME);
genfs_rename_cache_purge(fdvp, fvp, tdvp, tvp);
return 0;
@@ -404,7 +410,8 @@ rollback_attach:
*/
static int
udf_gro_remove(struct mount *mp, kauth_cred_t cred,
- struct vnode *dvp, struct componentname *cnp, void *de, struct vnode *vp)
+ struct vnode *dvp, struct componentname *cnp, void *de, struct vnode *vp,
+ nlink_t *tvp_nlinkp)
{
struct udf_node *dir_node, *udf_node;
@@ -426,6 +433,13 @@ udf_gro_remove(struct mount *mp, kauth_cred_t cred,
udf_node = VTOI(vp);
udf_dir_detach(dir_node->ump, dir_node, udf_node, cnp);
+ if (udf_node->fe) {
+ *tvp_nlinkp = udf_rw16(udf_node->fe->link_cnt);
+ } else {
+ KASSERT(udf_node->efe != NULL);
+ *tvp_nlinkp = udf_rw16(udf_node->efe->link_cnt);
+ }
+
return 0;
}
diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c
index 29912621240..a140c40c41a 100644
--- a/sys/fs/udf/udf_vnops.c
+++ b/sys/fs/udf/udf_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.116 2021/07/24 21:31:38 andvar Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.117 2021/10/20 03:08:17 thorpej Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.116 2021/07/24 21:31:38 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.117 2021/10/20 03:08:17 thorpej Exp $");
#endif /* not lint */
@@ -398,10 +398,6 @@ udf_write(void *v)
* the superuser as a precaution against tampering.
*/
- /* if we wrote a thing, note write action on vnode */
- if (resid > uio->uio_resid)
- VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0));
-
if (error) {
/* bring back file size to its former size */
/* take notice of its errors? */
@@ -1139,7 +1135,6 @@ udf_chsize(struct vnode *vp, u_quad_t newsize, kauth_cred_t cred)
udf_node->i_flags |= IN_CHANGE | IN_MODIFY;
if (vp->v_mount->mnt_flag & MNT_RELATIME)
udf_node->i_flags |= IN_ACCESS;
- VN_KNOTE(vp, NOTE_ATTRIB | (extended ? NOTE_EXTEND : 0));
udf_update(vp, NULL, NULL, NULL, 0);
}
@@ -1273,7 +1268,6 @@ udf_setattr(void *v)
error = udf_chtimes(vp, &vap->va_atime, &vap->va_mtime,
&vap->va_birthtime, vap->va_vaflags, cred);
}
- VN_KNOTE(vp, NOTE_ATTRIB);
return error;
}
@@ -1599,9 +1593,6 @@ udf_link(void *v)
if (error)
VOP_ABORTOP(dvp, cnp);
- VN_KNOTE(vp, NOTE_LINK);
- VN_KNOTE(dvp, NOTE_WRITE);
-
return error;
}
@@ -1939,10 +1930,11 @@ udf_readlink(void *v)
int
udf_remove(void *v)
{
- struct vop_remove_v2_args /* {
+ struct vop_remove_v3_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
+ nlink_t ctx_vp_new_nlink;
} */ *ap = v;
struct vnode *dvp = ap->a_dvp;
struct vnode *vp = ap->a_vp;
@@ -1956,16 +1948,21 @@ udf_remove(void *v)
if (vp->v_type != VDIR) {
error = udf_dir_detach(ump, dir_node, udf_node, cnp);
DPRINTFIF(NODE, error, ("\tgot error removing file\n"));
+ if (error == 0) {
+ if (udf_node->fe) {
+ ap->ctx_vp_new_nlink =
+ udf_rw16(udf_node->fe->link_cnt);
+ } else {
+ KASSERT(udf_node->efe != NULL);
+ ap->ctx_vp_new_nlink =
+ udf_rw16(udf_node->efe->link_cnt);
+ }
+ }
} else {
DPRINTF(NODE, ("\tis a directory: perm. denied\n"));
error = EPERM;
}
- if (error == 0) {
- VN_KNOTE(vp, NOTE_DELETE);
- VN_KNOTE(dvp, NOTE_WRITE);
- }
-
if (dvp == vp)
vrele(vp);
else
@@ -2031,7 +2028,6 @@ udf_rmdir(void *v)
*/
dirhash_purge(&udf_node->dir_hash);
udf_shrink_node(udf_node, 0);
- VN_KNOTE(vp, NOTE_DELETE);
}
DPRINTFIF(NODE, error, ("\tgot error removing dir\n"));
diff --git a/sys/fs/union/union_vnops.c b/sys/fs/union/union_vnops.c
index 8900c114586..78d437b0c05 100644
--- a/sys/fs/union/union_vnops.c
+++ b/sys/fs/union/union_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: union_vnops.c,v 1.78 2021/07/04 11:24:09 hannken Exp $ */
+/* $NetBSD: union_vnops.c,v 1.79 2021/10/20 03:08:17 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993, 1994, 1995
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.78 2021/07/04 11:24:09 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.79 2021/10/20 03:08:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1179,10 +1179,11 @@ union_seek(void *v)
int
union_remove(void *v)
{
- struct vop_remove_v2_args /* {
+ struct vop_remove_v3_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
+ nlink_t ctx_vp_new_nlink;
} */ *ap = v;
int error;
struct union_node *dun = VTOUNION(ap->a_dvp);
@@ -1296,7 +1297,7 @@ union_link(void *v)
int
union_rename(void *v)
{
- struct vop_rename_args /* {
+ struct vop_rename_args /* {
struct vnode *a_fdvp;
struct vnode *a_fvp;
struct componentname *a_fcnp;
diff --git a/sys/fs/unionfs/unionfs_vnops.c b/sys/fs/unionfs/unionfs_vnops.c
index f6b0601927a..12576ac6562 100644
--- a/sys/fs/unionfs/unionfs_vnops.c
+++ b/sys/fs/unionfs/unionfs_vnops.c
@@ -893,7 +893,7 @@ unionfs_fsync(void *v)
static int
unionfs_remove(void *v)
{
- struct vop_remove_v2_args *ap = v;
+ struct vop_remove_v3_args *ap = v;
int error;
struct unionfs_node *dunp;
struct unionfs_node *unp;
diff --git a/sys/fs/v7fs/v7fs_vnops.c b/sys/fs/v7fs/v7fs_vnops.c
index a2ad30668a6..2aa7f346bc0 100644
--- a/sys/fs/v7fs/v7fs_vnops.c
+++ b/sys/fs/v7fs/v7fs_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_vnops.c,v 1.31 2020/06/27 17:29:18 christos Exp $ */
+/* $NetBSD: v7fs_vnops.c,v 1.32 2021/10/20 03:08:18 thorpej Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.31 2020/06/27 17:29:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.32 2021/10/20 03:08:18 thorpej Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
#endif
@@ -683,11 +683,12 @@ v7fs_fsync(void *v)
int
v7fs_remove(void *v)
{
- struct vop_remove_v2_args /* {
+ struct vop_remove_v3_args /* {
struct vnodeop_desc *a_desc;
struct vnode * a_dvp;
struct vnode * a_vp;
struct componentname * a_cnp;
+ nlink_t ctx_vp_new_nlink;
} */ *a = v;
struct v7fs_node *parent_node = a->a_dvp->v_data;
struct v7fs_mount *v7fsmount = parent_node->v7fsmount;