Commit 96164ab2 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: store the leaseKey in the fid on SMB2_open

In SMB2_open(), if we got a lease we need to store this in the fid structure
or else we will never be able to map a lease break back to which file/fid
it applies to.
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent 71992e62
...@@ -417,7 +417,7 @@ struct smb_version_operations { ...@@ -417,7 +417,7 @@ struct smb_version_operations {
/* create lease context buffer for CREATE request */ /* create lease context buffer for CREATE request */
char * (*create_lease_buf)(u8 *, u8); char * (*create_lease_buf)(u8 *, u8);
/* parse lease context buffer and return oplock/epoch info */ /* parse lease context buffer and return oplock/epoch info */
__u8 (*parse_lease_buf)(void *, unsigned int *); __u8 (*parse_lease_buf)(void *buf, unsigned int *epoch, char *lkey);
ssize_t (*copychunk_range)(const unsigned int, ssize_t (*copychunk_range)(const unsigned int,
struct cifsFileInfo *src_file, struct cifsFileInfo *src_file,
struct cifsFileInfo *target_file, struct cifsFileInfo *target_file,
......
...@@ -2079,7 +2079,7 @@ smb3_create_lease_buf(u8 *lease_key, u8 oplock) ...@@ -2079,7 +2079,7 @@ smb3_create_lease_buf(u8 *lease_key, u8 oplock)
} }
static __u8 static __u8
smb2_parse_lease_buf(void *buf, unsigned int *epoch) smb2_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
{ {
struct create_lease *lc = (struct create_lease *)buf; struct create_lease *lc = (struct create_lease *)buf;
...@@ -2090,13 +2090,16 @@ smb2_parse_lease_buf(void *buf, unsigned int *epoch) ...@@ -2090,13 +2090,16 @@ smb2_parse_lease_buf(void *buf, unsigned int *epoch)
} }
static __u8 static __u8
smb3_parse_lease_buf(void *buf, unsigned int *epoch) smb3_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
{ {
struct create_lease_v2 *lc = (struct create_lease_v2 *)buf; struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
*epoch = le16_to_cpu(lc->lcontext.Epoch); *epoch = le16_to_cpu(lc->lcontext.Epoch);
if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS) if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
return SMB2_OPLOCK_LEVEL_NOCHANGE; return SMB2_OPLOCK_LEVEL_NOCHANGE;
if (lease_key)
memcpy(lease_key, &lc->lcontext.LeaseKeyLow,
SMB2_LEASE_KEY_SIZE);
return le32_to_cpu(lc->lcontext.LeaseState); return le32_to_cpu(lc->lcontext.LeaseState);
} }
......
...@@ -1575,7 +1575,7 @@ create_reconnect_durable_buf(struct cifs_fid *fid) ...@@ -1575,7 +1575,7 @@ create_reconnect_durable_buf(struct cifs_fid *fid)
static __u8 static __u8
parse_lease_state(struct TCP_Server_Info *server, struct smb2_create_rsp *rsp, parse_lease_state(struct TCP_Server_Info *server, struct smb2_create_rsp *rsp,
unsigned int *epoch) unsigned int *epoch, char *lease_key)
{ {
char *data_offset; char *data_offset;
struct create_context *cc; struct create_context *cc;
...@@ -1590,7 +1590,8 @@ parse_lease_state(struct TCP_Server_Info *server, struct smb2_create_rsp *rsp, ...@@ -1590,7 +1590,8 @@ parse_lease_state(struct TCP_Server_Info *server, struct smb2_create_rsp *rsp,
name = le16_to_cpu(cc->NameOffset) + (char *)cc; name = le16_to_cpu(cc->NameOffset) + (char *)cc;
if (le16_to_cpu(cc->NameLength) == 4 && if (le16_to_cpu(cc->NameLength) == 4 &&
strncmp(name, "RqLs", 4) == 0) strncmp(name, "RqLs", 4) == 0)
return server->ops->parse_lease_buf(cc, epoch); return server->ops->parse_lease_buf(cc, epoch,
lease_key);
next = le32_to_cpu(cc->Next); next = le32_to_cpu(cc->Next);
if (!next) if (!next)
...@@ -1972,7 +1973,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, ...@@ -1972,7 +1973,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
} }
if (rsp->OplockLevel == SMB2_OPLOCK_LEVEL_LEASE) if (rsp->OplockLevel == SMB2_OPLOCK_LEVEL_LEASE)
*oplock = parse_lease_state(server, rsp, &oparms->fid->epoch); *oplock = parse_lease_state(server, rsp, &oparms->fid->epoch,
oparms->fid->lease_key);
else else
*oplock = rsp->OplockLevel; *oplock = rsp->OplockLevel;
creat_exit: creat_exit:
......
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