diff options
Diffstat (limited to 'fs/ubifs/tnc.c')
-rw-r--r-- | fs/ubifs/tnc.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index 6eef5344a145..fa28a84c6a1b 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
@@ -443,6 +443,11 @@ static int tnc_read_node_nm(struct ubifs_info *c, struct ubifs_zbranch *zbr, | |||
443 | * This function performs that same function as ubifs_read_node except that | 443 | * This function performs that same function as ubifs_read_node except that |
444 | * it does not require that there is actually a node present and instead | 444 | * it does not require that there is actually a node present and instead |
445 | * the return code indicates if a node was read. | 445 | * the return code indicates if a node was read. |
446 | * | ||
447 | * Note, this function does not check CRC of data nodes if @c->no_chk_data_crc | ||
448 | * is true (it is controlled by corresponding mount option). However, if | ||
449 | * @c->always_chk_crc is true, @c->no_chk_data_crc is ignored and CRC is always | ||
450 | * checked. | ||
446 | */ | 451 | */ |
447 | static int try_read_node(const struct ubifs_info *c, void *buf, int type, | 452 | static int try_read_node(const struct ubifs_info *c, void *buf, int type, |
448 | int len, int lnum, int offs) | 453 | int len, int lnum, int offs) |
@@ -470,9 +475,8 @@ static int try_read_node(const struct ubifs_info *c, void *buf, int type, | |||
470 | if (node_len != len) | 475 | if (node_len != len) |
471 | return 0; | 476 | return 0; |
472 | 477 | ||
473 | if (type == UBIFS_DATA_NODE && !c->always_chk_crc) | 478 | if (type == UBIFS_DATA_NODE && !c->always_chk_crc && c->no_chk_data_crc) |
474 | if (c->no_chk_data_crc) | 479 | return 1; |
475 | return 0; | ||
476 | 480 | ||
477 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); | 481 | crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); |
478 | node_crc = le32_to_cpu(ch->crc); | 482 | node_crc = le32_to_cpu(ch->crc); |
@@ -1506,7 +1510,7 @@ out: | |||
1506 | * | 1510 | * |
1507 | * Note, if the bulk-read buffer length (@bu->buf_len) is known, this function | 1511 | * Note, if the bulk-read buffer length (@bu->buf_len) is known, this function |
1508 | * makes sure bulk-read nodes fit the buffer. Otherwise, this function prepares | 1512 | * makes sure bulk-read nodes fit the buffer. Otherwise, this function prepares |
1509 | * maxumum possible amount of nodes for bulk-read. | 1513 | * maximum possible amount of nodes for bulk-read. |
1510 | */ | 1514 | */ |
1511 | int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu) | 1515 | int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu) |
1512 | { | 1516 | { |
@@ -2245,12 +2249,11 @@ int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key, | |||
2245 | if (found) { | 2249 | if (found) { |
2246 | /* Ensure the znode is dirtied */ | 2250 | /* Ensure the znode is dirtied */ |
2247 | if (znode->cnext || !ubifs_zn_dirty(znode)) { | 2251 | if (znode->cnext || !ubifs_zn_dirty(znode)) { |
2248 | znode = dirty_cow_bottom_up(c, | 2252 | znode = dirty_cow_bottom_up(c, znode); |
2249 | znode); | 2253 | if (IS_ERR(znode)) { |
2250 | if (IS_ERR(znode)) { | 2254 | err = PTR_ERR(znode); |
2251 | err = PTR_ERR(znode); | 2255 | goto out_unlock; |
2252 | goto out_unlock; | 2256 | } |
2253 | } | ||
2254 | } | 2257 | } |
2255 | zbr = &znode->zbranch[n]; | 2258 | zbr = &znode->zbranch[n]; |
2256 | lnc_free(zbr); | 2259 | lnc_free(zbr); |
@@ -2317,11 +2320,11 @@ int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key, | |||
2317 | 2320 | ||
2318 | /* Ensure the znode is dirtied */ | 2321 | /* Ensure the znode is dirtied */ |
2319 | if (znode->cnext || !ubifs_zn_dirty(znode)) { | 2322 | if (znode->cnext || !ubifs_zn_dirty(znode)) { |
2320 | znode = dirty_cow_bottom_up(c, znode); | 2323 | znode = dirty_cow_bottom_up(c, znode); |
2321 | if (IS_ERR(znode)) { | 2324 | if (IS_ERR(znode)) { |
2322 | err = PTR_ERR(znode); | 2325 | err = PTR_ERR(znode); |
2323 | goto out_unlock; | 2326 | goto out_unlock; |
2324 | } | 2327 | } |
2325 | } | 2328 | } |
2326 | 2329 | ||
2327 | if (found == 1) { | 2330 | if (found == 1) { |
@@ -2627,11 +2630,11 @@ int ubifs_tnc_remove_range(struct ubifs_info *c, union ubifs_key *from_key, | |||
2627 | 2630 | ||
2628 | /* Ensure the znode is dirtied */ | 2631 | /* Ensure the znode is dirtied */ |
2629 | if (znode->cnext || !ubifs_zn_dirty(znode)) { | 2632 | if (znode->cnext || !ubifs_zn_dirty(znode)) { |
2630 | znode = dirty_cow_bottom_up(c, znode); | 2633 | znode = dirty_cow_bottom_up(c, znode); |
2631 | if (IS_ERR(znode)) { | 2634 | if (IS_ERR(znode)) { |
2632 | err = PTR_ERR(znode); | 2635 | err = PTR_ERR(znode); |
2633 | goto out_unlock; | 2636 | goto out_unlock; |
2634 | } | 2637 | } |
2635 | } | 2638 | } |
2636 | 2639 | ||
2637 | /* Remove all keys in range except the first */ | 2640 | /* Remove all keys in range except the first */ |