summaryrefslogtreecommitdiffstats
path: root/fs/cifs/smb2pdu.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-09-19 06:22:45 -0700
committerSteve French <smfrench@gmail.com>2012-09-24 21:46:33 -0500
commit0822f51426b51bd599b3a7e972b14aacaa045a92 (patch)
treec11376ec62881566a6ca9e1f7ef85881fc961599 /fs/cifs/smb2pdu.c
parent25078105fbe14e7b3270391eaa11514bec787a52 (diff)
downloadop-kernel-dev-0822f51426b51bd599b3a7e972b14aacaa045a92.zip
op-kernel-dev-0822f51426b51bd599b3a7e972b14aacaa045a92.tar.gz
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 89d2824..1572abe 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -911,7 +911,6 @@ parse_lease_state(struct smb2_create_rsp *rsp)
{
char *data_offset;
struct create_lease *lc;
- __u8 oplock = 0;
bool found = false;
data_offset = (char *)rsp;
@@ -932,19 +931,9 @@ parse_lease_state(struct smb2_create_rsp *rsp)
} while (le32_to_cpu(lc->ccontext.Next) != 0);
if (!found)
- return oplock;
-
- if (le32_to_cpu(lc->lcontext.LeaseState) & SMB2_LEASE_WRITE_CACHING) {
- if (le32_to_cpu(lc->lcontext.LeaseState) &
- SMB2_LEASE_HANDLE_CACHING)
- oplock = SMB2_OPLOCK_LEVEL_BATCH;
- else
- oplock = SMB2_OPLOCK_LEVEL_EXCLUSIVE;
- } else if (le32_to_cpu(lc->lcontext.LeaseState) &
- SMB2_LEASE_READ_CACHING)
- oplock = SMB2_OPLOCK_LEVEL_II;
+ return 0;
- return oplock;
+ return smb2_map_lease_to_oplock(lc->lcontext.LeaseState);
}
int
@@ -2228,3 +2217,34 @@ SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
return smb2_lockv(xid, tcon, persist_fid, volatile_fid, pid, 1, &lock);
}
+
+int
+SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
+ __u8 *lease_key, const __le32 lease_state)
+{
+ int rc;
+ struct smb2_lease_ack *req = NULL;
+
+ cFYI(1, "SMB2_lease_break");
+ rc = small_smb2_init(SMB2_OPLOCK_BREAK, tcon, (void **) &req);
+
+ if (rc)
+ return rc;
+
+ req->hdr.CreditRequest = cpu_to_le16(1);
+ req->StructureSize = cpu_to_le16(36);
+ inc_rfc1001_len(req, 12);
+
+ memcpy(req->LeaseKey, lease_key, 16);
+ req->LeaseState = lease_state;
+
+ rc = SendReceiveNoRsp(xid, tcon->ses, (char *) req, CIFS_OBREAK_OP);
+ /* SMB2 buffer freed by function above */
+
+ if (rc) {
+ cifs_stats_fail_inc(tcon, SMB2_OPLOCK_BREAK_HE);
+ cFYI(1, "Send error in Lease Break = %d", rc);
+ }
+
+ return rc;
+}
OpenPOWER on IntegriCloud