Skip to contentSkip to conversation

cifs: handle lease F_UNLCK requests properly

PATCH Applied Jeff Layton 2 participants 2 messages Aug 9, 2014 – Aug 16, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: handle lease F_UNLCK requests properly

Currently any F_UNLCK request for a lease just gets back -EAGAIN. Allow them to go immediately to generic_setlease instead.

---
 fs/cifs/cifsfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/cifs/cifsfs.c +3 -2
index 2c90d07c0b3a..f1a93d2b108d 100644
@@ -799,8 +799,9 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
 	if (!(S_ISREG(inode->i_mode)))
 		return -EINVAL;
 
-	/* check if file is oplocked */
-	if (((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) ||
+	/* Check if file is oplocked if this is request for new lease */
+	if (arg == F_UNLCK ||
+	    ((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) ||
 	    ((arg == F_WRLCK) && CIFS_CACHE_WRITE(CIFS_I(inode))))
 		return generic_setlease(file, arg, lease);
 	else if (tlink_tcon(cfile->tlink)->local_lease &&
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1407593804-28053-1-git-send-email-jlayton-7I+n7zu2hftEKMMhf/[email protected]

Applied
#2 lore raw

Merged into cifs-2.6.git

Did you find this with a test case or by inspection?

Quoted 27 lines · Jeff Layton

Currently any F_UNLCK request for a lease just gets back -EAGAIN. Allow them to go immediately to generic_setlease instead.

---
 fs/cifs/cifsfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/cifs/cifsfs.c +3 -3
index 2c90d07c0b3a..f1a93d2b108d 100644
@@ -799,8 +799,9 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
        if (!(S_ISREG(inode->i_mode)))
                return -EINVAL;
 
-       /* check if file is oplocked */
-       if (((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) ||
+       /* Check if file is oplocked if this is request for new lease */
+       if (arg == F_UNLCK ||
+           ((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) ||
            ((arg == F_WRLCK) && CIFS_CACHE_WRITE(CIFS_I(inode))))
                return generic_setlease(file, arg, lease);
        else if (tlink_tcon(cfile->tlink)->local_lease &&
--

1.9.3

Signature · 3 lines
Thanks,

Steve