Commit e374d90f authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French

CIFS: Fix rsize usage for sync read

If a server changes maximum buffer size for read requests (rsize)
on reconnect we can fail on repeating with a big size buffer on
-EAGAIN error in cifs_read. Fix this by checking rsize all the
time before repeating requests.
Reviewed-by: default avatarShirish Pargaonkar <spargaonkar@suse.com>
Signed-off-by: default avatarPavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent 25f40259
...@@ -3148,18 +3148,19 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset) ...@@ -3148,18 +3148,19 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)
for (total_read = 0, cur_offset = read_data; read_size > total_read; for (total_read = 0, cur_offset = read_data; read_size > total_read;
total_read += bytes_read, cur_offset += bytes_read) { total_read += bytes_read, cur_offset += bytes_read) {
current_read_size = min_t(uint, read_size - total_read, rsize); do {
current_read_size = min_t(uint, read_size - total_read,
rsize);
/* /*
* For windows me and 9x we do not want to request more than it * For windows me and 9x we do not want to request more
* negotiated since it will refuse the read then. * than it negotiated since it will refuse the read
* then.
*/ */
if ((tcon->ses) && !(tcon->ses->capabilities & if ((tcon->ses) && !(tcon->ses->capabilities &
tcon->ses->server->vals->cap_large_files)) { tcon->ses->server->vals->cap_large_files)) {
current_read_size = min_t(uint, current_read_size, current_read_size = min_t(uint,
CIFSMaxBufSize); current_read_size, CIFSMaxBufSize);
} }
rc = -EAGAIN;
while (rc == -EAGAIN) {
if (open_file->invalidHandle) { if (open_file->invalidHandle) {
rc = cifs_reopen_file(open_file, true); rc = cifs_reopen_file(open_file, true);
if (rc != 0) if (rc != 0)
...@@ -3172,7 +3173,8 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset) ...@@ -3172,7 +3173,8 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)
rc = server->ops->sync_read(xid, open_file, &io_parms, rc = server->ops->sync_read(xid, open_file, &io_parms,
&bytes_read, &cur_offset, &bytes_read, &cur_offset,
&buf_type); &buf_type);
} } while (rc == -EAGAIN);
if (rc || (bytes_read == 0)) { if (rc || (bytes_read == 0)) {
if (total_read) { if (total_read) {
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment