fanotify: Make wait for permission events interruptible
Subsystems (4)
Jan Kara
maintainerPATCH 1/1 fanotify: Make wait for permission events interruptible
Switch waiting for response to fanotify permission events interruptible. This allows e.g. the system to be suspended while there are some fanotify permission events pending (which is reportedly pretty common when for example AV solution is in use). However just making the wait interruptible can result in e.g. open(2) returning -EINTR where previously such error code never happened in practice. To avoid confusion of userspace due to this error code, return -ERESTARTNOINTR instead.
--- fs/notify/fanotify/fanotify.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
Orion, can you give this patch some testing with your usecase? Also if anybody sees any issue with returning -ERESTARTNOINTR I have missed, please speak up.
fs/notify/fanotify/fanotify.c +9 -2
@@ -92,10 +92,17 @@ static int fanotify_get_response(struct fsnotify_group *group,pr_debug ("%s: group=%p event=%p\n" , __func__, group, event); - ret =wait_event_killable (group->fanotify_data.access_waitq, - event->state ==FAN_EVENT_ANSWERED ); + ret =wait_event_interruptible (group->fanotify_data.access_waitq, + event->state ==FAN_EVENT_ANSWERED );/* Signal pending? */ if (ret <0 ) { +/* +* Force restarting a syscall so that this is mostly invisible +* for userspace which is not prepared for handling EINTR e.g. +* from open(2). +*/ +if (ret == -ERESTARTSYS ) + ret = -ERESTARTNOINTR ;spin_lock (&group->notification_lock);/* Event reported to userspace and no answer yet? */ if (event->state ==FAN_EVENT_REPORTED ) {
Signature · 1 line
2.16.4
Jan Kara
maintainerQuoted 9 lines · Jan Kara
Switch waiting for response to fanotify permission events interruptible. This allows e.g. the system to be suspended while there are some fanotify permission events pending (which is reportedly pretty common when for example AV solution is in use). However just making the wait interruptible can result in e.g. open(2) returning
-EINTRwhere previously such error code never happened in practice. To avoid confusion of userspace due to this error code, return-ERESTARTNOINTRinstead.
Quoted 7 lines
Signed-off-by Jan Kara <[email protected]>--- fs/notify/fanotify/fanotify.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)Orion, can you give this patch some testing with your usecase? Also if anybody sees any issue with returning
-ERESTARTNOINTRI have missed, please speak up.
Ping Orion? Did you have any chance to give this patch a try? Does it fix hibernation issues you observe without causing issues with bash and other programs? I'd like to queue this patch for the coming merge window but I'd like to see some testing results showing that it actually helps anything... Thanks!
Honza
Quoted 28 lines
fs/notify/fanotify/fanotify.c +9
-2@@ -92,10 +92,17 @@ static int fanotify_get_response(struct fsnotify_group *group,pr_debug ("%s: group=%p event=%p\n" , __func__, group, event); - ret =wait_event_killable (group->fanotify_data.access_waitq, - event->state ==FAN_EVENT_ANSWERED ); + ret =wait_event_interruptible (group->fanotify_data.access_waitq, + event->state ==FAN_EVENT_ANSWERED );/* Signal pending? */ if (ret <0 ) { +/* +* Force restarting a syscall so that this is mostly invisible +* for userspace which is not prepared for handling EINTR e.g. +* from open(2). +*/ +if (ret == -ERESTARTSYS ) + ret = -ERESTARTNOINTR ;spin_lock (&group->notification_lock);/* Event reported to userspace and no answer yet? */ if (event->state ==FAN_EVENT_REPORTED ) {Signature · 1 line
2.16.4
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 18 lines · Jan Kara
Quoted 9 lines · Jan Kara
Switch waiting for response to fanotify permission events interruptible. This allows e.g. the system to be suspended while there are some fanotify permission events pending (which is reportedly pretty common when for example AV solution is in use). However just making the wait interruptible can result in e.g. open(2) returning
-EINTRwhere previously such error code never happened in practice. To avoid confusion of userspace due to this error code, return-ERESTARTNOINTRinstead.Quoted 7 lines
Signed-off-by Jan Kara <[email protected]>--- fs/notify/fanotify/fanotify.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)Orion, can you give this patch some testing with your usecase? Also if anybody sees any issue with returning
-ERESTARTNOINTRI have missed, please speak up.
Quoted 7 lines
Ping Orion? Did you have any chance to give this patch a try? Does it fix hibernation issues you observe without causing issues with bash and other programs? I'd like to queue this patch for the coming merge window but I'd like to see some testing results showing that it actually helps anything... Thanks!
Honza
I've been running it for a while with mostly promising results but one concern. Notably, when running in conjuction with BitDefender Anti-Virus I have noticed issues when cloning large git projects (seems to be a good stress test on open()). I believe the problems go away when BD is stopped. At this point I'm not sure if the issue lies more with BD or with the kernel patch.
Signature · 5 lines
Orion Poplawski Manager of NWRA Technical Systems 720-772-5637 NWRA, Boulder/CoRA Office FAX: 303-415-9702 3380 Mitchell Lane [email protected] Boulder, CO 80301 https://www.nwra.com/