]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: allow use of direct io for disk access
authorDarrick J. Wong <djwong@kernel.org>
Thu, 24 Apr 2025 21:46:33 +0000 (14:46 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 21 May 2025 14:29:30 +0000 (10:29 -0400)
Allow users to ask for O_DIRECT for disk accesses so that block device
writes won't be throttled.  This should improve latency, but will put
a lot more pressure on the disk cache.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174553065581.1161238.969038742323698265.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/fuse2fs.1.in
misc/fuse2fs.c

index 517c67ff7199116403fcf7d70ccc577931e750ec..43678a1c1971c53353efd312384b03fd40d017c2 100644 (file)
@@ -62,6 +62,9 @@ Enables setuid and device files.
 Note that these options can still be overridden (e.g.
 .I nosuid
 ) later.
+.TP
+.BR -o direct
+Use O_DIRECT to access the block device.
 .SS "FUSE options:"
 .TP
 \fB-d -o\fR debug
index efe8614f69be9efce5a3802f8d90ff169d4f6263..96f30ac240e6b6f88a548216190b69301953d7c4 100644 (file)
@@ -158,6 +158,7 @@ struct fuse2fs {
        int alloc_all_blocks;
        int norecovery;
        int kernel;
+       int directio;
        unsigned long offset;
        unsigned int next_generation;
 };
@@ -3776,6 +3777,7 @@ static struct fuse_opt fuse2fs_opts[] = {
        FUSE2FS_OPT("noload",           norecovery,             1),
        FUSE2FS_OPT("offset=%lu",       offset,                 0),
        FUSE2FS_OPT("kernel",           kernel,                 1),
+       FUSE2FS_OPT("directio",         directio,               1),
 
        FUSE_OPT_KEY("acl",             FUSE2FS_IGNORED),
        FUSE_OPT_KEY("user_xattr",      FUSE2FS_IGNORED),
@@ -3824,6 +3826,7 @@ static int fuse2fs_opt_proc(void *data, const char *arg,
        "    -o fuse2fs_debug       enable fuse2fs debugging\n"
        "    -o kernel              run this as if it were the kernel, which sets:\n"
        "                           allow_others,default_permissions,suid,dev\n"
+       "    -o directio            use O_DIRECT to read and write the disk\n"
        "\n",
                        outargs->argv[0]);
                if (key == FUSE2FS_HELPFULL) {
@@ -3929,6 +3932,8 @@ int main(int argc, char *argv[])
        ret = 2;
        char options[50];
        sprintf(options, "offset=%lu", fctx.offset);
+       if (fctx.directio)
+               flags |= EXT2_FLAG_DIRECT_IO;
        err = ext2fs_open2(fctx.device, options, flags, 0, 0, unix_io_manager,
                           &global_fs);
        if (err) {