diff options
-rw-r--r-- | fs/ubifs/io.c | 12 | ||||
-rw-r--r-- | fs/ubifs/super.c | 11 | ||||
-rw-r--r-- | fs/ubifs/tnc.c | 10 | ||||
-rw-r--r-- | fs/ubifs/ubifs.h | 5 |
4 files changed, 19 insertions, 19 deletions
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index d82173182eeb..d1fe56203a1d 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c | |||
@@ -88,8 +88,12 @@ void ubifs_ro_mode(struct ubifs_info *c, int err) | |||
88 | * This function may skip data nodes CRC checking if @c->no_chk_data_crc is | 88 | * This function may skip data nodes CRC checking if @c->no_chk_data_crc is |
89 | * true, which is controlled by corresponding UBIFS mount option. However, if | 89 | * true, which is controlled by corresponding UBIFS mount option. However, if |
90 | * @must_chk_crc is true, then @c->no_chk_data_crc is ignored and CRC is | 90 | * @must_chk_crc is true, then @c->no_chk_data_crc is ignored and CRC is |
91 | * checked. Similarly, if @c->always_chk_crc is true, @c->no_chk_data_crc is | 91 | * checked. Similarly, if @c->mounting or @c->remounting_rw is true (we are |
92 | * ignored and CRC is checked. | 92 | * mounting or re-mounting to R/W mode), @c->no_chk_data_crc is ignored and CRC |
93 | * is checked. This is because during mounting or re-mounting from R/O mode to | ||
94 | * R/W mode we may read journal nodes (when replying the journal or doing the | ||
95 | * recovery) and the journal nodes may potentially be corrupted, so checking is | ||
96 | * required. | ||
93 | * | 97 | * |
94 | * This function returns zero in case of success and %-EUCLEAN in case of bad | 98 | * This function returns zero in case of success and %-EUCLEAN in case of bad |
95 | * CRC or magic. | 99 | * CRC or magic. |
@@ -131,8 +135,8 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, | |||
131 | node_len > c->ranges[type].max_len) | 135 | node_len > c->ranges[type].max_len) |
132 | goto out_len; | 136 | goto out_len; |
133 | 137 | ||
134 | if (!must_chk_crc && type == UBIFS_DATA_NODE && !c->always_chk_crc && | 138 | if (!must_chk_crc && type == UBIFS_DATA_NODE && !c->mounting && |
135 | c->no_chk_data_crc) | 139 | !c->remounting_rw && c->no_chk_data_crc) |
136 | return 0; | 140 | return 0; |
137 | 141 | ||
138 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); | 142 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 91fac54c70e3..703a62109cf2 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -1194,11 +1194,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1194 | if (c->bulk_read == 1) | 1194 | if (c->bulk_read == 1) |
1195 | bu_init(c); | 1195 | bu_init(c); |
1196 | 1196 | ||
1197 | /* | 1197 | c->mounting = 1; |
1198 | * We have to check all CRCs, even for data nodes, when we mount the FS | ||
1199 | * (specifically, when we are replaying). | ||
1200 | */ | ||
1201 | c->always_chk_crc = 1; | ||
1202 | 1198 | ||
1203 | err = ubifs_read_superblock(c); | 1199 | err = ubifs_read_superblock(c); |
1204 | if (err) | 1200 | if (err) |
@@ -1374,7 +1370,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1374 | if (err) | 1370 | if (err) |
1375 | goto out_infos; | 1371 | goto out_infos; |
1376 | 1372 | ||
1377 | c->always_chk_crc = 0; | 1373 | c->mounting = 0; |
1378 | 1374 | ||
1379 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", | 1375 | ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", |
1380 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); | 1376 | c->vi.ubi_num, c->vi.vol_id, c->vi.name); |
@@ -1535,7 +1531,6 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1535 | mutex_lock(&c->umount_mutex); | 1531 | mutex_lock(&c->umount_mutex); |
1536 | dbg_save_space_info(c); | 1532 | dbg_save_space_info(c); |
1537 | c->remounting_rw = 1; | 1533 | c->remounting_rw = 1; |
1538 | c->always_chk_crc = 1; | ||
1539 | 1534 | ||
1540 | err = check_free_space(c); | 1535 | err = check_free_space(c); |
1541 | if (err) | 1536 | if (err) |
@@ -1642,7 +1637,6 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1642 | dbg_gen("re-mounted read-write"); | 1637 | dbg_gen("re-mounted read-write"); |
1643 | c->ro_mount = 0; | 1638 | c->ro_mount = 0; |
1644 | c->remounting_rw = 0; | 1639 | c->remounting_rw = 0; |
1645 | c->always_chk_crc = 0; | ||
1646 | err = dbg_check_space_info(c); | 1640 | err = dbg_check_space_info(c); |
1647 | mutex_unlock(&c->umount_mutex); | 1641 | mutex_unlock(&c->umount_mutex); |
1648 | return err; | 1642 | return err; |
@@ -1659,7 +1653,6 @@ out: | |||
1659 | c->ileb_buf = NULL; | 1653 | c->ileb_buf = NULL; |
1660 | ubifs_lpt_free(c, 1); | 1654 | ubifs_lpt_free(c, 1); |
1661 | c->remounting_rw = 0; | 1655 | c->remounting_rw = 0; |
1662 | c->always_chk_crc = 0; | ||
1663 | mutex_unlock(&c->umount_mutex); | 1656 | mutex_unlock(&c->umount_mutex); |
1664 | return err; | 1657 | return err; |
1665 | } | 1658 | } |
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index ad9cf0133622..de485979ca39 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
@@ -447,8 +447,11 @@ static int tnc_read_node_nm(struct ubifs_info *c, struct ubifs_zbranch *zbr, | |||
447 | * | 447 | * |
448 | * Note, this function does not check CRC of data nodes if @c->no_chk_data_crc | 448 | * Note, this function does not check CRC of data nodes if @c->no_chk_data_crc |
449 | * is true (it is controlled by corresponding mount option). However, if | 449 | * is true (it is controlled by corresponding mount option). However, if |
450 | * @c->always_chk_crc is true, @c->no_chk_data_crc is ignored and CRC is always | 450 | * @c->mounting or @c->remounting_rw is true (we are mounting or re-mounting to |
451 | * checked. | 451 | * R/W mode), @c->no_chk_data_crc is ignored and CRC is checked. This is |
452 | * because during mounting or re-mounting from R/O mode to R/W mode we may read | ||
453 | * journal nodes (when replying the journal or doing the recovery) and the | ||
454 | * journal nodes may potentially be corrupted, so checking is required. | ||
452 | */ | 455 | */ |
453 | static int try_read_node(const struct ubifs_info *c, void *buf, int type, | 456 | static int try_read_node(const struct ubifs_info *c, void *buf, int type, |
454 | int len, int lnum, int offs) | 457 | int len, int lnum, int offs) |
@@ -476,7 +479,8 @@ static int try_read_node(const struct ubifs_info *c, void *buf, int type, | |||
476 | if (node_len != len) | 479 | if (node_len != len) |
477 | return 0; | 480 | return 0; |
478 | 481 | ||
479 | if (type == UBIFS_DATA_NODE && !c->always_chk_crc && c->no_chk_data_crc) | 482 | if (type == UBIFS_DATA_NODE && c->no_chk_data_crc && !c->mounting && |
483 | !c->remounting_rw) | ||
480 | return 1; | 484 | return 1; |
481 | 485 | ||
482 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); | 486 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index d1efa37d80ae..d1823541f987 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
@@ -1169,9 +1169,8 @@ struct ubifs_debug_info; | |||
1169 | * @empty: %1 if the UBI device is empty | 1169 | * @empty: %1 if the UBI device is empty |
1170 | * @need_recovery: %1 if the file-system needs recovery | 1170 | * @need_recovery: %1 if the file-system needs recovery |
1171 | * @replaying: %1 during journal replay | 1171 | * @replaying: %1 during journal replay |
1172 | * @mounting: %1 while mounting | ||
1172 | * @remounting_rw: %1 while re-mounting from R/O mode to R/W mode | 1173 | * @remounting_rw: %1 while re-mounting from R/O mode to R/W mode |
1173 | * @always_chk_crc: always check CRCs (while mounting and remounting to R/W | ||
1174 | * mode) | ||
1175 | * @replay_tree: temporary tree used during journal replay | 1174 | * @replay_tree: temporary tree used during journal replay |
1176 | * @replay_list: temporary list used during journal replay | 1175 | * @replay_list: temporary list used during journal replay |
1177 | * @replay_buds: list of buds to replay | 1176 | * @replay_buds: list of buds to replay |
@@ -1405,8 +1404,8 @@ struct ubifs_info { | |||
1405 | unsigned int empty:1; | 1404 | unsigned int empty:1; |
1406 | unsigned int need_recovery:1; | 1405 | unsigned int need_recovery:1; |
1407 | unsigned int replaying:1; | 1406 | unsigned int replaying:1; |
1407 | unsigned int mounting:1; | ||
1408 | unsigned int remounting_rw:1; | 1408 | unsigned int remounting_rw:1; |
1409 | unsigned int always_chk_crc:1; | ||
1410 | struct rb_root replay_tree; | 1409 | struct rb_root replay_tree; |
1411 | struct list_head replay_list; | 1410 | struct list_head replay_list; |
1412 | struct list_head replay_buds; | 1411 | struct list_head replay_buds; |