Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1306763
| From | Benjamin LaHaise <bcrl@kvack.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 07/13] aio: enabled thread based async fsync |
| Date | 2016-01-11 23:10 +0100 |
| Message-ID | <qPSP1-7w-47@gated-at.bofh.it> (permalink) |
| References | <qPSP0-7w-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Enable a fully asynchronous fsync and fdatasync operations in aio using
the aio thread queuing mechanism.
Signed-off-by: Benjamin LaHaise <ben.lahaise@solacesystems.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
---
fs/aio.c | 41 +++++++++++++++++++++++++++++++----------
1 file changed, 31 insertions(+), 10 deletions(-)
diff --git a/fs/aio.c b/fs/aio.c
index 88af450..576b780 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -224,8 +224,9 @@ static const struct file_operations aio_ring_fops;
static const struct address_space_operations aio_ctx_aops;
static void aio_complete(struct kiocb *kiocb, long res, long res2);
+ssize_t aio_fsync(struct kiocb *iocb, int datasync);
-static bool aio_may_use_threads(void)
+static __always_inline bool aio_may_use_threads(void)
{
#if IS_ENABLED(CONFIG_AIO_THREAD)
return !!(aio_auto_threads & 1);
@@ -1654,6 +1655,26 @@ ssize_t generic_async_write_iter(struct kiocb *iocb, struct iov_iter *iter)
AIO_THREAD_NEED_TASK);
}
EXPORT_SYMBOL(generic_async_write_iter);
+
+static long aio_thread_op_fsync(struct aio_kiocb *iocb)
+{
+ return vfs_fsync(iocb->common.ki_filp, 0);
+}
+
+static long aio_thread_op_fdatasync(struct aio_kiocb *iocb)
+{
+ return vfs_fsync(iocb->common.ki_filp, 1);
+}
+
+ssize_t aio_fsync(struct kiocb *iocb, int datasync)
+{
+ struct aio_kiocb *req;
+
+ req = container_of(iocb, struct aio_kiocb, common);
+
+ return aio_thread_queue_iocb(req, datasync ? aio_thread_op_fdatasync
+ : aio_thread_op_fsync, 0);
+}
#endif /* IS_ENABLED(CONFIG_AIO_THREAD) */
/*
@@ -1664,7 +1685,7 @@ static ssize_t aio_run_iocb(struct aio_kiocb *req, unsigned opcode,
char __user *buf, size_t len, bool compat)
{
struct file *file = req->common.ki_filp;
- ssize_t ret;
+ ssize_t ret = -EINVAL;
int rw;
fmode_t mode;
rw_iter_op *iter_op;
@@ -1730,17 +1751,17 @@ rw_common:
break;
case IOCB_CMD_FDSYNC:
- if (!file->f_op->aio_fsync)
- return -EINVAL;
-
- ret = file->f_op->aio_fsync(&req->common, 1);
+ if (file->f_op->aio_fsync)
+ ret = file->f_op->aio_fsync(&req->common, 1);
+ else if (file->f_op->fsync && (aio_may_use_threads()))
+ ret = aio_fsync(&req->common, 1);
break;
case IOCB_CMD_FSYNC:
- if (!file->f_op->aio_fsync)
- return -EINVAL;
-
- ret = file->f_op->aio_fsync(&req->common, 0);
+ if (file->f_op->aio_fsync)
+ ret = file->f_op->aio_fsync(&req->common, 0);
+ else if (file->f_op->fsync && (aio_may_use_threads()))
+ ret = aio_fsync(&req->common, 0);
break;
default:
--
2.5.0
--
"Thought is the essence of where you are now."
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/13] aio: thread (work queue) based aio and new aio functionality Benjamin LaHaise <bcrl@kvack.org> - 2016-01-11 23:10 +0100
[PATCH 09/13] aio: add support for async openat() Benjamin LaHaise <bcrl@kvack.org> - 2016-01-11 23:10 +0100
Re: [PATCH 09/13] aio: add support for async openat() Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-12 01:30 +0100
Re: [PATCH 09/13] aio: add support for async openat() Benjamin LaHaise <bcrl@kvack.org> - 2016-01-12 02:20 +0100
Re: [PATCH 09/13] aio: add support for async openat() Chris Mason <clm@fb.com> - 2016-01-12 02:50 +0100
Re: [PATCH 09/13] aio: add support for async openat() Ingo Molnar <mingo@kernel.org> - 2016-01-12 11:00 +0100
[PATCH 04/13] signals: add and use aio_get_task() to direct signals sent via io_send_sig() Benjamin LaHaise <bcrl@kvack.org> - 2016-01-11 23:10 +0100
[PATCH 10/13] aio: add async unlinkat functionality Benjamin LaHaise <bcrl@kvack.org> - 2016-01-11 23:10 +0100
[PATCH 07/13] aio: enabled thread based async fsync Benjamin LaHaise <bcrl@kvack.org> - 2016-01-11 23:10 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Dave Chinner <david@fromorbit.com> - 2016-01-12 02:20 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-12 02:30 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Dave Chinner <david@fromorbit.com> - 2016-01-12 03:30 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-12 03:40 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Dave Chinner <david@fromorbit.com> - 2016-01-12 04:40 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-12 05:10 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-12 05:50 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Benjamin LaHaise <bcrl@kvack.org> - 2016-01-13 00:00 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Andy Lutomirski <luto@amacapital.net> - 2016-01-13 00:00 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Paolo Bonzini <pbonzini@redhat.com> - 2016-01-14 10:30 +0100
Re: [PATCH 07/13] aio: enabled thread based async fsync Benjamin LaHaise <bcrl@kvack.org> - 2016-01-12 02:40 +0100
[PATCH 06/13] aio: add queue_work() based threaded aio support Benjamin LaHaise <bcrl@kvack.org> - 2016-01-11 23:20 +0100
csiph-web