aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sync.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2012-07-03 10:45:30 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-22 15:58:41 -0400
commitb3de653105180b57af90ef2f5b8441f085f4ff56 (patch)
treee7581933fbb53210620d4181ba2bf16c9d82502c /fs/sync.c
parenta1177825719ccef3f76ef39bbfd5ebb6087d53c7 (diff)
vfs: Reorder operations during sys_sync
Change the order of operations during sync from for_each_sb { writeback_inodes_sb(); sync_fs(nowait); __sync_blockdev(nowait); } for_each_sb { sync_inodes_sb(); sync_fs(wait); __sync_blockdev(wait); } to for_each_sb writeback_inodes_sb(); for_each_sb sync_fs(nowait); for_each_sb __sync_blockdev(nowait); for_each_sb sync_inodes_sb(); for_each_sb sync_fs(wait); for_each_sb __sync_blockdev(wait); This is a preparation for the following patches in this series. Reviewed-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/sync.c')
-rw-r--r--fs/sync.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/fs/sync.c b/fs/sync.c
index 66acd2ba91c4..490e90201135 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -67,18 +67,28 @@ int sync_filesystem(struct super_block *sb)
67} 67}
68EXPORT_SYMBOL_GPL(sync_filesystem); 68EXPORT_SYMBOL_GPL(sync_filesystem);
69 69
70static void sync_one_sb(struct super_block *sb, void *arg) 70static void sync_inodes_one_sb(struct super_block *sb, void *arg)
71{ 71{
72 if (!(sb->s_flags & MS_RDONLY)) 72 if (!(sb->s_flags & MS_RDONLY))
73 __sync_filesystem(sb, *(int *)arg); 73 sync_inodes_sb(sb);
74} 74}
75/* 75
76 * Sync all the data for all the filesystems (called by sys_sync() and 76static void writeback_inodes_one_sb(struct super_block *sb, void *arg)
77 * emergency sync)
78 */
79static void sync_filesystems(int wait)
80{ 77{
81 iterate_supers(sync_one_sb, &wait); 78 if (!(sb->s_flags & MS_RDONLY))
79 writeback_inodes_sb(sb, WB_REASON_SYNC);
80}
81
82static void sync_fs_one_sb(struct super_block *sb, void *arg)
83{
84 if (!(sb->s_flags & MS_RDONLY) && sb->s_op->sync_fs)
85 sb->s_op->sync_fs(sb, *(int *)arg);
86}
87
88static void sync_blkdev_one_sb(struct super_block *sb, void *arg)
89{
90 if (!(sb->s_flags & MS_RDONLY))
91 __sync_blockdev(sb->s_bdev, *(int *)arg);
82} 92}
83 93
84/* 94/*
@@ -87,9 +97,15 @@ static void sync_filesystems(int wait)
87 */ 97 */
88SYSCALL_DEFINE0(sync) 98SYSCALL_DEFINE0(sync)
89{ 99{
100 int nowait = 0, wait = 1;
101
90 wakeup_flusher_threads(0, WB_REASON_SYNC); 102 wakeup_flusher_threads(0, WB_REASON_SYNC);
91 sync_filesystems(0); 103 iterate_supers(writeback_inodes_one_sb, NULL);
92 sync_filesystems(1); 104 iterate_supers(sync_fs_one_sb, &nowait);
105 iterate_supers(sync_blkdev_one_sb, &nowait);
106 iterate_supers(sync_inodes_one_sb, NULL);
107 iterate_supers(sync_fs_one_sb, &wait);
108 iterate_supers(sync_blkdev_one_sb, &wait);
93 if (unlikely(laptop_mode)) 109 if (unlikely(laptop_mode))
94 laptop_sync_completion(); 110 laptop_sync_completion();
95 return 0; 111 return 0;
@@ -97,12 +113,18 @@ SYSCALL_DEFINE0(sync)
97 113
98static void do_sync_work(struct work_struct *work) 114static void do_sync_work(struct work_struct *work)
99{ 115{
116 int nowait = 0;
117
100 /* 118 /*
101 * Sync twice to reduce the possibility we skipped some inodes / pages 119 * Sync twice to reduce the possibility we skipped some inodes / pages
102 * because they were temporarily locked 120 * because they were temporarily locked
103 */ 121 */
104 sync_filesystems(0); 122 iterate_supers(sync_inodes_one_sb, &nowait);
105 sync_filesystems(0); 123 iterate_supers(sync_fs_one_sb, &nowait);
124 iterate_supers(sync_blkdev_one_sb, &nowait);
125 iterate_supers(sync_inodes_one_sb, &nowait);
126 iterate_supers(sync_fs_one_sb, &nowait);
127 iterate_supers(sync_blkdev_one_sb, &nowait);
106 printk("Emergency Sync complete\n"); 128 printk("Emergency Sync complete\n");
107 kfree(work); 129 kfree(work);
108} 130}