From a785697e039fc6b3eb78dae24f39bb5fe40a27ed Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Thu, 19 May 2011 14:49:26 +0200 Subject: [PATCH] Disable splice by default Disable splice by default, add "splice_read", "splice_write" and "splice_move" options. Keep the "no_splice_*" variants, which can disable splice even if the filesystem explicitly enables it. --- ChangeLog | 6 ++++++ lib/fuse_i.h | 3 +++ lib/fuse_lowlevel.c | 22 ++++++++++++++++------ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 15fa22c..f836222 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-05-19 Miklos Szeredi + + * Disable splice by default, add "splice_read", "splice_write" and + "splice_move" options. Keep the "no_splice_*" variants, which can + disable splice even if the filesystem explicitly enables it. + 2011-04-15 Max Krasnyansky * Added support for "auto_unmount" option which unmounts the filesystem automatically on process exit (or crash). diff --git a/lib/fuse_i.h b/lib/fuse_i.h index 9d0de58..d35d5f3 100644 --- a/lib/fuse_i.h +++ b/lib/fuse_i.h @@ -63,6 +63,9 @@ struct fuse_ll { int atomic_o_trunc; int no_remote_lock; int big_writes; + int splice_write; + int splice_move; + int splice_read; int no_splice_write; int no_splice_move; int no_splice_read; diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index a19d429..1715e2e1 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -1597,11 +1597,11 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) if (req->f->conn.proto_minor >= 14) { f->conn.capable |= FUSE_CAP_SPLICE_WRITE | FUSE_CAP_SPLICE_MOVE; f->conn.capable |= FUSE_CAP_SPLICE_READ; - if (!f->no_splice_write) + if (f->splice_write) f->conn.want |= FUSE_CAP_SPLICE_WRITE; - if (!f->no_splice_move) + if (f->splice_move) f->conn.want |= FUSE_CAP_SPLICE_MOVE; - if (!f->no_splice_read && + if (f->splice_read && (f->op.write_buf || f->op.retrieve_reply)) f->conn.want |= FUSE_CAP_SPLICE_READ; } @@ -1627,6 +1627,13 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) if (f->op.init) f->op.init(f->userdata, &f->conn); + if (f->no_splice_read) + f->conn.want &= ~FUSE_CAP_SPLICE_READ; + if (f->no_splice_write) + f->conn.want &= ~FUSE_CAP_SPLICE_WRITE; + if (f->no_splice_move) + f->conn.want &= ~FUSE_CAP_SPLICE_MOVE; + if (f->conn.async_read || (f->conn.want & FUSE_CAP_ASYNC_READ)) outarg.flags |= FUSE_ASYNC_READ; if (f->conn.want & FUSE_CAP_POSIX_LOCKS) @@ -2220,8 +2227,11 @@ static struct fuse_opt fuse_ll_opts[] = { { "atomic_o_trunc", offsetof(struct fuse_ll, atomic_o_trunc), 1}, { "no_remote_lock", offsetof(struct fuse_ll, no_remote_lock), 1}, { "big_writes", offsetof(struct fuse_ll, big_writes), 1}, + { "splice_write", offsetof(struct fuse_ll, splice_write), 1}, { "no_splice_write", offsetof(struct fuse_ll, no_splice_write), 1}, + { "splice_move", offsetof(struct fuse_ll, splice_move), 1}, { "no_splice_move", offsetof(struct fuse_ll, no_splice_move), 1}, + { "splice_read", offsetof(struct fuse_ll, splice_read), 1}, { "no_splice_read", offsetof(struct fuse_ll, no_splice_read), 1}, FUSE_OPT_KEY("max_read=", FUSE_OPT_KEY_DISCARD), FUSE_OPT_KEY("-h", KEY_HELP), @@ -2249,9 +2259,9 @@ static void fuse_ll_help(void) " -o atomic_o_trunc enable atomic open+truncate support\n" " -o big_writes enable larger than 4kB writes\n" " -o no_remote_lock disable remote file locking\n" -" -o no_splice_write don't use splice to write to the fuse device\n" -" -o no_splice_move don't move data while splicing to the fuse device\n" -" -o no_splice_read don't use splice to read from the fuse device\n" +" -o [no_]splice_write use splice to write to the fuse device\n" +" -o [no_]splice_move move data while splicing to the fuse device\n" +" -o [no_]splice_read use splice to read from the fuse device\n" ); } -- 2.30.2