aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/super.c
diff options
context:
space:
mode:
authorArthur Jones <ajones@riverbed.com>2008-11-06 15:53:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-11-06 18:41:19 -0500
commitc87591b719737b4e91eb1a9fa8fd55a4ff1886d6 (patch)
treeb442f22c99aa46524d4c1256dffadeaec975607e /fs/ext3/super.c
parentfbdd12676c83df77480f00ebd32fc98fbe3bf836 (diff)
ext3: wait on all pending commits in ext3_sync_fs
In ext3_sync_fs, we only wait for a commit to finish if we started it, but there may be one already in progress which will not be synced. In the case of a data=ordered umount with pending long symlinks which are delayed due to a long list of other I/O on the backing block device, this causes the buffer associated with the long symlinks to not be moved to the inode dirty list in the second phase of fsync_super. Then, before they can be dirtied again, kjournald exits, seeing the UMOUNT flag and the dirty pages are never written to the backing block device, causing long symlink corruption and exposing new or previously freed block data to userspace. This can be reproduced with a script created by Eric Sandeen <sandeen@redhat.com>: #!/bin/bash umount /mnt/test2 mount /dev/sdb4 /mnt/test2 rm -f /mnt/test2/* dd if=/dev/zero of=/mnt/test2/bigfile bs=1M count=512 touch /mnt/test2/thisisveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongfilename ln -s /mnt/test2/thisisveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongfilename /mnt/test2/link umount /mnt/test2 mount /dev/sdb4 /mnt/test2 ls /mnt/test2/ umount /mnt/test2 To ensure all commits are synced, we flush all journal commits now when sync_fs'ing ext3. Signed-off-by: Arthur Jones <ajones@riverbed.com> Cc: Eric Sandeen <sandeen@redhat.com> Cc: Theodore Ts'o <tytso@mit.edu> Cc: <linux-ext4@vger.kernel.org> Cc: <stable@kernel.org> [2.6.everything] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext3/super.c')
-rw-r--r--fs/ext3/super.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index e5717a4fae67..5dec6d1356c4 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2390,13 +2390,12 @@ static void ext3_write_super (struct super_block * sb)
2390 2390
2391static int ext3_sync_fs(struct super_block *sb, int wait) 2391static int ext3_sync_fs(struct super_block *sb, int wait)
2392{ 2392{
2393 tid_t target;
2394
2395 sb->s_dirt = 0; 2393 sb->s_dirt = 0;
2396 if (journal_start_commit(EXT3_SB(sb)->s_journal, &target)) { 2394 if (wait)
2397 if (wait) 2395 ext3_force_commit(sb);
2398 log_wait_commit(EXT3_SB(sb)->s_journal, target); 2396 else
2399 } 2397 journal_start_commit(EXT3_SB(sb)->s_journal, NULL);
2398
2400 return 0; 2399 return 0;
2401} 2400}
2402 2401