[Devel] [PATCH RHEL7 COMMIT] fuse: allow kernel to access "direct_io" files again

Konstantin Khorenko khorenko at virtuozzo.com
Mon Sep 30 18:41:12 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.27.2.vz7.107.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.27.2.vz7.107.10
------>
commit bf0043b935b83ca10496e7ed9af57a68c5b912f9
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Mon Sep 30 18:41:10 2019 +0300

    fuse: allow kernel to access "direct_io" files again
    
    This partially reverts bogus f2ac00874c20 ("fuse: remove direct_IO_page").
    The commit removed vital hunk needed to export fuse via nfsd.
    
    Let's bring it back.
    
    Fixes: f2ac00874c20 ("fuse: remove direct_IO_page").
    https://jira.sw.ru/browse/PSBM-97905
    
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 fs/fuse/file.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 344f35562bbe..ef2fcdbc9a05 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1703,6 +1703,21 @@ static int fuse_get_user_pages(struct fuse_req *req, struct iov_iter *ii,
 {
 	size_t nbytes = 0;  /* # bytes already packed in req */
 
+	/* Special case for kernel I/O: can copy directly into the buffer */
+	if (segment_eq(get_fs(), KERNEL_DS)) {
+		unsigned long user_addr = fuse_get_user_addr(ii);
+		size_t frag_size = fuse_get_frag_size(ii, *nbytesp);
+
+		if (write)
+			req->in.args[1].value = (void *) user_addr;
+		else
+			req->out.args[0].value = (void *) user_addr;
+
+		iov_iter_advance(ii, frag_size);
+		*nbytesp = frag_size;
+		return 0;
+	}
+
 	while (nbytes < *nbytesp && req->num_pages < req->max_pages) {
 		unsigned npages;
 		unsigned long user_addr = fuse_get_user_addr(ii);



More information about the Devel mailing list