afs: handle async processing of F_SETLK with FL_SLEEP flag
PATCH 1/1 afs: handle async processing of F_SETLK with FL_SLEEP flag
kernel export thread (nfsd/lockd/ksmbd) use F_SETLK cmd with set FL_SLEEP flag to request asynchronous processing of blocking locks.
afs does not support it, does not check F_SETLK cmd and handles FL_SLEEP flag like usual blocking lock request.
To work around the problem let's detect this situation and drop FL_SLEEP flag before afs_do_setlk() execution. Dropped flag should be restored back because some calling function (nfsd4_lock) require it.
https://bugzilla.kernel.org/show_bug.cgi?id=215383
Signed-off-by Vasily Averin <[email protected]>
--- fs/afs/flock.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
fs/afs/flock.c +10 -2
@@ -778,11 +778,19 @@ int afs_lock(struct file *file, int cmd, struct file_lock *fl) fl->fl_u.afs.debug_id =atomic_inc_return (&afs_file_lock_debug_id);trace_afs_flock_op (vnode, fl, afs_flock_op_lock); -if (fl->fl_type ==F_UNLCK ) +if (fl->fl_type ==F_UNLCK ) { ret =afs_do_unlk (file, fl); -else + }else { +bool async = (fl->fl_flags &FL_SLEEP ) &&IS_SETLK (cmd); + +if (async) + fl->fl_flags &= ~FL_SLEEP ; + ret =afs_do_setlk (file, fl); +if (async) + fl->fl_flags |=FL_SLEEP ; + }switch (ret) {case 0 : op = afs_flock_op_return_ok;break ;case -EAGAIN : op = afs_flock_op_return_eagain;break ;
Signature · 1 line
2.25.1