diff options
author | Bernd Schubert <bschubert@ddn.com> | 2025-04-15 20:42:19 +0200 |
---|---|---|
committer | Bernd Schubert <bernd@bsbernd.com> | 2025-04-28 19:57:39 +0200 |
commit | 91c9803cb4dc5251abbb9af312c917dddfdd689e (patch) | |
tree | 913630bb6c3a578017687f60038bf4be4322a697 /example/passthrough_hp.cc | |
parent | 538b51feedbcdcd78beefd7517ff19c77c4e4526 (diff) | |
download | libfuse-91c9803cb4dc5251abbb9af312c917dddfdd689e.tar.gz |
passthrough_hp: Add io-uring options
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
Diffstat (limited to 'example/passthrough_hp.cc')
-rw-r--r-- | example/passthrough_hp.cc | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/example/passthrough_hp.cc b/example/passthrough_hp.cc index 8b5214c..b88c2c5 100644 --- a/example/passthrough_hp.cc +++ b/example/passthrough_hp.cc @@ -77,6 +77,9 @@ using namespace std; #define SFS_DEFAULT_THREADS "-1" // take libfuse value as default #define SFS_DEFAULT_CLONE_FD "0" +#define SFS_DEFAULT_URING "1" +#define SFS_DEFAULT_URING_Q_DEPTH "0" +#define SFS_DEFAULT_URING_ARGLEN "0" /* We are re-using pointers to our `struct sfs_inode` and `struct sfs_dirp` elements as inodes and file handles. This means that we @@ -155,6 +158,11 @@ struct Fs { bool nocache; size_t num_threads; bool clone_fd; + struct { + bool enable; + int queue_depth; + } uring; + std::string fuse_mount_options; bool direct_io; bool passthrough; @@ -1400,10 +1408,12 @@ static cxxopts::ParseResult parse_options(int argc, char **argv) { ("o", "Mount options (see mount.fuse(5) - only use if you know what " "you are doing)", cxxopts::value(mount_options)) ("num-threads", "Number of libfuse worker threads", - cxxopts::value<int>()->default_value(SFS_DEFAULT_THREADS)) + cxxopts::value<int>()->default_value(SFS_DEFAULT_THREADS)) ("clone-fd", "use separate fuse device fd for each thread") - ("direct-io", "enable fuse kernel internal direct-io"); - + ("direct-io", "enable fuse kernel internal direct-io") + ("uring", "use uring communication") + ("uring-q-depth", "io-uring queue depth", + cxxopts::value<int>()->default_value(SFS_DEFAULT_URING_Q_DEPTH)); // FIXME: Find a better way to limit the try clause to just // opt_parser.parse() (cf. https://github.com/jarro2783/cxxopts/issues/146) auto options = parse_wrapper(opt_parser, argc, argv); @@ -1435,6 +1445,10 @@ static cxxopts::ParseResult parse_options(int argc, char **argv) { fs.num_threads = options["num-threads"].as<int>(); fs.clone_fd = options.count("clone-fd"); fs.direct_io = options.count("direct-io"); + + fs.uring.enable = options.count("uring"); + fs.uring.queue_depth = options["uring-q-depth"].as<int>(); + char* resolved_path = realpath(argv[1], NULL); if (resolved_path == NULL) warn("WARNING: realpath() failed with"); @@ -1518,7 +1532,14 @@ int main(int argc, char *argv[]) { fuse_opt_add_arg(&args, "-o") || fuse_opt_add_arg(&args, fs.fuse_mount_options.c_str()) || (fs.debug_fuse && fuse_opt_add_arg(&args, "-odebug"))) - errx(3, "ERROR: Out of memory"); + errx(3, "ERROR: Out of memory adding arguments"); + + if (fs.uring.enable) { + if (fuse_opt_add_arg(&args, "-oio_uring") || + fuse_opt_add_arg(&args, ("-oio_uring_q_depth=" + + std::to_string(fs.uring.queue_depth)).c_str())) + errx(3, "ERROR: Out of memory adding io-uring arguments"); + } ret = -1; fuse_lowlevel_ops sfs_oper {}; |