Commit b8db928b authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French

CIFS: Separate pushing mandatory locks and lock_sem handling

Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarPavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent 9ec3c882
...@@ -948,7 +948,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -948,7 +948,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
int rc = 0, stored_rc; int rc = 0, stored_rc;
struct cifsLockInfo *li, *tmp; struct cifsLockInfo *li, *tmp;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
unsigned int num, max_num, max_buf; unsigned int num, max_num, max_buf;
LOCKING_ANDX_RANGE *buf, *cur; LOCKING_ANDX_RANGE *buf, *cur;
int types[] = {LOCKING_ANDX_LARGE_FILES, int types[] = {LOCKING_ANDX_LARGE_FILES,
...@@ -958,21 +957,12 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -958,21 +957,12 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
xid = get_xid(); xid = get_xid();
tcon = tlink_tcon(cfile->tlink); tcon = tlink_tcon(cfile->tlink);
/* we are going to update can_cache_brlcks here - need a write access */
down_write(&cinode->lock_sem);
if (!cinode->can_cache_brlcks) {
up_write(&cinode->lock_sem);
free_xid(xid);
return rc;
}
/* /*
* Accessing maxBuf is racy with cifs_reconnect - need to store value * Accessing maxBuf is racy with cifs_reconnect - need to store value
* and check it for zero before using. * and check it for zero before using.
*/ */
max_buf = tcon->ses->server->maxBuf; max_buf = tcon->ses->server->maxBuf;
if (!max_buf) { if (!max_buf) {
up_write(&cinode->lock_sem);
free_xid(xid); free_xid(xid);
return -EINVAL; return -EINVAL;
} }
...@@ -981,7 +971,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -981,7 +971,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
sizeof(LOCKING_ANDX_RANGE); sizeof(LOCKING_ANDX_RANGE);
buf = kzalloc(max_num * sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL); buf = kzalloc(max_num * sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL);
if (!buf) { if (!buf) {
up_write(&cinode->lock_sem);
free_xid(xid); free_xid(xid);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1018,9 +1007,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -1018,9 +1007,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
} }
} }
cinode->can_cache_brlcks = false;
up_write(&cinode->lock_sem);
kfree(buf); kfree(buf);
free_xid(xid); free_xid(xid);
return rc; return rc;
...@@ -1041,7 +1027,7 @@ struct lock_to_push { ...@@ -1041,7 +1027,7 @@ struct lock_to_push {
}; };
static int static int
cifs_push_posix_locks_locked(struct cifsFileInfo *cfile) cifs_push_posix_locks(struct cifsFileInfo *cfile)
{ {
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
struct file_lock *flock, **before; struct file_lock *flock, **before;
...@@ -1129,9 +1115,11 @@ cifs_push_posix_locks_locked(struct cifsFileInfo *cfile) ...@@ -1129,9 +1115,11 @@ cifs_push_posix_locks_locked(struct cifsFileInfo *cfile)
} }
static int static int
cifs_push_posix_locks(struct cifsFileInfo *cfile) cifs_push_locks(struct cifsFileInfo *cfile)
{ {
struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb);
struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
int rc = 0; int rc = 0;
/* we are going to update can_cache_brlcks here - need a write access */ /* we are going to update can_cache_brlcks here - need a write access */
...@@ -1140,24 +1128,17 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) ...@@ -1140,24 +1128,17 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
up_write(&cinode->lock_sem); up_write(&cinode->lock_sem);
return rc; return rc;
} }
rc = cifs_push_posix_locks_locked(cfile);
cinode->can_cache_brlcks = false;
up_write(&cinode->lock_sem);
return rc;
}
static int
cifs_push_locks(struct cifsFileInfo *cfile)
{
struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb);
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
if (cap_unix(tcon->ses) && if (cap_unix(tcon->ses) &&
(CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
return cifs_push_posix_locks(cfile); rc = cifs_push_posix_locks(cfile);
else
rc = tcon->ses->server->ops->push_mand_locks(cfile);
return tcon->ses->server->ops->push_mand_locks(cfile); cinode->can_cache_brlcks = false;
up_write(&cinode->lock_sem);
return rc;
} }
static void static void
......
...@@ -260,13 +260,6 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -260,13 +260,6 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile)
struct cifs_fid_locks *fdlocks; struct cifs_fid_locks *fdlocks;
xid = get_xid(); xid = get_xid();
/* we are going to update can_cache_brlcks here - need a write access */
down_write(&cinode->lock_sem);
if (!cinode->can_cache_brlcks) {
up_write(&cinode->lock_sem);
free_xid(xid);
return rc;
}
/* /*
* Accessing maxBuf is racy with cifs_reconnect - need to store value * Accessing maxBuf is racy with cifs_reconnect - need to store value
...@@ -274,7 +267,6 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -274,7 +267,6 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile)
*/ */
max_buf = tlink_tcon(cfile->tlink)->ses->server->maxBuf; max_buf = tlink_tcon(cfile->tlink)->ses->server->maxBuf;
if (!max_buf) { if (!max_buf) {
up_write(&cinode->lock_sem);
free_xid(xid); free_xid(xid);
return -EINVAL; return -EINVAL;
} }
...@@ -282,7 +274,6 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -282,7 +274,6 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile)
max_num = max_buf / sizeof(struct smb2_lock_element); max_num = max_buf / sizeof(struct smb2_lock_element);
buf = kzalloc(max_num * sizeof(struct smb2_lock_element), GFP_KERNEL); buf = kzalloc(max_num * sizeof(struct smb2_lock_element), GFP_KERNEL);
if (!buf) { if (!buf) {
up_write(&cinode->lock_sem);
free_xid(xid); free_xid(xid);
return -ENOMEM; return -ENOMEM;
} }
...@@ -293,10 +284,7 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -293,10 +284,7 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile)
rc = stored_rc; rc = stored_rc;
} }
cinode->can_cache_brlcks = false;
kfree(buf); kfree(buf);
up_write(&cinode->lock_sem);
free_xid(xid); free_xid(xid);
return rc; return rc;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment