From 55d33667ee1902c2f577b250fefd7658466ab80c Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Tue, 15 Sep 2015 20:22:30 +0000 Subject: [PATCH] kevent(2): Note DOOMED vnodes with NOTE_REVOKE In poll mode, check for and wake VBAD vnodes. (Vnodes that are VBAD at registration will never be woken by the RECLAIM trigger.) Add post-VOP_RECLAIM hook to trigger notes on vnode reclamation. (Vnodes that were fine at registration but are vgoned while being monitored should signal waiters.) Reviewed by: kib Approved by: markj (mentor) Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3675 --- sys/kern/vfs_subr.c | 15 ++++++++++++--- sys/kern/vnode_if.src | 1 + sys/sys/vnode.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 410d1986b06f..29ca5b1011bd 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -4344,6 +4344,15 @@ vop_mknod_post(void *ap, int rc) VFS_KNOTE_LOCKED(a->a_dvp, NOTE_WRITE); } +void +vop_reclaim_post(void *ap, int rc) +{ + struct vop_reclaim_args *a = ap; + + if (!rc) + VFS_KNOTE_LOCKED(a->a_vp, NOTE_REVOKE); +} + void vop_remove_post(void *ap, int rc) { @@ -4624,7 +4633,7 @@ filt_vfsread(struct knote *kn, long hint) * filesystem is gone, so set the EOF flag and schedule * the knote for deletion. */ - if (hint == NOTE_REVOKE) { + if (hint == NOTE_REVOKE || (hint == 0 && vp->v_type == VBAD)) { VI_LOCK(vp); kn->kn_flags |= (EV_EOF | EV_ONESHOT); VI_UNLOCK(vp); @@ -4653,7 +4662,7 @@ filt_vfswrite(struct knote *kn, long hint) * filesystem is gone, so set the EOF flag and schedule * the knote for deletion. */ - if (hint == NOTE_REVOKE) + if (hint == NOTE_REVOKE || (hint == 0 && vp->v_type == VBAD)) kn->kn_flags |= (EV_EOF | EV_ONESHOT); kn->kn_data = 0; @@ -4670,7 +4679,7 @@ filt_vfsvnode(struct knote *kn, long hint) VI_LOCK(vp); if (kn->kn_sfflags & hint) kn->kn_fflags |= hint; - if (hint == NOTE_REVOKE) { + if (hint == NOTE_REVOKE || (hint == 0 && vp->v_type == VBAD)) { kn->kn_flags |= EV_EOF; VI_UNLOCK(vp); return (1); diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index c3c8ed36adb2..63f8eb9237cf 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -355,6 +355,7 @@ vop_inactive { %% reclaim vp E E E +%! reclaim post vop_reclaim_post vop_reclaim { IN struct vnode *vp; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 800d340edbf5..f37fd05e9ea1 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -781,6 +781,7 @@ void vop_lookup_post(void *a, int rc); void vop_lookup_pre(void *a); void vop_mkdir_post(void *a, int rc); void vop_mknod_post(void *a, int rc); +void vop_reclaim_post(void *a, int rc); void vop_remove_post(void *a, int rc); void vop_rename_post(void *a, int rc); void vop_rename_pre(void *a);