1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

Add a NOTE_REVOKE flag for vnodes, which is triggered from within vclean().

Use this to tell a filter attached to a vnode that the underlying vnode is
no longer valid, by returning EV_EOF.

PR: kern/25309, kern/25206
This commit is contained in:
Jonathan Lemon 2001-02-23 20:06:01 +00:00
parent 15e0aafdc2
commit 7df2842dee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=72956
4 changed files with 24 additions and 0 deletions

View File

@ -53,6 +53,7 @@
#include <sys/dirent.h>
#include <sys/domain.h>
#include <sys/eventhandler.h>
#include <sys/event.h>
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
@ -2745,6 +2746,9 @@ vn_pollevent(vp, events)
mtx_unlock(&vp->v_pollinfo.vpi_lock);
}
#define VN_KNOTE(vp, b) \
KNOTE((struct klist *)&vp->v_pollinfo.vpi_selinfo.si_note, (b))
/*
* Wake up anyone polling on vp because it is being revoked.
* This depends on dead_poll() returning POLLHUP for correct
@ -2755,6 +2759,7 @@ vn_pollgone(vp)
struct vnode *vp;
{
mtx_lock(&vp->v_pollinfo.vpi_lock);
VN_KNOTE(vp, NOTE_REVOKE);
if (vp->v_pollinfo.vpi_events) {
vp->v_pollinfo.vpi_events = 0;
selwakeup(&vp->v_pollinfo.vpi_selinfo);

View File

@ -53,6 +53,7 @@
#include <sys/dirent.h>
#include <sys/domain.h>
#include <sys/eventhandler.h>
#include <sys/event.h>
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
@ -2745,6 +2746,9 @@ vn_pollevent(vp, events)
mtx_unlock(&vp->v_pollinfo.vpi_lock);
}
#define VN_KNOTE(vp, b) \
KNOTE((struct klist *)&vp->v_pollinfo.vpi_selinfo.si_note, (b))
/*
* Wake up anyone polling on vp because it is being revoked.
* This depends on dead_poll() returning POLLHUP for correct
@ -2755,6 +2759,7 @@ vn_pollgone(vp)
struct vnode *vp;
{
mtx_lock(&vp->v_pollinfo.vpi_lock);
VN_KNOTE(vp, NOTE_REVOKE);
if (vp->v_pollinfo.vpi_events) {
vp->v_pollinfo.vpi_events = 0;
selwakeup(&vp->v_pollinfo.vpi_selinfo);

View File

@ -73,6 +73,7 @@ struct kevent {
#define NOTE_ATTRIB 0x0008 /* attributes changed */
#define NOTE_LINK 0x0010 /* link count changed */
#define NOTE_RENAME 0x0020 /* vnode was renamed */
#define NOTE_REVOKE 0x0040 /* vnode access was revoked */
/*
* data/hint flags for EVFILT_PROC, shared with userspace

View File

@ -2235,6 +2235,15 @@ filt_ufsread(struct knote *kn, long hint)
struct vnode *vp = (struct vnode *)kn->kn_hook;
struct inode *ip = VTOI(vp);
/*
* filesystem is gone, so set the EOF flag and schedule
* the knote for deletion.
*/
if (hint == NOTE_REVOKE) {
kn->kn_flags |= (EV_EOF | EV_ONESHOT);
return (1);
}
kn->kn_data = ip->i_size - kn->kn_fp->f_offset;
return (kn->kn_data != 0);
}
@ -2245,6 +2254,10 @@ filt_ufsvnode(struct knote *kn, long hint)
if (kn->kn_sfflags & hint)
kn->kn_fflags |= hint;
if (hint == NOTE_REVOKE) {
kn->kn_flags |= EV_EOF;
return (1);
}
return (kn->kn_fflags != 0);
}