diff options
author | Pavel Shilovsky <pshilovsky@samba.org> | 2012-09-19 09:22:43 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-09-24 22:46:32 -0400 |
commit | d39a4f710b7a7be05b6ed9d4ab8fac754c139f8a (patch) | |
tree | fad6f02af54ad574a7dd189f695b602e0c04f816 /fs/cifs | |
parent | f45d34167c67b083b54690e349e77f59062ef0ea (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.h | 8 | ||||
-rw-r--r-- | fs/cifs/cifsproto.h | 3 | ||||
-rw-r--r-- | fs/cifs/file.c | 42 | ||||
-rw-r--r-- | fs/cifs/smb1ops.c | 12 |
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 | ||
358 | struct smb_version_values { | 366 | struct 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); | |||
124 | extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, | 124 | extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, |
125 | int offset); | 125 | int offset); |
126 | extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); | 126 | extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); |
127 | extern int cifs_unlock_range(struct cifsFileInfo *cfile, | ||
128 | struct file_lock *flock, const unsigned int xid); | ||
129 | extern int cifs_push_mandatory_locks(struct cifsFileInfo *cfile); | ||
127 | 130 | ||
128 | extern struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, | 131 | extern 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 | ||
906 | static int | 906 | int |
907 | cifs_push_mandatory_locks(struct cifsFileInfo *cfile) | 907 | cifs_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 | ||
1117 | static void | 1117 | static void |
@@ -1162,15 +1162,6 @@ cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock, | |||
1162 | } | 1162 | } |
1163 | 1163 | ||
1164 | static int | 1164 | static int |
1165 | cifs_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 | |||
1173 | static int | ||
1174 | cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, | 1165 | cifs_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 | ||
1259 | static int | 1251 | int |
1260 | cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, | 1252 | cifs_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 | ||
1422 | out: | 1414 | out: |
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 | ||
902 | static int | ||
903 | cifs_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 | |||
902 | struct smb_version_operations smb1_operations = { | 911 | struct 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 | ||
965 | struct smb_version_values smb1_values = { | 977 | struct smb_version_values smb1_values = { |