linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Vigor <kvigor@gmail.com>
To: miklos@szeredi.hu
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kevin Vigor <kvigor@gmail.com>
Subject: [RFC PATCH 1/1] FUSE: Add FUSE_TRUST_MAX_RA flag enabling readahead settings >128KB.
Date: Wed,  2 Mar 2022 10:18:16 -0700	[thread overview]
Message-ID: <20220302171816.1170782-2-kvigor@gmail.com> (raw)
In-Reply-To: <20220302171816.1170782-1-kvigor@gmail.com>

The existing process_init_reply() in fs/fuse/inode.c sets the ra_pages
value to the minimum of the max_readahead value provided by the user
and the pre-existing ra_pages value, which is initialized to
VM_READAHEAD_PAGES. This makes it impossible to increase the readahead
value to larger values.

Add a new flag which causes us to blindly accept the user-provided
value. Note that the existing read_ahead_kb sysfs entry for normal
block devices does the same (simply accepts user-provided values
directly with no checks).

Signed-off-by: Kevin Vigor <kvigor@gmail.com>
---
 fs/fuse/inode.c           | 8 ++++++--
 include/uapi/linux/fuse.h | 3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 8b89e3ba7df3..81c96c404a76 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1182,8 +1182,12 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args,
 			fc->no_flock = 1;
 		}
 
-		fm->sb->s_bdi->ra_pages =
+		if (arg->flags & FUSE_TRUST_MAX_RA) {
+			fm->sb->s_bdi->ra_pages = ra_pages;
+		} else {
+			fm->sb->s_bdi->ra_pages =
 				min(fm->sb->s_bdi->ra_pages, ra_pages);
+		}
 		fc->minor = arg->minor;
 		fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
 		fc->max_write = max_t(unsigned, 4096, fc->max_write);
@@ -1219,7 +1223,7 @@ void fuse_send_init(struct fuse_mount *fm)
 		FUSE_PARALLEL_DIROPS | FUSE_HANDLE_KILLPRIV | FUSE_POSIX_ACL |
 		FUSE_ABORT_ERROR | FUSE_MAX_PAGES | FUSE_CACHE_SYMLINKS |
 		FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA |
-		FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT;
+		FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT | FUSE_TRUST_MAX_RA;
 #ifdef CONFIG_FUSE_DAX
 	if (fm->fc->dax)
 		ia->in.flags |= FUSE_MAP_ALIGNMENT;
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index a1dc3ee1d17c..df9840f4642f 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -341,6 +341,8 @@ struct fuse_file_lock {
  *			write/truncate sgid is killed only if file has group
  *			execute permission. (Same as Linux VFS behavior).
  * FUSE_SETXATTR_EXT:	Server supports extended struct fuse_setxattr_in
+ * FUSE_TRUST_MAX_RA:	Accept the user-provided max_readahead value instead
+ *			of clamping to <= VM_READAHEAD_PAGES.
  */
 #define FUSE_ASYNC_READ		(1 << 0)
 #define FUSE_POSIX_LOCKS	(1 << 1)
@@ -372,6 +374,7 @@ struct fuse_file_lock {
 #define FUSE_SUBMOUNTS		(1 << 27)
 #define FUSE_HANDLE_KILLPRIV_V2	(1 << 28)
 #define FUSE_SETXATTR_EXT	(1 << 29)
+#define FUSE_TRUST_MAX_RA	(1 << 30)
 
 /**
  * CUSE INIT request/reply flags
-- 
2.33.1


  reply	other threads:[~2022-03-02 17:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 17:18 [RFC PATCH 0/1] FUSE: allow drivers to increase readahead Kevin Vigor
2022-03-02 17:18 ` Kevin Vigor [this message]
2022-03-10 10:27   ` [RFC PATCH 1/1] FUSE: Add FUSE_TRUST_MAX_RA flag enabling readahead settings >128KB Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220302171816.1170782-2-kvigor@gmail.com \
    --to=kvigor@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).