From: Artem Bityutskiy Date: Tue, 9 Sep 2008 09:31:37 +0000 (+0300) Subject: UBIFS: commit on sync_fs X-Git-Tag: v2.6.28-rc1~98^2~9 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=403e12ab30ab160e1015bd998f0abc1865c574e0;p=linux-2.6-omap-h63xx.git UBIFS: commit on sync_fs Commit the journal when the FS is sync'ed. This will make statfs provide better free space report. And we anyway advice our users to sync the FS if they want better statfs report. Signed-off-by: Artem Bityutskiy --- diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index dae1c62156c..7e1f3efdf63 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -418,6 +418,7 @@ static int ubifs_sync_fs(struct super_block *sb, int wait) { struct ubifs_info *c = sb->s_fs_info; int i, ret = 0, err; + long long bud_bytes; if (c->jheads) for (i = 0; i < c->jhead_cnt; i++) { @@ -425,6 +426,17 @@ static int ubifs_sync_fs(struct super_block *sb, int wait) if (err && !ret) ret = err; } + + /* Commit the journal unless it has too few data */ + spin_lock(&c->buds_lock); + bud_bytes = c->bud_bytes; + spin_unlock(&c->buds_lock); + if (bud_bytes > c->leb_size) { + err = ubifs_run_commit(c); + if (err) + return err; + } + /* * We ought to call sync for c->ubi but it does not have one. If it had * it would in turn call mtd->sync, however mtd operations are