From: Amir Goldstein <amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
Cc: Marko Rauhamaa
<marko.rauhamaa-xdZvthzU1HpWk0Htik3J/w@public.gmane.org>,
Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>,
Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
linux-fsdevel
<linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Linux NFS Mailing List
<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: fanotify read returns with errno == EOPENSTALE
Date: Thu, 20 Apr 2017 18:06:18 +0300 [thread overview]
Message-ID: <CAOQ4uxgAOJjWP6PHY6WgOkNK0vmaTWnFZN+Jvea7zpjJ_VU8Bw@mail.gmail.com> (raw)
In-Reply-To: <20170420142035.GE22135-4I4JzKEfoa/jFM9bn6wA6Q@public.gmane.org>
On Thu, Apr 20, 2017 at 5:20 PM, Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org> wrote:
> On Thu 20-04-17 14:33:04, Amir Goldstein wrote:
>>
>> Sorry I messed up the previous patch. please try this one:
>>
>> diff --git a/fs/notify/fanotify/fanotify_user.c
>> b/fs/notify/fanotify/fanotify_user.c
>> index 2b37f27..7864354 100644
>> --- a/fs/notify/fanotify/fanotify_user.c
>> +++ b/fs/notify/fanotify/fanotify_user.c
>> @@ -295,6 +295,16 @@ static ssize_t fanotify_read(struct file *file,
>> char __user *buf,
>> }
>>
>> ret = copy_event_to_user(group, kevent, buf);
>> + if (unlikely(ret == -EOPENSTALE)) {
>> + /*
>> + * We cannot report events with stale fd so drop it.
>> + * Setting ret to 0 will continue the event loop and
>> + * do the right thing if there are no more events to
>> + * read (i.e. return bytes read, -EAGAIN or wait).
>> + */
>> + ret = 0;
>> + }
>> +
>> /*
>> * Permission events get queued to wait for response. Other
>> * events can be destroyed now.
>> @@ -305,7 +315,7 @@ static ssize_t fanotify_read(struct file *file,
>> char __user *buf,
>> break;
>> } else {
>> #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
>> - if (ret < 0) {
>> + if (ret <= 0) {
>> FANOTIFY_PE(kevent)->response = FAN_DENY;
>> wake_up(&group->fanotify_data.access_waitq);
>> break;
>
> I don't think you want to break out of the reading loop when ret == 0 and
> the code might be more readable as:
>
> if (!(kevent->mask & FAN_ALL_PERM_EVENTS)) {
> fsnotify_destroy_event(group, kevent);
> } else {
> #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
> if (ret <= 0) {
> FANOTIFY_PE(kevent)->response = FAN_DENY;
> wake_up(&group->fanotify_data.access_waitq);
> } else {
> spin_lock(&group->notification_lock);
> list_add_tail(&kevent->list,
> &group->fanotify_data.access_list);
> spin_unlock(&group->notification_lock);
> }
> #endif
> }
> if (ret < 0)
> break;
>
> Hmm?
>
Right, I missed that.
Thanks.
next prev parent reply other threads:[~2017-04-20 15:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87inn12urq.fsf@drapion.f-secure.com>
[not found] ` <CAOQ4uxjzjFDLmvebHmC4t4_tT8xyWfbHVGfKohEqw7ZjpxfV_w@mail.gmail.com>
[not found] ` <20170322193122.GV29622@ZenIV.linux.org.uk>
[not found] ` <CAOQ4uxhTd1j4HLgZFTdr7wwrhjzkVT8QeoXjca_AMZmYHF31sQ@mail.gmail.com>
[not found] ` <87a88c2yxq.fsf@drapion.f-secure.com>
[not found] ` <CAOQ4uxggwSDcjdyCDreKs7m0ZNy+6PQQNojm6qDU7mH2tQE-Bw@mail.gmail.com>
[not found] ` <1490270212.3921.10.camel@poochiereds.net>
[not found] ` <8760j02mfz.fsf@drapion.f-secure.com>
[not found] ` <8760j02mfz.fsf-q6puBR44SRrF1m+2HNTUelaTQe2KTcn/@public.gmane.org>
2017-03-23 13:47 ` fanotify read returns with errno == EOPENSTALE Amir Goldstein
[not found] ` <CAOQ4uxja14p02jQurLTGv_fHrs+UBa5qfacrgY_-7tyv6UJqdw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-19 13:46 ` Marko Rauhamaa
[not found] ` <87lgqwa4tg.fsf-q6puBR44SRrF1m+2HNTUelaTQe2KTcn/@public.gmane.org>
2017-04-20 11:06 ` Amir Goldstein
[not found] ` <CAOQ4uxirSfVVYBexXrWccDHnE5oqxNgUh3-X5Ey1w4R=nHXDjA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-20 11:33 ` Amir Goldstein
[not found] ` <CAOQ4uxjA8Z7wnwuHFCKeKT1xz0Gh-qS40Y6cfPi3fAM0MKsRuQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-20 12:43 ` Marko Rauhamaa
[not found] ` <87shl38d1x.fsf-q6puBR44SRrF1m+2HNTUelaTQe2KTcn/@public.gmane.org>
2017-04-20 13:34 ` Amir Goldstein
[not found] ` <CAOQ4uxiJyrvEJMhM1jhiE5pCgP0iA_LL4Eo_h7UY00wkTKhbTg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-21 13:13 ` Marko Rauhamaa
2017-04-20 14:20 ` Jan Kara
[not found] ` <20170420142035.GE22135-4I4JzKEfoa/jFM9bn6wA6Q@public.gmane.org>
2017-04-20 15:06 ` Amir Goldstein [this message]
[not found] ` <CAOQ4uxgAOJjWP6PHY6WgOkNK0vmaTWnFZN+Jvea7zpjJ_VU8Bw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-22 7:22 ` Amir Goldstein
[not found] ` <CAOQ4uxgkXz+8=m2o_faAh2g2Z21KhAf67WckgPNWhktz1=DaWA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-24 7:40 ` Marko Rauhamaa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOQ4uxgAOJjWP6PHY6WgOkNK0vmaTWnFZN+Jvea7zpjJ_VU8Bw@mail.gmail.com \
--to=amir73il-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=jack-AlSwsSmVLrQ@public.gmane.org \
--cc=jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=marko.rauhamaa-xdZvthzU1HpWk0Htik3J/w@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).