Skip to content

Commit 60b9df7

Browse files
author
Miklos Szeredi
committed
fuse: add flag to turn on async direct IO
Without async DIO write requests to a single file were always serialized. With async DIO that's no longer the case. So don't turn on async DIO by default for fear of breaking backward compatibility. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
1 parent efb9fa9 commit 60b9df7

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎fs/fuse/file.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,14 +2371,14 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
23712371
loff_t offset, unsigned long nr_segs)
23722372
{
23732373
ssize_t ret = 0;
2374-
struct file *file = NULL;
2374+
struct file *file = iocb->ki_filp;
2375+
struct fuse_file *ff = file->private_data;
23752376
loff_t pos = 0;
23762377
struct inode *inode;
23772378
loff_t i_size;
23782379
size_t count = iov_length(iov, nr_segs);
23792380
struct fuse_io_priv *io;
23802381

2381-
file = iocb->ki_filp;
23822382
pos = offset;
23832383
inode = file->f_mapping->host;
23842384
i_size = i_size_read(inode);
@@ -2403,9 +2403,9 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
24032403
io->file = file;
24042404
/*
24052405
* By default, we want to optimize all I/Os with async request
2406-
* submission to the client filesystem.
2406+
* submission to the client filesystem if supported.
24072407
*/
2408-
io->async = 1;
2408+
io->async = ff->fc->async_dio;
24092409
io->iocb = iocb;
24102410

24112411
/*

‎fs/fuse/fuse_i.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ struct fuse_conn {
541541
/** Does the filesystem want adaptive readdirplus? */
542542
unsigned readdirplus_auto:1;
543543

544+
/** Does the filesystem support asynchronous direct-IO submission? */
545+
unsigned async_dio:1;
546+
544547
/** The number of requests waiting for completion */
545548
atomic_t num_waiting;
546549

‎fs/fuse/inode.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,8 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
871871
fc->do_readdirplus = 1;
872872
if (arg->flags & FUSE_READDIRPLUS_AUTO)
873873
fc->readdirplus_auto = 1;
874+
if (arg->flags & FUSE_ASYNC_DIO)
875+
fc->async_dio = 1;
874876
} else {
875877
ra_pages = fc->max_read / PAGE_CACHE_SIZE;
876878
fc->no_lock = 1;
@@ -898,7 +900,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
898900
FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK |
899901
FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ |
900902
FUSE_FLOCK_LOCKS | FUSE_IOCTL_DIR | FUSE_AUTO_INVAL_DATA |
901-
FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO;
903+
FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO;
902904
req->in.h.opcode = FUSE_INIT;
903905
req->in.numargs = 1;
904906
req->in.args[0].size = sizeof(*arg);

‎include/uapi/linux/fuse.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
* 7.21
9191
* - add FUSE_READDIRPLUS
9292
* - send the requested events in POLL request
93+
*
94+
* 7.22
95+
* - add FUSE_ASYNC_DIO
9396
*/
9497

9598
#ifndef _LINUX_FUSE_H
@@ -125,7 +128,7 @@
125128
#define FUSE_KERNEL_VERSION 7
126129

127130
/** Minor version number of this interface */
128-
#define FUSE_KERNEL_MINOR_VERSION 21
131+
#define FUSE_KERNEL_MINOR_VERSION 22
129132

130133
/** The node ID of the root inode */
131134
#define FUSE_ROOT_ID 1
@@ -215,6 +218,7 @@ struct fuse_file_lock {
215218
* FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages
216219
* FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one)
217220
* FUSE_READDIRPLUS_AUTO: adaptive readdirplus
221+
* FUSE_ASYNC_DIO: asynchronous direct I/O submission
218222
*/
219223
#define FUSE_ASYNC_READ (1 << 0)
220224
#define FUSE_POSIX_LOCKS (1 << 1)
@@ -231,6 +235,7 @@ struct fuse_file_lock {
231235
#define FUSE_AUTO_INVAL_DATA (1 << 12)
232236
#define FUSE_DO_READDIRPLUS (1 << 13)
233237
#define FUSE_READDIRPLUS_AUTO (1 << 14)
238+
#define FUSE_ASYNC_DIO (1 << 15)
234239

235240
/**
236241
* CUSE INIT request/reply flags

0 commit comments

Comments
 (0)