lkml.org 
[lkml]   [2021]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] ksmbd: use F_SETLK to force vfs_file_lock() to return asynchronously
From
Date
On 21.12.2021 15:02, Namjae Jeon wrote:
> 2021-12-19 18:34 GMT+09:00, Vasily Averin <vvs@virtuozzo.com>:
>> To avoid possible deadlock ksmbd should process locks asynchronously.
>> Callers expecting vfs_file_locks() to return asynchronously should only
>> use F_SETLK, not F_SETLKW.
> Should I check this patch instead of
> [PATCH] ksmbd: force "fail immediately" flag on fs with its own ->lock ?

no, these patches are independent and both ones are required.
current patch fixes incorrect kernel thread behaviour:
kernel threads should not use F_SETLKW for locking requests.

"[PATCH] ksmbd: force "fail immediately" flag on fs with its own ->lock"
tries to workaround the incorrect behaviour of some exported filesystems.

Currently this way is used in nfsd and lockd, however it is not fully correct,
and I still search some better solution, so perhaps
'[PATCH] ksmbd: force "fail immediately" flag on fs with its own ->lock'
will be dropped later.

Thank you,
Vasily Averin

>> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
>> ---
>> fs/ksmbd/smb2pdu.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
>> index 0c020deb76bb..34f333549767 100644
>> --- a/fs/ksmbd/smb2pdu.c
>> +++ b/fs/ksmbd/smb2pdu.c
>> @@ -6646,13 +6646,13 @@ static int smb2_set_flock_flags(struct file_lock
>> *flock, int flags)
>> switch (flags) {
>> case SMB2_LOCKFLAG_SHARED:
>> ksmbd_debug(SMB, "received shared request\n");
>> - cmd = F_SETLKW;
>> + cmd = F_SETLK;
>> flock->fl_type = F_RDLCK;
>> flock->fl_flags |= FL_SLEEP;
>> break;
>> case SMB2_LOCKFLAG_EXCLUSIVE:
>> ksmbd_debug(SMB, "received exclusive request\n");
>> - cmd = F_SETLKW;
>> + cmd = F_SETLK;
>> flock->fl_type = F_WRLCK;
>> flock->fl_flags |= FL_SLEEP;
>> break;
>> --
>> 2.25.1
>>
>>

\
 
 \ /
  Last update: 2021-12-21 14:09    [W:0.076 / U:1.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site