summaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorPavel Shilovsky2014-07-10 09:31:48 +0200
committerSteve French2014-08-02 08:23:04 +0200
commitd913ed17f0a7d74e2847695bc920d77a33f2490b (patch)
tree2c511ecc0304b341b370834fc989d4b9d3c42d60 /fs/cifs/file.c
parentCIFS: Improve indentation in cifs_user_read() (diff)
downloadkernel-qcow2-linux-d913ed17f0a7d74e2847695bc920d77a33f2490b.tar.gz
kernel-qcow2-linux-d913ed17f0a7d74e2847695bc920d77a33f2490b.tar.xz
kernel-qcow2-linux-d913ed17f0a7d74e2847695bc920d77a33f2490b.zip
CIFS: Optimize cifs_user_read() in a short read case on reconnects
by filling the output buffer with a data got from a partially received response and requesting the remaining data from the server. This is suitable for non-signed connections. Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index e17012817d9d..5d2501df8f6b 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3030,13 +3030,30 @@ again:
else if (rdata->result == -EAGAIN) {
/* resend call if it's a retryable error */
struct list_head tmp_list;
+ unsigned int got_bytes = rdata->got_bytes;
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);
+ /*
+ * Got a part of data and then reconnect has
+ * happened -- fill the buffer and continue
+ * reading.
+ */
+ if (got_bytes && got_bytes < rdata->bytes) {
+ rc = cifs_readdata_to_iov(rdata, to);
+ if (rc) {
+ kref_put(&rdata->refcount,
+ cifs_uncached_readdata_release);
+ continue;
+ }
+ }
+
+ rc = cifs_send_async_read(
+ rdata->offset + got_bytes,
+ rdata->bytes - got_bytes,
+ rdata->cfile, cifs_sb,
+ &tmp_list);
list_splice(&tmp_list, &rdata_list);