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

Submitted by Maxim Patlasov on Oct. 14, 2016, 1:25 a.m.

Details

Message ID 147640829681.16351.15066476241299108133.stgit@maxim-thinkpad
State New
Series "fuse: process small sync direct reads synchronously"
Headers show

Commit Message

Maxim Patlasov Oct. 14, 2016, 1:25 a.m.
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)