diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-18 13:50:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-18 13:50:27 -0400 |
commit | 8f627a8a881481598c2591c3acc122fb9be7bac4 (patch) | |
tree | 06497d25e30824500aeaf8c736c45b070f121234 /fs/ubifs/super.c | |
parent | fd57ed021990157ee5b3997c3f21c734093a9e23 (diff) | |
parent | 5d630e43284fdb0613e4e7e7dd906f27bc25b6af (diff) |
Merge branch 'linux-next' of git://git.infradead.org/ubifs-2.6
* 'linux-next' of git://git.infradead.org/ubifs-2.6: (25 commits)
UBIFS: clean-up commentaries
UBIFS: save 128KiB or more RAM
UBIFS: allocate orphans scan buffer on demand
UBIFS: allocate lpt dump buffer on demand
UBIFS: allocate ltab checking buffer on demand
UBIFS: allocate scanning buffer on demand
UBIFS: allocate dump buffer on demand
UBIFS: do not check data crc by default
UBIFS: simplify UBIFS Kconfig menu
UBIFS: print max. index node size
UBIFS: handle allocation failures in UBIFS write path
UBIFS: use max_write_size during recovery
UBIFS: use max_write_size for write-buffers
UBIFS: introduce write-buffer size field
UBI: incorporate LEB offset information
UBIFS: incorporate maximum write size
UBI: provide LEB offset information
UBI: incorporate maximum write size
UBIFS: fix LEB number in printk
UBIFS: restrict world-writable debugfs files
...
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r-- | fs/ubifs/super.c | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 6e11c2975dcf..e5dc1e120e8d 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -512,9 +512,12 @@ static int init_constants_early(struct ubifs_info *c) | |||
512 | 512 | ||
513 | c->leb_cnt = c->vi.size; | 513 | c->leb_cnt = c->vi.size; |
514 | c->leb_size = c->vi.usable_leb_size; | 514 | c->leb_size = c->vi.usable_leb_size; |
515 | c->leb_start = c->di.leb_start; | ||
515 | c->half_leb_size = c->leb_size / 2; | 516 | c->half_leb_size = c->leb_size / 2; |
516 | c->min_io_size = c->di.min_io_size; | 517 | c->min_io_size = c->di.min_io_size; |
517 | c->min_io_shift = fls(c->min_io_size) - 1; | 518 | c->min_io_shift = fls(c->min_io_size) - 1; |
519 | c->max_write_size = c->di.max_write_size; | ||
520 | c->max_write_shift = fls(c->max_write_size) - 1; | ||
518 | 521 | ||
519 | if (c->leb_size < UBIFS_MIN_LEB_SZ) { | 522 | if (c->leb_size < UBIFS_MIN_LEB_SZ) { |
520 | ubifs_err("too small LEBs (%d bytes), min. is %d bytes", | 523 | ubifs_err("too small LEBs (%d bytes), min. is %d bytes", |
@@ -534,6 +537,18 @@ static int init_constants_early(struct ubifs_info *c) | |||
534 | } | 537 | } |
535 | 538 | ||
536 | /* | 539 | /* |
540 | * Maximum write size has to be greater or equivalent to min. I/O | ||
541 | * size, and be multiple of min. I/O size. | ||
542 | */ | ||
543 | if (c->max_write_size < c->min_io_size || | ||
544 | c->max_write_size % c->min_io_size || | ||
545 | !is_power_of_2(c->max_write_size)) { | ||
546 | ubifs_err("bad write buffer size %d for %d min. I/O unit", | ||
547 | c->max_write_size, c->min_io_size); | ||
548 | return -EINVAL; | ||
549 | } | ||
550 | |||
551 | /* | ||
537 | * UBIFS aligns all node to 8-byte boundary, so to make function in | 552 | * UBIFS aligns all node to 8-byte boundary, so to make function in |
538 | * io.c simpler, assume minimum I/O unit size to be 8 bytes if it is | 553 | * io.c simpler, assume minimum I/O unit size to be 8 bytes if it is |
539 | * less than 8. | 554 | * less than 8. |
@@ -541,6 +556,10 @@ static int init_constants_early(struct ubifs_info *c) | |||
541 | if (c->min_io_size < 8) { | 556 | if (c->min_io_size < 8) { |
542 | c->min_io_size = 8; | 557 | c->min_io_size = 8; |
543 | c->min_io_shift = 3; | 558 | c->min_io_shift = 3; |
559 | if (c->max_write_size < c->min_io_size) { | ||
560 | c->max_write_size = c->min_io_size; | ||
561 | c->max_write_shift = c->min_io_shift; | ||
562 | } | ||
544 | } | 563 | } |
545 | 564 | ||
546 | c->ref_node_alsz = ALIGN(UBIFS_REF_NODE_SZ, c->min_io_size); | 565 | c->ref_node_alsz = ALIGN(UBIFS_REF_NODE_SZ, c->min_io_size); |
@@ -1202,11 +1221,14 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1202 | if (c->bulk_read == 1) | 1221 | if (c->bulk_read == 1) |
1203 | bu_init(c); | 1222 | bu_init(c); |
1204 | 1223 | ||
1205 | /* | 1224 | if (!c->ro_mount) { |
1206 | * We have to check all CRCs, even for data nodes, when we mount the FS | 1225 | c->write_reserve_buf = kmalloc(COMPRESSED_DATA_NODE_BUF_SZ, |
1207 | * (specifically, when we are replaying). | 1226 | GFP_KERNEL); |
1208 | */ | 1227 | if (!c->write_reserve_buf) |
1209 | c->always_chk_crc = 1; | 1228 | goto out_free; |
1229 | } | ||
1230 | |||
1231 | c->mounting = 1; | ||
1210 | 1232 | ||
1211 | err = ubifs_read_superblock(c); | 1233 | err = ubifs_read_superblock(c); |
1212 | if (err) | 1234 | if (err) |
@@ -1382,7 +1404,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1382 | if (err) | 1404 | if (err) |
1383 | goto out_infos; | 1405 | goto out_infos; |
1384 | 1406 | ||
1385 | c->always_chk_crc = 0; | 1407 | c->mounting = 0; |
1386 | 1408 | ||
1387 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", | 1409 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", |
1388 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); | 1410 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); |
@@ -1403,6 +1425,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1403 | 1425 | ||
1404 | dbg_msg("compiled on: " __DATE__ " at " __TIME__); | 1426 | dbg_msg("compiled on: " __DATE__ " at " __TIME__); |
1405 | dbg_msg("min. I/O unit size: %d bytes", c->min_io_size); | 1427 | dbg_msg("min. I/O unit size: %d bytes", c->min_io_size); |
1428 | dbg_msg("max. write size: %d bytes", c->max_write_size); | ||
1406 | dbg_msg("LEB size: %d bytes (%d KiB)", | 1429 | dbg_msg("LEB size: %d bytes (%d KiB)", |
1407 | c->leb_size, c->leb_size >> 10); | 1430 | c->leb_size, c->leb_size >> 10); |
1408 | dbg_msg("data journal heads: %d", | 1431 | dbg_msg("data journal heads: %d", |
@@ -1432,9 +1455,9 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1432 | UBIFS_TRUN_NODE_SZ, UBIFS_SB_NODE_SZ, UBIFS_MST_NODE_SZ); | 1455 | UBIFS_TRUN_NODE_SZ, UBIFS_SB_NODE_SZ, UBIFS_MST_NODE_SZ); |
1433 | dbg_msg("node sizes: ref %zu, cmt. start %zu, orph %zu", | 1456 | dbg_msg("node sizes: ref %zu, cmt. start %zu, orph %zu", |
1434 | UBIFS_REF_NODE_SZ, UBIFS_CS_NODE_SZ, UBIFS_ORPH_NODE_SZ); | 1457 | UBIFS_REF_NODE_SZ, UBIFS_CS_NODE_SZ, UBIFS_ORPH_NODE_SZ); |
1435 | dbg_msg("max. node sizes: data %zu, inode %zu dentry %zu", | 1458 | dbg_msg("max. node sizes: data %zu, inode %zu dentry %zu, idx %d", |
1436 | UBIFS_MAX_DATA_NODE_SZ, UBIFS_MAX_INO_NODE_SZ, | 1459 | UBIFS_MAX_DATA_NODE_SZ, UBIFS_MAX_INO_NODE_SZ, |
1437 | UBIFS_MAX_DENT_NODE_SZ); | 1460 | UBIFS_MAX_DENT_NODE_SZ, ubifs_idx_node_sz(c, c->fanout)); |
1438 | dbg_msg("dead watermark: %d", c->dead_wm); | 1461 | dbg_msg("dead watermark: %d", c->dead_wm); |
1439 | dbg_msg("dark watermark: %d", c->dark_wm); | 1462 | dbg_msg("dark watermark: %d", c->dark_wm); |
1440 | dbg_msg("LEB overhead: %d", c->leb_overhead); | 1463 | dbg_msg("LEB overhead: %d", c->leb_overhead); |
@@ -1474,6 +1497,7 @@ out_wbufs: | |||
1474 | out_cbuf: | 1497 | out_cbuf: |
1475 | kfree(c->cbuf); | 1498 | kfree(c->cbuf); |
1476 | out_free: | 1499 | out_free: |
1500 | kfree(c->write_reserve_buf); | ||
1477 | kfree(c->bu.buf); | 1501 | kfree(c->bu.buf); |
1478 | vfree(c->ileb_buf); | 1502 | vfree(c->ileb_buf); |
1479 | vfree(c->sbuf); | 1503 | vfree(c->sbuf); |
@@ -1512,6 +1536,7 @@ static void ubifs_umount(struct ubifs_info *c) | |||
1512 | kfree(c->cbuf); | 1536 | kfree(c->cbuf); |
1513 | kfree(c->rcvrd_mst_node); | 1537 | kfree(c->rcvrd_mst_node); |
1514 | kfree(c->mst_node); | 1538 | kfree(c->mst_node); |
1539 | kfree(c->write_reserve_buf); | ||
1515 | kfree(c->bu.buf); | 1540 | kfree(c->bu.buf); |
1516 | vfree(c->ileb_buf); | 1541 | vfree(c->ileb_buf); |
1517 | vfree(c->sbuf); | 1542 | vfree(c->sbuf); |
@@ -1543,7 +1568,6 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1543 | mutex_lock(&c->umount_mutex); | 1568 | mutex_lock(&c->umount_mutex); |
1544 | dbg_save_space_info(c); | 1569 | dbg_save_space_info(c); |
1545 | c->remounting_rw = 1; | 1570 | c->remounting_rw = 1; |
1546 | c->always_chk_crc = 1; | ||
1547 | 1571 | ||
1548 | err = check_free_space(c); | 1572 | err = check_free_space(c); |
1549 | if (err) | 1573 | if (err) |
@@ -1598,6 +1622,10 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1598 | goto out; | 1622 | goto out; |
1599 | } | 1623 | } |
1600 | 1624 | ||
1625 | c->write_reserve_buf = kmalloc(COMPRESSED_DATA_NODE_BUF_SZ, GFP_KERNEL); | ||
1626 | if (!c->write_reserve_buf) | ||
1627 | goto out; | ||
1628 | |||
1601 | err = ubifs_lpt_init(c, 0, 1); | 1629 | err = ubifs_lpt_init(c, 0, 1); |
1602 | if (err) | 1630 | if (err) |
1603 | goto out; | 1631 | goto out; |
@@ -1650,7 +1678,6 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1650 | dbg_gen("re-mounted read-write"); | 1678 | dbg_gen("re-mounted read-write"); |
1651 | c->ro_mount = 0; | 1679 | c->ro_mount = 0; |
1652 | c->remounting_rw = 0; | 1680 | c->remounting_rw = 0; |
1653 | c->always_chk_crc = 0; | ||
1654 | err = dbg_check_space_info(c); | 1681 | err = dbg_check_space_info(c); |
1655 | mutex_unlock(&c->umount_mutex); | 1682 | mutex_unlock(&c->umount_mutex); |
1656 | return err; | 1683 | return err; |
@@ -1663,11 +1690,12 @@ out: | |||
1663 | c->bgt = NULL; | 1690 | c->bgt = NULL; |
1664 | } | 1691 | } |
1665 | free_wbufs(c); | 1692 | free_wbufs(c); |
1693 | kfree(c->write_reserve_buf); | ||
1694 | c->write_reserve_buf = NULL; | ||
1666 | vfree(c->ileb_buf); | 1695 | vfree(c->ileb_buf); |
1667 | c->ileb_buf = NULL; | 1696 | c->ileb_buf = NULL; |
1668 | ubifs_lpt_free(c, 1); | 1697 | ubifs_lpt_free(c, 1); |
1669 | c->remounting_rw = 0; | 1698 | c->remounting_rw = 0; |
1670 | c->always_chk_crc = 0; | ||
1671 | mutex_unlock(&c->umount_mutex); | 1699 | mutex_unlock(&c->umount_mutex); |
1672 | return err; | 1700 | return err; |
1673 | } | 1701 | } |
@@ -1707,6 +1735,8 @@ static void ubifs_remount_ro(struct ubifs_info *c) | |||
1707 | free_wbufs(c); | 1735 | free_wbufs(c); |
1708 | vfree(c->orph_buf); | 1736 | vfree(c->orph_buf); |
1709 | c->orph_buf = NULL; | 1737 | c->orph_buf = NULL; |
1738 | kfree(c->write_reserve_buf); | ||
1739 | c->write_reserve_buf = NULL; | ||
1710 | vfree(c->ileb_buf); | 1740 | vfree(c->ileb_buf); |
1711 | c->ileb_buf = NULL; | 1741 | c->ileb_buf = NULL; |
1712 | ubifs_lpt_free(c, 1); | 1742 | ubifs_lpt_free(c, 1); |
@@ -1937,6 +1967,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
1937 | mutex_init(&c->mst_mutex); | 1967 | mutex_init(&c->mst_mutex); |
1938 | mutex_init(&c->umount_mutex); | 1968 | mutex_init(&c->umount_mutex); |
1939 | mutex_init(&c->bu_mutex); | 1969 | mutex_init(&c->bu_mutex); |
1970 | mutex_init(&c->write_reserve_mutex); | ||
1940 | init_waitqueue_head(&c->cmt_wq); | 1971 | init_waitqueue_head(&c->cmt_wq); |
1941 | c->buds = RB_ROOT; | 1972 | c->buds = RB_ROOT; |
1942 | c->old_idx = RB_ROOT; | 1973 | c->old_idx = RB_ROOT; |
@@ -1954,6 +1985,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
1954 | INIT_LIST_HEAD(&c->old_buds); | 1985 | INIT_LIST_HEAD(&c->old_buds); |
1955 | INIT_LIST_HEAD(&c->orph_list); | 1986 | INIT_LIST_HEAD(&c->orph_list); |
1956 | INIT_LIST_HEAD(&c->orph_new); | 1987 | INIT_LIST_HEAD(&c->orph_new); |
1988 | c->no_chk_data_crc = 1; | ||
1957 | 1989 | ||
1958 | c->vfs_sb = sb; | 1990 | c->vfs_sb = sb; |
1959 | c->highest_inum = UBIFS_FIRST_INO; | 1991 | c->highest_inum = UBIFS_FIRST_INO; |