[Devel,RHEL7,COMMIT] fuse: process small sync direct reads synchronously

Submitted by Konstantin Khorenko on Oct. 24, 2016, 11:45 a.m.

Details

Message ID 201610241145.u9OBjOF4022445@finist_cl7.x64_64.work.ct
State New
Series "fuse: process small sync direct reads synchronously"
Headers show

Commit Message

Konstantin Khorenko Oct. 24, 2016, 11:45 a.m.
The commit is pushed to "branch-rh7-3.10.0-327.36.1.vz7.19.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.36.1.vz7.19.3
------>
commit 941e9596b36bbfbf8aa753bb8815b2cfb093a4cd
Author: Maxim Patlasov <mpatlasov@virtuozzo.com>
Date:   Mon Oct 24 15:45:23 2016 +0400

    fuse: process small sync direct reads synchronously
    
    It is useless to process small sync direct reads asynchronously,
    because that optimization works only if we send more than one
    request to userspace fused concurrently.
    
    On the other hand, the patch workarounds a problem reported by AK:
    
    > If a cluster hangs (for any reason), all max_background fuse
    > requests are usually consumed and async io is impossible.
    > Unfortunately it also makes impossible to read .vstorage.info
    > that is necessary to investigate why the cluster hanged.
    
    Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 fs/fuse/file.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 6b9e4ea..49ee3de 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -3307,8 +3307,11 @@  fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
 	 * We cannot asynchronously extend the size of a file. We have no method
 	 * to wait on real async I/O requests, so we must submit this request
 	 * synchronously.
+	 * And it's useless to process small sync READs asynchronously.
 	 */
-	if (!is_sync_kiocb(iocb) && (offset + count > i_size) && rw == WRITE)
+	if ((!is_sync_kiocb(iocb) && (offset + count > i_size) && rw == WRITE) ||
+	    (rw != WRITE && is_sync_kiocb(iocb) &&
+	     count <= (FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT)))
 		io->async = false;
 
 	if (rw == WRITE)