UBIFS: always commit in sync_fs
Always run commit in sync_fs, because even if the journal seems to be almost empty, there may be a deletion which removes a large file, which affects the index greatly. And because we want better free space predictions after 'sync_fs()', we have to commit. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
parent
304d427cd9
commit
f10383006c
|
@ -429,9 +429,8 @@ static int ubifs_show_options(struct seq_file *s, struct vfsmount *mnt)
|
||||||
|
|
||||||
static int ubifs_sync_fs(struct super_block *sb, int wait)
|
static int ubifs_sync_fs(struct super_block *sb, int wait)
|
||||||
{
|
{
|
||||||
|
int i, err;
|
||||||
struct ubifs_info *c = sb->s_fs_info;
|
struct ubifs_info *c = sb->s_fs_info;
|
||||||
int i, ret = 0, err;
|
|
||||||
long long bud_bytes;
|
|
||||||
struct writeback_control wbc = {
|
struct writeback_control wbc = {
|
||||||
.sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_HOLD,
|
.sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_HOLD,
|
||||||
.range_start = 0,
|
.range_start = 0,
|
||||||
|
@ -439,6 +438,19 @@ static int ubifs_sync_fs(struct super_block *sb, int wait)
|
||||||
.nr_to_write = LONG_MAX,
|
.nr_to_write = LONG_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (sb->s_flags & MS_RDONLY)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Synchronize write buffers, because 'ubifs_run_commit()' does not
|
||||||
|
* do this if it waits for an already running commit.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < c->jhead_cnt; i++) {
|
||||||
|
err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VFS calls '->sync_fs()' before synchronizing all dirty inodes and
|
* VFS calls '->sync_fs()' before synchronizing all dirty inodes and
|
||||||
* pages, so synchronize them first, then commit the journal. Strictly
|
* pages, so synchronize them first, then commit the journal. Strictly
|
||||||
|
@ -450,30 +462,16 @@ static int ubifs_sync_fs(struct super_block *sb, int wait)
|
||||||
*/
|
*/
|
||||||
generic_sync_sb_inodes(sb, &wbc);
|
generic_sync_sb_inodes(sb, &wbc);
|
||||||
|
|
||||||
if (c->jheads) {
|
err = ubifs_run_commit(c);
|
||||||
for (i = 0; i < c->jhead_cnt; i++) {
|
if (err)
|
||||||
err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
|
return err;
|
||||||
if (err && !ret)
|
|
||||||
ret = err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Commit the journal unless it has too little 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
|
* 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
|
* it would in turn call mtd->sync, however mtd operations are
|
||||||
* synchronous anyway, so we don't lose any sleep here.
|
* synchronous anyway, so we don't lose any sleep here.
|
||||||
*/
|
*/
|
||||||
return ret;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue