aboutsummaryrefslogtreecommitdiffstats
path: root/fs/direct-io.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2013-09-04 15:04:40 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2013-09-04 09:23:46 -0400
commit02afc27faec94c9e068517a22acf55400976c698 (patch)
tree45de9689088ea99e1197c3f20f08cb9835a66410 /fs/direct-io.c
parent7b7a8665edd8db733980389b098530f9e4f630b2 (diff)
downloadnet-02afc27faec94c9e068517a22acf55400976c698.tar.gz
direct-io: Handle O_(D)SYNC AIO
Call generic_write_sync() from the deferred I/O completion handler if O_DSYNC is set for a write request. Also make sure various callers don't call generic_write_sync if the direct I/O code returns -EIOCBQUEUED. Based on an earlier patch from Jan Kara <jack@suse.cz> with updates from Jeff Moyer <jmoyer@redhat.com> and Darrick J. Wong <darrick.wong@oracle.com>. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/direct-io.c')
-rw-r--r--fs/direct-io.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 8b31b9f449f460..1782023bd68a66 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -266,8 +266,18 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret,
dio->end_io(dio->iocb, offset, transferred, dio->private);
inode_dio_done(dio->inode);
- if (is_async)
+ if (is_async) {
+ if (dio->rw & WRITE) {
+ int err;
+
+ err = generic_write_sync(dio->iocb->ki_filp, offset,
+ transferred);
+ if (err < 0 && ret > 0)
+ ret = err;
+ }
+
aio_complete(dio->iocb, ret, 0);
+ }
kmem_cache_free(dio_cache, dio);
return ret;
@@ -1183,11 +1193,6 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
}
/*
- * Will be decremented at I/O completion time.
- */
- atomic_inc(&inode->i_dio_count);
-
- /*
* For file extending writes updating i_size before data
* writeouts complete can expose uninitialized blocks. So
* even for AIO, we need to wait for i/o to complete before
@@ -1195,11 +1200,33 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
*/
dio->is_async = !is_sync_kiocb(iocb) && !((rw & WRITE) &&
(end > i_size_read(inode)));
-
- retval = 0;
-
dio->inode = inode;
dio->rw = rw;
+
+ /*
+ * For AIO O_(D)SYNC writes we need to defer completions to a workqueue
+ * so that we can call ->fsync.
+ */
+ if (dio->is_async && (rw & WRITE) &&
+ ((iocb->ki_filp->f_flags & O_DSYNC) ||
+ IS_SYNC(iocb->ki_filp->f_mapping->host))) {
+ retval = dio_set_defer_completion(dio);
+ if (retval) {
+ /*
+ * We grab i_mutex only for reads so we don't have
+ * to release it here
+ */
+ kmem_cache_free(dio_cache, dio);
+ goto out;
+ }
+ }
+
+ /*
+ * Will be decremented at I/O completion time.
+ */
+ atomic_inc(&inode->i_dio_count);
+
+ retval = 0;
sdio.blkbits = blkbits;
sdio.blkfactor = i_blkbits - blkbits;
sdio.block_in_file = offset >> blkbits;
lue='chromeos-4.14__release/core76-35-2'>chromeos-4.14__release/core76-35-2 Intel wireless group's fork of linux.gitIntel wireless group
aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-07-16 21:05:12 +0000
committerchrome-bot <chrome-bot@chromium.org>2015-10-02 23:12:59 -0700
commit0bdac54ffb60b94a98689d223cba582d082619a5 (patch)
treee3c1abcbd7718c12e43c626b21e7d57d6cc1f534 /arch
parent0ed166182826f8f13e5d7ca5c0120e9543a2e24a (diff)
downloadchromeos-0bdac54ffb60b94a98689d223cba582d082619a5.tar.gz
BACKPORT: clocksource: Move cycle_last validation to core code
The only user of the cycle_last validation is the x86 TSC. In order to provide NMI safe accessor functions for clock monotonic and monotonic_raw we need to do that in the core. We can't do the TSC specific if (now < cycle_last) now = cycle_last; for the other wrapping around clocksources, but TSC has CLOCKSOURCE_MASK(64) which actually does not mask out anything so if now is less than cycle_last the subtraction will give a negative result. So we can check for that in clocksource_delta() and return 0 for that case. Implement and enable it for x86 BUG=chromium:324025 TEST=build/boot 3.8 on link Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org> (cherry picked from commit 09ec54429c6d10f87d1f084de53ae2c1c3a81108) Signed-off-by: Sonny Rao <sonnyrao@chromium.org> [SR: trivial conflict in Kconfig] [SR: 3.10: fix conflict in timekeeping_internal.h] [SR: 3.8: fix context conflict in tsc.c from 82f9c080] Conflicts: arch/x86/Kconfig arch/x86/kernel/tsc.c kernel/time/timekeeping_internal.h Change-Id: Ib980b5ef4733e9f73f8c5222221ad439f8b306f6 Reviewed-on: https://chromium-review.googlesource.com/300773 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Olof Johansson <olofj@chromium.org>