* [RFC PATCH 0/1] FUSE: allow drivers to increase readahead.
@ 2022-03-02 17:18 Kevin Vigor
2022-03-02 17:18 ` [RFC PATCH 1/1] FUSE: Add FUSE_TRUST_MAX_RA flag enabling readahead settings >128KB Kevin Vigor
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Vigor @ 2022-03-02 17:18 UTC (permalink / raw)
To: miklos; +Cc: linux-fsdevel, linux-kernel, Kevin Vigor
Summary:
Allow FUSE drivers to increase readahead setting.
Details:
FUSE drivers can set a max_readahead value in the fuse_init_out value.
However, this value can currently only decrease the readahead setting
from the default, which is set to VM_READAHEAD_PAGES in bdi_alloc().
Add a flag which causes the kernel driver to accept whatever
max_readahead value the user provides in fuse_init_out. Note that
read_ahead_kb_store() similarly allows users to set arbitrary ra_pages
values.
Kevin Vigor (1):
FUSE: Add FUSE_TRUST_MAX_RA flag enabling readahead settings >128KB.
fs/fuse/inode.c | 8 ++++++--
include/uapi/linux/fuse.h | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
--
2.33.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [RFC PATCH 1/1] FUSE: Add FUSE_TRUST_MAX_RA flag enabling readahead settings >128KB.
2022-03-02 17:18 [RFC PATCH 0/1] FUSE: allow drivers to increase readahead Kevin Vigor
@ 2022-03-02 17:18 ` Kevin Vigor
2022-03-10 10:27 ` Miklos Szeredi
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Vigor @ 2022-03-02 17:18 UTC (permalink / raw)
To: miklos; +Cc: linux-fsdevel, linux-kernel, Kevin Vigor
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 1/1] FUSE: Add FUSE_TRUST_MAX_RA flag enabling readahead settings >128KB.
2022-03-02 17:18 ` [RFC PATCH 1/1] FUSE: Add FUSE_TRUST_MAX_RA flag enabling readahead settings >128KB Kevin Vigor
@ 2022-03-10 10:27 ` Miklos Szeredi
0 siblings, 0 replies; 3+ messages in thread
From: Miklos Szeredi @ 2022-03-10 10:27 UTC (permalink / raw)
To: Kevin Vigor; +Cc: linux-fsdevel, linux-kernel
On Wed, 2 Mar 2022 at 18:18, Kevin Vigor <kvigor@gmail.com> wrote:
>
> 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).
read_ahead_kb only allows root to open for write. Allowing non-root
arbitrary read ahead window size is not a good idea, IMO.
Thanks,
Miklos
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-10 10:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-02 17:18 [RFC PATCH 0/1] FUSE: allow drivers to increase readahead Kevin Vigor
2022-03-02 17:18 ` [RFC PATCH 1/1] FUSE: Add FUSE_TRUST_MAX_RA flag enabling readahead settings >128KB Kevin Vigor
2022-03-10 10:27 ` Miklos Szeredi
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).