summaryrefslogtreecommitdiffstats
path: root/fs/ext4/file.c
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2018-05-13 22:54:44 -0400
committerTheodore Ts'o <tytso@mit.edu>2018-05-13 22:54:44 -0400
commitdb6516a5e7ddb6dc72d167b920f2f272596ea22d (patch)
treece820da46d4ef3e3f6f0a688f326d408ba8c506f /fs/ext4/file.c
parent833a950882d33a7dfc319d5e152fdf35028936eb (diff)
ext4: do not update s_last_mounted of a frozen fs
If fs is frozen after mount and before the first file open, the update of s_last_mounted bypasses freeze protection and prints out a WARNING splat: $ mount /vdf $ fsfreeze -f /vdf $ cat /vdf/foo [ 31.578555] WARNING: CPU: 1 PID: 1415 at fs/ext4/ext4_jbd2.c:53 ext4_journal_check_start+0x48/0x82 [ 31.614016] Call Trace: [ 31.614997] __ext4_journal_start_sb+0xe4/0x1a4 [ 31.616771] ? ext4_file_open+0xb6/0x189 [ 31.618094] ext4_file_open+0xb6/0x189 If fs is frozen, skip s_last_mounted update. [backport hint: to apply to stable tree, need to apply also patches vfs: add the sb_start_intwrite_trylock() helper ext4: factor out helper ext4_sample_last_mounted()] Cc: stable@vger.kernel.org Fixes: bc0b0d6d69ee ("ext4: update the s_last_mounted field in the superblock") Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext4/file.c')
-rw-r--r--fs/ext4/file.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index c48ea76b63e4..7f8023340eb8 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -393,7 +393,7 @@ static int ext4_sample_last_mounted(struct super_block *sb,
393 if (likely(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED)) 393 if (likely(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED))
394 return 0; 394 return 0;
395 395
396 if (sb_rdonly(sb)) 396 if (sb_rdonly(sb) || !sb_start_intwrite_trylock(sb))
397 return 0; 397 return 0;
398 398
399 sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED; 399 sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED;
@@ -407,21 +407,25 @@ static int ext4_sample_last_mounted(struct super_block *sb,
407 path.mnt = mnt; 407 path.mnt = mnt;
408 path.dentry = mnt->mnt_root; 408 path.dentry = mnt->mnt_root;
409 cp = d_path(&path, buf, sizeof(buf)); 409 cp = d_path(&path, buf, sizeof(buf));
410 err = 0;
410 if (IS_ERR(cp)) 411 if (IS_ERR(cp))
411 return 0; 412 goto out;
412 413
413 handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1); 414 handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1);
415 err = PTR_ERR(handle);
414 if (IS_ERR(handle)) 416 if (IS_ERR(handle))
415 return PTR_ERR(handle); 417 goto out;
416 BUFFER_TRACE(sbi->s_sbh, "get_write_access"); 418 BUFFER_TRACE(sbi->s_sbh, "get_write_access");
417 err = ext4_journal_get_write_access(handle, sbi->s_sbh); 419 err = ext4_journal_get_write_access(handle, sbi->s_sbh);
418 if (err) 420 if (err)
419 goto out; 421 goto out_journal;
420 strlcpy(sbi->s_es->s_last_mounted, cp, 422 strlcpy(sbi->s_es->s_last_mounted, cp,
421 sizeof(sbi->s_es->s_last_mounted)); 423 sizeof(sbi->s_es->s_last_mounted));
422 ext4_handle_dirty_super(handle, sb); 424 ext4_handle_dirty_super(handle, sb);
423out: 425out_journal:
424 ext4_journal_stop(handle); 426 ext4_journal_stop(handle);
427out:
428 sb_end_intwrite(sb);
425 return err; 429 return err;
426} 430}
427 431