]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Adjust cifssb maximum read size
authorRohith Surabattula <rohiths@microsoft.com>
Mon, 7 Mar 2022 18:37:22 +0000 (18:37 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:06:36 +0000 (14:06 +0200)
[ Upstream commit 06a466565d54a1a42168f9033a062a3f5c40e73b ]

When session gets reconnected during mount then read size in super block fs context
gets set to zero and after negotiate, rsize is not modified which results in
incorrect read with requested bytes as zero. Fixes intermittent failure
of xfstest generic/240

Note that stable requires a different version of this patch which will be
sent to the stable mailing list.

Signed-off-by: Rohith Surabattula <rohiths@microsoft.com>
Acked-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/cifs/cifsfs.c
fs/cifs/file.c

index 9dd5f89557b7099e921bb0ff9f2f4b50ee6eae23..02b762b7e3fda84d9c75032aebf98411b8e6b808 100644 (file)
@@ -209,6 +209,9 @@ cifs_read_super(struct super_block *sb)
        if (rc)
                goto out_no_root;
        /* 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);
        if (cifs_sb->ctx->rasize)
                sb->s_bdi->ra_pages = cifs_sb->ctx->rasize / PAGE_SIZE;
        else
index 9fee3af83a7369ba7d748ca3b36c66d0f7808cfc..abadc2f86dea6a7c5b1fb19b1d9012656d74d4d9 100644 (file)
@@ -3734,6 +3734,11 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,
                                break;
                }
 
+               if (cifs_sb->ctx->rsize == 0)
+                       cifs_sb->ctx->rsize =
+                               server->ops->negotiate_rsize(tlink_tcon(open_file->tlink),
+                                                            cifs_sb->ctx);
+
                rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
                                                   &rsize, credits);
                if (rc)
@@ -4512,6 +4517,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
                                break;
                }
 
+               if (cifs_sb->ctx->rsize == 0)
+                       cifs_sb->ctx->rsize =
+                               server->ops->negotiate_rsize(tlink_tcon(open_file->tlink),
+                                                            cifs_sb->ctx);
+
                rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
                                                   &rsize, credits);
                if (rc)