Re: VFS event hooks

Rene Janssen (reney@plex.nl)
Sun, 27 Jun 1999 19:27:24 +0200


> Ted Tso pointed something out at Expo we'd missed. There is a problem with
> using poll() as there is no "changed since last time" case. That means there
> is no way to do

> {
> if(its_changed()
> do_thing
> poll()
> }

> as the poll won't be working for "since last poll".

Correct, you can have only "changed since poll entry" kind of behaviour .
Ive done that once for select() and poll() is almost the same thing. You can
set a flag indicating that poll should not wake up until a new change occurs ,
not since last poll. But obvious it means that you miss changes that occur when
you dont sit in poll().

some fragments from my horrid code to illustrate (just an experiment):

in select:
if (file) {
mask = DEFAULT_POLLMASK;
if (file->f_op && file->f_op->poll)
mask = file->f_op->poll(file, wait);
else if (file->f_dentry && file->f_dentry->d_inode
&& vfs_is_a_notify_inode(file->f_dentry->d_inode)) {
if ((pollcntrl ^ (POLLFIRST|POLLLAST))) {
mask = vfs_poll(file, wait, pollcntrl);
pollcntrl = 0;
}
}
}

unsigned int vfs_poll(struct file *filp, poll_table *wait, unsigned char pollcntrl)
{
struct inode *i;
unsigned int rval = 0;

if (!filp->f_dentry)
return 0;
i = filp->f_dentry->d_inode;
poll_wait(filp, &i->i_cwait, wait);
spin_lock(&i->i_change_lock);
if (pollcntrl & POLLFIRST) {
i->i_nrwaiters++;
return 0; /* dont look at i_changed now */
}
if (i->i_changed) {
i->i_changed--;
rval = POLLIN | POLLRDNORM;
}
if (rval | (pollcntrl & POLLLAST))
i->i_nrwaiters--;
spin_unlock(&i->i_change_lock);
return rval;
}

>SIGIO instead is the model that is uglier but probably right - especially now
>we have rt signals that pass the fd back

I AGREE ;) And if you change the _sigpoll struct in siginfo.h you get optional
band , uid and pid too! RIght now fd overwrites uid in the siginfo struct if
you look at it twice in send_sigio_to_task(), but since it isnt used it does no
harm (phew).

regards,
Rene Janssen.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/