aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2013-09-05 12:16:45 -0400
committerSteve French <smfrench@gmail.com>2013-09-09 23:52:11 -0400
commitb5c7cde3fac35e33835d37be59cb4e5a0b9cf3c2 (patch)
tree25c65c2f865d60c2d7c5c24bcf020c57c5074be8 /fs/cifs
parenta41a28bda936ea627afbfe94a7f5cd63f23cf727 (diff)
CIFS: Move parsing lease buffer to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsglob.h2
-rw-r--r--fs/cifs/smb2ops.c13
-rw-r--r--fs/cifs/smb2pdu.c27
3 files changed, 25 insertions, 17 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index cb53e24ae9b2..38118938f0b6 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -376,6 +376,8 @@ struct smb_version_operations {
376 void (*set_oplock_level)(struct cifsInodeInfo *, __u32); 376 void (*set_oplock_level)(struct cifsInodeInfo *, __u32);
377 /* create lease context buffer for CREATE request */ 377 /* create lease context buffer for CREATE request */
378 char * (*create_lease_buf)(u8 *, u8); 378 char * (*create_lease_buf)(u8 *, u8);
379 /* parse lease context buffer and return oplock info */
380 __u8 (*parse_lease_buf)(void *);
379}; 381};
380 382
381struct smb_version_values { 383struct smb_version_values {
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index ecff4d6e4b16..0215e60267e2 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -748,6 +748,16 @@ smb2_create_lease_buf(u8 *lease_key, u8 oplock)
748 return (char *)buf; 748 return (char *)buf;
749} 749}
750 750
751static __u8
752smb2_parse_lease_buf(void *buf)
753{
754 struct create_lease *lc = (struct create_lease *)buf;
755
756 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
757 return SMB2_OPLOCK_LEVEL_NOCHANGE;
758 return le32_to_cpu(lc->lcontext.LeaseState);
759}
760
751struct smb_version_operations smb20_operations = { 761struct smb_version_operations smb20_operations = {
752 .compare_fids = smb2_compare_fids, 762 .compare_fids = smb2_compare_fids,
753 .setup_request = smb2_setup_request, 763 .setup_request = smb2_setup_request,
@@ -816,6 +826,7 @@ struct smb_version_operations smb20_operations = {
816 .is_read_op = smb2_is_read_op, 826 .is_read_op = smb2_is_read_op,
817 .set_oplock_level = smb2_set_oplock_level, 827 .set_oplock_level = smb2_set_oplock_level,
818 .create_lease_buf = smb2_create_lease_buf, 828 .create_lease_buf = smb2_create_lease_buf,
829 .parse_lease_buf = smb2_parse_lease_buf,
819}; 830};
820 831
821struct smb_version_operations smb21_operations = { 832struct smb_version_operations smb21_operations = {
@@ -886,6 +897,7 @@ struct smb_version_operations smb21_operations = {
886 .is_read_op = smb21_is_read_op, 897 .is_read_op = smb21_is_read_op,
887 .set_oplock_level = smb21_set_oplock_level, 898 .set_oplock_level = smb21_set_oplock_level,
888 .create_lease_buf = smb2_create_lease_buf, 899 .create_lease_buf = smb2_create_lease_buf,
900 .parse_lease_buf = smb2_parse_lease_buf,
889}; 901};
890 902
891struct smb_version_operations smb30_operations = { 903struct smb_version_operations smb30_operations = {
@@ -958,6 +970,7 @@ struct smb_version_operations smb30_operations = {
958 .is_read_op = smb21_is_read_op, 970 .is_read_op = smb21_is_read_op,
959 .set_oplock_level = smb21_set_oplock_level, 971 .set_oplock_level = smb21_set_oplock_level,
960 .create_lease_buf = smb2_create_lease_buf, 972 .create_lease_buf = smb2_create_lease_buf,
973 .parse_lease_buf = smb2_parse_lease_buf,
961}; 974};
962 975
963struct smb_version_values smb20_values = { 976struct smb_version_values smb20_values = {
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index f5f1f5341f04..6eef8b67e709 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -903,34 +903,27 @@ create_reconnect_durable_buf(struct cifs_fid *fid)
903} 903}
904 904
905static __u8 905static __u8
906parse_lease_state(struct smb2_create_rsp *rsp) 906parse_lease_state(struct TCP_Server_Info *server, struct smb2_create_rsp *rsp)
907{ 907{
908 char *data_offset; 908 char *data_offset;
909 struct create_lease *lc; 909 struct create_context *cc;
910 bool found = false;
911 unsigned int next = 0; 910 unsigned int next = 0;
912 char *name; 911 char *name;
913 912
914 data_offset = (char *)rsp + 4 + le32_to_cpu(rsp->CreateContextsOffset); 913 data_offset = (char *)rsp + 4 + le32_to_cpu(rsp->CreateContextsOffset);
915 lc = (struct create_lease *)data_offset; 914 cc = (struct create_context *)data_offset;
916 do { 915 do {
917 lc = (struct create_lease *)((char *)lc + next); 916 cc = (struct create_context *)((char *)cc + next);
918 name = le16_to_cpu(lc->ccontext.NameOffset) + (char *)lc; 917 name = le16_to_cpu(cc->NameOffset) + (char *)cc;
919 if (le16_to_cpu(lc->ccontext.NameLength) != 4 || 918 if (le16_to_cpu(cc->NameLength) != 4 ||
920 strncmp(name, "RqLs", 4)) { 919 strncmp(name, "RqLs", 4)) {
921 next = le32_to_cpu(lc->ccontext.Next); 920 next = le32_to_cpu(cc->Next);
922 continue; 921 continue;
923 } 922 }
924 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS) 923 return server->ops->parse_lease_buf(cc);
925 return SMB2_OPLOCK_LEVEL_NOCHANGE;
926 found = true;
927 break;
928 } while (next != 0); 924 } while (next != 0);
929 925
930 if (!found) 926 return 0;
931 return 0;
932
933 return le32_to_cpu(lc->lcontext.LeaseState);
934} 927}
935 928
936static int 929static int
@@ -1109,7 +1102,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
1109 } 1102 }
1110 1103
1111 if (rsp->OplockLevel == SMB2_OPLOCK_LEVEL_LEASE) 1104 if (rsp->OplockLevel == SMB2_OPLOCK_LEVEL_LEASE)
1112 *oplock = parse_lease_state(rsp); 1105 *oplock = parse_lease_state(server, rsp);
1113 else 1106 else
1114 *oplock = rsp->OplockLevel; 1107 *oplock = rsp->OplockLevel;
1115creat_exit: 1108creat_exit: