Skip to content

Commit 2e98c01

Browse files
yangerkunsmfrench
authored andcommitted
cifs: remove the retry in cifs_poxis_lock_set
The caller of cifs_posix_lock_set will do retry(like fcntl_setlk64->do_lock_file_wait) if we will wait for any file_lock. So the retry in cifs_poxis_lock_set seems duplicated, remove it to make a cleanup. Signed-off-by: yangerkun <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: NeilBrown <[email protected]>
1 parent 4ef9b4f commit 2e98c01

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

fs/cifs/file.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,20 +1149,20 @@ cifs_posix_lock_test(struct file *file, struct file_lock *flock)
11491149

11501150
/*
11511151
* Set the byte-range lock (posix style). Returns:
1152-
* 1) 0, if we set the lock and don't need to request to the server;
1153-
* 2) 1, if we need to request to the server;
1154-
* 3) <0, if the error occurs while setting the lock.
1152+
* 1) <0, if the error occurs while setting the lock;
1153+
* 2) 0, if we set the lock and don't need to request to the server;
1154+
* 3) FILE_LOCK_DEFERRED, if we will wait for some other file_lock;
1155+
* 4) FILE_LOCK_DEFERRED + 1, if we need to request to the server.
11551156
*/
11561157
static int
11571158
cifs_posix_lock_set(struct file *file, struct file_lock *flock)
11581159
{
11591160
struct cifsInodeInfo *cinode = CIFS_I(file_inode(file));
1160-
int rc = 1;
1161+
int rc = FILE_LOCK_DEFERRED + 1;
11611162

11621163
if ((flock->fl_flags & FL_POSIX) == 0)
11631164
return rc;
11641165

1165-
try_again:
11661166
cifs_down_write(&cinode->lock_sem);
11671167
if (!cinode->can_cache_brlcks) {
11681168
up_write(&cinode->lock_sem);
@@ -1171,13 +1171,6 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)
11711171

11721172
rc = posix_lock_file(file, flock, NULL);
11731173
up_write(&cinode->lock_sem);
1174-
if (rc == FILE_LOCK_DEFERRED) {
1175-
rc = wait_event_interruptible(flock->fl_wait,
1176-
list_empty(&flock->fl_blocked_member));
1177-
if (!rc)
1178-
goto try_again;
1179-
locks_delete_block(flock);
1180-
}
11811174
return rc;
11821175
}
11831176

@@ -1652,7 +1645,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
16521645
int posix_lock_type;
16531646

16541647
rc = cifs_posix_lock_set(file, flock);
1655-
if (!rc || rc < 0)
1648+
if (rc <= FILE_LOCK_DEFERRED)
16561649
return rc;
16571650

16581651
if (type & server->vals->shared_lock_type)

0 commit comments

Comments
 (0)