Commit d22cbfec authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French

CIFS: Simplify SMB2 create context handling

to make it easier to add other create context further.
Signed-off-by: default avatarPavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: default avatarSteven French <steven@steven-GA-970A-DS3.(none)>
parent 59aa3718
...@@ -878,6 +878,29 @@ parse_lease_state(struct smb2_create_rsp *rsp) ...@@ -878,6 +878,29 @@ parse_lease_state(struct smb2_create_rsp *rsp)
return smb2_map_lease_to_oplock(lc->lcontext.LeaseState); return smb2_map_lease_to_oplock(lc->lcontext.LeaseState);
} }
static int
add_lease_context(struct kvec *iov, unsigned int *num_iovec, __u8 *oplock)
{
struct smb2_create_req *req = iov[0].iov_base;
unsigned int num = *num_iovec;
iov[num].iov_base = create_lease_buf(oplock+1, *oplock);
if (iov[num].iov_base == NULL)
return -ENOMEM;
iov[num].iov_len = sizeof(struct create_lease);
req->RequestedOplockLevel = SMB2_OPLOCK_LEVEL_LEASE;
if (!req->CreateContextsOffset)
req->CreateContextsOffset = cpu_to_le32(
sizeof(struct smb2_create_req) - 4 +
iov[num - 1].iov_len);
req->CreateContextsLength = cpu_to_le32(
le32_to_cpu(req->CreateContextsLength) +
sizeof(struct create_lease));
inc_rfc1001_len(&req->hdr, sizeof(struct create_lease));
*num_iovec = num + 1;
return 0;
}
int int
SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access, 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,21 +979,12 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
*oplock == SMB2_OPLOCK_LEVEL_NONE) *oplock == SMB2_OPLOCK_LEVEL_NONE)
req->RequestedOplockLevel = *oplock; req->RequestedOplockLevel = *oplock;
else { else {
iov[num_iovecs].iov_base = create_lease_buf(oplock+1, *oplock); rc = add_lease_context(iov, &num_iovecs, oplock);
if (iov[num_iovecs].iov_base == NULL) { if (rc) {
cifs_small_buf_release(req); cifs_small_buf_release(req);
kfree(copy_path); kfree(copy_path);
return -ENOMEM; return rc;
} }
iov[num_iovecs].iov_len = sizeof(struct create_lease);
req->RequestedOplockLevel = SMB2_OPLOCK_LEVEL_LEASE;
req->CreateContextsOffset = cpu_to_le32(
sizeof(struct smb2_create_req) - 4 +
iov[num_iovecs-1].iov_len);
req->CreateContextsLength = cpu_to_le32(
sizeof(struct create_lease));
inc_rfc1001_len(&req->hdr, sizeof(struct create_lease));
num_iovecs++;
} }
rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0); rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment