Skip to content

Commit 0667059

Browse files
Murphy Zhousmfrench
authored andcommitted
cifs: allow unlock flock and OFD lock across fork
Since commit d067799 ("cifs: add support for flock") added support for flock, LTP/flock03[1] testcase started to fail. This testcase is testing flock lock and unlock across fork. The parent locks file and starts the child process, in which it unlock the same fd and lock the same file with another fd again. All the lock and unlock operation should succeed. Now the child process does not actually unlock the file, so the following lock fails. Fix this by allowing flock and OFD lock go through the unlock routine, not skipping if the unlock request comes from another process. Patch has been tested by LTP/xfstests on samba and Windows server, v3.11, with or without cache=none mount option. [1] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/flock/flock03.c Signed-off-by: Murphy Zhou <[email protected]> Signed-off-by: Steve French <[email protected]> Acked-by: Pavel Shilovsky <[email protected]>
1 parent c7e9f78 commit 0667059

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/cifs/smb2file.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
152152
(li->offset + li->length))
153153
continue;
154154
if (current->tgid != li->pid)
155-
continue;
155+
/*
156+
* flock and OFD lock are associated with an open
157+
* file description, not the process.
158+
*/
159+
if (!(flock->fl_flags & (FL_FLOCK | FL_OFDLCK)))
160+
continue;
156161
if (cinode->can_cache_brlcks) {
157162
/*
158163
* We can cache brlock requests - simply remove a lock

0 commit comments

Comments
 (0)