Adjust cifssb maximum read size
authorSteve French <stfrench@microsoft.com>
Wed, 20 Apr 2022 14:13:10 +0000 (09:13 -0500)
committerSteve French <stfrench@microsoft.com>
Thu, 21 Jul 2022 15:40:01 +0000 (10:40 -0500)
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>
fs/cifs/cifsfs.c
fs/cifs/file.c

index e1bfa419f6230747a4c54dd804e007a38a1bb9a1..cbbd94940522279804212913e7fab63ea718b749 100644 (file)
@@ -210,6 +210,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 82bbaf8e92b79c8a99c13ae1946b3e2dd1ec1a88..b23f6b489bb9d90662cd4fb21deb36cdd037fd6b 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)