提交 25f40259 编写于 作者: P Pavel Shilovsky 提交者: Steve French

CIFS: Fix rsize usage in user read

If a server changes maximum buffer size for read (rsize) requests
on reconnect we can fail on repeating with a big size buffer on
-EAGAIN error in user read. Fix this by checking rsize all the
time before repeating requests.
Reviewed-by: NShirish Pargaonkar <spargaonkar@suse.com>
Signed-off-by: NPavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: NSteve French <smfrench@gmail.com>
上级 0ada36b2
...@@ -2828,26 +2828,6 @@ cifs_uncached_readdata_release(struct kref *refcount) ...@@ -2828,26 +2828,6 @@ cifs_uncached_readdata_release(struct kref *refcount)
cifs_readdata_release(refcount); cifs_readdata_release(refcount);
} }
static int
cifs_retry_async_readv(struct cifs_readdata *rdata)
{
int rc;
struct TCP_Server_Info *server;
server = tlink_tcon(rdata->cfile->tlink)->ses->server;
do {
if (rdata->cfile->invalidHandle) {
rc = cifs_reopen_file(rdata->cfile, true);
if (rc != 0)
continue;
}
rc = server->ops->async_readv(rdata);
} while (rc == -EAGAIN);
return rc;
}
/** /**
* cifs_readdata_to_iov - copy data from pages in response to an iovec * cifs_readdata_to_iov - copy data from pages in response to an iovec
* @rdata: the readdata response with list of pages holding data * @rdata: the readdata response with list of pages holding data
...@@ -2941,6 +2921,9 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, ...@@ -2941,6 +2921,9 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,
size_t cur_len; size_t cur_len;
int rc; int rc;
pid_t pid; pid_t pid;
struct TCP_Server_Info *server;
server = tlink_tcon(open_file->tlink)->ses->server;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
pid = open_file->pid; pid = open_file->pid;
...@@ -2971,11 +2954,15 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, ...@@ -2971,11 +2954,15 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,
rdata->pagesz = PAGE_SIZE; rdata->pagesz = PAGE_SIZE;
rdata->read_into_pages = cifs_uncached_read_into_pages; rdata->read_into_pages = cifs_uncached_read_into_pages;
rc = cifs_retry_async_readv(rdata); if (!rdata->cfile->invalidHandle ||
!cifs_reopen_file(rdata->cfile, true))
rc = server->ops->async_readv(rdata);
error: error:
if (rc) { if (rc) {
kref_put(&rdata->refcount, kref_put(&rdata->refcount,
cifs_uncached_readdata_release); cifs_uncached_readdata_release);
if (rc == -EAGAIN)
continue;
break; break;
} }
...@@ -3023,8 +3010,8 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) ...@@ -3023,8 +3010,8 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to)
len = iov_iter_count(to); len = iov_iter_count(to);
/* the loop below should proceed in the order of increasing offsets */ /* the loop below should proceed in the order of increasing offsets */
again:
list_for_each_entry_safe(rdata, tmp, &rdata_list, list) { list_for_each_entry_safe(rdata, tmp, &rdata_list, list) {
again:
if (!rc) { if (!rc) {
/* FIXME: freezable sleep too? */ /* FIXME: freezable sleep too? */
rc = wait_for_completion_killable(&rdata->done); rc = wait_for_completion_killable(&rdata->done);
...@@ -3034,7 +3021,19 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) ...@@ -3034,7 +3021,19 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to)
rc = rdata->result; rc = rdata->result;
/* resend call if it's a retryable error */ /* resend call if it's a retryable error */
if (rc == -EAGAIN) { if (rc == -EAGAIN) {
rc = cifs_retry_async_readv(rdata); struct list_head tmp_list;
list_del_init(&rdata->list);
INIT_LIST_HEAD(&tmp_list);
rc = cifs_send_async_read(rdata->offset,
rdata->bytes, rdata->cfile,
cifs_sb, &tmp_list);
list_splice(&tmp_list, &rdata_list);
kref_put(&rdata->refcount,
cifs_uncached_readdata_release);
goto again; goto again;
} }
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册