aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/smb2pdu.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-09-19 09:22:45 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:33 -0400
commit0822f51426b51bd599b3a7e972b14aacaa045a92 (patch)
treec11376ec62881566a6ca9e1f7ef85881fc961599 /fs/cifs/smb2pdu.c
parent25078105fbe14e7b3270391eaa11514bec787a52 (diff)
CIFS: Add SMB2.1 lease break support
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/smb2pdu.c')
-rw-r--r--fs/cifs/smb2pdu.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 89d2824587b2..1572abefb378 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -911,7 +911,6 @@ parse_lease_state(struct smb2_create_rsp *rsp)
911{ 911{
912 char *data_offset; 912 char *data_offset;
913 struct create_lease *lc; 913 struct create_lease *lc;
914 __u8 oplock = 0;
915 bool found = false; 914 bool found = false;
916 915
917 data_offset = (char *)rsp; 916 data_offset = (char *)rsp;
@@ -932,19 +931,9 @@ parse_lease_state(struct smb2_create_rsp *rsp)
932 } while (le32_to_cpu(lc->ccontext.Next) != 0); 931 } while (le32_to_cpu(lc->ccontext.Next) != 0);
933 932
934 if (!found) 933 if (!found)
935 return oplock; 934 return 0;
936
937 if (le32_to_cpu(lc->lcontext.LeaseState) & SMB2_LEASE_WRITE_CACHING) {
938 if (le32_to_cpu(lc->lcontext.LeaseState) &
939 SMB2_LEASE_HANDLE_CACHING)
940 oplock = SMB2_OPLOCK_LEVEL_BATCH;
941 else
942 oplock = SMB2_OPLOCK_LEVEL_EXCLUSIVE;
943 } else if (le32_to_cpu(lc->lcontext.LeaseState) &
944 SMB2_LEASE_READ_CACHING)
945 oplock = SMB2_OPLOCK_LEVEL_II;
946 935
947 return oplock; 936 return smb2_map_lease_to_oplock(lc->lcontext.LeaseState);
948} 937}
949 938
950int 939int
@@ -2228,3 +2217,34 @@ SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
2228 2217
2229 return smb2_lockv(xid, tcon, persist_fid, volatile_fid, pid, 1, &lock); 2218 return smb2_lockv(xid, tcon, persist_fid, volatile_fid, pid, 1, &lock);
2230} 2219}
2220
2221int
2222SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
2223 __u8 *lease_key, const __le32 lease_state)
2224{
2225 int rc;
2226 struct smb2_lease_ack *req = NULL;
2227
2228 cFYI(1, "SMB2_lease_break");
2229 rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req);
2230
2231 if (rc)
2232 return rc;
2233
2234 req->hdr.CreditRequest = cpu_to_le16(1);
2235 req->StructureSize = cpu_to_le16(36);
2236 inc_rfc1001_len(req, 12);
2237
2238 memcpy(req->LeaseKey, lease_key, 16);
2239 req->LeaseState = lease_state;
2240
2241 rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, CIFS_OBREAK_OP);
2242 /* SMB2 buffer freed by function above */
2243
2244 if (rc) {
2245 cifs_stats_fail_inc(tcon, SMB2_OPLOCK_BREAK_HE);
2246 cFYI(1, "Send error in Lease Break = %d", rc);
2247 }
2248
2249 return rc;
2250}