aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/super.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-28 01:16:32 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-31 07:13:24 -0500
commitf10383006c26b33539820759b9dc8656497b02a4 (patch)
treee06ed0b85804ca52d309dc137f06ab4d89de876a /fs/ubifs/super.c
parent304d427cd99eb645b44b08d77e70ce308e6bcd8c (diff)
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>
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r--fs/ubifs/super.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 471301799c52..ee8e7749eae1 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -429,9 +429,8 @@ static int ubifs_show_options(struct seq_file *s, struct vfsmount *mnt)
429 429
430static int ubifs_sync_fs(struct super_block *sb, int wait) 430static int ubifs_sync_fs(struct super_block *sb, int wait)
431{ 431{
432 int i, err;
432 struct ubifs_info *c = sb->s_fs_info; 433 struct ubifs_info *c = sb->s_fs_info;
433 int i, ret = 0, err;
434 long long bud_bytes;
435 struct writeback_control wbc = { 434 struct writeback_control wbc = {
436 .sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_HOLD, 435 .sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_HOLD,
437 .range_start = 0, 436 .range_start = 0,
@@ -439,6 +438,19 @@ static int ubifs_sync_fs(struct super_block *sb, int wait)
439 .nr_to_write = LONG_MAX, 438 .nr_to_write = LONG_MAX,
440 }; 439 };
441 440
441 if (sb->s_flags & MS_RDONLY)
442 return 0;
443
444 /*
445 * Synchronize write buffers, because 'ubifs_run_commit()' does not
446 * do this if it waits for an already running commit.
447 */
448 for (i = 0; i < c->jhead_cnt; i++) {
449 err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
450 if (err)
451 return err;
452 }
453
442 /* 454 /*
443 * VFS calls '->sync_fs()' before synchronizing all dirty inodes and 455 * VFS calls '->sync_fs()' before synchronizing all dirty inodes and
444 * pages, so synchronize them first, then commit the journal. Strictly 456 * 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)
450 */ 462 */
451 generic_sync_sb_inodes(sb, &wbc); 463 generic_sync_sb_inodes(sb, &wbc);
452 464
453 if (c->jheads) { 465 err = ubifs_run_commit(c);
454 for (i = 0; i < c->jhead_cnt; i++) { 466 if (err)
455 err = ubifs_wbuf_sync(&c->jheads[i].wbuf); 467 return err;
456 if (err && !ret)
457 ret = err;
458 }
459
460 /* Commit the journal unless it has too little data */
461 spin_lock(&c->buds_lock);
462 bud_bytes = c->bud_bytes;
463 spin_unlock(&c->buds_lock);
464 if (bud_bytes > c->leb_size) {
465 err = ubifs_run_commit(c);
466 if (err)
467 return err;
468 }
469 }
470 468
471 /* 469 /*
472 * We ought to call sync for c->ubi but it does not have one. If it had 470 * We ought to call sync for c->ubi but it does not have one. If it had
473 * it would in turn call mtd->sync, however mtd operations are 471 * it would in turn call mtd->sync, however mtd operations are
474 * synchronous anyway, so we don't lose any sleep here. 472 * synchronous anyway, so we don't lose any sleep here.
475 */ 473 */
476 return ret; 474 return err;
477} 475}
478 476
479/** 477/**