aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/super.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index a14703e0a9a..1c1bbe4135c 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1570,20 +1570,24 @@ out:
1570 * @c: UBIFS file-system description object 1570 * @c: UBIFS file-system description object
1571 * 1571 *
1572 * This function is called during un-mounting and re-mounting, and it commits 1572 * This function is called during un-mounting and re-mounting, and it commits
1573 * the journal unless the "fast unmount" mode is enabled. It also avoids 1573 * the journal unless the "fast unmount" mode is enabled.
1574 * committing the journal if it contains too few data.
1575 */ 1574 */
1576static void commit_on_unmount(struct ubifs_info *c) 1575static void commit_on_unmount(struct ubifs_info *c)
1577{ 1576{
1578 if (!c->fast_unmount) { 1577 struct super_block *sb = c->vfs_sb;
1579 long long bud_bytes; 1578 long long bud_bytes;
1580 1579
1581 spin_lock(&c->buds_lock); 1580 /*
1582 bud_bytes = c->bud_bytes; 1581 * This function is called before the background thread is stopped, so
1583 spin_unlock(&c->buds_lock); 1582 * we may race with ongoing commit, which means we have to take
1584 if (bud_bytes > c->leb_size) 1583 * @c->bud_lock to access @c->bud_bytes.
1585 ubifs_run_commit(c); 1584 */
1586 } 1585 spin_lock(&c->buds_lock);
1586 bud_bytes = c->bud_bytes;
1587 spin_unlock(&c->buds_lock);
1588
1589 if (!c->fast_unmount && !(sb->s_flags & MS_RDONLY) && bud_bytes)
1590 ubifs_run_commit(c);
1587} 1591}
1588 1592
1589/** 1593/**
@@ -2009,7 +2013,7 @@ static void ubifs_kill_sb(struct super_block *sb)
2009 * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()' 2013 * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()'
2010 * in order to be outside BKL. 2014 * in order to be outside BKL.
2011 */ 2015 */
2012 if (sb->s_root && !(sb->s_flags & MS_RDONLY)) 2016 if (sb->s_root)
2013 commit_on_unmount(c); 2017 commit_on_unmount(c);
2014 /* The un-mount routine is actually done in put_super() */ 2018 /* The un-mount routine is actually done in put_super() */
2015 generic_shutdown_super(sb); 2019 generic_shutdown_super(sb);