aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c39
1 files changed, 10 insertions, 29 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 5fbbf99e61f9..1747cbff7ddf 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -948,7 +948,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
948 int rc = 0, stored_rc; 948 int rc = 0, stored_rc;
949 struct cifsLockInfo *li, *tmp; 949 struct cifsLockInfo *li, *tmp;
950 struct cifs_tcon *tcon; 950 struct cifs_tcon *tcon;
951 struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
952 unsigned int num, max_num, max_buf; 951 unsigned int num, max_num, max_buf;
953 LOCKING_ANDX_RANGE *buf, *cur; 952 LOCKING_ANDX_RANGE *buf, *cur;
954 int types[] = {LOCKING_ANDX_LARGE_FILES, 953 int types[] = {LOCKING_ANDX_LARGE_FILES,
@@ -958,21 +957,12 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
958 xid = get_xid(); 957 xid = get_xid();
959 tcon = tlink_tcon(cfile->tlink); 958 tcon = tlink_tcon(cfile->tlink);
960 959
961 /* we are going to update can_cache_brlcks here - need a write access */
962 down_write(&cinode->lock_sem);
963 if (!cinode->can_cache_brlcks) {
964 up_write(&cinode->lock_sem);
965 free_xid(xid);
966 return rc;
967 }
968
969 /* 960 /*
970 * Accessing maxBuf is racy with cifs_reconnect - need to store value 961 * Accessing maxBuf is racy with cifs_reconnect - need to store value
971 * and check it for zero before using. 962 * and check it for zero before using.
972 */ 963 */
973 max_buf = tcon->ses->server->maxBuf; 964 max_buf = tcon->ses->server->maxBuf;
974 if (!max_buf) { 965 if (!max_buf) {
975 up_write(&cinode->lock_sem);
976 free_xid(xid); 966 free_xid(xid);
977 return -EINVAL; 967 return -EINVAL;
978 } 968 }
@@ -981,7 +971,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
981 sizeof(LOCKING_ANDX_RANGE); 971 sizeof(LOCKING_ANDX_RANGE);
982 buf = kzalloc(max_num * sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL); 972 buf = kzalloc(max_num * sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL);
983 if (!buf) { 973 if (!buf) {
984 up_write(&cinode->lock_sem);
985 free_xid(xid); 974 free_xid(xid);
986 return -ENOMEM; 975 return -ENOMEM;
987 } 976 }
@@ -1018,9 +1007,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
1018 } 1007 }
1019 } 1008 }
1020 1009
1021 cinode->can_cache_brlcks = false;
1022 up_write(&cinode->lock_sem);
1023
1024 kfree(buf); 1010 kfree(buf);
1025 free_xid(xid); 1011 free_xid(xid);
1026 return rc; 1012 return rc;
@@ -1041,7 +1027,7 @@ struct lock_to_push {
1041}; 1027};
1042 1028
1043static int 1029static int
1044cifs_push_posix_locks_locked(struct cifsFileInfo *cfile) 1030cifs_push_posix_locks(struct cifsFileInfo *cfile)
1045{ 1031{
1046 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 1032 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
1047 struct file_lock *flock, **before; 1033 struct file_lock *flock, **before;
@@ -1129,9 +1115,11 @@ err_out:
1129} 1115}
1130 1116
1131static int 1117static int
1132cifs_push_posix_locks(struct cifsFileInfo *cfile) 1118cifs_push_locks(struct cifsFileInfo *cfile)
1133{ 1119{
1120 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb);
1134 struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); 1121 struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
1122 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
1135 int rc = 0; 1123 int rc = 0;
1136 1124
1137 /* we are going to update can_cache_brlcks here - need a write access */ 1125 /* 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 up_write(&cinode->lock_sem); 1128 up_write(&cinode->lock_sem);
1141 return rc; 1129 return rc;
1142 } 1130 }
1143 rc = cifs_push_posix_locks_locked(cfile);
1144 cinode->can_cache_brlcks = false;
1145 up_write(&cinode->lock_sem);
1146 return rc;
1147}
1148
1149static int
1150cifs_push_locks(struct cifsFileInfo *cfile)
1151{
1152 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb);
1153 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
1154 1131
1155 if (cap_unix(tcon->ses) && 1132 if (cap_unix(tcon->ses) &&
1156 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 1133 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
1157 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) 1134 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
1158 return cifs_push_posix_locks(cfile); 1135 rc = cifs_push_posix_locks(cfile);
1136 else
1137 rc = tcon->ses->server->ops->push_mand_locks(cfile);
1159 1138
1160 return tcon->ses->server->ops->push_mand_locks(cfile); 1139 cinode->can_cache_brlcks = false;
1140 up_write(&cinode->lock_sem);
1141 return rc;
1161} 1142}
1162 1143
1163static void 1144static void