Skip to content

Commit 18d8696

Browse files
Paulo Alcantarasmfrench
authored andcommitted
smb: client: fix rename(2) regression against samba
After commit 2c7d399 ("smb: client: reuse file lease key in compound operations") the client started reusing lease keys for rename, unlink and set path size operations to prevent it from breaking its own leases and thus causing unnecessary lease breaks to same connection. The implementation relies on positive dentries and cifsInodeInfo::lease_granted to decide whether reusing lease keys for the compound requests. cifsInodeInfo::lease_granted was introduced by commit 0ab95c2 ("Defer close only when lease is enabled.") to indicate whether lease caching is granted for a specific file, but that can only happen until file is open, so cifsInodeInfo::lease_granted was left uninitialised in ->alloc_inode and then client started sending random lease keys for files that hadn't any leases. This fixes the following test case against samba: mount.cifs //srv/share /mnt/1 -o ...,nosharesock mount.cifs //srv/share /mnt/2 -o ...,nosharesock touch /mnt/1/foo; tail -f /mnt/1/foo & pid=$! mv /mnt/2/foo /mnt/2/bar # fails with -EIO kill $pid Fixes: 0ab95c2 ("Defer close only when lease is enabled.") Signed-off-by: Paulo Alcantara (Red Hat) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent afc23fe commit 18d8696

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/smb/client/cifsfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ cifs_alloc_inode(struct super_block *sb)
389389
* server, can not assume caching of file data or metadata.
390390
*/
391391
cifs_set_oplock_level(cifs_inode, 0);
392+
cifs_inode->lease_granted = false;
392393
cifs_inode->flags = 0;
393394
spin_lock_init(&cifs_inode->writers_lock);
394395
cifs_inode->writers = 0;

0 commit comments

Comments
 (0)