From d2cdb4e1ce3df4e28b0e51807455ddf424ff2e71 Mon Sep 17 00:00:00 2001 From: Paul Reioux Date: Sun, 29 Mar 2015 14:52:41 -0400 Subject: Dynamic Fsync Control --- fs/sync.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'fs/sync.c') diff --git a/fs/sync.c b/fs/sync.c index 905f3f6b3..686996e50 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -17,6 +17,11 @@ #include #include "internal.h" +#ifdef CONFIG_DYNAMIC_FSYNC +extern bool early_suspend_active; +extern bool dyn_fsync_active; +#endif + #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \ SYNC_FILE_RANGE_WAIT_AFTER) @@ -89,6 +94,17 @@ static void fdatawait_one_bdev(struct block_device *bdev, void *arg) filemap_fdatawait(bdev->bd_inode->i_mapping); } +#ifndef CONFIG_DYNAMIC_FSYNC +static +#endif +void sync_filesystems(int wait) +{ + iterate_supers(sync_fs_one_sb, &wait); +} +#ifdef CONFIG_DYNAMIC_FSYNC +EXPORT_SYMBOL_GPL(sync_filesystems); +#endif + /* * Sync everything. We start by waking flusher threads so that most of * writeback runs on all devices in parallel. Then we sync all inodes reliably @@ -193,7 +209,15 @@ EXPORT_SYMBOL(vfs_fsync_range); */ int vfs_fsync(struct file *file, int datasync) { +#ifdef CONFIG_DYNAMIC_FSYNC + if (likely(dyn_fsync_active && !early_suspend_active)) + return 0; + else { +#endif return vfs_fsync_range(file, 0, LLONG_MAX, datasync); +#ifdef CONFIG_DYNAMIC_FSYNC + } +#endif } EXPORT_SYMBOL(vfs_fsync); @@ -211,11 +235,21 @@ static int do_fsync(unsigned int fd, int datasync) SYSCALL_DEFINE1(fsync, unsigned int, fd) { +#ifdef CONFIG_DYNAMIC_FSYNC + if (likely(dyn_fsync_active && !early_suspend_active)) + return 0; + else +#endif return do_fsync(fd, 0); } SYSCALL_DEFINE1(fdatasync, unsigned int, fd) { +#if 0 + if (likely(dyn_fsync_active && !early_suspend_active)) + return 0; + else +#endif return do_fsync(fd, 1); } @@ -286,6 +320,12 @@ EXPORT_SYMBOL(generic_write_sync); SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes, unsigned int, flags) { +#ifdef CONFIG_DYNAMIC_FSYNC +if (likely(dyn_fsync_active && !early_suspend_active)) +return 0; +else { +#endif + int ret; struct fd f; struct address_space *mapping; @@ -364,6 +404,9 @@ out_put: fdput(f); out: return ret; +#ifdef CONFIG_DYNAMIC_FSYNC + } +#endif } /* It would be nice if people remember that not all the world's an i386 @@ -371,5 +414,10 @@ out: SYSCALL_DEFINE4(sync_file_range2, int, fd, unsigned int, flags, loff_t, offset, loff_t, nbytes) { +#ifdef CONFIG_DYNAMIC_FSYNC + if (likely(dyn_fsync_active && !early_suspend_active)) + return 0; + else +#endif return sys_sync_file_range(fd, offset, nbytes, flags); } -- cgit v1.2.3