* [PATCH AUTOSEL 4.14 47/95] fuse: fix possibly missed wake-up after abort [not found] <20190507053826.31622-1-sashal@kernel.org> @ 2019-05-07 5:37 ` Sasha Levin 2019-05-07 5:37 ` [PATCH AUTOSEL 4.14 50/95] fsnotify: generalize handling of extra event flags Sasha Levin 1 sibling, 0 replies; 4+ messages in thread From: Sasha Levin @ 2019-05-07 5:37 UTC (permalink / raw) To: linux-kernel, stable; +Cc: Miklos Szeredi, Sasha Levin, linux-fsdevel From: Miklos Szeredi <mszeredi@redhat.com> [ Upstream commit 2d84a2d19b6150c6dbac1e6ebad9c82e4c123772 ] In current fuse_drop_waiting() implementation it's possible that fuse_wait_aborted() will not be woken up in the unlikely case that fuse_abort_conn() + fuse_wait_aborted() runs in between checking fc->connected and calling atomic_dec(&fc->num_waiting). Do the atomic_dec_and_test() unconditionally, which also provides the necessary barrier against reordering with the fc->connected check. The explicit smp_mb() in fuse_wait_aborted() is not actually needed, since the spin_unlock() in fuse_abort_conn() provides the necessary RELEASE barrier after resetting fc->connected. However, this is not a performance sensitive path, and adding the explicit barrier makes it easier to document. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Fixes: b8f95e5d13f5 ("fuse: umount should wait for all requests") Cc: <stable@vger.kernel.org> #v4.19 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> --- fs/fuse/dev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 63fd33383413..af78ceead2dc 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -133,9 +133,13 @@ static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background) static void fuse_drop_waiting(struct fuse_conn *fc) { - if (fc->connected) { - atomic_dec(&fc->num_waiting); - } else if (atomic_dec_and_test(&fc->num_waiting)) { + /* + * lockess check of fc->connected is okay, because atomic_dec_and_test() + * provides a memory barrier mached with the one in fuse_wait_aborted() + * to ensure no wake-up is missed. + */ + if (atomic_dec_and_test(&fc->num_waiting) && + !READ_ONCE(fc->connected)) { /* wake up aborters */ wake_up_all(&fc->blocked_waitq); } @@ -2170,6 +2174,8 @@ EXPORT_SYMBOL_GPL(fuse_abort_conn); void fuse_wait_aborted(struct fuse_conn *fc) { + /* matches implicit memory barrier in fuse_drop_waiting() */ + smp_mb(); wait_event(fc->blocked_waitq, atomic_read(&fc->num_waiting) == 0); } -- 2.20.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 4.14 50/95] fsnotify: generalize handling of extra event flags [not found] <20190507053826.31622-1-sashal@kernel.org> 2019-05-07 5:37 ` [PATCH AUTOSEL 4.14 47/95] fuse: fix possibly missed wake-up after abort Sasha Levin @ 2019-05-07 5:37 ` Sasha Levin 2019-05-07 13:23 ` Jan Kara 1 sibling, 1 reply; 4+ messages in thread From: Sasha Levin @ 2019-05-07 5:37 UTC (permalink / raw) To: linux-kernel, stable; +Cc: Amir Goldstein, Jan Kara, Sasha Levin, linux-fsdevel From: Amir Goldstein <amir73il@gmail.com> [ Upstream commit 007d1e8395eaa59b0e7ad9eb2b53a40859446a88 ] FS_EVENT_ON_CHILD gets a special treatment in fsnotify() because it is not a flag specifying an event type, but rather an extra flags that may be reported along with another event and control the handling of the event by the backend. FS_ISDIR is also an "extra flag" and not an "event type" and therefore desrves the same treatment. With inotify/dnotify backends it was never possible to set FS_ISDIR in mark masks, so it did not matter. With fanotify backend, mark adding code jumps through hoops to avoid setting the FS_ISDIR in the commulative object mask. Separate the constant ALL_FSNOTIFY_EVENTS to ALL_FSNOTIFY_FLAGS and ALL_FSNOTIFY_EVENTS, so the latter can be used to test for specific event types. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> --- fs/notify/fsnotify.c | 7 +++---- include/linux/fsnotify_backend.h | 9 +++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 506da82ff3f1..dc080c642dd0 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -192,7 +192,7 @@ static int send_to_group(struct inode *to_tell, struct fsnotify_iter_info *iter_info) { struct fsnotify_group *group = NULL; - __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); + __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); __u32 marks_mask = 0; __u32 marks_ignored_mask = 0; @@ -256,8 +256,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, struct fsnotify_iter_info iter_info; struct mount *mnt; int ret = 0; - /* global tests shouldn't care about events on child only the specific event */ - __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); + __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); if (data_is == FSNOTIFY_EVENT_PATH) mnt = real_mount(((const struct path *)data)->mnt); @@ -380,7 +379,7 @@ static __init int fsnotify_init(void) { int ret; - BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 23); + BUG_ON(hweight32(ALL_FSNOTIFY_BITS) != 23); ret = init_srcu_struct(&fsnotify_mark_srcu); if (ret) diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index ce74278a454a..81052313adeb 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -67,15 +67,20 @@ #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM) +/* Events that can be reported to backends */ #define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \ FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \ FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \ FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \ FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \ - FS_OPEN_PERM | FS_ACCESS_PERM | FS_EXCL_UNLINK | \ - FS_ISDIR | FS_IN_ONESHOT | FS_DN_RENAME | \ + FS_OPEN_PERM | FS_ACCESS_PERM | FS_DN_RENAME) + +/* Extra flags that may be reported with event or control handling of events */ +#define ALL_FSNOTIFY_FLAGS (FS_EXCL_UNLINK | FS_ISDIR | FS_IN_ONESHOT | \ FS_DN_MULTISHOT | FS_EVENT_ON_CHILD) +#define ALL_FSNOTIFY_BITS (ALL_FSNOTIFY_EVENTS | ALL_FSNOTIFY_FLAGS) + struct fsnotify_group; struct fsnotify_event; struct fsnotify_mark; -- 2.20.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 4.14 50/95] fsnotify: generalize handling of extra event flags 2019-05-07 5:37 ` [PATCH AUTOSEL 4.14 50/95] fsnotify: generalize handling of extra event flags Sasha Levin @ 2019-05-07 13:23 ` Jan Kara 2019-05-07 16:29 ` Sasha Levin 0 siblings, 1 reply; 4+ messages in thread From: Jan Kara @ 2019-05-07 13:23 UTC (permalink / raw) To: Sasha Levin Cc: linux-kernel, stable, Amir Goldstein, Jan Kara, Sasha Levin, linux-fsdevel On Tue 07-05-19 01:37:39, Sasha Levin wrote: > From: Amir Goldstein <amir73il@gmail.com> > > [ Upstream commit 007d1e8395eaa59b0e7ad9eb2b53a40859446a88 ] > > FS_EVENT_ON_CHILD gets a special treatment in fsnotify() because it is > not a flag specifying an event type, but rather an extra flags that may > be reported along with another event and control the handling of the > event by the backend. > > FS_ISDIR is also an "extra flag" and not an "event type" and therefore > desrves the same treatment. With inotify/dnotify backends it was never > possible to set FS_ISDIR in mark masks, so it did not matter. > With fanotify backend, mark adding code jumps through hoops to avoid > setting the FS_ISDIR in the commulative object mask. > > Separate the constant ALL_FSNOTIFY_EVENTS to ALL_FSNOTIFY_FLAGS and > ALL_FSNOTIFY_EVENTS, so the latter can be used to test for specific > event types. > > Signed-off-by: Amir Goldstein <amir73il@gmail.com> > Signed-off-by: Jan Kara <jack@suse.cz> > Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Sasha, why did you select this patch? It is just a cleanup with no user visible effect and was done mostly to simplify implementing following features... Honza > --- > fs/notify/fsnotify.c | 7 +++---- > include/linux/fsnotify_backend.h | 9 +++++++-- > 2 files changed, 10 insertions(+), 6 deletions(-) > > diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c > index 506da82ff3f1..dc080c642dd0 100644 > --- a/fs/notify/fsnotify.c > +++ b/fs/notify/fsnotify.c > @@ -192,7 +192,7 @@ static int send_to_group(struct inode *to_tell, > struct fsnotify_iter_info *iter_info) > { > struct fsnotify_group *group = NULL; > - __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); > + __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); > __u32 marks_mask = 0; > __u32 marks_ignored_mask = 0; > > @@ -256,8 +256,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, > struct fsnotify_iter_info iter_info; > struct mount *mnt; > int ret = 0; > - /* global tests shouldn't care about events on child only the specific event */ > - __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); > + __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); > > if (data_is == FSNOTIFY_EVENT_PATH) > mnt = real_mount(((const struct path *)data)->mnt); > @@ -380,7 +379,7 @@ static __init int fsnotify_init(void) > { > int ret; > > - BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 23); > + BUG_ON(hweight32(ALL_FSNOTIFY_BITS) != 23); > > ret = init_srcu_struct(&fsnotify_mark_srcu); > if (ret) > diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h > index ce74278a454a..81052313adeb 100644 > --- a/include/linux/fsnotify_backend.h > +++ b/include/linux/fsnotify_backend.h > @@ -67,15 +67,20 @@ > > #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM) > > +/* Events that can be reported to backends */ > #define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \ > FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \ > FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \ > FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \ > FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \ > - FS_OPEN_PERM | FS_ACCESS_PERM | FS_EXCL_UNLINK | \ > - FS_ISDIR | FS_IN_ONESHOT | FS_DN_RENAME | \ > + FS_OPEN_PERM | FS_ACCESS_PERM | FS_DN_RENAME) > + > +/* Extra flags that may be reported with event or control handling of events */ > +#define ALL_FSNOTIFY_FLAGS (FS_EXCL_UNLINK | FS_ISDIR | FS_IN_ONESHOT | \ > FS_DN_MULTISHOT | FS_EVENT_ON_CHILD) > > +#define ALL_FSNOTIFY_BITS (ALL_FSNOTIFY_EVENTS | ALL_FSNOTIFY_FLAGS) > + > struct fsnotify_group; > struct fsnotify_event; > struct fsnotify_mark; > -- > 2.20.1 > -- Jan Kara <jack@suse.com> SUSE Labs, CR ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 4.14 50/95] fsnotify: generalize handling of extra event flags 2019-05-07 13:23 ` Jan Kara @ 2019-05-07 16:29 ` Sasha Levin 0 siblings, 0 replies; 4+ messages in thread From: Sasha Levin @ 2019-05-07 16:29 UTC (permalink / raw) To: Jan Kara; +Cc: linux-kernel, stable, Amir Goldstein, Sasha Levin, linux-fsdevel On Tue, May 07, 2019 at 03:23:30PM +0200, Jan Kara wrote: >On Tue 07-05-19 01:37:39, Sasha Levin wrote: >> From: Amir Goldstein <amir73il@gmail.com> >> >> [ Upstream commit 007d1e8395eaa59b0e7ad9eb2b53a40859446a88 ] >> >> FS_EVENT_ON_CHILD gets a special treatment in fsnotify() because it is >> not a flag specifying an event type, but rather an extra flags that may >> be reported along with another event and control the handling of the >> event by the backend. >> >> FS_ISDIR is also an "extra flag" and not an "event type" and therefore >> desrves the same treatment. With inotify/dnotify backends it was never >> possible to set FS_ISDIR in mark masks, so it did not matter. >> With fanotify backend, mark adding code jumps through hoops to avoid >> setting the FS_ISDIR in the commulative object mask. >> >> Separate the constant ALL_FSNOTIFY_EVENTS to ALL_FSNOTIFY_FLAGS and >> ALL_FSNOTIFY_EVENTS, so the latter can be used to test for specific >> event types. >> >> Signed-off-by: Amir Goldstein <amir73il@gmail.com> >> Signed-off-by: Jan Kara <jack@suse.cz> >> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> > >Sasha, why did you select this patch? It is just a cleanup with no user >visible effect and was done mostly to simplify implementing following >features... Sigh, my script picked up the patch after this one (by mistake). I've dropped that one but missed this one twice(!). Thanks for the heads-up, I'll drop it. -- Thanks, Sasha ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-07 16:29 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20190507053826.31622-1-sashal@kernel.org> 2019-05-07 5:37 ` [PATCH AUTOSEL 4.14 47/95] fuse: fix possibly missed wake-up after abort Sasha Levin 2019-05-07 5:37 ` [PATCH AUTOSEL 4.14 50/95] fsnotify: generalize handling of extra event flags Sasha Levin 2019-05-07 13:23 ` Jan Kara 2019-05-07 16:29 ` Sasha Levin
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).