aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/smb2pdu.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 9a35dcda9099..e65ccdb528cf 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -878,6 +878,29 @@ parse_lease_state(struct smb2_create_rsp *rsp)
878 return smb2_map_lease_to_oplock(lc->lcontext.LeaseState); 878 return smb2_map_lease_to_oplock(lc->lcontext.LeaseState);
879} 879}
880 880
881static int
882add_lease_context(struct kvec *iov, unsigned int *num_iovec, __u8 *oplock)
883{
884 struct smb2_create_req *req = iov[0].iov_base;
885 unsigned int num = *num_iovec;
886
887 iov[num].iov_base = create_lease_buf(oplock+1, *oplock);
888 if (iov[num].iov_base == NULL)
889 return -ENOMEM;
890 iov[num].iov_len = sizeof(struct create_lease);
891 req->RequestedOplockLevel = SMB2_OPLOCK_LEVEL_LEASE;
892 if (!req->CreateContextsOffset)
893 req->CreateContextsOffset = cpu_to_le32(
894 sizeof(struct smb2_create_req) - 4 +
895 iov[num - 1].iov_len);
896 req->CreateContextsLength = cpu_to_le32(
897 le32_to_cpu(req->CreateContextsLength) +
898 sizeof(struct create_lease));
899 inc_rfc1001_len(&req->hdr, sizeof(struct create_lease));
900 *num_iovec = num + 1;
901 return 0;
902}
903
881int 904int
882SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, 905SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
883 u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access, 906 u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access,
@@ -956,21 +979,12 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
956 *oplock == SMB2_OPLOCK_LEVEL_NONE) 979 *oplock == SMB2_OPLOCK_LEVEL_NONE)
957 req->RequestedOplockLevel = *oplock; 980 req->RequestedOplockLevel = *oplock;
958 else { 981 else {
959 iov[num_iovecs].iov_base = create_lease_buf(oplock+1, *oplock); 982 rc = add_lease_context(iov, &num_iovecs, oplock);
960 if (iov[num_iovecs].iov_base == NULL) { 983 if (rc) {
961 cifs_small_buf_release(req); 984 cifs_small_buf_release(req);
962 kfree(copy_path); 985 kfree(copy_path);
963 return -ENOMEM; 986 return rc;
964 } 987 }
965 iov[num_iovecs].iov_len = sizeof(struct create_lease);
966 req->RequestedOplockLevel = SMB2_OPLOCK_LEVEL_LEASE;
967 req->CreateContextsOffset = cpu_to_le32(
968 sizeof(struct smb2_create_req) - 4 +
969 iov[num_iovecs-1].iov_len);
970 req->CreateContextsLength = cpu_to_le32(
971 sizeof(struct create_lease));
972 inc_rfc1001_len(&req->hdr, sizeof(struct create_lease));
973 num_iovecs++;
974 } 988 }
975 989
976 rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0); 990 rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);