Adjust cifssb maximum read size
authorRohith Surabattula <rohiths@microsoft.com>
Mon, 7 Mar 2022 18:37:22 +0000 (18:37 +0000)
committerSteve French <stfrench@microsoft.com>
Sat, 19 Mar 2022 04:06:28 +0000 (23:06 -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 a61bb5d683c6551e1ab9da0c3c434f7a43dc9a1e..677c02aa8731f5b40bf583c101e022d28b3e232b 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 e7af802dcfa600293aa6bf58539dd769892ac6ff..a2723f7cb5e9d35b3d8f7f0e403b778fdb359f42 100644 (file)
@@ -3740,6 +3740,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)
@@ -4474,6 +4479,11 @@ static void cifs_readahead(struct readahead_control *ractl)
                        }
                }
 
+               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)