summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrique Carvalho <henrique.carvalho@suse.com>2024-11-14 15:23:17 -0300
committerHenrique Carvalho <henrique.carvalho@suse.com>2024-11-14 16:00:19 -0300
commit17834418bc200cae3d8e1106df74eda027c0752c (patch)
tree3b7e27d18efe6775c03659e79a286202d11e3521
parent901faf55139e52654601461dd9b2954b7c701c42 (diff)
downloadlinux-17834418bc200cae3d8e1106df74eda027c0752c.tar.gz
linux-17834418bc200cae3d8e1106df74eda027c0752c.tar.bz2
linux-17834418bc200cae3d8e1106df74eda027c0752c.zip
smb: client: remove ->negotiate_rsize op
Add generic smb_negotiate_rsize function for smb21, smb30 and smb311. Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
-rw-r--r--fs/smb/client/cifsfs.c2
-rw-r--r--fs/smb/client/cifsglob.h2
-rw-r--r--fs/smb/client/connect.c7
-rw-r--r--fs/smb/client/file.c5
-rw-r--r--fs/smb/client/smb2ops.c16
-rw-r--r--fs/smb/client/smb2proto.h3
6 files changed, 22 insertions, 13 deletions
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index 990bb7d4caab..cef26233e791 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -221,7 +221,7 @@ cifs_read_super(struct super_block *sb)
/* tune readahead according to rsize if readahead size not set on mount */
if (cifs_sb->ctx->rsize == 0)
cifs_sb->ctx->rsize =
- tcon->ses->server->ops->negotiate_rsize(tcon, cifs_sb->ctx);
+ smb_negotiate_rsize(tcon, cifs_sb->ctx);
if (cifs_sb->ctx->rasize)
sb->s_bdi->ra_pages = cifs_sb->ctx->rasize / PAGE_SIZE;
else
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index e861987894ea..86d5d6840e39 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -280,8 +280,6 @@ struct smb_version_operations {
unsigned int epoch, bool *purge_cache);
/* set negotiated write size */
unsigned int (*negotiate_wsize)(struct cifs_tcon *tcon, struct smb3_fs_context *ctx);
- /* set negotiated read size */
- unsigned int (*negotiate_rsize)(struct cifs_tcon *tcon, struct smb3_fs_context *ctx);
/* informational QFS call */
void (*qfs_tcon)(const unsigned int, struct cifs_tcon *,
struct cifs_sb_info *);
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index e4027b97e168..6905ee3bfc6e 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -3302,9 +3302,10 @@ int cifs_mount_get_tcon(struct cifs_mount_ctx *mnt_ctx)
cifs_dbg(VFS, "wsize too small, reset to minimum ie PAGE_SIZE, usually 4096\n");
}
}
- if ((cifs_sb->ctx->rsize == 0) ||
- (cifs_sb->ctx->rsize > server->ops->negotiate_rsize(tcon, ctx)))
- cifs_sb->ctx->rsize = server->ops->negotiate_rsize(tcon, ctx);
+
+ unsigned int negotiated_rsize = smb_negotiate_rsize(tcon, ctx);
+ if ((cifs_sb->ctx->rsize == 0) || (cifs_sb->ctx->rsize > negotiated_rsize))
+ cifs_sb->ctx->rsize = negotiated_rsize;
/*
* The cookie is initialized from volume info returned above.
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 23e75de833bc..b671bd061af4 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -162,10 +162,7 @@ static bool cifs_clamp_length(struct netfs_io_subrequest *subreq)
rdata->server = server;
if (cifs_sb->ctx->rsize == 0)
- cifs_sb->ctx->rsize =
- server->ops->negotiate_rsize(tlink_tcon(req->cfile->tlink),
- cifs_sb->ctx);
-
+ cifs_sb->ctx->rsize = smb_negotiate_rsize(tlink_tcon(req->cfile->tlink), cifs_sb->ctx);
rc = smb2_wait_mtu_credits(server, cifs_sb->ctx->rsize,
&rsize, &rdata->credits);
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 03eb706140ba..4d673c5f1e3f 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -535,6 +535,19 @@ smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
return rsize;
}
+unsigned int
+smb_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
+{
+ u16 protocol_id = tcon->ses->server->vals->protocol_id;
+ if (protocol_id >= SMB30_PROT_ID)
+ return smb3_negotiate_rsize(tcon, ctx);
+ else if (protocol_id == SMB21_PROT_ID)
+ return smb2_negotiate_rsize(tcon, ctx);
+ else
+ pr_warn_once("unsupported protocol id 0x%x\n", protocol_id);
+ return -ENOTSUPP;
+}
+
/*
* compare two interfaces a and b
* return 0 if everything matches.
@@ -5022,7 +5035,6 @@ struct smb_version_operations smb21_operations = {
/* send_cancel is missing */
.downgrade_oplock = smb2_downgrade_oplock,
.negotiate_wsize = smb2_negotiate_wsize,
- .negotiate_rsize = smb2_negotiate_rsize,
.qfs_tcon = smb2_qfs_tcon,
.queryfs = smb2_queryfs,
.calc_signature = smb2_calc_signature,
@@ -5032,7 +5044,6 @@ struct smb_version_operations smb21_operations = {
struct smb_version_operations smb30_operations = {
.downgrade_oplock = smb3_downgrade_oplock,
.negotiate_wsize = smb3_negotiate_wsize,
- .negotiate_rsize = smb3_negotiate_rsize,
.qfs_tcon = smb3_qfs_tcon,
/* WSL tags introduced long after smb2.1, enable for SMB3, 3.11 only */
.close_getattr = smb2_close_getattr,
@@ -5050,7 +5061,6 @@ struct smb_version_operations smb30_operations = {
struct smb_version_operations smb311_operations = {
.downgrade_oplock = smb3_downgrade_oplock,
.negotiate_wsize = smb3_negotiate_wsize,
- .negotiate_rsize = smb3_negotiate_rsize,
.qfs_tcon = smb3_qfs_tcon,
.posix_mkdir = smb311_posix_mkdir,
.close_getattr = smb2_close_getattr,
diff --git a/fs/smb/client/smb2proto.h b/fs/smb/client/smb2proto.h
index 8f8e5751f9b9..95a45cd379ba 100644
--- a/fs/smb/client/smb2proto.h
+++ b/fs/smb/client/smb2proto.h
@@ -46,12 +46,15 @@ struct create_posix_rsp;
struct cifs_ntsd;
struct smb2_file_network_open_info;
struct smb311_posix_qinfo;
+struct smb3_fs_context;
/*
*****************************************************************
* All Prototypes
*****************************************************************
*/
+extern unsigned int smb_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx);
+
extern int map_smb2_to_linux_error(char *buf, bool log_err);
extern int smb2_check_message(char *buf, unsigned int length,
struct TCP_Server_Info *server);