diff options
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r-- | fs/ubifs/super.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 04ad07f4fcc3..6db0bdaa9f74 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -375,7 +375,7 @@ out: | |||
375 | ubifs_release_dirty_inode_budget(c, ui); | 375 | ubifs_release_dirty_inode_budget(c, ui); |
376 | else { | 376 | else { |
377 | /* We've deleted something - clean the "no space" flags */ | 377 | /* We've deleted something - clean the "no space" flags */ |
378 | c->nospace = c->nospace_rp = 0; | 378 | c->bi.nospace = c->bi.nospace_rp = 0; |
379 | smp_wmb(); | 379 | smp_wmb(); |
380 | } | 380 | } |
381 | done: | 381 | done: |
@@ -694,11 +694,11 @@ static int init_constants_sb(struct ubifs_info *c) | |||
694 | * be compressed and direntries are of the maximum size. | 694 | * be compressed and direntries are of the maximum size. |
695 | * | 695 | * |
696 | * Note, data, which may be stored in inodes is budgeted separately, so | 696 | * Note, data, which may be stored in inodes is budgeted separately, so |
697 | * it is not included into 'c->inode_budget'. | 697 | * it is not included into 'c->bi.inode_budget'. |
698 | */ | 698 | */ |
699 | c->page_budget = UBIFS_MAX_DATA_NODE_SZ * UBIFS_BLOCKS_PER_PAGE; | 699 | c->bi.page_budget = UBIFS_MAX_DATA_NODE_SZ * UBIFS_BLOCKS_PER_PAGE; |
700 | c->inode_budget = UBIFS_INO_NODE_SZ; | 700 | c->bi.inode_budget = UBIFS_INO_NODE_SZ; |
701 | c->dent_budget = UBIFS_MAX_DENT_NODE_SZ; | 701 | c->bi.dent_budget = UBIFS_MAX_DENT_NODE_SZ; |
702 | 702 | ||
703 | /* | 703 | /* |
704 | * When the amount of flash space used by buds becomes | 704 | * When the amount of flash space used by buds becomes |
@@ -742,7 +742,7 @@ static void init_constants_master(struct ubifs_info *c) | |||
742 | { | 742 | { |
743 | long long tmp64; | 743 | long long tmp64; |
744 | 744 | ||
745 | c->min_idx_lebs = ubifs_calc_min_idx_lebs(c); | 745 | c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c); |
746 | c->report_rp_size = ubifs_reported_space(c, c->rp_size); | 746 | c->report_rp_size = ubifs_reported_space(c, c->rp_size); |
747 | 747 | ||
748 | /* | 748 | /* |
@@ -1144,8 +1144,8 @@ static int check_free_space(struct ubifs_info *c) | |||
1144 | { | 1144 | { |
1145 | ubifs_assert(c->dark_wm > 0); | 1145 | ubifs_assert(c->dark_wm > 0); |
1146 | if (c->lst.total_free + c->lst.total_dirty < c->dark_wm) { | 1146 | if (c->lst.total_free + c->lst.total_dirty < c->dark_wm) { |
1147 | ubifs_err("insufficient free space to mount in read/write mode"); | 1147 | ubifs_err("insufficient free space to mount in R/W mode"); |
1148 | dbg_dump_budg(c); | 1148 | dbg_dump_budg(c, &c->bi); |
1149 | dbg_dump_lprops(c); | 1149 | dbg_dump_lprops(c); |
1150 | return -ENOSPC; | 1150 | return -ENOSPC; |
1151 | } | 1151 | } |
@@ -1304,7 +1304,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1304 | if (err) | 1304 | if (err) |
1305 | goto out_lpt; | 1305 | goto out_lpt; |
1306 | 1306 | ||
1307 | err = dbg_check_idx_size(c, c->old_idx_sz); | 1307 | err = dbg_check_idx_size(c, c->bi.old_idx_sz); |
1308 | if (err) | 1308 | if (err) |
1309 | goto out_lpt; | 1309 | goto out_lpt; |
1310 | 1310 | ||
@@ -1313,7 +1313,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1313 | goto out_journal; | 1313 | goto out_journal; |
1314 | 1314 | ||
1315 | /* Calculate 'min_idx_lebs' after journal replay */ | 1315 | /* Calculate 'min_idx_lebs' after journal replay */ |
1316 | c->min_idx_lebs = ubifs_calc_min_idx_lebs(c); | 1316 | c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c); |
1317 | 1317 | ||
1318 | err = ubifs_mount_orphans(c, c->need_recovery, c->ro_mount); | 1318 | err = ubifs_mount_orphans(c, c->need_recovery, c->ro_mount); |
1319 | if (err) | 1319 | if (err) |
@@ -1396,6 +1396,12 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1396 | } else | 1396 | } else |
1397 | ubifs_assert(c->lst.taken_empty_lebs > 0); | 1397 | ubifs_assert(c->lst.taken_empty_lebs > 0); |
1398 | 1398 | ||
1399 | if (!c->ro_mount && c->space_fixup) { | ||
1400 | err = ubifs_fixup_free_space(c); | ||
1401 | if (err) | ||
1402 | goto out_infos; | ||
1403 | } | ||
1404 | |||
1399 | err = dbg_check_filesystem(c); | 1405 | err = dbg_check_filesystem(c); |
1400 | if (err) | 1406 | if (err) |
1401 | goto out_infos; | 1407 | goto out_infos; |
@@ -1442,7 +1448,8 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1442 | c->main_lebs, c->main_first, c->leb_cnt - 1); | 1448 | c->main_lebs, c->main_first, c->leb_cnt - 1); |
1443 | dbg_msg("index LEBs: %d", c->lst.idx_lebs); | 1449 | dbg_msg("index LEBs: %d", c->lst.idx_lebs); |
1444 | dbg_msg("total index bytes: %lld (%lld KiB, %lld MiB)", | 1450 | dbg_msg("total index bytes: %lld (%lld KiB, %lld MiB)", |
1445 | c->old_idx_sz, c->old_idx_sz >> 10, c->old_idx_sz >> 20); | 1451 | c->bi.old_idx_sz, c->bi.old_idx_sz >> 10, |
1452 | c->bi.old_idx_sz >> 20); | ||
1446 | dbg_msg("key hash type: %d", c->key_hash_type); | 1453 | dbg_msg("key hash type: %d", c->key_hash_type); |
1447 | dbg_msg("tree fanout: %d", c->fanout); | 1454 | dbg_msg("tree fanout: %d", c->fanout); |
1448 | dbg_msg("reserved GC LEB: %d", c->gc_lnum); | 1455 | dbg_msg("reserved GC LEB: %d", c->gc_lnum); |
@@ -1456,7 +1463,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1456 | dbg_msg("node sizes: ref %zu, cmt. start %zu, orph %zu", | 1463 | dbg_msg("node sizes: ref %zu, cmt. start %zu, orph %zu", |
1457 | UBIFS_REF_NODE_SZ, UBIFS_CS_NODE_SZ, UBIFS_ORPH_NODE_SZ); | 1464 | UBIFS_REF_NODE_SZ, UBIFS_CS_NODE_SZ, UBIFS_ORPH_NODE_SZ); |
1458 | dbg_msg("max. node sizes: data %zu, inode %zu dentry %zu, idx %d", | 1465 | dbg_msg("max. node sizes: data %zu, inode %zu dentry %zu, idx %d", |
1459 | UBIFS_MAX_DATA_NODE_SZ, UBIFS_MAX_INO_NODE_SZ, | 1466 | UBIFS_MAX_DATA_NODE_SZ, UBIFS_MAX_INO_NODE_SZ, |
1460 | UBIFS_MAX_DENT_NODE_SZ, ubifs_idx_node_sz(c, c->fanout)); | 1467 | UBIFS_MAX_DENT_NODE_SZ, ubifs_idx_node_sz(c, c->fanout)); |
1461 | dbg_msg("dead watermark: %d", c->dead_wm); | 1468 | dbg_msg("dead watermark: %d", c->dead_wm); |
1462 | dbg_msg("dark watermark: %d", c->dark_wm); | 1469 | dbg_msg("dark watermark: %d", c->dark_wm); |
@@ -1584,6 +1591,7 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1584 | } | 1591 | } |
1585 | sup->leb_cnt = cpu_to_le32(c->leb_cnt); | 1592 | sup->leb_cnt = cpu_to_le32(c->leb_cnt); |
1586 | err = ubifs_write_sb_node(c, sup); | 1593 | err = ubifs_write_sb_node(c, sup); |
1594 | kfree(sup); | ||
1587 | if (err) | 1595 | if (err) |
1588 | goto out; | 1596 | goto out; |
1589 | } | 1597 | } |
@@ -1684,6 +1692,13 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1684 | */ | 1692 | */ |
1685 | err = dbg_check_space_info(c); | 1693 | err = dbg_check_space_info(c); |
1686 | } | 1694 | } |
1695 | |||
1696 | if (c->space_fixup) { | ||
1697 | err = ubifs_fixup_free_space(c); | ||
1698 | if (err) | ||
1699 | goto out; | ||
1700 | } | ||
1701 | |||
1687 | mutex_unlock(&c->umount_mutex); | 1702 | mutex_unlock(&c->umount_mutex); |
1688 | return err; | 1703 | return err; |
1689 | 1704 | ||
@@ -1766,10 +1781,9 @@ static void ubifs_put_super(struct super_block *sb) | |||
1766 | * to write them back because of I/O errors. | 1781 | * to write them back because of I/O errors. |
1767 | */ | 1782 | */ |
1768 | if (!c->ro_error) { | 1783 | if (!c->ro_error) { |
1769 | ubifs_assert(atomic_long_read(&c->dirty_pg_cnt) == 0); | 1784 | ubifs_assert(c->bi.idx_growth == 0); |
1770 | ubifs_assert(c->budg_idx_growth == 0); | 1785 | ubifs_assert(c->bi.dd_growth == 0); |
1771 | ubifs_assert(c->budg_dd_growth == 0); | 1786 | ubifs_assert(c->bi.data_growth == 0); |
1772 | ubifs_assert(c->budg_data_growth == 0); | ||
1773 | } | 1787 | } |
1774 | 1788 | ||
1775 | /* | 1789 | /* |