From 243a36e40501ffddf3f9d43e340399182473e93f Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 14 Nov 2016 10:30:05 -0800 Subject: [PATCH] Add fsync file operation method Add a scoutfs_file_fsync() which synchronously commits the current transaction and call it to fsync files and directories. This fixes a number of generic xfstests in the quick group which were failing because fsync wasn't supported. Signed-off-by: Zach Brown Reviewed-by: Mark Fasheh --- kmod/src/dir.c | 1 + kmod/src/filerw.c | 1 + kmod/src/trans.c | 6 ++++++ kmod/src/trans.h | 2 ++ 4 files changed, 10 insertions(+) diff --git a/kmod/src/dir.c b/kmod/src/dir.c index 8a03f986..59d2aabd 100644 --- a/kmod/src/dir.c +++ b/kmod/src/dir.c @@ -1013,6 +1013,7 @@ out: const struct file_operations scoutfs_dir_fops = { .readdir = scoutfs_readdir, + .fsync = scoutfs_file_fsync, }; const struct inode_operations scoutfs_dir_iops = { diff --git a/kmod/src/filerw.c b/kmod/src/filerw.c index 5c9196d9..091f2333 100644 --- a/kmod/src/filerw.c +++ b/kmod/src/filerw.c @@ -671,4 +671,5 @@ const struct file_operations scoutfs_file_fops = { .aio_read = generic_file_aio_read, .aio_write = generic_file_aio_write, .unlocked_ioctl = scoutfs_ioctl, + .fsync = scoutfs_file_fsync, }; diff --git a/kmod/src/trans.c b/kmod/src/trans.c index 0b6b7be6..b9108500 100644 --- a/kmod/src/trans.c +++ b/kmod/src/trans.c @@ -177,6 +177,12 @@ int scoutfs_sync_fs(struct super_block *sb, int wait) return ret; } +int scoutfs_file_fsync(struct file *file, loff_t start, loff_t end, + int datasync) +{ + return scoutfs_sync_fs(file->f_inode->i_sb, 1); +} + int scoutfs_hold_trans(struct super_block *sb) { struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); diff --git a/kmod/src/trans.h b/kmod/src/trans.h index 9cd0753a..22c5755a 100644 --- a/kmod/src/trans.h +++ b/kmod/src/trans.h @@ -3,6 +3,8 @@ void scoutfs_trans_write_func(struct work_struct *work); int scoutfs_sync_fs(struct super_block *sb, int wait); +int scoutfs_file_fsync(struct file *file, loff_t start, loff_t end, + int datasync); int scoutfs_hold_trans(struct super_block *sb); void scoutfs_release_trans(struct super_block *sb);