Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F173887685
D56639.id176514.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D56639.id176514.diff
View Options
diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c
--- a/sys/fs/nullfs/null_vnops.c
+++ b/sys/fs/nullfs/null_vnops.c
@@ -968,6 +968,7 @@
struct vnode *vp;
struct null_node *xp;
struct vnode *lowervp;
+ short flags;
vp = ap->a_vp;
xp = VTONULL(vp);
@@ -997,6 +998,13 @@
else if (vp->v_writecount < 0)
vp->v_writecount = 0;
+ /*
+ * We no longer have a lower vnode to forward events to.
+ */
+ flags = vn_irflag_read(vp) & (VIRF_INOTIFY | VIRF_INOTIFY_PARENT);
+ if (flags != 0)
+ vn_irflag_unset_locked(vp, flags);
+
VI_UNLOCK(vp);
if ((xp->null_flags & NULLV_NOUNLOCK) != 0)
diff --git a/tests/sys/kern/inotify_test.c b/tests/sys/kern/inotify_test.c
--- a/tests/sys/kern/inotify_test.c
+++ b/tests/sys/kern/inotify_test.c
@@ -392,6 +392,64 @@
}
}
+/*
+ * Exercise a scenario where a watched lower vnode is deleted by a rename. The
+ * deletion causes the upper vnode to be reclaimed, and after that point it
+ * should stop trying to forward events back to the (now detached) lower vnode.
+ */
+ATF_TC_WITH_CLEANUP(inotify_nullfs_rename);
+ATF_TC_HEAD(inotify_nullfs_rename, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(inotify_nullfs_rename, tc)
+{
+ char dir[PATH_MAX], path1[PATH_MAX], path2[PATH_MAX], *p;
+ int error, fd, ifd, wd;
+
+ strlcpy(dir, "./test.XXXXXX", sizeof(dir));
+ p = mkdtemp(dir);
+ ATF_REQUIRE(p == dir);
+
+ error = mkdir("./mnt", 0755);
+ ATF_REQUIRE(error == 0);
+
+ /* Mount the testdir onto ./mnt. */
+ mount_nullfs("./mnt", dir);
+
+ ifd = inotify(IN_NONBLOCK);
+
+ /* Create two files, they will be renamed in the upper layer. */
+ snprintf(path1, sizeof(path1), "%s/file1", dir);
+ fd = open(path1, O_RDWR | O_CREAT, 0644);
+ ATF_REQUIRE(fd != -1);
+ close_checked(fd);
+ snprintf(path2, sizeof(path2), "%s/file2", dir);
+ fd = open(path2, O_RDWR | O_CREAT, 0644);
+ ATF_REQUIRE(fd != -1);
+ close_checked(fd);
+
+ wd = inotify_add_watch(ifd, "./mnt/file1", IN_DELETE_SELF);
+ ATF_REQUIRE(wd != -1);
+ error = rename("./mnt/file2", "./mnt/file1");
+ ATF_REQUIRE(error == 0);
+
+ consume_event(ifd, wd, IN_DELETE_SELF, 0, NULL);
+ consume_event(ifd, wd, 0, IN_IGNORED, NULL);
+
+ close_inotify(ifd);
+}
+ATF_TC_CLEANUP(inotify_nullfs_rename, tc)
+{
+ int error;
+
+ error = unmount("./mnt", 0);
+ if (error != 0) {
+ perror("unmount");
+ exit(1);
+ }
+}
+
/*
* Make sure that exceeding max_events pending events results in an overflow
* event.
@@ -878,6 +936,7 @@
ATF_TP_ADD_TC(tp, inotify_coalesce);
ATF_TP_ADD_TC(tp, inotify_mask_create);
ATF_TP_ADD_TC(tp, inotify_nullfs);
+ ATF_TP_ADD_TC(tp, inotify_nullfs_rename);
ATF_TP_ADD_TC(tp, inotify_queue_overflow);
/* Tests for the various inotify event types. */
ATF_TP_ADD_TC(tp, inotify_event_access_file);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Sep 30, 3:23 AM (2 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39920023
Default Alt Text
D56639.id176514.diff (2 KB)
Attached To
Mode
D56639: nullfs: Clear inotify flags during reclaim
Attached
Detach File
Event Timeline
Log In to Comment