summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnzo Matsumiya <ematsumiya@suse.de>2024-11-14 13:47:34 -0300
committerEnzo Matsumiya <ematsumiya@suse.de>2024-11-14 15:54:44 -0300
commitc1aade97026dd9766e871adc047d57b4b6907c3f (patch)
treeee05a682c762169499c8bb1c1d59e42bca8d8e51
parent53caeaa17cd267570de61424de306f6a6b4e14d0 (diff)
downloadlinux-c1aade97026dd9766e871adc047d57b4b6907c3f.tar.gz
linux-c1aade97026dd9766e871adc047d57b4b6907c3f.tar.bz2
linux-c1aade97026dd9766e871adc047d57b4b6907c3f.zip
smb: client: remove ->parse_lease_buf op
Make it static in smb2pdu.c as it's used only in a single place. Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
-rw-r--r--fs/smb/client/cifsglob.h2
-rw-r--r--fs/smb/client/smb2ops.c27
-rw-r--r--fs/smb/client/smb2pdu.c27
3 files changed, 21 insertions, 35 deletions
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index d1eea3ff133b..ac3b18d18003 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -302,8 +302,6 @@ struct smb_version_operations {
struct TCP_Server_Info *server);
int (*calc_signature)(struct smb_rqst *, struct TCP_Server_Info *,
bool allocate_crypto);
- /* parse lease context buffer and return oplock/epoch info */
- __u8 (*parse_lease_buf)(void *buf, unsigned int *epoch, char *lkey);
int (*duplicate_extents)(const unsigned int, struct cifsFileInfo *src,
struct cifsFileInfo *target_file, u64 src_off, u64 len,
u64 dest_off);
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 78a73939094e..990e8c89b55d 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -3990,30 +3990,6 @@ bool smb21_is_read_op(__u32 oplock)
!(oplock & SMB2_LEASE_WRITE_CACHING_HE);
}
-static __u8
-smb2_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
-{
- struct create_lease *lc = (struct create_lease *)buf;
-
- *epoch = 0; /* not used */
- if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE)
- return SMB2_OPLOCK_LEVEL_NOCHANGE;
- return le32_to_cpu(lc->lcontext.LeaseState);
-}
-
-static __u8
-smb3_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
-{
- struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
-
- *epoch = le16_to_cpu(lc->lcontext.Epoch);
- if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE)
- return SMB2_OPLOCK_LEVEL_NOCHANGE;
- if (lease_key)
- memcpy(lease_key, &lc->lcontext.LeaseKey, SMB2_LEASE_KEY_SIZE);
- return le32_to_cpu(lc->lcontext.LeaseState);
-}
-
unsigned int smb2_wp_retry_size(struct inode *inode)
{
return min_t(unsigned int, CIFS_SB(inode->i_sb)->ctx->wsize,
@@ -5026,7 +5002,6 @@ struct smb_version_operations smb21_operations = {
.qfs_tcon = smb2_qfs_tcon,
.queryfs = smb2_queryfs,
.calc_signature = smb2_calc_signature,
- .parse_lease_buf = smb2_parse_lease_buf,
};
struct smb_version_operations smb30_operations = {
@@ -5040,7 +5015,6 @@ struct smb_version_operations smb30_operations = {
.queryfs = smb2_queryfs,
.generate_signingkey = generate_smb30signingkey,
.calc_signature = smb3_calc_signature,
- .parse_lease_buf = smb3_parse_lease_buf,
.duplicate_extents = smb2_duplicate_extents,
.fallocate = smb3_fallocate,
.init_transform_rq = smb3_init_transform_rq,
@@ -5059,7 +5033,6 @@ struct smb_version_operations smb311_operations = {
.queryfs = smb311_queryfs,
.generate_signingkey = generate_smb311signingkey,
.calc_signature = smb3_calc_signature,
- .parse_lease_buf = smb3_parse_lease_buf,
.duplicate_extents = smb2_duplicate_extents,
.fallocate = smb3_fallocate,
.init_transform_rq = smb3_init_transform_rq,
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 9ed77efb9b62..048b01c7f14f 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -2305,6 +2305,23 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
posix->nlink, posix->mode, posix->reparse_tag);
}
+/*
+ * create_lease_v2 only has an extra 4-byte padding compared to create_lease, so it's ok to use it
+ * for both cases here.
+ */
+static inline u8 parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key, u16 protocol_id)
+{
+ struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
+ bool is_smb3 = (protocol_id >= SMB30_PROT_ID);
+
+ *epoch = is_smb3 ? le16_to_cpu(lc->lcontext.Epoch) : 0;
+ if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE)
+ return SMB2_OPLOCK_LEVEL_NOCHANGE;
+ if (is_smb3 && lease_key)
+ memcpy(lease_key, &lc->lcontext.LeaseKey, SMB2_LEASE_KEY_SIZE);
+ return le32_to_cpu(lc->lcontext.LeaseState);
+}
+
int smb2_parse_contexts(struct TCP_Server_Info *server,
struct kvec *rsp_iov,
unsigned int *epoch,
@@ -2350,13 +2367,11 @@ int smb2_parse_contexts(struct TCP_Server_Info *server,
name = (char *)cc + noff;
switch (nlen) {
case 4:
- if (!strncmp(name, SMB2_CREATE_REQUEST_LEASE, 4)) {
- *oplock = server->ops->parse_lease_buf(cc, epoch,
- lease_key);
- } else if (buf &&
- !strncmp(name, SMB2_CREATE_QUERY_ON_DISK_ID, 4)) {
+ if (!strncmp(name, SMB2_CREATE_REQUEST_LEASE, 4))
+ *oplock = parse_lease_buf(cc, epoch, lease_key,
+ server->vals->protocol_id);
+ else if (buf && !strncmp(name, SMB2_CREATE_QUERY_ON_DISK_ID, 4))
parse_query_id_ctxt(cc, buf);
- }
break;
case 16:
if (posix && !memcmp(name, smb3_create_tag_posix, 16))