linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] FS: Add generic data flush to fsync
@ 2014-04-11  4:52 Fabian Frederick
  2014-04-11  7:45 ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Fabian Frederick @ 2014-04-11  4:52 UTC (permalink / raw)
  To: Viro; +Cc: linux-kernel, linux-fsdevel, jack, akpm

Currently, there's no generic HW flush management support in kernel.
Only 7 filesystems have their own way to manage the barrier flag.

This patch adds MS_BARRIER in sb_flags and conditionnaly issues the flush
in generic_file_fsync.

That option would be enabled from userspace mount tool.

(-As discussed with Jan, we could add barrier/no barrier in older filesystems
 but this would mix both filesystem and vfs barrier terminology plus
 generic_file_fsync does not have access to FS sbi.
 -Some modern FS will be involved as well ; eg no journal ext4 partitions.
)

Cc: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org
Suggested-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/libfs.c              | 7 +++++++
 include/uapi/linux/fs.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/fs/libfs.c b/fs/libfs.c
index a184424..21983d9 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -3,6 +3,7 @@
  *	Library for filesystems writers.
  */
 
+#include <linux/blkdev.h>
 #include <linux/export.h>
 #include <linux/pagemap.h>
 #include <linux/slab.h>
@@ -952,6 +953,12 @@ int generic_file_fsync(struct file *file, loff_t start, loff_t end,
 	err = sync_inode_metadata(inode, 1);
 	if (ret == 0)
 		ret = err;
+	if (inode->i_sb->s_flags & MS_BARRIER) {
+		err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
+		if (ret == 0)
+			ret = err;
+	}
+
 out:
 	mutex_unlock(&inode->i_mutex);
 	return ret;
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index ca1a11b..7c14ebd 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -89,6 +89,7 @@ struct inodes_stat_t {
 #define MS_KERNMOUNT	(1<<22) /* this is a kern_mount call */
 #define MS_I_VERSION	(1<<23) /* Update inode I_version field */
 #define MS_STRICTATIME	(1<<24) /* Always perform atime updates */
+#define MS_BARRIER	(1<<25) /* Flush data during sync operations */
 
 /* These sb flags are internal to the kernel */
 #define MS_NOSEC	(1<<28)
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-04-15 17:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-11  4:52 [PATCH 1/1] FS: Add generic data flush to fsync Fabian Frederick
2014-04-11  7:45 ` Christoph Hellwig
2014-04-11 13:00   ` Jan Kara
2014-04-11 21:05   ` Fabian Frederick
2014-04-14  7:22     ` Christoph Hellwig
2014-04-15 17:04       ` Fabian Frederick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).