summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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