aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
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
parentf45d34167c67b083b54690e349e77f59062ef0ea (diff)
CIFS: Move brlock code to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsglob.h8
-rw-r--r--fs/cifs/cifsproto.h3
-rw-r--r--fs/cifs/file.c42
-rw-r--r--fs/cifs/smb1ops.c12
4 files changed, 40 insertions, 25 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index b2eb577b5f3f..d3c72713fec4 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -353,6 +353,14 @@ struct smb_version_operations {
353 /* query remote filesystem */ 353 /* query remote filesystem */
354 int (*queryfs)(const unsigned int, struct cifs_tcon *, 354 int (*queryfs)(const unsigned int, struct cifs_tcon *,
355 struct kstatfs *); 355 struct kstatfs *);
356 /* send mandatory brlock to the server */
357 int (*mand_lock)(const unsigned int, struct cifsFileInfo *, __u64,
358 __u64, __u32, int, int, bool);
359 /* unlock range of mandatory locks */
360 int (*mand_unlock_range)(struct cifsFileInfo *, struct file_lock *,
361 const unsigned int);
362 /* push brlocks from the cache to the server */
363 int (*push_mand_locks)(struct cifsFileInfo *);
356}; 364};
357 365
358struct smb_version_values { 366struct smb_version_values {
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 3b628f2af258..a7e238f88898 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -124,6 +124,9 @@ extern u64 cifs_UnixTimeToNT(struct timespec);
124extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, 124extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
125 int offset); 125 int offset);
126extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); 126extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
127extern int cifs_unlock_range(struct cifsFileInfo *cfile,
128 struct file_lock *flock, const unsigned int xid);
129extern int cifs_push_mandatory_locks(struct cifsFileInfo *cfile);
127 130
128extern struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, 131extern struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid,
129 struct file *file, 132 struct file *file,
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 63963730cb28..90ab83647b82 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)
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index ed7f95532383..5fb0fe5f72b6 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -899,6 +899,15 @@ cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
899 return rc; 899 return rc;
900} 900}
901 901
902static int
903cifs_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
904 __u64 length, __u32 type, int lock, int unlock, bool wait)
905{
906 return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->fid.netfid,
907 current->tgid, length, offset, unlock, lock,
908 (__u8)type, wait, 0);
909}
910
902struct smb_version_operations smb1_operations = { 911struct smb_version_operations smb1_operations = {
903 .send_cancel = send_nt_cancel, 912 .send_cancel = send_nt_cancel,
904 .compare_fids = cifs_compare_fids, 913 .compare_fids = cifs_compare_fids,
@@ -960,6 +969,9 @@ struct smb_version_operations smb1_operations = {
960 .calc_smb_size = smbCalcSize, 969 .calc_smb_size = smbCalcSize,
961 .oplock_response = cifs_oplock_response, 970 .oplock_response = cifs_oplock_response,
962 .queryfs = cifs_queryfs, 971 .queryfs = cifs_queryfs,
972 .mand_lock = cifs_mand_lock,
973 .mand_unlock_range = cifs_unlock_range,
974 .push_mand_locks = cifs_push_mandatory_locks,
963}; 975};
964 976
965struct smb_version_values smb1_values = { 977struct smb_version_values smb1_values = {