aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-09-19 09:22:43 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:32 -0400
commitd39a4f710b7a7be05b6ed9d4ab8fac754c139f8a (patch)
treefad6f02af54ad574a7dd189f695b602e0c04f816 /fs/cifs/file.c
parentf45d34167c67b083b54690e349e77f59062ef0ea (diff)
CIFS: Move brlock code to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 63963730cb2..90ab83647b8 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -903,7 +903,7 @@ try_again:
903 return rc; 903 return rc;
904} 904}
905 905
906static int 906int
907cifs_push_mandatory_locks(struct cifsFileInfo *cfile) 907cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
908{ 908{
909 unsigned int xid; 909 unsigned int xid;
@@ -1111,7 +1111,7 @@ cifs_push_locks(struct cifsFileInfo *cfile)
1111 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) 1111 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
1112 return cifs_push_posix_locks(cfile); 1112 return cifs_push_posix_locks(cfile);
1113 1113
1114 return cifs_push_mandatory_locks(cfile); 1114 return tcon->ses->server->ops->push_mand_locks(cfile);
1115} 1115}
1116 1116
1117static void 1117static void
@@ -1162,15 +1162,6 @@ cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock,
1162} 1162}
1163 1163
1164static int 1164static int
1165cifs_mandatory_lock(unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
1166 __u64 length, __u32 type, int lock, int unlock, bool wait)
1167{
1168 return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->fid.netfid,
1169 current->tgid, length, offset, unlock, lock,
1170 (__u8)type, wait, 0);
1171}
1172
1173static int
1174cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, 1165cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
1175 bool wait_flag, bool posix_lck, unsigned int xid) 1166 bool wait_flag, bool posix_lck, unsigned int xid)
1176{ 1167{
@@ -1203,11 +1194,11 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
1203 return rc; 1194 return rc;
1204 1195
1205 /* BB we could chain these into one lock request BB */ 1196 /* BB we could chain these into one lock request BB */
1206 rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, type, 1197 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, type,
1207 1, 0, false); 1198 1, 0, false);
1208 if (rc == 0) { 1199 if (rc == 0) {
1209 rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, 1200 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
1210 type, 0, 1, false); 1201 type, 0, 1, false);
1211 flock->fl_type = F_UNLCK; 1202 flock->fl_type = F_UNLCK;
1212 if (rc != 0) 1203 if (rc != 0)
1213 cERROR(1, "Error unlocking previously locked " 1204 cERROR(1, "Error unlocking previously locked "
@@ -1220,13 +1211,14 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
1220 return 0; 1211 return 0;
1221 } 1212 }
1222 1213
1223 rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, 1214 type &= ~server->vals->exclusive_lock_type;
1224 type | server->vals->shared_lock_type, 1, 0, 1215
1225 false); 1216 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
1217 type | server->vals->shared_lock_type,
1218 1, 0, false);
1226 if (rc == 0) { 1219 if (rc == 0) {
1227 rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, 1220 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
1228 type | server->vals->shared_lock_type, 1221 type | server->vals->shared_lock_type, 0, 1, false);
1229 0, 1, false);
1230 flock->fl_type = F_RDLCK; 1222 flock->fl_type = F_RDLCK;
1231 if (rc != 0) 1223 if (rc != 0)
1232 cERROR(1, "Error unlocking previously locked " 1224 cERROR(1, "Error unlocking previously locked "
@@ -1256,7 +1248,7 @@ cifs_free_llist(struct list_head *llist)
1256 } 1248 }
1257} 1249}
1258 1250
1259static int 1251int
1260cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, 1252cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
1261 unsigned int xid) 1253 unsigned int xid)
1262{ 1254{
@@ -1408,8 +1400,8 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
1408 if (rc <= 0) 1400 if (rc <= 0)
1409 goto out; 1401 goto out;
1410 1402
1411 rc = cifs_mandatory_lock(xid, cfile, flock->fl_start, length, 1403 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
1412 type, 1, 0, wait_flag); 1404 type, 1, 0, wait_flag);
1413 if (rc) { 1405 if (rc) {
1414 kfree(lock); 1406 kfree(lock);
1415 goto out; 1407 goto out;
@@ -1417,7 +1409,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
1417 1409
1418 cifs_lock_add(cfile, lock); 1410 cifs_lock_add(cfile, lock);
1419 } else if (unlock) 1411 } else if (unlock)
1420 rc = cifs_unlock_range(cfile, flock, xid); 1412 rc = server->ops->mand_unlock_range(cfile, flock, xid);
1421 1413
1422out: 1414out:
1423 if (flock->fl_flags & FL_POSIX) 1415 if (flock->fl_flags & FL_POSIX)