diff options
| author | Richard Weinberger <richard@nod.at> | 2018-07-12 07:01:57 -0400 |
|---|---|---|
| committer | Richard Weinberger <richard@nod.at> | 2018-08-14 18:25:21 -0400 |
| commit | 6eb61d587f4515e4be5669eff383c0185009954f (patch) | |
| tree | a5d3183e104338319152a888e0ff980c2546e6e1 /fs/ubifs | |
| parent | 54169ddd382d461f7c01cc5a5182a4b4bc539489 (diff) | |
ubifs: Pass struct ubifs_info to ubifs_assert()
This allows us to have more context in ubifs_assert()
and take different actions depending on the configuration.
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs')
| -rw-r--r-- | fs/ubifs/budget.c | 68 | ||||
| -rw-r--r-- | fs/ubifs/commit.c | 8 | ||||
| -rw-r--r-- | fs/ubifs/crypto.c | 4 | ||||
| -rw-r--r-- | fs/ubifs/debug.c | 20 | ||||
| -rw-r--r-- | fs/ubifs/debug.h | 4 | ||||
| -rw-r--r-- | fs/ubifs/dir.c | 35 | ||||
| -rw-r--r-- | fs/ubifs/file.c | 47 | ||||
| -rw-r--r-- | fs/ubifs/file.h | 0 | ||||
| -rw-r--r-- | fs/ubifs/find.c | 54 | ||||
| -rw-r--r-- | fs/ubifs/gc.c | 64 | ||||
| -rw-r--r-- | fs/ubifs/io.c | 97 | ||||
| -rw-r--r-- | fs/ubifs/journal.c | 52 | ||||
| -rw-r--r-- | fs/ubifs/key.h | 14 | ||||
| -rw-r--r-- | fs/ubifs/log.c | 12 | ||||
| -rw-r--r-- | fs/ubifs/lprops.c | 86 | ||||
| -rw-r--r-- | fs/ubifs/lpt.c | 112 | ||||
| -rw-r--r-- | fs/ubifs/lpt_commit.c | 50 | ||||
| -rw-r--r-- | fs/ubifs/master.c | 2 | ||||
| -rw-r--r-- | fs/ubifs/misc.h | 14 | ||||
| -rw-r--r-- | fs/ubifs/orphan.c | 26 | ||||
| -rw-r--r-- | fs/ubifs/recovery.c | 14 | ||||
| -rw-r--r-- | fs/ubifs/replay.c | 13 | ||||
| -rw-r--r-- | fs/ubifs/sb.c | 12 | ||||
| -rw-r--r-- | fs/ubifs/scan.c | 2 | ||||
| -rw-r--r-- | fs/ubifs/shrinker.c | 10 | ||||
| -rw-r--r-- | fs/ubifs/super.c | 45 | ||||
| -rw-r--r-- | fs/ubifs/tnc.c | 107 | ||||
| -rw-r--r-- | fs/ubifs/tnc_commit.c | 28 | ||||
| -rw-r--r-- | fs/ubifs/tnc_misc.c | 38 | ||||
| -rw-r--r-- | fs/ubifs/ubifs.h | 17 | ||||
| -rw-r--r-- | fs/ubifs/xattr.c | 16 |
31 files changed, 550 insertions, 521 deletions
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c index 11a11b32a2a9..7ef22baf9d15 100644 --- a/fs/ubifs/budget.c +++ b/fs/ubifs/budget.c | |||
| @@ -439,16 +439,16 @@ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req) | |||
| 439 | { | 439 | { |
| 440 | int err, idx_growth, data_growth, dd_growth, retried = 0; | 440 | int err, idx_growth, data_growth, dd_growth, retried = 0; |
| 441 | 441 | ||
| 442 | ubifs_assert(req->new_page <= 1); | 442 | ubifs_assert(c, req->new_page <= 1); |
| 443 | ubifs_assert(req->dirtied_page <= 1); | 443 | ubifs_assert(c, req->dirtied_page <= 1); |
| 444 | ubifs_assert(req->new_dent <= 1); | 444 | ubifs_assert(c, req->new_dent <= 1); |
| 445 | ubifs_assert(req->mod_dent <= 1); | 445 | ubifs_assert(c, req->mod_dent <= 1); |
| 446 | ubifs_assert(req->new_ino <= 1); | 446 | ubifs_assert(c, req->new_ino <= 1); |
| 447 | ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA); | 447 | ubifs_assert(c, req->new_ino_d <= UBIFS_MAX_INO_DATA); |
| 448 | ubifs_assert(req->dirtied_ino <= 4); | 448 | ubifs_assert(c, req->dirtied_ino <= 4); |
| 449 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); | 449 | ubifs_assert(c, req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); |
| 450 | ubifs_assert(!(req->new_ino_d & 7)); | 450 | ubifs_assert(c, !(req->new_ino_d & 7)); |
| 451 | ubifs_assert(!(req->dirtied_ino_d & 7)); | 451 | ubifs_assert(c, !(req->dirtied_ino_d & 7)); |
| 452 | 452 | ||
| 453 | data_growth = calc_data_growth(c, req); | 453 | data_growth = calc_data_growth(c, req); |
| 454 | dd_growth = calc_dd_growth(c, req); | 454 | dd_growth = calc_dd_growth(c, req); |
| @@ -458,9 +458,9 @@ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req) | |||
| 458 | 458 | ||
| 459 | again: | 459 | again: |
| 460 | spin_lock(&c->space_lock); | 460 | spin_lock(&c->space_lock); |
| 461 | ubifs_assert(c->bi.idx_growth >= 0); | 461 | ubifs_assert(c, c->bi.idx_growth >= 0); |
| 462 | ubifs_assert(c->bi.data_growth >= 0); | 462 | ubifs_assert(c, c->bi.data_growth >= 0); |
| 463 | ubifs_assert(c->bi.dd_growth >= 0); | 463 | ubifs_assert(c, c->bi.dd_growth >= 0); |
| 464 | 464 | ||
| 465 | if (unlikely(c->bi.nospace) && (c->bi.nospace_rp || !can_use_rp(c))) { | 465 | if (unlikely(c->bi.nospace) && (c->bi.nospace_rp || !can_use_rp(c))) { |
| 466 | dbg_budg("no space"); | 466 | dbg_budg("no space"); |
| @@ -526,20 +526,20 @@ again: | |||
| 526 | */ | 526 | */ |
| 527 | void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req) | 527 | void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req) |
| 528 | { | 528 | { |
| 529 | ubifs_assert(req->new_page <= 1); | 529 | ubifs_assert(c, req->new_page <= 1); |
| 530 | ubifs_assert(req->dirtied_page <= 1); | 530 | ubifs_assert(c, req->dirtied_page <= 1); |
| 531 | ubifs_assert(req->new_dent <= 1); | 531 | ubifs_assert(c, req->new_dent <= 1); |
| 532 | ubifs_assert(req->mod_dent <= 1); | 532 | ubifs_assert(c, req->mod_dent <= 1); |
| 533 | ubifs_assert(req->new_ino <= 1); | 533 | ubifs_assert(c, req->new_ino <= 1); |
| 534 | ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA); | 534 | ubifs_assert(c, req->new_ino_d <= UBIFS_MAX_INO_DATA); |
| 535 | ubifs_assert(req->dirtied_ino <= 4); | 535 | ubifs_assert(c, req->dirtied_ino <= 4); |
| 536 | ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); | 536 | ubifs_assert(c, req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4); |
| 537 | ubifs_assert(!(req->new_ino_d & 7)); | 537 | ubifs_assert(c, !(req->new_ino_d & 7)); |
| 538 | ubifs_assert(!(req->dirtied_ino_d & 7)); | 538 | ubifs_assert(c, !(req->dirtied_ino_d & 7)); |
| 539 | if (!req->recalculate) { | 539 | if (!req->recalculate) { |
| 540 | ubifs_assert(req->idx_growth >= 0); | 540 | ubifs_assert(c, req->idx_growth >= 0); |
| 541 | ubifs_assert(req->data_growth >= 0); | 541 | ubifs_assert(c, req->data_growth >= 0); |
| 542 | ubifs_assert(req->dd_growth >= 0); | 542 | ubifs_assert(c, req->dd_growth >= 0); |
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | if (req->recalculate) { | 545 | if (req->recalculate) { |
| @@ -561,13 +561,13 @@ void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req) | |||
| 561 | c->bi.dd_growth -= req->dd_growth; | 561 | c->bi.dd_growth -= req->dd_growth; |
| 562 | c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c); | 562 | c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c); |
| 563 | 563 | ||
| 564 | ubifs_assert(c->bi.idx_growth >= 0); | 564 | ubifs_assert(c, c->bi.idx_growth >= 0); |
| 565 | ubifs_assert(c->bi.data_growth >= 0); | 565 | ubifs_assert(c, c->bi.data_growth >= 0); |
| 566 | ubifs_assert(c->bi.dd_growth >= 0); | 566 | ubifs_assert(c, c->bi.dd_growth >= 0); |
| 567 | ubifs_assert(c->bi.min_idx_lebs < c->main_lebs); | 567 | ubifs_assert(c, c->bi.min_idx_lebs < c->main_lebs); |
| 568 | ubifs_assert(!(c->bi.idx_growth & 7)); | 568 | ubifs_assert(c, !(c->bi.idx_growth & 7)); |
| 569 | ubifs_assert(!(c->bi.data_growth & 7)); | 569 | ubifs_assert(c, !(c->bi.data_growth & 7)); |
| 570 | ubifs_assert(!(c->bi.dd_growth & 7)); | 570 | ubifs_assert(c, !(c->bi.dd_growth & 7)); |
| 571 | spin_unlock(&c->space_lock); | 571 | spin_unlock(&c->space_lock); |
| 572 | } | 572 | } |
| 573 | 573 | ||
| @@ -680,7 +680,7 @@ long long ubifs_get_free_space_nolock(struct ubifs_info *c) | |||
| 680 | int rsvd_idx_lebs, lebs; | 680 | int rsvd_idx_lebs, lebs; |
| 681 | long long available, outstanding, free; | 681 | long long available, outstanding, free; |
| 682 | 682 | ||
| 683 | ubifs_assert(c->bi.min_idx_lebs == ubifs_calc_min_idx_lebs(c)); | 683 | ubifs_assert(c, c->bi.min_idx_lebs == ubifs_calc_min_idx_lebs(c)); |
| 684 | outstanding = c->bi.data_growth + c->bi.dd_growth; | 684 | outstanding = c->bi.data_growth + c->bi.dd_growth; |
| 685 | available = ubifs_calc_available(c, c->bi.min_idx_lebs); | 685 | available = ubifs_calc_available(c, c->bi.min_idx_lebs); |
| 686 | 686 | ||
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c index 63f56619991d..591f2c7a48f0 100644 --- a/fs/ubifs/commit.c +++ b/fs/ubifs/commit.c | |||
| @@ -91,9 +91,9 @@ static int nothing_to_commit(struct ubifs_info *c) | |||
| 91 | if (c->nroot && test_bit(DIRTY_CNODE, &c->nroot->flags)) | 91 | if (c->nroot && test_bit(DIRTY_CNODE, &c->nroot->flags)) |
| 92 | return 0; | 92 | return 0; |
| 93 | 93 | ||
| 94 | ubifs_assert(atomic_long_read(&c->dirty_zn_cnt) == 0); | 94 | ubifs_assert(c, atomic_long_read(&c->dirty_zn_cnt) == 0); |
| 95 | ubifs_assert(c->dirty_pn_cnt == 0); | 95 | ubifs_assert(c, c->dirty_pn_cnt == 0); |
| 96 | ubifs_assert(c->dirty_nn_cnt == 0); | 96 | ubifs_assert(c, c->dirty_nn_cnt == 0); |
| 97 | 97 | ||
| 98 | return 1; | 98 | return 1; |
| 99 | } | 99 | } |
| @@ -113,7 +113,7 @@ static int do_commit(struct ubifs_info *c) | |||
| 113 | struct ubifs_lp_stats lst; | 113 | struct ubifs_lp_stats lst; |
| 114 | 114 | ||
| 115 | dbg_cmt("start"); | 115 | dbg_cmt("start"); |
| 116 | ubifs_assert(!c->ro_media && !c->ro_mount); | 116 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 117 | 117 | ||
| 118 | if (c->ro_error) { | 118 | if (c->ro_error) { |
| 119 | err = -EROFS; | 119 | err = -EROFS; |
diff --git a/fs/ubifs/crypto.c b/fs/ubifs/crypto.c index 55c508fe8131..4aaedf2d7f44 100644 --- a/fs/ubifs/crypto.c +++ b/fs/ubifs/crypto.c | |||
| @@ -32,7 +32,7 @@ int ubifs_encrypt(const struct inode *inode, struct ubifs_data_node *dn, | |||
| 32 | struct page *ret; | 32 | struct page *ret; |
| 33 | unsigned int pad_len = round_up(in_len, UBIFS_CIPHER_BLOCK_SIZE); | 33 | unsigned int pad_len = round_up(in_len, UBIFS_CIPHER_BLOCK_SIZE); |
| 34 | 34 | ||
| 35 | ubifs_assert(pad_len <= *out_len); | 35 | ubifs_assert(c, pad_len <= *out_len); |
| 36 | dn->compr_size = cpu_to_le16(in_len); | 36 | dn->compr_size = cpu_to_le16(in_len); |
| 37 | 37 | ||
| 38 | /* pad to full block cipher length */ | 38 | /* pad to full block cipher length */ |
| @@ -63,7 +63,7 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn, | |||
| 63 | return -EINVAL; | 63 | return -EINVAL; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | ubifs_assert(dlen <= UBIFS_BLOCK_SIZE); | 66 | ubifs_assert(c, dlen <= UBIFS_BLOCK_SIZE); |
| 67 | err = fscrypt_decrypt_page(inode, virt_to_page(&dn->data), dlen, | 67 | err = fscrypt_decrypt_page(inode, virt_to_page(&dn->data), dlen, |
| 68 | offset_in_page(&dn->data), block); | 68 | offset_in_page(&dn->data), block); |
| 69 | if (err) { | 69 | if (err) { |
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 7cd8a7b95299..1a626484f8ae 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
| @@ -134,7 +134,7 @@ const char *dbg_snprintf_key(const struct ubifs_info *c, | |||
| 134 | } | 134 | } |
| 135 | } else | 135 | } else |
| 136 | len -= snprintf(p, len, "bad key format %d", c->key_fmt); | 136 | len -= snprintf(p, len, "bad key format %d", c->key_fmt); |
| 137 | ubifs_assert(len > 0); | 137 | ubifs_assert(c, len > 0); |
| 138 | return p; | 138 | return p; |
| 139 | } | 139 | } |
| 140 | 140 | ||
| @@ -276,7 +276,7 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode) | |||
| 276 | return; | 276 | return; |
| 277 | 277 | ||
| 278 | pr_err("List of directory entries:\n"); | 278 | pr_err("List of directory entries:\n"); |
| 279 | ubifs_assert(!mutex_is_locked(&c->tnc_mutex)); | 279 | ubifs_assert(c, !mutex_is_locked(&c->tnc_mutex)); |
| 280 | 280 | ||
| 281 | lowest_dent_key(c, &key, inode->i_ino); | 281 | lowest_dent_key(c, &key, inode->i_ino); |
| 282 | while (1) { | 282 | while (1) { |
| @@ -931,7 +931,7 @@ void ubifs_dump_tnc(struct ubifs_info *c) | |||
| 931 | 931 | ||
| 932 | pr_err("\n"); | 932 | pr_err("\n"); |
| 933 | pr_err("(pid %d) start dumping TNC tree\n", current->pid); | 933 | pr_err("(pid %d) start dumping TNC tree\n", current->pid); |
| 934 | znode = ubifs_tnc_levelorder_next(c->zroot.znode, NULL); | 934 | znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, NULL); |
| 935 | level = znode->level; | 935 | level = znode->level; |
| 936 | pr_err("== Level %d ==\n", level); | 936 | pr_err("== Level %d ==\n", level); |
| 937 | while (znode) { | 937 | while (znode) { |
| @@ -940,7 +940,7 @@ void ubifs_dump_tnc(struct ubifs_info *c) | |||
| 940 | pr_err("== Level %d ==\n", level); | 940 | pr_err("== Level %d ==\n", level); |
| 941 | } | 941 | } |
| 942 | ubifs_dump_znode(c, znode); | 942 | ubifs_dump_znode(c, znode); |
| 943 | znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode); | 943 | znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, znode); |
| 944 | } | 944 | } |
| 945 | pr_err("(pid %d) finish dumping TNC tree\n", current->pid); | 945 | pr_err("(pid %d) finish dumping TNC tree\n", current->pid); |
| 946 | } | 946 | } |
| @@ -1183,7 +1183,7 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1, | |||
| 1183 | union ubifs_key key; | 1183 | union ubifs_key key; |
| 1184 | char key_buf[DBG_KEY_BUF_LEN]; | 1184 | char key_buf[DBG_KEY_BUF_LEN]; |
| 1185 | 1185 | ||
| 1186 | ubifs_assert(!keys_cmp(c, &zbr1->key, &zbr2->key)); | 1186 | ubifs_assert(c, !keys_cmp(c, &zbr1->key, &zbr2->key)); |
| 1187 | dent1 = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS); | 1187 | dent1 = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS); |
| 1188 | if (!dent1) | 1188 | if (!dent1) |
| 1189 | return -ENOMEM; | 1189 | return -ENOMEM; |
| @@ -1479,7 +1479,7 @@ int dbg_check_tnc(struct ubifs_info *c, int extra) | |||
| 1479 | if (!dbg_is_chk_index(c)) | 1479 | if (!dbg_is_chk_index(c)) |
| 1480 | return 0; | 1480 | return 0; |
| 1481 | 1481 | ||
| 1482 | ubifs_assert(mutex_is_locked(&c->tnc_mutex)); | 1482 | ubifs_assert(c, mutex_is_locked(&c->tnc_mutex)); |
| 1483 | if (!c->zroot.znode) | 1483 | if (!c->zroot.znode) |
| 1484 | return 0; | 1484 | return 0; |
| 1485 | 1485 | ||
| @@ -1505,7 +1505,7 @@ int dbg_check_tnc(struct ubifs_info *c, int extra) | |||
| 1505 | } | 1505 | } |
| 1506 | 1506 | ||
| 1507 | prev = znode; | 1507 | prev = znode; |
| 1508 | znode = ubifs_tnc_postorder_next(znode); | 1508 | znode = ubifs_tnc_postorder_next(c, znode); |
| 1509 | if (!znode) | 1509 | if (!znode) |
| 1510 | break; | 1510 | break; |
| 1511 | 1511 | ||
| @@ -2036,7 +2036,7 @@ static int check_leaf(struct ubifs_info *c, struct ubifs_zbranch *zbr, | |||
| 2036 | long long blk_offs; | 2036 | long long blk_offs; |
| 2037 | struct ubifs_data_node *dn = node; | 2037 | struct ubifs_data_node *dn = node; |
| 2038 | 2038 | ||
| 2039 | ubifs_assert(zbr->len >= UBIFS_DATA_NODE_SZ); | 2039 | ubifs_assert(c, zbr->len >= UBIFS_DATA_NODE_SZ); |
| 2040 | 2040 | ||
| 2041 | /* | 2041 | /* |
| 2042 | * Search the inode node this data node belongs to and insert | 2042 | * Search the inode node this data node belongs to and insert |
| @@ -2066,7 +2066,7 @@ static int check_leaf(struct ubifs_info *c, struct ubifs_zbranch *zbr, | |||
| 2066 | struct ubifs_dent_node *dent = node; | 2066 | struct ubifs_dent_node *dent = node; |
| 2067 | struct fsck_inode *fscki1; | 2067 | struct fsck_inode *fscki1; |
| 2068 | 2068 | ||
| 2069 | ubifs_assert(zbr->len >= UBIFS_DENT_NODE_SZ); | 2069 | ubifs_assert(c, zbr->len >= UBIFS_DENT_NODE_SZ); |
| 2070 | 2070 | ||
| 2071 | err = ubifs_validate_entry(c, dent); | 2071 | err = ubifs_validate_entry(c, dent); |
| 2072 | if (err) | 2072 | if (err) |
| @@ -2461,7 +2461,7 @@ static int power_cut_emulated(struct ubifs_info *c, int lnum, int write) | |||
| 2461 | { | 2461 | { |
| 2462 | struct ubifs_debug_info *d = c->dbg; | 2462 | struct ubifs_debug_info *d = c->dbg; |
| 2463 | 2463 | ||
| 2464 | ubifs_assert(dbg_is_tst_rcvry(c)); | 2464 | ubifs_assert(c, dbg_is_tst_rcvry(c)); |
| 2465 | 2465 | ||
| 2466 | if (!d->pc_cnt) { | 2466 | if (!d->pc_cnt) { |
| 2467 | /* First call - decide delay to the power cut */ | 2467 | /* First call - decide delay to the power cut */ |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index e03d5179769a..981a3fa081f3 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
| @@ -148,7 +148,7 @@ struct ubifs_global_debug_info { | |||
| 148 | unsigned int tst_rcvry:1; | 148 | unsigned int tst_rcvry:1; |
| 149 | }; | 149 | }; |
| 150 | 150 | ||
| 151 | #define ubifs_assert(expr) do { \ | 151 | #define ubifs_assert(c, expr) do { \ |
| 152 | if (unlikely(!(expr))) { \ | 152 | if (unlikely(!(expr))) { \ |
| 153 | pr_crit("UBIFS assert failed in %s at %u (pid %d)\n", \ | 153 | pr_crit("UBIFS assert failed in %s at %u (pid %d)\n", \ |
| 154 | __func__, __LINE__, current->pid); \ | 154 | __func__, __LINE__, current->pid); \ |
| @@ -160,7 +160,7 @@ struct ubifs_global_debug_info { | |||
| 160 | if (unlikely(down_write_trylock(&(c)->commit_sem))) { \ | 160 | if (unlikely(down_write_trylock(&(c)->commit_sem))) { \ |
| 161 | up_write(&(c)->commit_sem); \ | 161 | up_write(&(c)->commit_sem); \ |
| 162 | pr_crit("commit lock is not locked!\n"); \ | 162 | pr_crit("commit lock is not locked!\n"); \ |
| 163 | ubifs_assert(0); \ | 163 | ubifs_assert(c, 0); \ |
| 164 | } \ | 164 | } \ |
| 165 | } while (0) | 165 | } while (0) |
| 166 | 166 | ||
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 85aea556b709..5767b373a8ff 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c | |||
| @@ -240,8 +240,8 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry, | |||
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | if (nm.hash) { | 242 | if (nm.hash) { |
| 243 | ubifs_assert(fname_len(&nm) == 0); | 243 | ubifs_assert(c, fname_len(&nm) == 0); |
| 244 | ubifs_assert(fname_name(&nm) == NULL); | 244 | ubifs_assert(c, fname_name(&nm) == NULL); |
| 245 | dent_key_init_hash(c, &key, dir->i_ino, nm.hash); | 245 | dent_key_init_hash(c, &key, dir->i_ino, nm.hash); |
| 246 | err = ubifs_tnc_lookup_dh(c, &key, dent, nm.minor_hash); | 246 | err = ubifs_tnc_lookup_dh(c, &key, dent, nm.minor_hash); |
| 247 | } else { | 247 | } else { |
| @@ -404,7 +404,7 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry, | |||
| 404 | 404 | ||
| 405 | if (whiteout) { | 405 | if (whiteout) { |
| 406 | init_special_inode(inode, inode->i_mode, WHITEOUT_DEV); | 406 | init_special_inode(inode, inode->i_mode, WHITEOUT_DEV); |
| 407 | ubifs_assert(inode->i_op == &ubifs_file_inode_operations); | 407 | ubifs_assert(c, inode->i_op == &ubifs_file_inode_operations); |
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | err = ubifs_init_security(dir, inode, &dentry->d_name); | 410 | err = ubifs_init_security(dir, inode, &dentry->d_name); |
| @@ -421,7 +421,7 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry, | |||
| 421 | } else { | 421 | } else { |
| 422 | d_tmpfile(dentry, inode); | 422 | d_tmpfile(dentry, inode); |
| 423 | } | 423 | } |
| 424 | ubifs_assert(ui->dirty); | 424 | ubifs_assert(c, ui->dirty); |
| 425 | 425 | ||
| 426 | instantiated = 1; | 426 | instantiated = 1; |
| 427 | mutex_unlock(&ui->ui_mutex); | 427 | mutex_unlock(&ui->ui_mutex); |
| @@ -556,7 +556,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) | |||
| 556 | 556 | ||
| 557 | /* File positions 0 and 1 correspond to "." and ".." */ | 557 | /* File positions 0 and 1 correspond to "." and ".." */ |
| 558 | if (ctx->pos < 2) { | 558 | if (ctx->pos < 2) { |
| 559 | ubifs_assert(!file->private_data); | 559 | ubifs_assert(c, !file->private_data); |
| 560 | if (!dir_emit_dots(file, ctx)) { | 560 | if (!dir_emit_dots(file, ctx)) { |
| 561 | if (encrypted) | 561 | if (encrypted) |
| 562 | fscrypt_fname_free_buffer(&fstr); | 562 | fscrypt_fname_free_buffer(&fstr); |
| @@ -597,7 +597,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) | |||
| 597 | dbg_gen("ino %llu, new f_pos %#x", | 597 | dbg_gen("ino %llu, new f_pos %#x", |
| 598 | (unsigned long long)le64_to_cpu(dent->inum), | 598 | (unsigned long long)le64_to_cpu(dent->inum), |
| 599 | key_hash_flash(c, &dent->key)); | 599 | key_hash_flash(c, &dent->key)); |
| 600 | ubifs_assert(le64_to_cpu(dent->ch.sqnum) > | 600 | ubifs_assert(c, le64_to_cpu(dent->ch.sqnum) > |
| 601 | ubifs_inode(dir)->creat_sqnum); | 601 | ubifs_inode(dir)->creat_sqnum); |
| 602 | 602 | ||
| 603 | fname_len(&nm) = le16_to_cpu(dent->nlen); | 603 | fname_len(&nm) = le16_to_cpu(dent->nlen); |
| @@ -716,8 +716,8 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir, | |||
| 716 | dbg_gen("dent '%pd' to ino %lu (nlink %d) in dir ino %lu", | 716 | dbg_gen("dent '%pd' to ino %lu (nlink %d) in dir ino %lu", |
| 717 | dentry, inode->i_ino, | 717 | dentry, inode->i_ino, |
| 718 | inode->i_nlink, dir->i_ino); | 718 | inode->i_nlink, dir->i_ino); |
| 719 | ubifs_assert(inode_is_locked(dir)); | 719 | ubifs_assert(c, inode_is_locked(dir)); |
| 720 | ubifs_assert(inode_is_locked(inode)); | 720 | ubifs_assert(c, inode_is_locked(inode)); |
| 721 | 721 | ||
| 722 | err = fscrypt_prepare_link(old_dentry, dir, dentry); | 722 | err = fscrypt_prepare_link(old_dentry, dir, dentry); |
| 723 | if (err) | 723 | if (err) |
| @@ -804,8 +804,8 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry) | |||
| 804 | 804 | ||
| 805 | sz_change = CALC_DENT_SIZE(fname_len(&nm)); | 805 | sz_change = CALC_DENT_SIZE(fname_len(&nm)); |
| 806 | 806 | ||
| 807 | ubifs_assert(inode_is_locked(dir)); | 807 | ubifs_assert(c, inode_is_locked(dir)); |
| 808 | ubifs_assert(inode_is_locked(inode)); | 808 | ubifs_assert(c, inode_is_locked(inode)); |
| 809 | err = dbg_check_synced_i_size(c, inode); | 809 | err = dbg_check_synced_i_size(c, inode); |
| 810 | if (err) | 810 | if (err) |
| 811 | goto out_fname; | 811 | goto out_fname; |
| @@ -896,8 +896,8 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry) | |||
| 896 | 896 | ||
| 897 | dbg_gen("directory '%pd', ino %lu in dir ino %lu", dentry, | 897 | dbg_gen("directory '%pd', ino %lu in dir ino %lu", dentry, |
| 898 | inode->i_ino, dir->i_ino); | 898 | inode->i_ino, dir->i_ino); |
| 899 | ubifs_assert(inode_is_locked(dir)); | 899 | ubifs_assert(c, inode_is_locked(dir)); |
| 900 | ubifs_assert(inode_is_locked(inode)); | 900 | ubifs_assert(c, inode_is_locked(inode)); |
| 901 | err = ubifs_check_dir_empty(d_inode(dentry)); | 901 | err = ubifs_check_dir_empty(d_inode(dentry)); |
| 902 | if (err) | 902 | if (err) |
| 903 | return err; | 903 | return err; |
| @@ -1295,7 +1295,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 1295 | new_dentry, new_dir->i_ino, flags); | 1295 | new_dentry, new_dir->i_ino, flags); |
| 1296 | 1296 | ||
| 1297 | if (unlink) | 1297 | if (unlink) |
| 1298 | ubifs_assert(inode_is_locked(new_inode)); | 1298 | ubifs_assert(c, inode_is_locked(new_inode)); |
| 1299 | 1299 | ||
| 1300 | if (unlink && is_dir) { | 1300 | if (unlink && is_dir) { |
| 1301 | err = ubifs_check_dir_empty(new_inode); | 1301 | err = ubifs_check_dir_empty(new_inode); |
| @@ -1349,7 +1349,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 1349 | whiteout_ui = ubifs_inode(whiteout); | 1349 | whiteout_ui = ubifs_inode(whiteout); |
| 1350 | whiteout_ui->data = dev; | 1350 | whiteout_ui->data = dev; |
| 1351 | whiteout_ui->data_len = ubifs_encode_dev(dev, MKDEV(0, 0)); | 1351 | whiteout_ui->data_len = ubifs_encode_dev(dev, MKDEV(0, 0)); |
| 1352 | ubifs_assert(!whiteout_ui->dirty); | 1352 | ubifs_assert(c, !whiteout_ui->dirty); |
| 1353 | } | 1353 | } |
| 1354 | 1354 | ||
| 1355 | lock_4_inodes(old_dir, new_dir, new_inode, whiteout); | 1355 | lock_4_inodes(old_dir, new_dir, new_inode, whiteout); |
| @@ -1509,7 +1509,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 1509 | int err; | 1509 | int err; |
| 1510 | struct fscrypt_name fst_nm, snd_nm; | 1510 | struct fscrypt_name fst_nm, snd_nm; |
| 1511 | 1511 | ||
| 1512 | ubifs_assert(fst_inode && snd_inode); | 1512 | ubifs_assert(c, fst_inode && snd_inode); |
| 1513 | 1513 | ||
| 1514 | err = fscrypt_setup_filename(old_dir, &old_dentry->d_name, 0, &fst_nm); | 1514 | err = fscrypt_setup_filename(old_dir, &old_dentry->d_name, 0, &fst_nm); |
| 1515 | if (err) | 1515 | if (err) |
| @@ -1556,12 +1556,13 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 1556 | unsigned int flags) | 1556 | unsigned int flags) |
| 1557 | { | 1557 | { |
| 1558 | int err; | 1558 | int err; |
| 1559 | struct ubifs_info *c = old_dir->i_sb->s_fs_info; | ||
| 1559 | 1560 | ||
| 1560 | if (flags & ~(RENAME_NOREPLACE | RENAME_WHITEOUT | RENAME_EXCHANGE)) | 1561 | if (flags & ~(RENAME_NOREPLACE | RENAME_WHITEOUT | RENAME_EXCHANGE)) |
| 1561 | return -EINVAL; | 1562 | return -EINVAL; |
| 1562 | 1563 | ||
| 1563 | ubifs_assert(inode_is_locked(old_dir)); | 1564 | ubifs_assert(c, inode_is_locked(old_dir)); |
| 1564 | ubifs_assert(inode_is_locked(new_dir)); | 1565 | ubifs_assert(c, inode_is_locked(new_dir)); |
| 1565 | 1566 | ||
| 1566 | err = fscrypt_prepare_rename(old_dir, old_dentry, new_dir, new_dentry, | 1567 | err = fscrypt_prepare_rename(old_dir, old_dentry, new_dir, new_dentry, |
| 1567 | flags); | 1568 | flags); |
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 745b3f810fb9..1b78f2e09218 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c | |||
| @@ -71,7 +71,7 @@ static int read_block(struct inode *inode, void *addr, unsigned int block, | |||
| 71 | return err; | 71 | return err; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | ubifs_assert(le64_to_cpu(dn->ch.sqnum) > | 74 | ubifs_assert(c, le64_to_cpu(dn->ch.sqnum) > |
| 75 | ubifs_inode(inode)->creat_sqnum); | 75 | ubifs_inode(inode)->creat_sqnum); |
| 76 | len = le32_to_cpu(dn->size); | 76 | len = le32_to_cpu(dn->size); |
| 77 | if (len <= 0 || len > UBIFS_BLOCK_SIZE) | 77 | if (len <= 0 || len > UBIFS_BLOCK_SIZE) |
| @@ -115,12 +115,13 @@ static int do_readpage(struct page *page) | |||
| 115 | unsigned int block, beyond; | 115 | unsigned int block, beyond; |
| 116 | struct ubifs_data_node *dn; | 116 | struct ubifs_data_node *dn; |
| 117 | struct inode *inode = page->mapping->host; | 117 | struct inode *inode = page->mapping->host; |
| 118 | struct ubifs_info *c = inode->i_sb->s_fs_info; | ||
| 118 | loff_t i_size = i_size_read(inode); | 119 | loff_t i_size = i_size_read(inode); |
| 119 | 120 | ||
| 120 | dbg_gen("ino %lu, pg %lu, i_size %lld, flags %#lx", | 121 | dbg_gen("ino %lu, pg %lu, i_size %lld, flags %#lx", |
| 121 | inode->i_ino, page->index, i_size, page->flags); | 122 | inode->i_ino, page->index, i_size, page->flags); |
| 122 | ubifs_assert(!PageChecked(page)); | 123 | ubifs_assert(c, !PageChecked(page)); |
| 123 | ubifs_assert(!PagePrivate(page)); | 124 | ubifs_assert(c, !PagePrivate(page)); |
| 124 | 125 | ||
| 125 | addr = kmap(page); | 126 | addr = kmap(page); |
| 126 | 127 | ||
| @@ -441,8 +442,8 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, | |||
| 441 | int skipped_read = 0; | 442 | int skipped_read = 0; |
| 442 | struct page *page; | 443 | struct page *page; |
| 443 | 444 | ||
| 444 | ubifs_assert(ubifs_inode(inode)->ui_size == inode->i_size); | 445 | ubifs_assert(c, ubifs_inode(inode)->ui_size == inode->i_size); |
| 445 | ubifs_assert(!c->ro_media && !c->ro_mount); | 446 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 446 | 447 | ||
| 447 | if (unlikely(c->ro_error)) | 448 | if (unlikely(c->ro_error)) |
| 448 | return -EROFS; | 449 | return -EROFS; |
| @@ -481,7 +482,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, | |||
| 481 | 482 | ||
| 482 | err = allocate_budget(c, page, ui, appending); | 483 | err = allocate_budget(c, page, ui, appending); |
| 483 | if (unlikely(err)) { | 484 | if (unlikely(err)) { |
| 484 | ubifs_assert(err == -ENOSPC); | 485 | ubifs_assert(c, err == -ENOSPC); |
| 485 | /* | 486 | /* |
| 486 | * If we skipped reading the page because we were going to | 487 | * If we skipped reading the page because we were going to |
| 487 | * write all of it, then it is not up to date. | 488 | * write all of it, then it is not up to date. |
| @@ -498,7 +499,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, | |||
| 498 | * everything and fall-back to slow-path. | 499 | * everything and fall-back to slow-path. |
| 499 | */ | 500 | */ |
| 500 | if (appending) { | 501 | if (appending) { |
| 501 | ubifs_assert(mutex_is_locked(&ui->ui_mutex)); | 502 | ubifs_assert(c, mutex_is_locked(&ui->ui_mutex)); |
| 502 | mutex_unlock(&ui->ui_mutex); | 503 | mutex_unlock(&ui->ui_mutex); |
| 503 | } | 504 | } |
| 504 | unlock_page(page); | 505 | unlock_page(page); |
| @@ -595,7 +596,7 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping, | |||
| 595 | * '__set_page_dirty_nobuffers()'. | 596 | * '__set_page_dirty_nobuffers()'. |
| 596 | */ | 597 | */ |
| 597 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); | 598 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); |
| 598 | ubifs_assert(mutex_is_locked(&ui->ui_mutex)); | 599 | ubifs_assert(c, mutex_is_locked(&ui->ui_mutex)); |
| 599 | mutex_unlock(&ui->ui_mutex); | 600 | mutex_unlock(&ui->ui_mutex); |
| 600 | } | 601 | } |
| 601 | 602 | ||
| @@ -648,7 +649,7 @@ static int populate_page(struct ubifs_info *c, struct page *page, | |||
| 648 | 649 | ||
| 649 | dn = bu->buf + (bu->zbranch[nn].offs - offs); | 650 | dn = bu->buf + (bu->zbranch[nn].offs - offs); |
| 650 | 651 | ||
| 651 | ubifs_assert(le64_to_cpu(dn->ch.sqnum) > | 652 | ubifs_assert(c, le64_to_cpu(dn->ch.sqnum) > |
| 652 | ubifs_inode(inode)->creat_sqnum); | 653 | ubifs_inode(inode)->creat_sqnum); |
| 653 | 654 | ||
| 654 | len = le32_to_cpu(dn->size); | 655 | len = le32_to_cpu(dn->size); |
| @@ -767,8 +768,8 @@ static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu, | |||
| 767 | bu->buf_len = bu->zbranch[bu->cnt - 1].offs + | 768 | bu->buf_len = bu->zbranch[bu->cnt - 1].offs + |
| 768 | bu->zbranch[bu->cnt - 1].len - | 769 | bu->zbranch[bu->cnt - 1].len - |
| 769 | bu->zbranch[0].offs; | 770 | bu->zbranch[0].offs; |
| 770 | ubifs_assert(bu->buf_len > 0); | 771 | ubifs_assert(c, bu->buf_len > 0); |
| 771 | ubifs_assert(bu->buf_len <= c->leb_size); | 772 | ubifs_assert(c, bu->buf_len <= c->leb_size); |
| 772 | bu->buf = kmalloc(bu->buf_len, GFP_NOFS | __GFP_NOWARN); | 773 | bu->buf = kmalloc(bu->buf_len, GFP_NOFS | __GFP_NOWARN); |
| 773 | if (!bu->buf) | 774 | if (!bu->buf) |
| 774 | goto out_bu_off; | 775 | goto out_bu_off; |
| @@ -920,7 +921,7 @@ static int do_writepage(struct page *page, int len) | |||
| 920 | #ifdef UBIFS_DEBUG | 921 | #ifdef UBIFS_DEBUG |
| 921 | struct ubifs_inode *ui = ubifs_inode(inode); | 922 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 922 | spin_lock(&ui->ui_lock); | 923 | spin_lock(&ui->ui_lock); |
| 923 | ubifs_assert(page->index <= ui->synced_i_size >> PAGE_SHIFT); | 924 | ubifs_assert(c, page->index <= ui->synced_i_size >> PAGE_SHIFT); |
| 924 | spin_unlock(&ui->ui_lock); | 925 | spin_unlock(&ui->ui_lock); |
| 925 | #endif | 926 | #endif |
| 926 | 927 | ||
| @@ -949,7 +950,7 @@ static int do_writepage(struct page *page, int len) | |||
| 949 | ubifs_ro_mode(c, err); | 950 | ubifs_ro_mode(c, err); |
| 950 | } | 951 | } |
| 951 | 952 | ||
| 952 | ubifs_assert(PagePrivate(page)); | 953 | ubifs_assert(c, PagePrivate(page)); |
| 953 | if (PageChecked(page)) | 954 | if (PageChecked(page)) |
| 954 | release_new_page_budget(c); | 955 | release_new_page_budget(c); |
| 955 | else | 956 | else |
| @@ -1014,6 +1015,7 @@ static int do_writepage(struct page *page, int len) | |||
| 1014 | static int ubifs_writepage(struct page *page, struct writeback_control *wbc) | 1015 | static int ubifs_writepage(struct page *page, struct writeback_control *wbc) |
| 1015 | { | 1016 | { |
| 1016 | struct inode *inode = page->mapping->host; | 1017 | struct inode *inode = page->mapping->host; |
| 1018 | struct ubifs_info *c = inode->i_sb->s_fs_info; | ||
| 1017 | struct ubifs_inode *ui = ubifs_inode(inode); | 1019 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 1018 | loff_t i_size = i_size_read(inode), synced_i_size; | 1020 | loff_t i_size = i_size_read(inode), synced_i_size; |
| 1019 | pgoff_t end_index = i_size >> PAGE_SHIFT; | 1021 | pgoff_t end_index = i_size >> PAGE_SHIFT; |
| @@ -1022,7 +1024,7 @@ static int ubifs_writepage(struct page *page, struct writeback_control *wbc) | |||
| 1022 | 1024 | ||
| 1023 | dbg_gen("ino %lu, pg %lu, pg flags %#lx", | 1025 | dbg_gen("ino %lu, pg %lu, pg flags %#lx", |
| 1024 | inode->i_ino, page->index, page->flags); | 1026 | inode->i_ino, page->index, page->flags); |
| 1025 | ubifs_assert(PagePrivate(page)); | 1027 | ubifs_assert(c, PagePrivate(page)); |
| 1026 | 1028 | ||
| 1027 | /* Is the page fully outside @i_size? (truncate in progress) */ | 1029 | /* Is the page fully outside @i_size? (truncate in progress) */ |
| 1028 | if (page->index > end_index || (page->index == end_index && !len)) { | 1030 | if (page->index > end_index || (page->index == end_index && !len)) { |
| @@ -1167,7 +1169,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode, | |||
| 1167 | * 'ubifs_jnl_truncate()' will see an already | 1169 | * 'ubifs_jnl_truncate()' will see an already |
| 1168 | * truncated (and up to date) data node. | 1170 | * truncated (and up to date) data node. |
| 1169 | */ | 1171 | */ |
| 1170 | ubifs_assert(PagePrivate(page)); | 1172 | ubifs_assert(c, PagePrivate(page)); |
| 1171 | 1173 | ||
| 1172 | clear_page_dirty_for_io(page); | 1174 | clear_page_dirty_for_io(page); |
| 1173 | if (UBIFS_BLOCKS_PER_PAGE_SHIFT) | 1175 | if (UBIFS_BLOCKS_PER_PAGE_SHIFT) |
| @@ -1303,7 +1305,7 @@ static void ubifs_invalidatepage(struct page *page, unsigned int offset, | |||
| 1303 | struct inode *inode = page->mapping->host; | 1305 | struct inode *inode = page->mapping->host; |
| 1304 | struct ubifs_info *c = inode->i_sb->s_fs_info; | 1306 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
| 1305 | 1307 | ||
| 1306 | ubifs_assert(PagePrivate(page)); | 1308 | ubifs_assert(c, PagePrivate(page)); |
| 1307 | if (offset || length < PAGE_SIZE) | 1309 | if (offset || length < PAGE_SIZE) |
| 1308 | /* Partial page remains dirty */ | 1310 | /* Partial page remains dirty */ |
| 1309 | return; | 1311 | return; |
| @@ -1461,13 +1463,15 @@ static ssize_t ubifs_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
| 1461 | static int ubifs_set_page_dirty(struct page *page) | 1463 | static int ubifs_set_page_dirty(struct page *page) |
| 1462 | { | 1464 | { |
| 1463 | int ret; | 1465 | int ret; |
| 1466 | struct inode *inode = page->mapping->host; | ||
| 1467 | struct ubifs_info *c = inode->i_sb->s_fs_info; | ||
| 1464 | 1468 | ||
| 1465 | ret = __set_page_dirty_nobuffers(page); | 1469 | ret = __set_page_dirty_nobuffers(page); |
| 1466 | /* | 1470 | /* |
| 1467 | * An attempt to dirty a page without budgeting for it - should not | 1471 | * An attempt to dirty a page without budgeting for it - should not |
| 1468 | * happen. | 1472 | * happen. |
| 1469 | */ | 1473 | */ |
| 1470 | ubifs_assert(ret == 0); | 1474 | ubifs_assert(c, ret == 0); |
| 1471 | return ret; | 1475 | return ret; |
| 1472 | } | 1476 | } |
| 1473 | 1477 | ||
| @@ -1496,14 +1500,17 @@ static int ubifs_migrate_page(struct address_space *mapping, | |||
| 1496 | 1500 | ||
| 1497 | static int ubifs_releasepage(struct page *page, gfp_t unused_gfp_flags) | 1501 | static int ubifs_releasepage(struct page *page, gfp_t unused_gfp_flags) |
| 1498 | { | 1502 | { |
| 1503 | struct inode *inode = page->mapping->host; | ||
| 1504 | struct ubifs_info *c = inode->i_sb->s_fs_info; | ||
| 1505 | |||
| 1499 | /* | 1506 | /* |
| 1500 | * An attempt to release a dirty page without budgeting for it - should | 1507 | * An attempt to release a dirty page without budgeting for it - should |
| 1501 | * not happen. | 1508 | * not happen. |
| 1502 | */ | 1509 | */ |
| 1503 | if (PageWriteback(page)) | 1510 | if (PageWriteback(page)) |
| 1504 | return 0; | 1511 | return 0; |
| 1505 | ubifs_assert(PagePrivate(page)); | 1512 | ubifs_assert(c, PagePrivate(page)); |
| 1506 | ubifs_assert(0); | 1513 | ubifs_assert(c, 0); |
| 1507 | ClearPagePrivate(page); | 1514 | ClearPagePrivate(page); |
| 1508 | ClearPageChecked(page); | 1515 | ClearPageChecked(page); |
| 1509 | return 1; | 1516 | return 1; |
| @@ -1524,7 +1531,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf) | |||
| 1524 | 1531 | ||
| 1525 | dbg_gen("ino %lu, pg %lu, i_size %lld", inode->i_ino, page->index, | 1532 | dbg_gen("ino %lu, pg %lu, i_size %lld", inode->i_ino, page->index, |
| 1526 | i_size_read(inode)); | 1533 | i_size_read(inode)); |
| 1527 | ubifs_assert(!c->ro_media && !c->ro_mount); | 1534 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 1528 | 1535 | ||
| 1529 | if (unlikely(c->ro_error)) | 1536 | if (unlikely(c->ro_error)) |
| 1530 | return VM_FAULT_SIGBUS; /* -EROFS */ | 1537 | return VM_FAULT_SIGBUS; /* -EROFS */ |
diff --git a/fs/ubifs/file.h b/fs/ubifs/file.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/fs/ubifs/file.h | |||
diff --git a/fs/ubifs/find.c b/fs/ubifs/find.c index 36198f86e260..f9646835b026 100644 --- a/fs/ubifs/find.c +++ b/fs/ubifs/find.c | |||
| @@ -183,18 +183,18 @@ static const struct ubifs_lprops *scan_for_dirty(struct ubifs_info *c, | |||
| 183 | &data); | 183 | &data); |
| 184 | if (err) | 184 | if (err) |
| 185 | return ERR_PTR(err); | 185 | return ERR_PTR(err); |
| 186 | ubifs_assert(data.lnum >= c->main_first && data.lnum < c->leb_cnt); | 186 | ubifs_assert(c, data.lnum >= c->main_first && data.lnum < c->leb_cnt); |
| 187 | c->lscan_lnum = data.lnum; | 187 | c->lscan_lnum = data.lnum; |
| 188 | lprops = ubifs_lpt_lookup_dirty(c, data.lnum); | 188 | lprops = ubifs_lpt_lookup_dirty(c, data.lnum); |
| 189 | if (IS_ERR(lprops)) | 189 | if (IS_ERR(lprops)) |
| 190 | return lprops; | 190 | return lprops; |
| 191 | ubifs_assert(lprops->lnum == data.lnum); | 191 | ubifs_assert(c, lprops->lnum == data.lnum); |
| 192 | ubifs_assert(lprops->free + lprops->dirty >= min_space); | 192 | ubifs_assert(c, lprops->free + lprops->dirty >= min_space); |
| 193 | ubifs_assert(lprops->dirty >= c->dead_wm || | 193 | ubifs_assert(c, lprops->dirty >= c->dead_wm || |
| 194 | (pick_free && | 194 | (pick_free && |
| 195 | lprops->free + lprops->dirty == c->leb_size)); | 195 | lprops->free + lprops->dirty == c->leb_size)); |
| 196 | ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); | 196 | ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); |
| 197 | ubifs_assert(!exclude_index || !(lprops->flags & LPROPS_INDEX)); | 197 | ubifs_assert(c, !exclude_index || !(lprops->flags & LPROPS_INDEX)); |
| 198 | return lprops; | 198 | return lprops; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| @@ -315,7 +315,7 @@ int ubifs_find_dirty_leb(struct ubifs_info *c, struct ubifs_lprops *ret_lp, | |||
| 315 | lp = idx_lp; | 315 | lp = idx_lp; |
| 316 | 316 | ||
| 317 | if (lp) { | 317 | if (lp) { |
| 318 | ubifs_assert(lp->free + lp->dirty >= c->dead_wm); | 318 | ubifs_assert(c, lp->free + lp->dirty >= c->dead_wm); |
| 319 | goto found; | 319 | goto found; |
| 320 | } | 320 | } |
| 321 | 321 | ||
| @@ -326,7 +326,7 @@ int ubifs_find_dirty_leb(struct ubifs_info *c, struct ubifs_lprops *ret_lp, | |||
| 326 | err = PTR_ERR(lp); | 326 | err = PTR_ERR(lp); |
| 327 | goto out; | 327 | goto out; |
| 328 | } | 328 | } |
| 329 | ubifs_assert(lp->dirty >= c->dead_wm || | 329 | ubifs_assert(c, lp->dirty >= c->dead_wm || |
| 330 | (pick_free && lp->free + lp->dirty == c->leb_size)); | 330 | (pick_free && lp->free + lp->dirty == c->leb_size)); |
| 331 | 331 | ||
| 332 | found: | 332 | found: |
| @@ -462,15 +462,15 @@ const struct ubifs_lprops *do_find_free_space(struct ubifs_info *c, | |||
| 462 | &data); | 462 | &data); |
| 463 | if (err) | 463 | if (err) |
| 464 | return ERR_PTR(err); | 464 | return ERR_PTR(err); |
| 465 | ubifs_assert(data.lnum >= c->main_first && data.lnum < c->leb_cnt); | 465 | ubifs_assert(c, data.lnum >= c->main_first && data.lnum < c->leb_cnt); |
| 466 | c->lscan_lnum = data.lnum; | 466 | c->lscan_lnum = data.lnum; |
| 467 | lprops = ubifs_lpt_lookup_dirty(c, data.lnum); | 467 | lprops = ubifs_lpt_lookup_dirty(c, data.lnum); |
| 468 | if (IS_ERR(lprops)) | 468 | if (IS_ERR(lprops)) |
| 469 | return lprops; | 469 | return lprops; |
| 470 | ubifs_assert(lprops->lnum == data.lnum); | 470 | ubifs_assert(c, lprops->lnum == data.lnum); |
| 471 | ubifs_assert(lprops->free >= min_space); | 471 | ubifs_assert(c, lprops->free >= min_space); |
| 472 | ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); | 472 | ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); |
| 473 | ubifs_assert(!(lprops->flags & LPROPS_INDEX)); | 473 | ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); |
| 474 | return lprops; | 474 | return lprops; |
| 475 | } | 475 | } |
| 476 | 476 | ||
| @@ -574,7 +574,7 @@ int ubifs_find_free_space(struct ubifs_info *c, int min_space, int *offs, | |||
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | dbg_find("found LEB %d, free %d", lnum, c->leb_size - *offs); | 576 | dbg_find("found LEB %d, free %d", lnum, c->leb_size - *offs); |
| 577 | ubifs_assert(*offs <= c->leb_size - min_space); | 577 | ubifs_assert(c, *offs <= c->leb_size - min_space); |
| 578 | return lnum; | 578 | return lnum; |
| 579 | 579 | ||
| 580 | out: | 580 | out: |
| @@ -642,15 +642,15 @@ static const struct ubifs_lprops *scan_for_leb_for_idx(struct ubifs_info *c) | |||
| 642 | &data); | 642 | &data); |
| 643 | if (err) | 643 | if (err) |
| 644 | return ERR_PTR(err); | 644 | return ERR_PTR(err); |
| 645 | ubifs_assert(data.lnum >= c->main_first && data.lnum < c->leb_cnt); | 645 | ubifs_assert(c, data.lnum >= c->main_first && data.lnum < c->leb_cnt); |
| 646 | c->lscan_lnum = data.lnum; | 646 | c->lscan_lnum = data.lnum; |
| 647 | lprops = ubifs_lpt_lookup_dirty(c, data.lnum); | 647 | lprops = ubifs_lpt_lookup_dirty(c, data.lnum); |
| 648 | if (IS_ERR(lprops)) | 648 | if (IS_ERR(lprops)) |
| 649 | return lprops; | 649 | return lprops; |
| 650 | ubifs_assert(lprops->lnum == data.lnum); | 650 | ubifs_assert(c, lprops->lnum == data.lnum); |
| 651 | ubifs_assert(lprops->free + lprops->dirty == c->leb_size); | 651 | ubifs_assert(c, lprops->free + lprops->dirty == c->leb_size); |
| 652 | ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); | 652 | ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); |
| 653 | ubifs_assert(!(lprops->flags & LPROPS_INDEX)); | 653 | ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); |
| 654 | return lprops; | 654 | return lprops; |
| 655 | } | 655 | } |
| 656 | 656 | ||
| @@ -690,7 +690,7 @@ int ubifs_find_free_leb_for_idx(struct ubifs_info *c) | |||
| 690 | */ | 690 | */ |
| 691 | if (c->in_a_category_cnt != c->main_lebs || | 691 | if (c->in_a_category_cnt != c->main_lebs || |
| 692 | c->lst.empty_lebs - c->lst.taken_empty_lebs > 0) { | 692 | c->lst.empty_lebs - c->lst.taken_empty_lebs > 0) { |
| 693 | ubifs_assert(c->freeable_cnt == 0); | 693 | ubifs_assert(c, c->freeable_cnt == 0); |
| 694 | lprops = scan_for_leb_for_idx(c); | 694 | lprops = scan_for_leb_for_idx(c); |
| 695 | if (IS_ERR(lprops)) { | 695 | if (IS_ERR(lprops)) { |
| 696 | err = PTR_ERR(lprops); | 696 | err = PTR_ERR(lprops); |
| @@ -867,15 +867,15 @@ static int find_dirty_idx_leb(struct ubifs_info *c) | |||
| 867 | if (err) | 867 | if (err) |
| 868 | return err; | 868 | return err; |
| 869 | found: | 869 | found: |
| 870 | ubifs_assert(data.lnum >= c->main_first && data.lnum < c->leb_cnt); | 870 | ubifs_assert(c, data.lnum >= c->main_first && data.lnum < c->leb_cnt); |
| 871 | c->lscan_lnum = data.lnum; | 871 | c->lscan_lnum = data.lnum; |
| 872 | lprops = ubifs_lpt_lookup_dirty(c, data.lnum); | 872 | lprops = ubifs_lpt_lookup_dirty(c, data.lnum); |
| 873 | if (IS_ERR(lprops)) | 873 | if (IS_ERR(lprops)) |
| 874 | return PTR_ERR(lprops); | 874 | return PTR_ERR(lprops); |
| 875 | ubifs_assert(lprops->lnum == data.lnum); | 875 | ubifs_assert(c, lprops->lnum == data.lnum); |
| 876 | ubifs_assert(lprops->free + lprops->dirty >= c->min_idx_node_sz); | 876 | ubifs_assert(c, lprops->free + lprops->dirty >= c->min_idx_node_sz); |
| 877 | ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); | 877 | ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); |
| 878 | ubifs_assert((lprops->flags & LPROPS_INDEX)); | 878 | ubifs_assert(c, (lprops->flags & LPROPS_INDEX)); |
| 879 | 879 | ||
| 880 | dbg_find("found dirty LEB %d, free %d, dirty %d, flags %#x", | 880 | dbg_find("found dirty LEB %d, free %d, dirty %d, flags %#x", |
| 881 | lprops->lnum, lprops->free, lprops->dirty, lprops->flags); | 881 | lprops->lnum, lprops->free, lprops->dirty, lprops->flags); |
| @@ -944,8 +944,8 @@ static int find_dirtiest_idx_leb(struct ubifs_info *c) | |||
| 944 | } | 944 | } |
| 945 | dbg_find("LEB %d, dirty %d and free %d flags %#x", lp->lnum, lp->dirty, | 945 | dbg_find("LEB %d, dirty %d and free %d flags %#x", lp->lnum, lp->dirty, |
| 946 | lp->free, lp->flags); | 946 | lp->free, lp->flags); |
| 947 | ubifs_assert(lp->flags & LPROPS_TAKEN); | 947 | ubifs_assert(c, lp->flags & LPROPS_TAKEN); |
| 948 | ubifs_assert(lp->flags & LPROPS_INDEX); | 948 | ubifs_assert(c, lp->flags & LPROPS_INDEX); |
| 949 | return lnum; | 949 | return lnum; |
| 950 | } | 950 | } |
| 951 | 951 | ||
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c index 2adc994ffd9f..d2680e0b4a36 100644 --- a/fs/ubifs/gc.c +++ b/fs/ubifs/gc.c | |||
| @@ -83,7 +83,7 @@ static int switch_gc_head(struct ubifs_info *c) | |||
| 83 | int err, gc_lnum = c->gc_lnum; | 83 | int err, gc_lnum = c->gc_lnum; |
| 84 | struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf; | 84 | struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf; |
| 85 | 85 | ||
| 86 | ubifs_assert(gc_lnum != -1); | 86 | ubifs_assert(c, gc_lnum != -1); |
| 87 | dbg_gc("switch GC head from LEB %d:%d to LEB %d (waste %d bytes)", | 87 | dbg_gc("switch GC head from LEB %d:%d to LEB %d (waste %d bytes)", |
| 88 | wbuf->lnum, wbuf->offs + wbuf->used, gc_lnum, | 88 | wbuf->lnum, wbuf->offs + wbuf->used, gc_lnum, |
| 89 | c->leb_size - wbuf->offs - wbuf->used); | 89 | c->leb_size - wbuf->offs - wbuf->used); |
| @@ -131,10 +131,10 @@ static int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b) | |||
| 131 | sa = list_entry(a, struct ubifs_scan_node, list); | 131 | sa = list_entry(a, struct ubifs_scan_node, list); |
| 132 | sb = list_entry(b, struct ubifs_scan_node, list); | 132 | sb = list_entry(b, struct ubifs_scan_node, list); |
| 133 | 133 | ||
| 134 | ubifs_assert(key_type(c, &sa->key) == UBIFS_DATA_KEY); | 134 | ubifs_assert(c, key_type(c, &sa->key) == UBIFS_DATA_KEY); |
| 135 | ubifs_assert(key_type(c, &sb->key) == UBIFS_DATA_KEY); | 135 | ubifs_assert(c, key_type(c, &sb->key) == UBIFS_DATA_KEY); |
| 136 | ubifs_assert(sa->type == UBIFS_DATA_NODE); | 136 | ubifs_assert(c, sa->type == UBIFS_DATA_NODE); |
| 137 | ubifs_assert(sb->type == UBIFS_DATA_NODE); | 137 | ubifs_assert(c, sb->type == UBIFS_DATA_NODE); |
| 138 | 138 | ||
| 139 | inuma = key_inum(c, &sa->key); | 139 | inuma = key_inum(c, &sa->key); |
| 140 | inumb = key_inum(c, &sb->key); | 140 | inumb = key_inum(c, &sb->key); |
| @@ -175,9 +175,9 @@ static int nondata_nodes_cmp(void *priv, struct list_head *a, | |||
| 175 | sa = list_entry(a, struct ubifs_scan_node, list); | 175 | sa = list_entry(a, struct ubifs_scan_node, list); |
| 176 | sb = list_entry(b, struct ubifs_scan_node, list); | 176 | sb = list_entry(b, struct ubifs_scan_node, list); |
| 177 | 177 | ||
| 178 | ubifs_assert(key_type(c, &sa->key) != UBIFS_DATA_KEY && | 178 | ubifs_assert(c, key_type(c, &sa->key) != UBIFS_DATA_KEY && |
| 179 | key_type(c, &sb->key) != UBIFS_DATA_KEY); | 179 | key_type(c, &sb->key) != UBIFS_DATA_KEY); |
| 180 | ubifs_assert(sa->type != UBIFS_DATA_NODE && | 180 | ubifs_assert(c, sa->type != UBIFS_DATA_NODE && |
| 181 | sb->type != UBIFS_DATA_NODE); | 181 | sb->type != UBIFS_DATA_NODE); |
| 182 | 182 | ||
| 183 | /* Inodes go before directory entries */ | 183 | /* Inodes go before directory entries */ |
| @@ -189,13 +189,13 @@ static int nondata_nodes_cmp(void *priv, struct list_head *a, | |||
| 189 | if (sb->type == UBIFS_INO_NODE) | 189 | if (sb->type == UBIFS_INO_NODE) |
| 190 | return 1; | 190 | return 1; |
| 191 | 191 | ||
| 192 | ubifs_assert(key_type(c, &sa->key) == UBIFS_DENT_KEY || | 192 | ubifs_assert(c, key_type(c, &sa->key) == UBIFS_DENT_KEY || |
| 193 | key_type(c, &sa->key) == UBIFS_XENT_KEY); | 193 | key_type(c, &sa->key) == UBIFS_XENT_KEY); |
| 194 | ubifs_assert(key_type(c, &sb->key) == UBIFS_DENT_KEY || | 194 | ubifs_assert(c, key_type(c, &sb->key) == UBIFS_DENT_KEY || |
| 195 | key_type(c, &sb->key) == UBIFS_XENT_KEY); | 195 | key_type(c, &sb->key) == UBIFS_XENT_KEY); |
| 196 | ubifs_assert(sa->type == UBIFS_DENT_NODE || | 196 | ubifs_assert(c, sa->type == UBIFS_DENT_NODE || |
| 197 | sa->type == UBIFS_XENT_NODE); | 197 | sa->type == UBIFS_XENT_NODE); |
| 198 | ubifs_assert(sb->type == UBIFS_DENT_NODE || | 198 | ubifs_assert(c, sb->type == UBIFS_DENT_NODE || |
| 199 | sb->type == UBIFS_XENT_NODE); | 199 | sb->type == UBIFS_XENT_NODE); |
| 200 | 200 | ||
| 201 | inuma = key_inum(c, &sa->key); | 201 | inuma = key_inum(c, &sa->key); |
| @@ -250,7 +250,7 @@ static int sort_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb, | |||
| 250 | 250 | ||
| 251 | /* Separate data nodes and non-data nodes */ | 251 | /* Separate data nodes and non-data nodes */ |
| 252 | list_for_each_entry_safe(snod, tmp, &sleb->nodes, list) { | 252 | list_for_each_entry_safe(snod, tmp, &sleb->nodes, list) { |
| 253 | ubifs_assert(snod->type == UBIFS_INO_NODE || | 253 | ubifs_assert(c, snod->type == UBIFS_INO_NODE || |
| 254 | snod->type == UBIFS_DATA_NODE || | 254 | snod->type == UBIFS_DATA_NODE || |
| 255 | snod->type == UBIFS_DENT_NODE || | 255 | snod->type == UBIFS_DENT_NODE || |
| 256 | snod->type == UBIFS_XENT_NODE || | 256 | snod->type == UBIFS_XENT_NODE || |
| @@ -266,7 +266,7 @@ static int sort_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb, | |||
| 266 | continue; | 266 | continue; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | ubifs_assert(key_type(c, &snod->key) == UBIFS_DATA_KEY || | 269 | ubifs_assert(c, key_type(c, &snod->key) == UBIFS_DATA_KEY || |
| 270 | key_type(c, &snod->key) == UBIFS_INO_KEY || | 270 | key_type(c, &snod->key) == UBIFS_INO_KEY || |
| 271 | key_type(c, &snod->key) == UBIFS_DENT_KEY || | 271 | key_type(c, &snod->key) == UBIFS_DENT_KEY || |
| 272 | key_type(c, &snod->key) == UBIFS_XENT_KEY); | 272 | key_type(c, &snod->key) == UBIFS_XENT_KEY); |
| @@ -469,15 +469,15 @@ int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp) | |||
| 469 | struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf; | 469 | struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf; |
| 470 | int err = 0, lnum = lp->lnum; | 470 | int err = 0, lnum = lp->lnum; |
| 471 | 471 | ||
| 472 | ubifs_assert(c->gc_lnum != -1 || wbuf->offs + wbuf->used == 0 || | 472 | ubifs_assert(c, c->gc_lnum != -1 || wbuf->offs + wbuf->used == 0 || |
| 473 | c->need_recovery); | 473 | c->need_recovery); |
| 474 | ubifs_assert(c->gc_lnum != lnum); | 474 | ubifs_assert(c, c->gc_lnum != lnum); |
| 475 | ubifs_assert(wbuf->lnum != lnum); | 475 | ubifs_assert(c, wbuf->lnum != lnum); |
| 476 | 476 | ||
| 477 | if (lp->free + lp->dirty == c->leb_size) { | 477 | if (lp->free + lp->dirty == c->leb_size) { |
| 478 | /* Special case - a free LEB */ | 478 | /* Special case - a free LEB */ |
| 479 | dbg_gc("LEB %d is free, return it", lp->lnum); | 479 | dbg_gc("LEB %d is free, return it", lp->lnum); |
| 480 | ubifs_assert(!(lp->flags & LPROPS_INDEX)); | 480 | ubifs_assert(c, !(lp->flags & LPROPS_INDEX)); |
| 481 | 481 | ||
| 482 | if (lp->free != c->leb_size) { | 482 | if (lp->free != c->leb_size) { |
| 483 | /* | 483 | /* |
| @@ -513,7 +513,7 @@ int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp) | |||
| 513 | if (IS_ERR(sleb)) | 513 | if (IS_ERR(sleb)) |
| 514 | return PTR_ERR(sleb); | 514 | return PTR_ERR(sleb); |
| 515 | 515 | ||
| 516 | ubifs_assert(!list_empty(&sleb->nodes)); | 516 | ubifs_assert(c, !list_empty(&sleb->nodes)); |
| 517 | snod = list_entry(sleb->nodes.next, struct ubifs_scan_node, list); | 517 | snod = list_entry(sleb->nodes.next, struct ubifs_scan_node, list); |
| 518 | 518 | ||
| 519 | if (snod->type == UBIFS_IDX_NODE) { | 519 | if (snod->type == UBIFS_IDX_NODE) { |
| @@ -525,7 +525,7 @@ int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp) | |||
| 525 | struct ubifs_idx_node *idx = snod->node; | 525 | struct ubifs_idx_node *idx = snod->node; |
| 526 | int level = le16_to_cpu(idx->level); | 526 | int level = le16_to_cpu(idx->level); |
| 527 | 527 | ||
| 528 | ubifs_assert(snod->type == UBIFS_IDX_NODE); | 528 | ubifs_assert(c, snod->type == UBIFS_IDX_NODE); |
| 529 | key_read(c, ubifs_idx_key(c, idx), &snod->key); | 529 | key_read(c, ubifs_idx_key(c, idx), &snod->key); |
| 530 | err = ubifs_dirty_idx_node(c, &snod->key, level, lnum, | 530 | err = ubifs_dirty_idx_node(c, &snod->key, level, lnum, |
| 531 | snod->offs); | 531 | snod->offs); |
| @@ -648,7 +648,7 @@ int ubifs_garbage_collect(struct ubifs_info *c, int anyway) | |||
| 648 | struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf; | 648 | struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf; |
| 649 | 649 | ||
| 650 | ubifs_assert_cmt_locked(c); | 650 | ubifs_assert_cmt_locked(c); |
| 651 | ubifs_assert(!c->ro_media && !c->ro_mount); | 651 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 652 | 652 | ||
| 653 | if (ubifs_gc_should_commit(c)) | 653 | if (ubifs_gc_should_commit(c)) |
| 654 | return -EAGAIN; | 654 | return -EAGAIN; |
| @@ -661,7 +661,7 @@ int ubifs_garbage_collect(struct ubifs_info *c, int anyway) | |||
| 661 | } | 661 | } |
| 662 | 662 | ||
| 663 | /* We expect the write-buffer to be empty on entry */ | 663 | /* We expect the write-buffer to be empty on entry */ |
| 664 | ubifs_assert(!wbuf->used); | 664 | ubifs_assert(c, !wbuf->used); |
| 665 | 665 | ||
| 666 | for (i = 0; ; i++) { | 666 | for (i = 0; ; i++) { |
| 667 | int space_before, space_after; | 667 | int space_before, space_after; |
| @@ -752,7 +752,7 @@ int ubifs_garbage_collect(struct ubifs_info *c, int anyway) | |||
| 752 | continue; | 752 | continue; |
| 753 | } | 753 | } |
| 754 | 754 | ||
| 755 | ubifs_assert(ret == LEB_RETAINED); | 755 | ubifs_assert(c, ret == LEB_RETAINED); |
| 756 | space_after = c->leb_size - wbuf->offs - wbuf->used; | 756 | space_after = c->leb_size - wbuf->offs - wbuf->used; |
| 757 | dbg_gc("LEB %d retained, freed %d bytes", lp.lnum, | 757 | dbg_gc("LEB %d retained, freed %d bytes", lp.lnum, |
| 758 | space_after - space_before); | 758 | space_after - space_before); |
| @@ -812,8 +812,8 @@ out_unlock: | |||
| 812 | return ret; | 812 | return ret; |
| 813 | 813 | ||
| 814 | out: | 814 | out: |
| 815 | ubifs_assert(ret < 0); | 815 | ubifs_assert(c, ret < 0); |
| 816 | ubifs_assert(ret != -ENOSPC && ret != -EAGAIN); | 816 | ubifs_assert(c, ret != -ENOSPC && ret != -EAGAIN); |
| 817 | ubifs_wbuf_sync_nolock(wbuf); | 817 | ubifs_wbuf_sync_nolock(wbuf); |
| 818 | ubifs_ro_mode(c, ret); | 818 | ubifs_ro_mode(c, ret); |
| 819 | mutex_unlock(&wbuf->io_mutex); | 819 | mutex_unlock(&wbuf->io_mutex); |
| @@ -848,8 +848,8 @@ int ubifs_gc_start_commit(struct ubifs_info *c) | |||
| 848 | lp = ubifs_fast_find_freeable(c); | 848 | lp = ubifs_fast_find_freeable(c); |
| 849 | if (!lp) | 849 | if (!lp) |
| 850 | break; | 850 | break; |
| 851 | ubifs_assert(!(lp->flags & LPROPS_TAKEN)); | 851 | ubifs_assert(c, !(lp->flags & LPROPS_TAKEN)); |
| 852 | ubifs_assert(!(lp->flags & LPROPS_INDEX)); | 852 | ubifs_assert(c, !(lp->flags & LPROPS_INDEX)); |
| 853 | err = ubifs_leb_unmap(c, lp->lnum); | 853 | err = ubifs_leb_unmap(c, lp->lnum); |
| 854 | if (err) | 854 | if (err) |
| 855 | goto out; | 855 | goto out; |
| @@ -858,8 +858,8 @@ int ubifs_gc_start_commit(struct ubifs_info *c) | |||
| 858 | err = PTR_ERR(lp); | 858 | err = PTR_ERR(lp); |
| 859 | goto out; | 859 | goto out; |
| 860 | } | 860 | } |
| 861 | ubifs_assert(!(lp->flags & LPROPS_TAKEN)); | 861 | ubifs_assert(c, !(lp->flags & LPROPS_TAKEN)); |
| 862 | ubifs_assert(!(lp->flags & LPROPS_INDEX)); | 862 | ubifs_assert(c, !(lp->flags & LPROPS_INDEX)); |
| 863 | } | 863 | } |
| 864 | 864 | ||
| 865 | /* Mark GC'd index LEBs OK to unmap after this commit finishes */ | 865 | /* Mark GC'd index LEBs OK to unmap after this commit finishes */ |
| @@ -880,8 +880,8 @@ int ubifs_gc_start_commit(struct ubifs_info *c) | |||
| 880 | err = -ENOMEM; | 880 | err = -ENOMEM; |
| 881 | goto out; | 881 | goto out; |
| 882 | } | 882 | } |
| 883 | ubifs_assert(!(lp->flags & LPROPS_TAKEN)); | 883 | ubifs_assert(c, !(lp->flags & LPROPS_TAKEN)); |
| 884 | ubifs_assert(lp->flags & LPROPS_INDEX); | 884 | ubifs_assert(c, lp->flags & LPROPS_INDEX); |
| 885 | /* Don't release the LEB until after the next commit */ | 885 | /* Don't release the LEB until after the next commit */ |
| 886 | flags = (lp->flags | LPROPS_TAKEN) ^ LPROPS_INDEX; | 886 | flags = (lp->flags | LPROPS_TAKEN) ^ LPROPS_INDEX; |
| 887 | lp = ubifs_change_lp(c, lp, c->leb_size, 0, flags, 1); | 887 | lp = ubifs_change_lp(c, lp, c->leb_size, 0, flags, 1); |
| @@ -890,8 +890,8 @@ int ubifs_gc_start_commit(struct ubifs_info *c) | |||
| 890 | kfree(idx_gc); | 890 | kfree(idx_gc); |
| 891 | goto out; | 891 | goto out; |
| 892 | } | 892 | } |
| 893 | ubifs_assert(lp->flags & LPROPS_TAKEN); | 893 | ubifs_assert(c, lp->flags & LPROPS_TAKEN); |
| 894 | ubifs_assert(!(lp->flags & LPROPS_INDEX)); | 894 | ubifs_assert(c, !(lp->flags & LPROPS_INDEX)); |
| 895 | idx_gc->lnum = lp->lnum; | 895 | idx_gc->lnum = lp->lnum; |
| 896 | idx_gc->unmap = 1; | 896 | idx_gc->unmap = 1; |
| 897 | list_add(&idx_gc->list, &c->idx_gc); | 897 | list_add(&idx_gc->list, &c->idx_gc); |
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index fe77e9625e84..099bec94b820 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c | |||
| @@ -119,7 +119,7 @@ int ubifs_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs, | |||
| 119 | { | 119 | { |
| 120 | int err; | 120 | int err; |
| 121 | 121 | ||
| 122 | ubifs_assert(!c->ro_media && !c->ro_mount); | 122 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 123 | if (c->ro_error) | 123 | if (c->ro_error) |
| 124 | return -EROFS; | 124 | return -EROFS; |
| 125 | if (!dbg_is_tst_rcvry(c)) | 125 | if (!dbg_is_tst_rcvry(c)) |
| @@ -139,7 +139,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len) | |||
| 139 | { | 139 | { |
| 140 | int err; | 140 | int err; |
| 141 | 141 | ||
| 142 | ubifs_assert(!c->ro_media && !c->ro_mount); | 142 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 143 | if (c->ro_error) | 143 | if (c->ro_error) |
| 144 | return -EROFS; | 144 | return -EROFS; |
| 145 | if (!dbg_is_tst_rcvry(c)) | 145 | if (!dbg_is_tst_rcvry(c)) |
| @@ -159,7 +159,7 @@ int ubifs_leb_unmap(struct ubifs_info *c, int lnum) | |||
| 159 | { | 159 | { |
| 160 | int err; | 160 | int err; |
| 161 | 161 | ||
| 162 | ubifs_assert(!c->ro_media && !c->ro_mount); | 162 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 163 | if (c->ro_error) | 163 | if (c->ro_error) |
| 164 | return -EROFS; | 164 | return -EROFS; |
| 165 | if (!dbg_is_tst_rcvry(c)) | 165 | if (!dbg_is_tst_rcvry(c)) |
| @@ -178,7 +178,7 @@ int ubifs_leb_map(struct ubifs_info *c, int lnum) | |||
| 178 | { | 178 | { |
| 179 | int err; | 179 | int err; |
| 180 | 180 | ||
| 181 | ubifs_assert(!c->ro_media && !c->ro_mount); | 181 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 182 | if (c->ro_error) | 182 | if (c->ro_error) |
| 183 | return -EROFS; | 183 | return -EROFS; |
| 184 | if (!dbg_is_tst_rcvry(c)) | 184 | if (!dbg_is_tst_rcvry(c)) |
| @@ -241,8 +241,8 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, | |||
| 241 | uint32_t crc, node_crc, magic; | 241 | uint32_t crc, node_crc, magic; |
| 242 | const struct ubifs_ch *ch = buf; | 242 | const struct ubifs_ch *ch = buf; |
| 243 | 243 | ||
| 244 | ubifs_assert(lnum >= 0 && lnum < c->leb_cnt && offs >= 0); | 244 | ubifs_assert(c, lnum >= 0 && lnum < c->leb_cnt && offs >= 0); |
| 245 | ubifs_assert(!(offs & 7) && offs < c->leb_size); | 245 | ubifs_assert(c, !(offs & 7) && offs < c->leb_size); |
| 246 | 246 | ||
| 247 | magic = le32_to_cpu(ch->magic); | 247 | magic = le32_to_cpu(ch->magic); |
| 248 | if (magic != UBIFS_NODE_MAGIC) { | 248 | if (magic != UBIFS_NODE_MAGIC) { |
| @@ -319,7 +319,7 @@ void ubifs_pad(const struct ubifs_info *c, void *buf, int pad) | |||
| 319 | { | 319 | { |
| 320 | uint32_t crc; | 320 | uint32_t crc; |
| 321 | 321 | ||
| 322 | ubifs_assert(pad >= 0 && !(pad & 7)); | 322 | ubifs_assert(c, pad >= 0 && !(pad & 7)); |
| 323 | 323 | ||
| 324 | if (pad >= UBIFS_PAD_NODE_SZ) { | 324 | if (pad >= UBIFS_PAD_NODE_SZ) { |
| 325 | struct ubifs_ch *ch = buf; | 325 | struct ubifs_ch *ch = buf; |
| @@ -382,7 +382,7 @@ void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad) | |||
| 382 | struct ubifs_ch *ch = node; | 382 | struct ubifs_ch *ch = node; |
| 383 | unsigned long long sqnum = next_sqnum(c); | 383 | unsigned long long sqnum = next_sqnum(c); |
| 384 | 384 | ||
| 385 | ubifs_assert(len >= UBIFS_CH_SZ); | 385 | ubifs_assert(c, len >= UBIFS_CH_SZ); |
| 386 | 386 | ||
| 387 | ch->magic = cpu_to_le32(UBIFS_NODE_MAGIC); | 387 | ch->magic = cpu_to_le32(UBIFS_NODE_MAGIC); |
| 388 | ch->len = cpu_to_le32(len); | 388 | ch->len = cpu_to_le32(len); |
| @@ -415,7 +415,7 @@ void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last) | |||
| 415 | struct ubifs_ch *ch = node; | 415 | struct ubifs_ch *ch = node; |
| 416 | unsigned long long sqnum = next_sqnum(c); | 416 | unsigned long long sqnum = next_sqnum(c); |
| 417 | 417 | ||
| 418 | ubifs_assert(len >= UBIFS_CH_SZ); | 418 | ubifs_assert(c, len >= UBIFS_CH_SZ); |
| 419 | 419 | ||
| 420 | ch->magic = cpu_to_le32(UBIFS_NODE_MAGIC); | 420 | ch->magic = cpu_to_le32(UBIFS_NODE_MAGIC); |
| 421 | ch->len = cpu_to_le32(len); | 421 | ch->len = cpu_to_le32(len); |
| @@ -448,9 +448,10 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer) | |||
| 448 | 448 | ||
| 449 | /** | 449 | /** |
| 450 | * new_wbuf_timer - start new write-buffer timer. | 450 | * new_wbuf_timer - start new write-buffer timer. |
| 451 | * @c: UBIFS file-system description object | ||
| 451 | * @wbuf: write-buffer descriptor | 452 | * @wbuf: write-buffer descriptor |
| 452 | */ | 453 | */ |
| 453 | static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) | 454 | static void new_wbuf_timer_nolock(struct ubifs_info *c, struct ubifs_wbuf *wbuf) |
| 454 | { | 455 | { |
| 455 | ktime_t softlimit = ms_to_ktime(dirty_writeback_interval * 10); | 456 | ktime_t softlimit = ms_to_ktime(dirty_writeback_interval * 10); |
| 456 | unsigned long long delta = dirty_writeback_interval; | 457 | unsigned long long delta = dirty_writeback_interval; |
| @@ -458,8 +459,8 @@ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) | |||
| 458 | /* centi to milli, milli to nano, then 10% */ | 459 | /* centi to milli, milli to nano, then 10% */ |
| 459 | delta *= 10ULL * NSEC_PER_MSEC / 10ULL; | 460 | delta *= 10ULL * NSEC_PER_MSEC / 10ULL; |
| 460 | 461 | ||
| 461 | ubifs_assert(!hrtimer_active(&wbuf->timer)); | 462 | ubifs_assert(c, !hrtimer_active(&wbuf->timer)); |
| 462 | ubifs_assert(delta <= ULONG_MAX); | 463 | ubifs_assert(c, delta <= ULONG_MAX); |
| 463 | 464 | ||
| 464 | if (wbuf->no_timer) | 465 | if (wbuf->no_timer) |
| 465 | return; | 466 | return; |
| @@ -508,14 +509,14 @@ int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf) | |||
| 508 | 509 | ||
| 509 | dbg_io("LEB %d:%d, %d bytes, jhead %s", | 510 | dbg_io("LEB %d:%d, %d bytes, jhead %s", |
| 510 | wbuf->lnum, wbuf->offs, wbuf->used, dbg_jhead(wbuf->jhead)); | 511 | wbuf->lnum, wbuf->offs, wbuf->used, dbg_jhead(wbuf->jhead)); |
| 511 | ubifs_assert(!(wbuf->avail & 7)); | 512 | ubifs_assert(c, !(wbuf->avail & 7)); |
| 512 | ubifs_assert(wbuf->offs + wbuf->size <= c->leb_size); | 513 | ubifs_assert(c, wbuf->offs + wbuf->size <= c->leb_size); |
| 513 | ubifs_assert(wbuf->size >= c->min_io_size); | 514 | ubifs_assert(c, wbuf->size >= c->min_io_size); |
| 514 | ubifs_assert(wbuf->size <= c->max_write_size); | 515 | ubifs_assert(c, wbuf->size <= c->max_write_size); |
| 515 | ubifs_assert(wbuf->size % c->min_io_size == 0); | 516 | ubifs_assert(c, wbuf->size % c->min_io_size == 0); |
| 516 | ubifs_assert(!c->ro_media && !c->ro_mount); | 517 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 517 | if (c->leb_size - wbuf->offs >= c->max_write_size) | 518 | if (c->leb_size - wbuf->offs >= c->max_write_size) |
| 518 | ubifs_assert(!((wbuf->offs + wbuf->size) % c->max_write_size)); | 519 | ubifs_assert(c, !((wbuf->offs + wbuf->size) % c->max_write_size)); |
| 519 | 520 | ||
| 520 | if (c->ro_error) | 521 | if (c->ro_error) |
| 521 | return -EROFS; | 522 | return -EROFS; |
| @@ -576,11 +577,11 @@ int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs) | |||
| 576 | const struct ubifs_info *c = wbuf->c; | 577 | const struct ubifs_info *c = wbuf->c; |
| 577 | 578 | ||
| 578 | dbg_io("LEB %d:%d, jhead %s", lnum, offs, dbg_jhead(wbuf->jhead)); | 579 | dbg_io("LEB %d:%d, jhead %s", lnum, offs, dbg_jhead(wbuf->jhead)); |
| 579 | ubifs_assert(lnum >= 0 && lnum < c->leb_cnt); | 580 | ubifs_assert(c, lnum >= 0 && lnum < c->leb_cnt); |
| 580 | ubifs_assert(offs >= 0 && offs <= c->leb_size); | 581 | ubifs_assert(c, offs >= 0 && offs <= c->leb_size); |
| 581 | ubifs_assert(offs % c->min_io_size == 0 && !(offs & 7)); | 582 | ubifs_assert(c, offs % c->min_io_size == 0 && !(offs & 7)); |
| 582 | ubifs_assert(lnum != wbuf->lnum); | 583 | ubifs_assert(c, lnum != wbuf->lnum); |
| 583 | ubifs_assert(wbuf->used == 0); | 584 | ubifs_assert(c, wbuf->used == 0); |
| 584 | 585 | ||
| 585 | spin_lock(&wbuf->lock); | 586 | spin_lock(&wbuf->lock); |
| 586 | wbuf->lnum = lnum; | 587 | wbuf->lnum = lnum; |
| @@ -610,7 +611,7 @@ int ubifs_bg_wbufs_sync(struct ubifs_info *c) | |||
| 610 | { | 611 | { |
| 611 | int err, i; | 612 | int err, i; |
| 612 | 613 | ||
| 613 | ubifs_assert(!c->ro_media && !c->ro_mount); | 614 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 614 | if (!c->need_wbuf_sync) | 615 | if (!c->need_wbuf_sync) |
| 615 | return 0; | 616 | return 0; |
| 616 | c->need_wbuf_sync = 0; | 617 | c->need_wbuf_sync = 0; |
| @@ -686,18 +687,18 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len) | |||
| 686 | dbg_io("%d bytes (%s) to jhead %s wbuf at LEB %d:%d", len, | 687 | dbg_io("%d bytes (%s) to jhead %s wbuf at LEB %d:%d", len, |
| 687 | dbg_ntype(((struct ubifs_ch *)buf)->node_type), | 688 | dbg_ntype(((struct ubifs_ch *)buf)->node_type), |
| 688 | dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs + wbuf->used); | 689 | dbg_jhead(wbuf->jhead), wbuf->lnum, wbuf->offs + wbuf->used); |
| 689 | ubifs_assert(len > 0 && wbuf->lnum >= 0 && wbuf->lnum < c->leb_cnt); | 690 | ubifs_assert(c, len > 0 && wbuf->lnum >= 0 && wbuf->lnum < c->leb_cnt); |
| 690 | ubifs_assert(wbuf->offs >= 0 && wbuf->offs % c->min_io_size == 0); | 691 | ubifs_assert(c, wbuf->offs >= 0 && wbuf->offs % c->min_io_size == 0); |
| 691 | ubifs_assert(!(wbuf->offs & 7) && wbuf->offs <= c->leb_size); | 692 | ubifs_assert(c, !(wbuf->offs & 7) && wbuf->offs <= c->leb_size); |
| 692 | ubifs_assert(wbuf->avail > 0 && wbuf->avail <= wbuf->size); | 693 | ubifs_assert(c, wbuf->avail > 0 && wbuf->avail <= wbuf->size); |
| 693 | ubifs_assert(wbuf->size >= c->min_io_size); | 694 | ubifs_assert(c, wbuf->size >= c->min_io_size); |
| 694 | ubifs_assert(wbuf->size <= c->max_write_size); | 695 | ubifs_assert(c, wbuf->size <= c->max_write_size); |
| 695 | ubifs_assert(wbuf->size % c->min_io_size == 0); | 696 | ubifs_assert(c, wbuf->size % c->min_io_size == 0); |
| 696 | ubifs_assert(mutex_is_locked(&wbuf->io_mutex)); | 697 | ubifs_assert(c, mutex_is_locked(&wbuf->io_mutex)); |
| 697 | ubifs_assert(!c->ro_media && !c->ro_mount); | 698 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 698 | ubifs_assert(!c->space_fixup); | 699 | ubifs_assert(c, !c->space_fixup); |
| 699 | if (c->leb_size - wbuf->offs >= c->max_write_size) | 700 | if (c->leb_size - wbuf->offs >= c->max_write_size) |
| 700 | ubifs_assert(!((wbuf->offs + wbuf->size) % c->max_write_size)); | 701 | ubifs_assert(c, !((wbuf->offs + wbuf->size) % c->max_write_size)); |
| 701 | 702 | ||
| 702 | if (c->leb_size - wbuf->offs - wbuf->used < aligned_len) { | 703 | if (c->leb_size - wbuf->offs - wbuf->used < aligned_len) { |
| 703 | err = -ENOSPC; | 704 | err = -ENOSPC; |
| @@ -834,7 +835,7 @@ exit: | |||
| 834 | } | 835 | } |
| 835 | 836 | ||
| 836 | if (wbuf->used) | 837 | if (wbuf->used) |
| 837 | new_wbuf_timer_nolock(wbuf); | 838 | new_wbuf_timer_nolock(c, wbuf); |
| 838 | 839 | ||
| 839 | return 0; | 840 | return 0; |
| 840 | 841 | ||
| @@ -869,10 +870,10 @@ int ubifs_write_node(struct ubifs_info *c, void *buf, int len, int lnum, | |||
| 869 | dbg_io("LEB %d:%d, %s, length %d (aligned %d)", | 870 | dbg_io("LEB %d:%d, %s, length %d (aligned %d)", |
| 870 | lnum, offs, dbg_ntype(((struct ubifs_ch *)buf)->node_type), len, | 871 | lnum, offs, dbg_ntype(((struct ubifs_ch *)buf)->node_type), len, |
| 871 | buf_len); | 872 | buf_len); |
| 872 | ubifs_assert(lnum >= 0 && lnum < c->leb_cnt && offs >= 0); | 873 | ubifs_assert(c, lnum >= 0 && lnum < c->leb_cnt && offs >= 0); |
| 873 | ubifs_assert(offs % c->min_io_size == 0 && offs < c->leb_size); | 874 | ubifs_assert(c, offs % c->min_io_size == 0 && offs < c->leb_size); |
| 874 | ubifs_assert(!c->ro_media && !c->ro_mount); | 875 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 875 | ubifs_assert(!c->space_fixup); | 876 | ubifs_assert(c, !c->space_fixup); |
| 876 | 877 | ||
| 877 | if (c->ro_error) | 878 | if (c->ro_error) |
| 878 | return -EROFS; | 879 | return -EROFS; |
| @@ -909,9 +910,9 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len, | |||
| 909 | 910 | ||
| 910 | dbg_io("LEB %d:%d, %s, length %d, jhead %s", lnum, offs, | 911 | dbg_io("LEB %d:%d, %s, length %d, jhead %s", lnum, offs, |
| 911 | dbg_ntype(type), len, dbg_jhead(wbuf->jhead)); | 912 | dbg_ntype(type), len, dbg_jhead(wbuf->jhead)); |
| 912 | ubifs_assert(wbuf && lnum >= 0 && lnum < c->leb_cnt && offs >= 0); | 913 | ubifs_assert(c, wbuf && lnum >= 0 && lnum < c->leb_cnt && offs >= 0); |
| 913 | ubifs_assert(!(offs & 7) && offs < c->leb_size); | 914 | ubifs_assert(c, !(offs & 7) && offs < c->leb_size); |
| 914 | ubifs_assert(type >= 0 && type < UBIFS_NODE_TYPES_CNT); | 915 | ubifs_assert(c, type >= 0 && type < UBIFS_NODE_TYPES_CNT); |
| 915 | 916 | ||
| 916 | spin_lock(&wbuf->lock); | 917 | spin_lock(&wbuf->lock); |
| 917 | overlap = (lnum == wbuf->lnum && offs + len > wbuf->offs); | 918 | overlap = (lnum == wbuf->lnum && offs + len > wbuf->offs); |
| @@ -984,10 +985,10 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len, | |||
| 984 | struct ubifs_ch *ch = buf; | 985 | struct ubifs_ch *ch = buf; |
| 985 | 986 | ||
| 986 | dbg_io("LEB %d:%d, %s, length %d", lnum, offs, dbg_ntype(type), len); | 987 | dbg_io("LEB %d:%d, %s, length %d", lnum, offs, dbg_ntype(type), len); |
| 987 | ubifs_assert(lnum >= 0 && lnum < c->leb_cnt && offs >= 0); | 988 | ubifs_assert(c, lnum >= 0 && lnum < c->leb_cnt && offs >= 0); |
| 988 | ubifs_assert(len >= UBIFS_CH_SZ && offs + len <= c->leb_size); | 989 | ubifs_assert(c, len >= UBIFS_CH_SZ && offs + len <= c->leb_size); |
| 989 | ubifs_assert(!(offs & 7) && offs < c->leb_size); | 990 | ubifs_assert(c, !(offs & 7) && offs < c->leb_size); |
| 990 | ubifs_assert(type >= 0 && type < UBIFS_NODE_TYPES_CNT); | 991 | ubifs_assert(c, type >= 0 && type < UBIFS_NODE_TYPES_CNT); |
| 991 | 992 | ||
| 992 | err = ubifs_leb_read(c, lnum, buf, offs, len, 0); | 993 | err = ubifs_leb_read(c, lnum, buf, offs, len, 0); |
| 993 | if (err && err != -EBADMSG) | 994 | if (err && err != -EBADMSG) |
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 42ba4ceb81ee..802565a17733 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c | |||
| @@ -111,7 +111,7 @@ static int reserve_space(struct ubifs_info *c, int jhead, int len) | |||
| 111 | * better to try to allocate space at the ends of eraseblocks. This is | 111 | * better to try to allocate space at the ends of eraseblocks. This is |
| 112 | * what the squeeze parameter does. | 112 | * what the squeeze parameter does. |
| 113 | */ | 113 | */ |
| 114 | ubifs_assert(!c->ro_media && !c->ro_mount); | 114 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 115 | squeeze = (jhead == BASEHD); | 115 | squeeze = (jhead == BASEHD); |
| 116 | again: | 116 | again: |
| 117 | mutex_lock_nested(&wbuf->io_mutex, wbuf->jhead); | 117 | mutex_lock_nested(&wbuf->io_mutex, wbuf->jhead); |
| @@ -215,7 +215,7 @@ out_unlock: | |||
| 215 | 215 | ||
| 216 | out_return: | 216 | out_return: |
| 217 | /* An error occurred and the LEB has to be returned to lprops */ | 217 | /* An error occurred and the LEB has to be returned to lprops */ |
| 218 | ubifs_assert(err < 0); | 218 | ubifs_assert(c, err < 0); |
| 219 | err1 = ubifs_return_leb(c, lnum); | 219 | err1 = ubifs_return_leb(c, lnum); |
| 220 | if (err1 && err == -EAGAIN) | 220 | if (err1 && err == -EAGAIN) |
| 221 | /* | 221 | /* |
| @@ -246,7 +246,7 @@ static int write_node(struct ubifs_info *c, int jhead, void *node, int len, | |||
| 246 | { | 246 | { |
| 247 | struct ubifs_wbuf *wbuf = &c->jheads[jhead].wbuf; | 247 | struct ubifs_wbuf *wbuf = &c->jheads[jhead].wbuf; |
| 248 | 248 | ||
| 249 | ubifs_assert(jhead != GCHD); | 249 | ubifs_assert(c, jhead != GCHD); |
| 250 | 250 | ||
| 251 | *lnum = c->jheads[jhead].wbuf.lnum; | 251 | *lnum = c->jheads[jhead].wbuf.lnum; |
| 252 | *offs = c->jheads[jhead].wbuf.offs + c->jheads[jhead].wbuf.used; | 252 | *offs = c->jheads[jhead].wbuf.offs + c->jheads[jhead].wbuf.used; |
| @@ -278,7 +278,7 @@ static int write_head(struct ubifs_info *c, int jhead, void *buf, int len, | |||
| 278 | int err; | 278 | int err; |
| 279 | struct ubifs_wbuf *wbuf = &c->jheads[jhead].wbuf; | 279 | struct ubifs_wbuf *wbuf = &c->jheads[jhead].wbuf; |
| 280 | 280 | ||
| 281 | ubifs_assert(jhead != GCHD); | 281 | ubifs_assert(c, jhead != GCHD); |
| 282 | 282 | ||
| 283 | *lnum = c->jheads[jhead].wbuf.lnum; | 283 | *lnum = c->jheads[jhead].wbuf.lnum; |
| 284 | *offs = c->jheads[jhead].wbuf.offs + c->jheads[jhead].wbuf.used; | 284 | *offs = c->jheads[jhead].wbuf.offs + c->jheads[jhead].wbuf.used; |
| @@ -549,7 +549,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, | |||
| 549 | struct ubifs_ino_node *ino; | 549 | struct ubifs_ino_node *ino; |
| 550 | union ubifs_key dent_key, ino_key; | 550 | union ubifs_key dent_key, ino_key; |
| 551 | 551 | ||
| 552 | ubifs_assert(mutex_is_locked(&host_ui->ui_mutex)); | 552 | ubifs_assert(c, mutex_is_locked(&host_ui->ui_mutex)); |
| 553 | 553 | ||
| 554 | dlen = UBIFS_DENT_NODE_SZ + fname_len(nm) + 1; | 554 | dlen = UBIFS_DENT_NODE_SZ + fname_len(nm) + 1; |
| 555 | ilen = UBIFS_INO_NODE_SZ; | 555 | ilen = UBIFS_INO_NODE_SZ; |
| @@ -713,7 +713,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, | |||
| 713 | 713 | ||
| 714 | dbg_jnlk(key, "ino %lu, blk %u, len %d, key ", | 714 | dbg_jnlk(key, "ino %lu, blk %u, len %d, key ", |
| 715 | (unsigned long)key_inum(c, key), key_block(c, key), len); | 715 | (unsigned long)key_inum(c, key), key_block(c, key), len); |
| 716 | ubifs_assert(len <= UBIFS_BLOCK_SIZE); | 716 | ubifs_assert(c, len <= UBIFS_BLOCK_SIZE); |
| 717 | 717 | ||
| 718 | if (encrypted) | 718 | if (encrypted) |
| 719 | dlen += UBIFS_CIPHER_BLOCK_SIZE; | 719 | dlen += UBIFS_CIPHER_BLOCK_SIZE; |
| @@ -744,7 +744,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, | |||
| 744 | 744 | ||
| 745 | out_len = compr_len = dlen - UBIFS_DATA_NODE_SZ; | 745 | out_len = compr_len = dlen - UBIFS_DATA_NODE_SZ; |
| 746 | ubifs_compress(c, buf, len, &data->data, &compr_len, &compr_type); | 746 | ubifs_compress(c, buf, len, &data->data, &compr_len, &compr_type); |
| 747 | ubifs_assert(compr_len <= UBIFS_BLOCK_SIZE); | 747 | ubifs_assert(c, compr_len <= UBIFS_BLOCK_SIZE); |
| 748 | 748 | ||
| 749 | if (encrypted) { | 749 | if (encrypted) { |
| 750 | err = ubifs_encrypt(inode, data, compr_len, &out_len, key_block(c, key)); | 750 | err = ubifs_encrypt(inode, data, compr_len, &out_len, key_block(c, key)); |
| @@ -904,7 +904,7 @@ int ubifs_jnl_delete_inode(struct ubifs_info *c, const struct inode *inode) | |||
| 904 | int err; | 904 | int err; |
| 905 | struct ubifs_inode *ui = ubifs_inode(inode); | 905 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 906 | 906 | ||
| 907 | ubifs_assert(inode->i_nlink == 0); | 907 | ubifs_assert(c, inode->i_nlink == 0); |
| 908 | 908 | ||
| 909 | if (ui->del_cmtno != c->cmt_no) | 909 | if (ui->del_cmtno != c->cmt_no) |
| 910 | /* A commit happened for sure */ | 910 | /* A commit happened for sure */ |
| @@ -959,10 +959,10 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir, | |||
| 959 | int twoparents = (fst_dir != snd_dir); | 959 | int twoparents = (fst_dir != snd_dir); |
| 960 | void *p; | 960 | void *p; |
| 961 | 961 | ||
| 962 | ubifs_assert(ubifs_inode(fst_dir)->data_len == 0); | 962 | ubifs_assert(c, ubifs_inode(fst_dir)->data_len == 0); |
| 963 | ubifs_assert(ubifs_inode(snd_dir)->data_len == 0); | 963 | ubifs_assert(c, ubifs_inode(snd_dir)->data_len == 0); |
| 964 | ubifs_assert(mutex_is_locked(&ubifs_inode(fst_dir)->ui_mutex)); | 964 | ubifs_assert(c, mutex_is_locked(&ubifs_inode(fst_dir)->ui_mutex)); |
| 965 | ubifs_assert(mutex_is_locked(&ubifs_inode(snd_dir)->ui_mutex)); | 965 | ubifs_assert(c, mutex_is_locked(&ubifs_inode(snd_dir)->ui_mutex)); |
| 966 | 966 | ||
| 967 | dlen1 = UBIFS_DENT_NODE_SZ + fname_len(snd_nm) + 1; | 967 | dlen1 = UBIFS_DENT_NODE_SZ + fname_len(snd_nm) + 1; |
| 968 | dlen2 = UBIFS_DENT_NODE_SZ + fname_len(fst_nm) + 1; | 968 | dlen2 = UBIFS_DENT_NODE_SZ + fname_len(fst_nm) + 1; |
| @@ -1102,16 +1102,16 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir, | |||
| 1102 | int move = (old_dir != new_dir); | 1102 | int move = (old_dir != new_dir); |
| 1103 | struct ubifs_inode *uninitialized_var(new_ui); | 1103 | struct ubifs_inode *uninitialized_var(new_ui); |
| 1104 | 1104 | ||
| 1105 | ubifs_assert(ubifs_inode(old_dir)->data_len == 0); | 1105 | ubifs_assert(c, ubifs_inode(old_dir)->data_len == 0); |
| 1106 | ubifs_assert(ubifs_inode(new_dir)->data_len == 0); | 1106 | ubifs_assert(c, ubifs_inode(new_dir)->data_len == 0); |
| 1107 | ubifs_assert(mutex_is_locked(&ubifs_inode(old_dir)->ui_mutex)); | 1107 | ubifs_assert(c, mutex_is_locked(&ubifs_inode(old_dir)->ui_mutex)); |
| 1108 | ubifs_assert(mutex_is_locked(&ubifs_inode(new_dir)->ui_mutex)); | 1108 | ubifs_assert(c, mutex_is_locked(&ubifs_inode(new_dir)->ui_mutex)); |
| 1109 | 1109 | ||
| 1110 | dlen1 = UBIFS_DENT_NODE_SZ + fname_len(new_nm) + 1; | 1110 | dlen1 = UBIFS_DENT_NODE_SZ + fname_len(new_nm) + 1; |
| 1111 | dlen2 = UBIFS_DENT_NODE_SZ + fname_len(old_nm) + 1; | 1111 | dlen2 = UBIFS_DENT_NODE_SZ + fname_len(old_nm) + 1; |
| 1112 | if (new_inode) { | 1112 | if (new_inode) { |
| 1113 | new_ui = ubifs_inode(new_inode); | 1113 | new_ui = ubifs_inode(new_inode); |
| 1114 | ubifs_assert(mutex_is_locked(&new_ui->ui_mutex)); | 1114 | ubifs_assert(c, mutex_is_locked(&new_ui->ui_mutex)); |
| 1115 | ilen = UBIFS_INO_NODE_SZ; | 1115 | ilen = UBIFS_INO_NODE_SZ; |
| 1116 | if (!last_reference) | 1116 | if (!last_reference) |
| 1117 | ilen += new_ui->data_len; | 1117 | ilen += new_ui->data_len; |
| @@ -1324,7 +1324,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in | |||
| 1324 | dn->compr_size = 0; | 1324 | dn->compr_size = 0; |
| 1325 | } | 1325 | } |
| 1326 | 1326 | ||
| 1327 | ubifs_assert(out_len <= UBIFS_BLOCK_SIZE); | 1327 | ubifs_assert(c, out_len <= UBIFS_BLOCK_SIZE); |
| 1328 | dn->compr_type = cpu_to_le16(compr_type); | 1328 | dn->compr_type = cpu_to_le16(compr_type); |
| 1329 | dn->size = cpu_to_le32(*new_len); | 1329 | dn->size = cpu_to_le32(*new_len); |
| 1330 | *new_len = UBIFS_DATA_NODE_SZ + out_len; | 1330 | *new_len = UBIFS_DATA_NODE_SZ + out_len; |
| @@ -1363,9 +1363,9 @@ int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode, | |||
| 1363 | 1363 | ||
| 1364 | dbg_jnl("ino %lu, size %lld -> %lld", | 1364 | dbg_jnl("ino %lu, size %lld -> %lld", |
| 1365 | (unsigned long)inum, old_size, new_size); | 1365 | (unsigned long)inum, old_size, new_size); |
| 1366 | ubifs_assert(!ui->data_len); | 1366 | ubifs_assert(c, !ui->data_len); |
| 1367 | ubifs_assert(S_ISREG(inode->i_mode)); | 1367 | ubifs_assert(c, S_ISREG(inode->i_mode)); |
| 1368 | ubifs_assert(mutex_is_locked(&ui->ui_mutex)); | 1368 | ubifs_assert(c, mutex_is_locked(&ui->ui_mutex)); |
| 1369 | 1369 | ||
| 1370 | sz = UBIFS_TRUN_NODE_SZ + UBIFS_INO_NODE_SZ + | 1370 | sz = UBIFS_TRUN_NODE_SZ + UBIFS_INO_NODE_SZ + |
| 1371 | UBIFS_MAX_DATA_NODE_SZ * WORST_COMPR_FACTOR; | 1371 | UBIFS_MAX_DATA_NODE_SZ * WORST_COMPR_FACTOR; |
| @@ -1502,8 +1502,8 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host, | |||
| 1502 | int sync = IS_DIRSYNC(host); | 1502 | int sync = IS_DIRSYNC(host); |
| 1503 | struct ubifs_inode *host_ui = ubifs_inode(host); | 1503 | struct ubifs_inode *host_ui = ubifs_inode(host); |
| 1504 | 1504 | ||
| 1505 | ubifs_assert(inode->i_nlink == 0); | 1505 | ubifs_assert(c, inode->i_nlink == 0); |
| 1506 | ubifs_assert(mutex_is_locked(&host_ui->ui_mutex)); | 1506 | ubifs_assert(c, mutex_is_locked(&host_ui->ui_mutex)); |
| 1507 | 1507 | ||
| 1508 | /* | 1508 | /* |
| 1509 | * Since we are deleting the inode, we do not bother to attach any data | 1509 | * Since we are deleting the inode, we do not bother to attach any data |
| @@ -1612,9 +1612,9 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode, | |||
| 1612 | int sync = IS_DIRSYNC(host); | 1612 | int sync = IS_DIRSYNC(host); |
| 1613 | 1613 | ||
| 1614 | dbg_jnl("ino %lu, ino %lu", host->i_ino, inode->i_ino); | 1614 | dbg_jnl("ino %lu, ino %lu", host->i_ino, inode->i_ino); |
| 1615 | ubifs_assert(host->i_nlink > 0); | 1615 | ubifs_assert(c, host->i_nlink > 0); |
| 1616 | ubifs_assert(inode->i_nlink > 0); | 1616 | ubifs_assert(c, inode->i_nlink > 0); |
| 1617 | ubifs_assert(mutex_is_locked(&host_ui->ui_mutex)); | 1617 | ubifs_assert(c, mutex_is_locked(&host_ui->ui_mutex)); |
| 1618 | 1618 | ||
| 1619 | len1 = UBIFS_INO_NODE_SZ + host_ui->data_len; | 1619 | len1 = UBIFS_INO_NODE_SZ + host_ui->data_len; |
| 1620 | len2 = UBIFS_INO_NODE_SZ + ubifs_inode(inode)->data_len; | 1620 | len2 = UBIFS_INO_NODE_SZ + ubifs_inode(inode)->data_len; |
diff --git a/fs/ubifs/key.h b/fs/ubifs/key.h index b1f7c0caa3ac..2feff6cbbb77 100644 --- a/fs/ubifs/key.h +++ b/fs/ubifs/key.h | |||
| @@ -161,8 +161,8 @@ static inline void dent_key_init(const struct ubifs_info *c, | |||
| 161 | { | 161 | { |
| 162 | uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm)); | 162 | uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm)); |
| 163 | 163 | ||
| 164 | ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK)); | 164 | ubifs_assert(c, !(hash & ~UBIFS_S_KEY_HASH_MASK)); |
| 165 | ubifs_assert(!nm->hash && !nm->minor_hash); | 165 | ubifs_assert(c, !nm->hash && !nm->minor_hash); |
| 166 | key->u32[0] = inum; | 166 | key->u32[0] = inum; |
| 167 | key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS); | 167 | key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS); |
| 168 | } | 168 | } |
| @@ -179,7 +179,7 @@ static inline void dent_key_init_hash(const struct ubifs_info *c, | |||
| 179 | union ubifs_key *key, ino_t inum, | 179 | union ubifs_key *key, ino_t inum, |
| 180 | uint32_t hash) | 180 | uint32_t hash) |
| 181 | { | 181 | { |
| 182 | ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK)); | 182 | ubifs_assert(c, !(hash & ~UBIFS_S_KEY_HASH_MASK)); |
| 183 | key->u32[0] = inum; | 183 | key->u32[0] = inum; |
| 184 | key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS); | 184 | key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS); |
| 185 | } | 185 | } |
| @@ -198,7 +198,7 @@ static inline void dent_key_init_flash(const struct ubifs_info *c, void *k, | |||
| 198 | union ubifs_key *key = k; | 198 | union ubifs_key *key = k; |
| 199 | uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm)); | 199 | uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm)); |
| 200 | 200 | ||
| 201 | ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK)); | 201 | ubifs_assert(c, !(hash & ~UBIFS_S_KEY_HASH_MASK)); |
| 202 | key->j32[0] = cpu_to_le32(inum); | 202 | key->j32[0] = cpu_to_le32(inum); |
| 203 | key->j32[1] = cpu_to_le32(hash | | 203 | key->j32[1] = cpu_to_le32(hash | |
| 204 | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS)); | 204 | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS)); |
| @@ -231,7 +231,7 @@ static inline void xent_key_init(const struct ubifs_info *c, | |||
| 231 | { | 231 | { |
| 232 | uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm)); | 232 | uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm)); |
| 233 | 233 | ||
| 234 | ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK)); | 234 | ubifs_assert(c, !(hash & ~UBIFS_S_KEY_HASH_MASK)); |
| 235 | key->u32[0] = inum; | 235 | key->u32[0] = inum; |
| 236 | key->u32[1] = hash | (UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS); | 236 | key->u32[1] = hash | (UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS); |
| 237 | } | 237 | } |
| @@ -249,7 +249,7 @@ static inline void xent_key_init_flash(const struct ubifs_info *c, void *k, | |||
| 249 | union ubifs_key *key = k; | 249 | union ubifs_key *key = k; |
| 250 | uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm)); | 250 | uint32_t hash = c->key_hash(fname_name(nm), fname_len(nm)); |
| 251 | 251 | ||
| 252 | ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK)); | 252 | ubifs_assert(c, !(hash & ~UBIFS_S_KEY_HASH_MASK)); |
| 253 | key->j32[0] = cpu_to_le32(inum); | 253 | key->j32[0] = cpu_to_le32(inum); |
| 254 | key->j32[1] = cpu_to_le32(hash | | 254 | key->j32[1] = cpu_to_le32(hash | |
| 255 | (UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS)); | 255 | (UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS)); |
| @@ -280,7 +280,7 @@ static inline void data_key_init(const struct ubifs_info *c, | |||
| 280 | union ubifs_key *key, ino_t inum, | 280 | union ubifs_key *key, ino_t inum, |
| 281 | unsigned int block) | 281 | unsigned int block) |
| 282 | { | 282 | { |
| 283 | ubifs_assert(!(block & ~UBIFS_S_KEY_BLOCK_MASK)); | 283 | ubifs_assert(c, !(block & ~UBIFS_S_KEY_BLOCK_MASK)); |
| 284 | key->u32[0] = inum; | 284 | key->u32[0] = inum; |
| 285 | key->u32[1] = block | (UBIFS_DATA_KEY << UBIFS_S_KEY_BLOCK_BITS); | 285 | key->u32[1] = block | (UBIFS_DATA_KEY << UBIFS_S_KEY_BLOCK_BITS); |
| 286 | } | 286 | } |
diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c index 7cffa120a750..86b0828f5499 100644 --- a/fs/ubifs/log.c +++ b/fs/ubifs/log.c | |||
| @@ -132,7 +132,7 @@ void ubifs_add_bud(struct ubifs_info *c, struct ubifs_bud *bud) | |||
| 132 | while (*p) { | 132 | while (*p) { |
| 133 | parent = *p; | 133 | parent = *p; |
| 134 | b = rb_entry(parent, struct ubifs_bud, rb); | 134 | b = rb_entry(parent, struct ubifs_bud, rb); |
| 135 | ubifs_assert(bud->lnum != b->lnum); | 135 | ubifs_assert(c, bud->lnum != b->lnum); |
| 136 | if (bud->lnum < b->lnum) | 136 | if (bud->lnum < b->lnum) |
| 137 | p = &(*p)->rb_left; | 137 | p = &(*p)->rb_left; |
| 138 | else | 138 | else |
| @@ -145,7 +145,7 @@ void ubifs_add_bud(struct ubifs_info *c, struct ubifs_bud *bud) | |||
| 145 | jhead = &c->jheads[bud->jhead]; | 145 | jhead = &c->jheads[bud->jhead]; |
| 146 | list_add_tail(&bud->list, &jhead->buds_list); | 146 | list_add_tail(&bud->list, &jhead->buds_list); |
| 147 | } else | 147 | } else |
| 148 | ubifs_assert(c->replaying && c->ro_mount); | 148 | ubifs_assert(c, c->replaying && c->ro_mount); |
| 149 | 149 | ||
| 150 | /* | 150 | /* |
| 151 | * Note, although this is a new bud, we anyway account this space now, | 151 | * Note, although this is a new bud, we anyway account this space now, |
| @@ -189,7 +189,7 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs) | |||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | mutex_lock(&c->log_mutex); | 191 | mutex_lock(&c->log_mutex); |
| 192 | ubifs_assert(!c->ro_media && !c->ro_mount); | 192 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 193 | if (c->ro_error) { | 193 | if (c->ro_error) { |
| 194 | err = -EROFS; | 194 | err = -EROFS; |
| 195 | goto out_unlock; | 195 | goto out_unlock; |
| @@ -244,7 +244,7 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs) | |||
| 244 | 244 | ||
| 245 | if (c->lhead_offs > c->leb_size - c->ref_node_alsz) { | 245 | if (c->lhead_offs > c->leb_size - c->ref_node_alsz) { |
| 246 | c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum); | 246 | c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum); |
| 247 | ubifs_assert(c->lhead_lnum != c->ltail_lnum); | 247 | ubifs_assert(c, c->lhead_lnum != c->ltail_lnum); |
| 248 | c->lhead_offs = 0; | 248 | c->lhead_offs = 0; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| @@ -301,7 +301,7 @@ static void remove_buds(struct ubifs_info *c) | |||
| 301 | { | 301 | { |
| 302 | struct rb_node *p; | 302 | struct rb_node *p; |
| 303 | 303 | ||
| 304 | ubifs_assert(list_empty(&c->old_buds)); | 304 | ubifs_assert(c, list_empty(&c->old_buds)); |
| 305 | c->cmt_bud_bytes = 0; | 305 | c->cmt_bud_bytes = 0; |
| 306 | spin_lock(&c->buds_lock); | 306 | spin_lock(&c->buds_lock); |
| 307 | p = rb_first(&c->buds); | 307 | p = rb_first(&c->buds); |
| @@ -409,7 +409,7 @@ int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum) | |||
| 409 | /* Switch to the next log LEB */ | 409 | /* Switch to the next log LEB */ |
| 410 | if (c->lhead_offs) { | 410 | if (c->lhead_offs) { |
| 411 | c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum); | 411 | c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum); |
| 412 | ubifs_assert(c->lhead_lnum != c->ltail_lnum); | 412 | ubifs_assert(c, c->lhead_lnum != c->ltail_lnum); |
| 413 | c->lhead_offs = 0; | 413 | c->lhead_offs = 0; |
| 414 | } | 414 | } |
| 415 | 415 | ||
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c index 8ade493a423a..fa8d775c9753 100644 --- a/fs/ubifs/lprops.c +++ b/fs/ubifs/lprops.c | |||
| @@ -187,9 +187,9 @@ static int add_to_lpt_heap(struct ubifs_info *c, struct ubifs_lprops *lprops, | |||
| 187 | /* Compare to some other LEB on the bottom of heap */ | 187 | /* Compare to some other LEB on the bottom of heap */ |
| 188 | /* Pick a position kind of randomly */ | 188 | /* Pick a position kind of randomly */ |
| 189 | cpos = (((size_t)lprops >> 4) & b) + b; | 189 | cpos = (((size_t)lprops >> 4) & b) + b; |
| 190 | ubifs_assert(cpos >= b); | 190 | ubifs_assert(c, cpos >= b); |
| 191 | ubifs_assert(cpos < LPT_HEAP_SZ); | 191 | ubifs_assert(c, cpos < LPT_HEAP_SZ); |
| 192 | ubifs_assert(cpos < heap->cnt); | 192 | ubifs_assert(c, cpos < heap->cnt); |
| 193 | 193 | ||
| 194 | val1 = get_heap_comp_val(lprops, cat); | 194 | val1 = get_heap_comp_val(lprops, cat); |
| 195 | val2 = get_heap_comp_val(heap->arr[cpos], cat); | 195 | val2 = get_heap_comp_val(heap->arr[cpos], cat); |
| @@ -230,8 +230,8 @@ static void remove_from_lpt_heap(struct ubifs_info *c, | |||
| 230 | int hpos = lprops->hpos; | 230 | int hpos = lprops->hpos; |
| 231 | 231 | ||
| 232 | heap = &c->lpt_heap[cat - 1]; | 232 | heap = &c->lpt_heap[cat - 1]; |
| 233 | ubifs_assert(hpos >= 0 && hpos < heap->cnt); | 233 | ubifs_assert(c, hpos >= 0 && hpos < heap->cnt); |
| 234 | ubifs_assert(heap->arr[hpos] == lprops); | 234 | ubifs_assert(c, heap->arr[hpos] == lprops); |
| 235 | heap->cnt -= 1; | 235 | heap->cnt -= 1; |
| 236 | if (hpos < heap->cnt) { | 236 | if (hpos < heap->cnt) { |
| 237 | heap->arr[hpos] = heap->arr[heap->cnt]; | 237 | heap->arr[hpos] = heap->arr[heap->cnt]; |
| @@ -296,13 +296,13 @@ void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, | |||
| 296 | list_add(&lprops->list, &c->frdi_idx_list); | 296 | list_add(&lprops->list, &c->frdi_idx_list); |
| 297 | break; | 297 | break; |
| 298 | default: | 298 | default: |
| 299 | ubifs_assert(0); | 299 | ubifs_assert(c, 0); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | lprops->flags &= ~LPROPS_CAT_MASK; | 302 | lprops->flags &= ~LPROPS_CAT_MASK; |
| 303 | lprops->flags |= cat; | 303 | lprops->flags |= cat; |
| 304 | c->in_a_category_cnt += 1; | 304 | c->in_a_category_cnt += 1; |
| 305 | ubifs_assert(c->in_a_category_cnt <= c->main_lebs); | 305 | ubifs_assert(c, c->in_a_category_cnt <= c->main_lebs); |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | /** | 308 | /** |
| @@ -324,20 +324,20 @@ static void ubifs_remove_from_cat(struct ubifs_info *c, | |||
| 324 | break; | 324 | break; |
| 325 | case LPROPS_FREEABLE: | 325 | case LPROPS_FREEABLE: |
| 326 | c->freeable_cnt -= 1; | 326 | c->freeable_cnt -= 1; |
| 327 | ubifs_assert(c->freeable_cnt >= 0); | 327 | ubifs_assert(c, c->freeable_cnt >= 0); |
| 328 | /* Fall through */ | 328 | /* Fall through */ |
| 329 | case LPROPS_UNCAT: | 329 | case LPROPS_UNCAT: |
| 330 | case LPROPS_EMPTY: | 330 | case LPROPS_EMPTY: |
| 331 | case LPROPS_FRDI_IDX: | 331 | case LPROPS_FRDI_IDX: |
| 332 | ubifs_assert(!list_empty(&lprops->list)); | 332 | ubifs_assert(c, !list_empty(&lprops->list)); |
| 333 | list_del(&lprops->list); | 333 | list_del(&lprops->list); |
| 334 | break; | 334 | break; |
| 335 | default: | 335 | default: |
| 336 | ubifs_assert(0); | 336 | ubifs_assert(c, 0); |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | c->in_a_category_cnt -= 1; | 339 | c->in_a_category_cnt -= 1; |
| 340 | ubifs_assert(c->in_a_category_cnt >= 0); | 340 | ubifs_assert(c, c->in_a_category_cnt >= 0); |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | /** | 343 | /** |
| @@ -369,7 +369,7 @@ void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops, | |||
| 369 | list_replace(&old_lprops->list, &new_lprops->list); | 369 | list_replace(&old_lprops->list, &new_lprops->list); |
| 370 | break; | 370 | break; |
| 371 | default: | 371 | default: |
| 372 | ubifs_assert(0); | 372 | ubifs_assert(c, 0); |
| 373 | } | 373 | } |
| 374 | } | 374 | } |
| 375 | 375 | ||
| @@ -412,7 +412,7 @@ int ubifs_categorize_lprops(const struct ubifs_info *c, | |||
| 412 | return LPROPS_UNCAT; | 412 | return LPROPS_UNCAT; |
| 413 | 413 | ||
| 414 | if (lprops->free == c->leb_size) { | 414 | if (lprops->free == c->leb_size) { |
| 415 | ubifs_assert(!(lprops->flags & LPROPS_INDEX)); | 415 | ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); |
| 416 | return LPROPS_EMPTY; | 416 | return LPROPS_EMPTY; |
| 417 | } | 417 | } |
| 418 | 418 | ||
| @@ -478,7 +478,7 @@ static void change_category(struct ubifs_info *c, struct ubifs_lprops *lprops) | |||
| 478 | */ | 478 | */ |
| 479 | int ubifs_calc_dark(const struct ubifs_info *c, int spc) | 479 | int ubifs_calc_dark(const struct ubifs_info *c, int spc) |
| 480 | { | 480 | { |
| 481 | ubifs_assert(!(spc & 7)); | 481 | ubifs_assert(c, !(spc & 7)); |
| 482 | 482 | ||
| 483 | if (spc < c->dark_wm) | 483 | if (spc < c->dark_wm) |
| 484 | return spc; | 484 | return spc; |
| @@ -543,27 +543,27 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, | |||
| 543 | dbg_lp("LEB %d, free %d, dirty %d, flags %d", | 543 | dbg_lp("LEB %d, free %d, dirty %d, flags %d", |
| 544 | lprops->lnum, free, dirty, flags); | 544 | lprops->lnum, free, dirty, flags); |
| 545 | 545 | ||
| 546 | ubifs_assert(mutex_is_locked(&c->lp_mutex)); | 546 | ubifs_assert(c, mutex_is_locked(&c->lp_mutex)); |
| 547 | ubifs_assert(c->lst.empty_lebs >= 0 && | 547 | ubifs_assert(c, c->lst.empty_lebs >= 0 && |
| 548 | c->lst.empty_lebs <= c->main_lebs); | 548 | c->lst.empty_lebs <= c->main_lebs); |
| 549 | ubifs_assert(c->freeable_cnt >= 0); | 549 | ubifs_assert(c, c->freeable_cnt >= 0); |
| 550 | ubifs_assert(c->freeable_cnt <= c->main_lebs); | 550 | ubifs_assert(c, c->freeable_cnt <= c->main_lebs); |
| 551 | ubifs_assert(c->lst.taken_empty_lebs >= 0); | 551 | ubifs_assert(c, c->lst.taken_empty_lebs >= 0); |
| 552 | ubifs_assert(c->lst.taken_empty_lebs <= c->lst.empty_lebs); | 552 | ubifs_assert(c, c->lst.taken_empty_lebs <= c->lst.empty_lebs); |
| 553 | ubifs_assert(!(c->lst.total_free & 7) && !(c->lst.total_dirty & 7)); | 553 | ubifs_assert(c, !(c->lst.total_free & 7) && !(c->lst.total_dirty & 7)); |
| 554 | ubifs_assert(!(c->lst.total_dead & 7) && !(c->lst.total_dark & 7)); | 554 | ubifs_assert(c, !(c->lst.total_dead & 7) && !(c->lst.total_dark & 7)); |
| 555 | ubifs_assert(!(c->lst.total_used & 7)); | 555 | ubifs_assert(c, !(c->lst.total_used & 7)); |
| 556 | ubifs_assert(free == LPROPS_NC || free >= 0); | 556 | ubifs_assert(c, free == LPROPS_NC || free >= 0); |
| 557 | ubifs_assert(dirty == LPROPS_NC || dirty >= 0); | 557 | ubifs_assert(c, dirty == LPROPS_NC || dirty >= 0); |
| 558 | 558 | ||
| 559 | if (!is_lprops_dirty(c, lprops)) { | 559 | if (!is_lprops_dirty(c, lprops)) { |
| 560 | lprops = ubifs_lpt_lookup_dirty(c, lprops->lnum); | 560 | lprops = ubifs_lpt_lookup_dirty(c, lprops->lnum); |
| 561 | if (IS_ERR(lprops)) | 561 | if (IS_ERR(lprops)) |
| 562 | return lprops; | 562 | return lprops; |
| 563 | } else | 563 | } else |
| 564 | ubifs_assert(lprops == ubifs_lpt_lookup_dirty(c, lprops->lnum)); | 564 | ubifs_assert(c, lprops == ubifs_lpt_lookup_dirty(c, lprops->lnum)); |
| 565 | 565 | ||
| 566 | ubifs_assert(!(lprops->free & 7) && !(lprops->dirty & 7)); | 566 | ubifs_assert(c, !(lprops->free & 7) && !(lprops->dirty & 7)); |
| 567 | 567 | ||
| 568 | spin_lock(&c->space_lock); | 568 | spin_lock(&c->space_lock); |
| 569 | if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size) | 569 | if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size) |
| @@ -768,15 +768,15 @@ const struct ubifs_lprops *ubifs_fast_find_free(struct ubifs_info *c) | |||
| 768 | struct ubifs_lprops *lprops; | 768 | struct ubifs_lprops *lprops; |
| 769 | struct ubifs_lpt_heap *heap; | 769 | struct ubifs_lpt_heap *heap; |
| 770 | 770 | ||
| 771 | ubifs_assert(mutex_is_locked(&c->lp_mutex)); | 771 | ubifs_assert(c, mutex_is_locked(&c->lp_mutex)); |
| 772 | 772 | ||
| 773 | heap = &c->lpt_heap[LPROPS_FREE - 1]; | 773 | heap = &c->lpt_heap[LPROPS_FREE - 1]; |
| 774 | if (heap->cnt == 0) | 774 | if (heap->cnt == 0) |
| 775 | return NULL; | 775 | return NULL; |
| 776 | 776 | ||
| 777 | lprops = heap->arr[0]; | 777 | lprops = heap->arr[0]; |
| 778 | ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); | 778 | ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); |
| 779 | ubifs_assert(!(lprops->flags & LPROPS_INDEX)); | 779 | ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); |
| 780 | return lprops; | 780 | return lprops; |
| 781 | } | 781 | } |
| 782 | 782 | ||
| @@ -791,15 +791,15 @@ const struct ubifs_lprops *ubifs_fast_find_empty(struct ubifs_info *c) | |||
| 791 | { | 791 | { |
| 792 | struct ubifs_lprops *lprops; | 792 | struct ubifs_lprops *lprops; |
| 793 | 793 | ||
| 794 | ubifs_assert(mutex_is_locked(&c->lp_mutex)); | 794 | ubifs_assert(c, mutex_is_locked(&c->lp_mutex)); |
| 795 | 795 | ||
| 796 | if (list_empty(&c->empty_list)) | 796 | if (list_empty(&c->empty_list)) |
| 797 | return NULL; | 797 | return NULL; |
| 798 | 798 | ||
| 799 | lprops = list_entry(c->empty_list.next, struct ubifs_lprops, list); | 799 | lprops = list_entry(c->empty_list.next, struct ubifs_lprops, list); |
| 800 | ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); | 800 | ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); |
| 801 | ubifs_assert(!(lprops->flags & LPROPS_INDEX)); | 801 | ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); |
| 802 | ubifs_assert(lprops->free == c->leb_size); | 802 | ubifs_assert(c, lprops->free == c->leb_size); |
| 803 | return lprops; | 803 | return lprops; |
| 804 | } | 804 | } |
| 805 | 805 | ||
| @@ -814,16 +814,16 @@ const struct ubifs_lprops *ubifs_fast_find_freeable(struct ubifs_info *c) | |||
| 814 | { | 814 | { |
| 815 | struct ubifs_lprops *lprops; | 815 | struct ubifs_lprops *lprops; |
| 816 | 816 | ||
| 817 | ubifs_assert(mutex_is_locked(&c->lp_mutex)); | 817 | ubifs_assert(c, mutex_is_locked(&c->lp_mutex)); |
| 818 | 818 | ||
| 819 | if (list_empty(&c->freeable_list)) | 819 | if (list_empty(&c->freeable_list)) |
| 820 | return NULL; | 820 | return NULL; |
| 821 | 821 | ||
| 822 | lprops = list_entry(c->freeable_list.next, struct ubifs_lprops, list); | 822 | lprops = list_entry(c->freeable_list.next, struct ubifs_lprops, list); |
| 823 | ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); | 823 | ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); |
| 824 | ubifs_assert(!(lprops->flags & LPROPS_INDEX)); | 824 | ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); |
| 825 | ubifs_assert(lprops->free + lprops->dirty == c->leb_size); | 825 | ubifs_assert(c, lprops->free + lprops->dirty == c->leb_size); |
| 826 | ubifs_assert(c->freeable_cnt > 0); | 826 | ubifs_assert(c, c->freeable_cnt > 0); |
| 827 | return lprops; | 827 | return lprops; |
| 828 | } | 828 | } |
| 829 | 829 | ||
| @@ -838,15 +838,15 @@ const struct ubifs_lprops *ubifs_fast_find_frdi_idx(struct ubifs_info *c) | |||
| 838 | { | 838 | { |
| 839 | struct ubifs_lprops *lprops; | 839 | struct ubifs_lprops *lprops; |
| 840 | 840 | ||
| 841 | ubifs_assert(mutex_is_locked(&c->lp_mutex)); | 841 | ubifs_assert(c, mutex_is_locked(&c->lp_mutex)); |
| 842 | 842 | ||
| 843 | if (list_empty(&c->frdi_idx_list)) | 843 | if (list_empty(&c->frdi_idx_list)) |
| 844 | return NULL; | 844 | return NULL; |
| 845 | 845 | ||
| 846 | lprops = list_entry(c->frdi_idx_list.next, struct ubifs_lprops, list); | 846 | lprops = list_entry(c->frdi_idx_list.next, struct ubifs_lprops, list); |
| 847 | ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); | 847 | ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); |
| 848 | ubifs_assert((lprops->flags & LPROPS_INDEX)); | 848 | ubifs_assert(c, (lprops->flags & LPROPS_INDEX)); |
| 849 | ubifs_assert(lprops->free + lprops->dirty == c->leb_size); | 849 | ubifs_assert(c, lprops->free + lprops->dirty == c->leb_size); |
| 850 | return lprops; | 850 | return lprops; |
| 851 | } | 851 | } |
| 852 | 852 | ||
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 8e99dad18880..31393370e334 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
| @@ -225,21 +225,22 @@ static int calc_dflt_lpt_geom(struct ubifs_info *c, int *main_lebs, | |||
| 225 | 225 | ||
| 226 | /** | 226 | /** |
| 227 | * pack_bits - pack bit fields end-to-end. | 227 | * pack_bits - pack bit fields end-to-end. |
| 228 | * @c: UBIFS file-system description object | ||
| 228 | * @addr: address at which to pack (passed and next address returned) | 229 | * @addr: address at which to pack (passed and next address returned) |
| 229 | * @pos: bit position at which to pack (passed and next position returned) | 230 | * @pos: bit position at which to pack (passed and next position returned) |
| 230 | * @val: value to pack | 231 | * @val: value to pack |
| 231 | * @nrbits: number of bits of value to pack (1-32) | 232 | * @nrbits: number of bits of value to pack (1-32) |
| 232 | */ | 233 | */ |
| 233 | static void pack_bits(uint8_t **addr, int *pos, uint32_t val, int nrbits) | 234 | static void pack_bits(const struct ubifs_info *c, uint8_t **addr, int *pos, uint32_t val, int nrbits) |
| 234 | { | 235 | { |
| 235 | uint8_t *p = *addr; | 236 | uint8_t *p = *addr; |
| 236 | int b = *pos; | 237 | int b = *pos; |
| 237 | 238 | ||
| 238 | ubifs_assert(nrbits > 0); | 239 | ubifs_assert(c, nrbits > 0); |
| 239 | ubifs_assert(nrbits <= 32); | 240 | ubifs_assert(c, nrbits <= 32); |
| 240 | ubifs_assert(*pos >= 0); | 241 | ubifs_assert(c, *pos >= 0); |
| 241 | ubifs_assert(*pos < 8); | 242 | ubifs_assert(c, *pos < 8); |
| 242 | ubifs_assert((val >> nrbits) == 0 || nrbits == 32); | 243 | ubifs_assert(c, (val >> nrbits) == 0 || nrbits == 32); |
| 243 | if (b) { | 244 | if (b) { |
| 244 | *p |= ((uint8_t)val) << b; | 245 | *p |= ((uint8_t)val) << b; |
| 245 | nrbits += b; | 246 | nrbits += b; |
| @@ -274,13 +275,14 @@ static void pack_bits(uint8_t **addr, int *pos, uint32_t val, int nrbits) | |||
| 274 | 275 | ||
| 275 | /** | 276 | /** |
| 276 | * ubifs_unpack_bits - unpack bit fields. | 277 | * ubifs_unpack_bits - unpack bit fields. |
| 278 | * @c: UBIFS file-system description object | ||
| 277 | * @addr: address at which to unpack (passed and next address returned) | 279 | * @addr: address at which to unpack (passed and next address returned) |
| 278 | * @pos: bit position at which to unpack (passed and next position returned) | 280 | * @pos: bit position at which to unpack (passed and next position returned) |
| 279 | * @nrbits: number of bits of value to unpack (1-32) | 281 | * @nrbits: number of bits of value to unpack (1-32) |
| 280 | * | 282 | * |
| 281 | * This functions returns the value unpacked. | 283 | * This functions returns the value unpacked. |
| 282 | */ | 284 | */ |
| 283 | uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits) | 285 | uint32_t ubifs_unpack_bits(const struct ubifs_info *c, uint8_t **addr, int *pos, int nrbits) |
| 284 | { | 286 | { |
| 285 | const int k = 32 - nrbits; | 287 | const int k = 32 - nrbits; |
| 286 | uint8_t *p = *addr; | 288 | uint8_t *p = *addr; |
| @@ -288,10 +290,10 @@ uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits) | |||
| 288 | uint32_t uninitialized_var(val); | 290 | uint32_t uninitialized_var(val); |
| 289 | const int bytes = (nrbits + b + 7) >> 3; | 291 | const int bytes = (nrbits + b + 7) >> 3; |
| 290 | 292 | ||
| 291 | ubifs_assert(nrbits > 0); | 293 | ubifs_assert(c, nrbits > 0); |
| 292 | ubifs_assert(nrbits <= 32); | 294 | ubifs_assert(c, nrbits <= 32); |
| 293 | ubifs_assert(*pos >= 0); | 295 | ubifs_assert(c, *pos >= 0); |
| 294 | ubifs_assert(*pos < 8); | 296 | ubifs_assert(c, *pos < 8); |
| 295 | if (b) { | 297 | if (b) { |
| 296 | switch (bytes) { | 298 | switch (bytes) { |
| 297 | case 2: | 299 | case 2: |
| @@ -337,7 +339,7 @@ uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits) | |||
| 337 | p += nrbits >> 3; | 339 | p += nrbits >> 3; |
| 338 | *addr = p; | 340 | *addr = p; |
| 339 | *pos = b; | 341 | *pos = b; |
| 340 | ubifs_assert((val >> nrbits) == 0 || nrbits - b == 32); | 342 | ubifs_assert(c, (val >> nrbits) == 0 || nrbits - b == 32); |
| 341 | return val; | 343 | return val; |
| 342 | } | 344 | } |
| 343 | 345 | ||
| @@ -354,24 +356,24 @@ void ubifs_pack_pnode(struct ubifs_info *c, void *buf, | |||
| 354 | int i, pos = 0; | 356 | int i, pos = 0; |
| 355 | uint16_t crc; | 357 | uint16_t crc; |
| 356 | 358 | ||
| 357 | pack_bits(&addr, &pos, UBIFS_LPT_PNODE, UBIFS_LPT_TYPE_BITS); | 359 | pack_bits(c, &addr, &pos, UBIFS_LPT_PNODE, UBIFS_LPT_TYPE_BITS); |
| 358 | if (c->big_lpt) | 360 | if (c->big_lpt) |
| 359 | pack_bits(&addr, &pos, pnode->num, c->pcnt_bits); | 361 | pack_bits(c, &addr, &pos, pnode->num, c->pcnt_bits); |
| 360 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { | 362 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { |
| 361 | pack_bits(&addr, &pos, pnode->lprops[i].free >> 3, | 363 | pack_bits(c, &addr, &pos, pnode->lprops[i].free >> 3, |
| 362 | c->space_bits); | 364 | c->space_bits); |
| 363 | pack_bits(&addr, &pos, pnode->lprops[i].dirty >> 3, | 365 | pack_bits(c, &addr, &pos, pnode->lprops[i].dirty >> 3, |
| 364 | c->space_bits); | 366 | c->space_bits); |
| 365 | if (pnode->lprops[i].flags & LPROPS_INDEX) | 367 | if (pnode->lprops[i].flags & LPROPS_INDEX) |
| 366 | pack_bits(&addr, &pos, 1, 1); | 368 | pack_bits(c, &addr, &pos, 1, 1); |
| 367 | else | 369 | else |
| 368 | pack_bits(&addr, &pos, 0, 1); | 370 | pack_bits(c, &addr, &pos, 0, 1); |
| 369 | } | 371 | } |
| 370 | crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, | 372 | crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, |
| 371 | c->pnode_sz - UBIFS_LPT_CRC_BYTES); | 373 | c->pnode_sz - UBIFS_LPT_CRC_BYTES); |
| 372 | addr = buf; | 374 | addr = buf; |
| 373 | pos = 0; | 375 | pos = 0; |
| 374 | pack_bits(&addr, &pos, crc, UBIFS_LPT_CRC_BITS); | 376 | pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS); |
| 375 | } | 377 | } |
| 376 | 378 | ||
| 377 | /** | 379 | /** |
| @@ -387,23 +389,23 @@ void ubifs_pack_nnode(struct ubifs_info *c, void *buf, | |||
| 387 | int i, pos = 0; | 389 | int i, pos = 0; |
| 388 | uint16_t crc; | 390 | uint16_t crc; |
| 389 | 391 | ||
| 390 | pack_bits(&addr, &pos, UBIFS_LPT_NNODE, UBIFS_LPT_TYPE_BITS); | 392 | pack_bits(c, &addr, &pos, UBIFS_LPT_NNODE, UBIFS_LPT_TYPE_BITS); |
| 391 | if (c->big_lpt) | 393 | if (c->big_lpt) |
| 392 | pack_bits(&addr, &pos, nnode->num, c->pcnt_bits); | 394 | pack_bits(c, &addr, &pos, nnode->num, c->pcnt_bits); |
| 393 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { | 395 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { |
| 394 | int lnum = nnode->nbranch[i].lnum; | 396 | int lnum = nnode->nbranch[i].lnum; |
| 395 | 397 | ||
| 396 | if (lnum == 0) | 398 | if (lnum == 0) |
| 397 | lnum = c->lpt_last + 1; | 399 | lnum = c->lpt_last + 1; |
| 398 | pack_bits(&addr, &pos, lnum - c->lpt_first, c->lpt_lnum_bits); | 400 | pack_bits(c, &addr, &pos, lnum - c->lpt_first, c->lpt_lnum_bits); |
| 399 | pack_bits(&addr, &pos, nnode->nbranch[i].offs, | 401 | pack_bits(c, &addr, &pos, nnode->nbranch[i].offs, |
| 400 | c->lpt_offs_bits); | 402 | c->lpt_offs_bits); |
| 401 | } | 403 | } |
| 402 | crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, | 404 | crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, |
| 403 | c->nnode_sz - UBIFS_LPT_CRC_BYTES); | 405 | c->nnode_sz - UBIFS_LPT_CRC_BYTES); |
| 404 | addr = buf; | 406 | addr = buf; |
| 405 | pos = 0; | 407 | pos = 0; |
| 406 | pack_bits(&addr, &pos, crc, UBIFS_LPT_CRC_BITS); | 408 | pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS); |
| 407 | } | 409 | } |
| 408 | 410 | ||
| 409 | /** | 411 | /** |
| @@ -419,16 +421,16 @@ void ubifs_pack_ltab(struct ubifs_info *c, void *buf, | |||
| 419 | int i, pos = 0; | 421 | int i, pos = 0; |
| 420 | uint16_t crc; | 422 | uint16_t crc; |
| 421 | 423 | ||
| 422 | pack_bits(&addr, &pos, UBIFS_LPT_LTAB, UBIFS_LPT_TYPE_BITS); | 424 | pack_bits(c, &addr, &pos, UBIFS_LPT_LTAB, UBIFS_LPT_TYPE_BITS); |
| 423 | for (i = 0; i < c->lpt_lebs; i++) { | 425 | for (i = 0; i < c->lpt_lebs; i++) { |
| 424 | pack_bits(&addr, &pos, ltab[i].free, c->lpt_spc_bits); | 426 | pack_bits(c, &addr, &pos, ltab[i].free, c->lpt_spc_bits); |
| 425 | pack_bits(&addr, &pos, ltab[i].dirty, c->lpt_spc_bits); | 427 | pack_bits(c, &addr, &pos, ltab[i].dirty, c->lpt_spc_bits); |
| 426 | } | 428 | } |
| 427 | crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, | 429 | crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, |
| 428 | c->ltab_sz - UBIFS_LPT_CRC_BYTES); | 430 | c->ltab_sz - UBIFS_LPT_CRC_BYTES); |
| 429 | addr = buf; | 431 | addr = buf; |
| 430 | pos = 0; | 432 | pos = 0; |
| 431 | pack_bits(&addr, &pos, crc, UBIFS_LPT_CRC_BITS); | 433 | pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS); |
| 432 | } | 434 | } |
| 433 | 435 | ||
| 434 | /** | 436 | /** |
| @@ -443,14 +445,14 @@ void ubifs_pack_lsave(struct ubifs_info *c, void *buf, int *lsave) | |||
| 443 | int i, pos = 0; | 445 | int i, pos = 0; |
| 444 | uint16_t crc; | 446 | uint16_t crc; |
| 445 | 447 | ||
| 446 | pack_bits(&addr, &pos, UBIFS_LPT_LSAVE, UBIFS_LPT_TYPE_BITS); | 448 | pack_bits(c, &addr, &pos, UBIFS_LPT_LSAVE, UBIFS_LPT_TYPE_BITS); |
| 447 | for (i = 0; i < c->lsave_cnt; i++) | 449 | for (i = 0; i < c->lsave_cnt; i++) |
| 448 | pack_bits(&addr, &pos, lsave[i], c->lnum_bits); | 450 | pack_bits(c, &addr, &pos, lsave[i], c->lnum_bits); |
| 449 | crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, | 451 | crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, |
| 450 | c->lsave_sz - UBIFS_LPT_CRC_BYTES); | 452 | c->lsave_sz - UBIFS_LPT_CRC_BYTES); |
| 451 | addr = buf; | 453 | addr = buf; |
| 452 | pos = 0; | 454 | pos = 0; |
| 453 | pack_bits(&addr, &pos, crc, UBIFS_LPT_CRC_BITS); | 455 | pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS); |
| 454 | } | 456 | } |
| 455 | 457 | ||
| 456 | /** | 458 | /** |
| @@ -465,7 +467,7 @@ void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty) | |||
| 465 | return; | 467 | return; |
| 466 | dbg_lp("LEB %d add %d to %d", | 468 | dbg_lp("LEB %d add %d to %d", |
| 467 | lnum, dirty, c->ltab[lnum - c->lpt_first].dirty); | 469 | lnum, dirty, c->ltab[lnum - c->lpt_first].dirty); |
| 468 | ubifs_assert(lnum >= c->lpt_first && lnum <= c->lpt_last); | 470 | ubifs_assert(c, lnum >= c->lpt_first && lnum <= c->lpt_last); |
| 469 | c->ltab[lnum - c->lpt_first].dirty += dirty; | 471 | c->ltab[lnum - c->lpt_first].dirty += dirty; |
| 470 | } | 472 | } |
| 471 | 473 | ||
| @@ -481,7 +483,7 @@ static void set_ltab(struct ubifs_info *c, int lnum, int free, int dirty) | |||
| 481 | dbg_lp("LEB %d free %d dirty %d to %d %d", | 483 | dbg_lp("LEB %d free %d dirty %d to %d %d", |
| 482 | lnum, c->ltab[lnum - c->lpt_first].free, | 484 | lnum, c->ltab[lnum - c->lpt_first].free, |
| 483 | c->ltab[lnum - c->lpt_first].dirty, free, dirty); | 485 | c->ltab[lnum - c->lpt_first].dirty, free, dirty); |
| 484 | ubifs_assert(lnum >= c->lpt_first && lnum <= c->lpt_last); | 486 | ubifs_assert(c, lnum >= c->lpt_first && lnum <= c->lpt_last); |
| 485 | c->ltab[lnum - c->lpt_first].free = free; | 487 | c->ltab[lnum - c->lpt_first].free = free; |
| 486 | c->ltab[lnum - c->lpt_first].dirty = dirty; | 488 | c->ltab[lnum - c->lpt_first].dirty = dirty; |
| 487 | } | 489 | } |
| @@ -639,7 +641,7 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, | |||
| 639 | goto out; | 641 | goto out; |
| 640 | } | 642 | } |
| 641 | 643 | ||
| 642 | ubifs_assert(!c->ltab); | 644 | ubifs_assert(c, !c->ltab); |
| 643 | c->ltab = ltab; /* Needed by set_ltab */ | 645 | c->ltab = ltab; /* Needed by set_ltab */ |
| 644 | 646 | ||
| 645 | /* Initialize LPT's own lprops */ | 647 | /* Initialize LPT's own lprops */ |
| @@ -918,7 +920,7 @@ static int check_lpt_crc(const struct ubifs_info *c, void *buf, int len) | |||
| 918 | uint8_t *addr = buf; | 920 | uint8_t *addr = buf; |
| 919 | uint16_t crc, calc_crc; | 921 | uint16_t crc, calc_crc; |
| 920 | 922 | ||
| 921 | crc = ubifs_unpack_bits(&addr, &pos, UBIFS_LPT_CRC_BITS); | 923 | crc = ubifs_unpack_bits(c, &addr, &pos, UBIFS_LPT_CRC_BITS); |
| 922 | calc_crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, | 924 | calc_crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, |
| 923 | len - UBIFS_LPT_CRC_BYTES); | 925 | len - UBIFS_LPT_CRC_BYTES); |
| 924 | if (crc != calc_crc) { | 926 | if (crc != calc_crc) { |
| @@ -944,7 +946,7 @@ static int check_lpt_type(const struct ubifs_info *c, uint8_t **addr, | |||
| 944 | { | 946 | { |
| 945 | int node_type; | 947 | int node_type; |
| 946 | 948 | ||
| 947 | node_type = ubifs_unpack_bits(addr, pos, UBIFS_LPT_TYPE_BITS); | 949 | node_type = ubifs_unpack_bits(c, addr, pos, UBIFS_LPT_TYPE_BITS); |
| 948 | if (node_type != type) { | 950 | if (node_type != type) { |
| 949 | ubifs_err(c, "invalid type (%d) in LPT node type %d", | 951 | ubifs_err(c, "invalid type (%d) in LPT node type %d", |
| 950 | node_type, type); | 952 | node_type, type); |
| @@ -972,16 +974,16 @@ static int unpack_pnode(const struct ubifs_info *c, void *buf, | |||
| 972 | if (err) | 974 | if (err) |
| 973 | return err; | 975 | return err; |
| 974 | if (c->big_lpt) | 976 | if (c->big_lpt) |
| 975 | pnode->num = ubifs_unpack_bits(&addr, &pos, c->pcnt_bits); | 977 | pnode->num = ubifs_unpack_bits(c, &addr, &pos, c->pcnt_bits); |
| 976 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { | 978 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { |
| 977 | struct ubifs_lprops * const lprops = &pnode->lprops[i]; | 979 | struct ubifs_lprops * const lprops = &pnode->lprops[i]; |
| 978 | 980 | ||
| 979 | lprops->free = ubifs_unpack_bits(&addr, &pos, c->space_bits); | 981 | lprops->free = ubifs_unpack_bits(c, &addr, &pos, c->space_bits); |
| 980 | lprops->free <<= 3; | 982 | lprops->free <<= 3; |
| 981 | lprops->dirty = ubifs_unpack_bits(&addr, &pos, c->space_bits); | 983 | lprops->dirty = ubifs_unpack_bits(c, &addr, &pos, c->space_bits); |
| 982 | lprops->dirty <<= 3; | 984 | lprops->dirty <<= 3; |
| 983 | 985 | ||
| 984 | if (ubifs_unpack_bits(&addr, &pos, 1)) | 986 | if (ubifs_unpack_bits(c, &addr, &pos, 1)) |
| 985 | lprops->flags = LPROPS_INDEX; | 987 | lprops->flags = LPROPS_INDEX; |
| 986 | else | 988 | else |
| 987 | lprops->flags = 0; | 989 | lprops->flags = 0; |
| @@ -1009,16 +1011,16 @@ int ubifs_unpack_nnode(const struct ubifs_info *c, void *buf, | |||
| 1009 | if (err) | 1011 | if (err) |
| 1010 | return err; | 1012 | return err; |
| 1011 | if (c->big_lpt) | 1013 | if (c->big_lpt) |
| 1012 | nnode->num = ubifs_unpack_bits(&addr, &pos, c->pcnt_bits); | 1014 | nnode->num = ubifs_unpack_bits(c, &addr, &pos, c->pcnt_bits); |
| 1013 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { | 1015 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { |
| 1014 | int lnum; | 1016 | int lnum; |
| 1015 | 1017 | ||
| 1016 | lnum = ubifs_unpack_bits(&addr, &pos, c->lpt_lnum_bits) + | 1018 | lnum = ubifs_unpack_bits(c, &addr, &pos, c->lpt_lnum_bits) + |
| 1017 | c->lpt_first; | 1019 | c->lpt_first; |
| 1018 | if (lnum == c->lpt_last + 1) | 1020 | if (lnum == c->lpt_last + 1) |
| 1019 | lnum = 0; | 1021 | lnum = 0; |
| 1020 | nnode->nbranch[i].lnum = lnum; | 1022 | nnode->nbranch[i].lnum = lnum; |
| 1021 | nnode->nbranch[i].offs = ubifs_unpack_bits(&addr, &pos, | 1023 | nnode->nbranch[i].offs = ubifs_unpack_bits(c, &addr, &pos, |
| 1022 | c->lpt_offs_bits); | 1024 | c->lpt_offs_bits); |
| 1023 | } | 1025 | } |
| 1024 | err = check_lpt_crc(c, buf, c->nnode_sz); | 1026 | err = check_lpt_crc(c, buf, c->nnode_sz); |
| @@ -1041,8 +1043,8 @@ static int unpack_ltab(const struct ubifs_info *c, void *buf) | |||
| 1041 | if (err) | 1043 | if (err) |
| 1042 | return err; | 1044 | return err; |
| 1043 | for (i = 0; i < c->lpt_lebs; i++) { | 1045 | for (i = 0; i < c->lpt_lebs; i++) { |
| 1044 | int free = ubifs_unpack_bits(&addr, &pos, c->lpt_spc_bits); | 1046 | int free = ubifs_unpack_bits(c, &addr, &pos, c->lpt_spc_bits); |
| 1045 | int dirty = ubifs_unpack_bits(&addr, &pos, c->lpt_spc_bits); | 1047 | int dirty = ubifs_unpack_bits(c, &addr, &pos, c->lpt_spc_bits); |
| 1046 | 1048 | ||
| 1047 | if (free < 0 || free > c->leb_size || dirty < 0 || | 1049 | if (free < 0 || free > c->leb_size || dirty < 0 || |
| 1048 | dirty > c->leb_size || free + dirty > c->leb_size) | 1050 | dirty > c->leb_size || free + dirty > c->leb_size) |
| @@ -1073,7 +1075,7 @@ static int unpack_lsave(const struct ubifs_info *c, void *buf) | |||
| 1073 | if (err) | 1075 | if (err) |
| 1074 | return err; | 1076 | return err; |
| 1075 | for (i = 0; i < c->lsave_cnt; i++) { | 1077 | for (i = 0; i < c->lsave_cnt; i++) { |
| 1076 | int lnum = ubifs_unpack_bits(&addr, &pos, c->lnum_bits); | 1078 | int lnum = ubifs_unpack_bits(c, &addr, &pos, c->lnum_bits); |
| 1077 | 1079 | ||
| 1078 | if (lnum < c->main_first || lnum >= c->leb_cnt) | 1080 | if (lnum < c->main_first || lnum >= c->leb_cnt) |
| 1079 | return -EINVAL; | 1081 | return -EINVAL; |
| @@ -1515,7 +1517,7 @@ static struct ubifs_nnode *dirty_cow_nnode(struct ubifs_info *c, | |||
| 1515 | branch->cnode->parent = n; | 1517 | branch->cnode->parent = n; |
| 1516 | } | 1518 | } |
| 1517 | 1519 | ||
| 1518 | ubifs_assert(!test_bit(OBSOLETE_CNODE, &nnode->flags)); | 1520 | ubifs_assert(c, !test_bit(OBSOLETE_CNODE, &nnode->flags)); |
| 1519 | __set_bit(OBSOLETE_CNODE, &nnode->flags); | 1521 | __set_bit(OBSOLETE_CNODE, &nnode->flags); |
| 1520 | 1522 | ||
| 1521 | c->dirty_nn_cnt += 1; | 1523 | c->dirty_nn_cnt += 1; |
| @@ -1558,7 +1560,7 @@ static struct ubifs_pnode *dirty_cow_pnode(struct ubifs_info *c, | |||
| 1558 | __clear_bit(COW_CNODE, &p->flags); | 1560 | __clear_bit(COW_CNODE, &p->flags); |
| 1559 | replace_cats(c, pnode, p); | 1561 | replace_cats(c, pnode, p); |
| 1560 | 1562 | ||
| 1561 | ubifs_assert(!test_bit(OBSOLETE_CNODE, &pnode->flags)); | 1563 | ubifs_assert(c, !test_bit(OBSOLETE_CNODE, &pnode->flags)); |
| 1562 | __set_bit(OBSOLETE_CNODE, &pnode->flags); | 1564 | __set_bit(OBSOLETE_CNODE, &pnode->flags); |
| 1563 | 1565 | ||
| 1564 | c->dirty_pn_cnt += 1; | 1566 | c->dirty_pn_cnt += 1; |
| @@ -1613,7 +1615,7 @@ struct ubifs_lprops *ubifs_lpt_lookup_dirty(struct ubifs_info *c, int lnum) | |||
| 1613 | dbg_lp("LEB %d, free %d, dirty %d, flags %d", lnum, | 1615 | dbg_lp("LEB %d, free %d, dirty %d, flags %d", lnum, |
| 1614 | pnode->lprops[iip].free, pnode->lprops[iip].dirty, | 1616 | pnode->lprops[iip].free, pnode->lprops[iip].dirty, |
| 1615 | pnode->lprops[iip].flags); | 1617 | pnode->lprops[iip].flags); |
| 1616 | ubifs_assert(test_bit(DIRTY_CNODE, &pnode->flags)); | 1618 | ubifs_assert(c, test_bit(DIRTY_CNODE, &pnode->flags)); |
| 1617 | return &pnode->lprops[iip]; | 1619 | return &pnode->lprops[iip]; |
| 1618 | } | 1620 | } |
| 1619 | 1621 | ||
| @@ -1889,9 +1891,9 @@ static struct ubifs_pnode *scan_get_pnode(struct ubifs_info *c, | |||
| 1889 | lprops->flags = ubifs_categorize_lprops(c, lprops); | 1891 | lprops->flags = ubifs_categorize_lprops(c, lprops); |
| 1890 | } | 1892 | } |
| 1891 | } else { | 1893 | } else { |
| 1892 | ubifs_assert(branch->lnum >= c->lpt_first && | 1894 | ubifs_assert(c, branch->lnum >= c->lpt_first && |
| 1893 | branch->lnum <= c->lpt_last); | 1895 | branch->lnum <= c->lpt_last); |
| 1894 | ubifs_assert(branch->offs >= 0 && branch->offs < c->leb_size); | 1896 | ubifs_assert(c, branch->offs >= 0 && branch->offs < c->leb_size); |
| 1895 | err = ubifs_leb_read(c, branch->lnum, buf, branch->offs, | 1897 | err = ubifs_leb_read(c, branch->lnum, buf, branch->offs, |
| 1896 | c->pnode_sz, 1); | 1898 | c->pnode_sz, 1); |
| 1897 | if (err) | 1899 | if (err) |
| @@ -1935,8 +1937,8 @@ int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum, | |||
| 1935 | start_lnum = c->main_first; | 1937 | start_lnum = c->main_first; |
| 1936 | } | 1938 | } |
| 1937 | 1939 | ||
| 1938 | ubifs_assert(start_lnum >= c->main_first && start_lnum < c->leb_cnt); | 1940 | ubifs_assert(c, start_lnum >= c->main_first && start_lnum < c->leb_cnt); |
| 1939 | ubifs_assert(end_lnum >= c->main_first && end_lnum < c->leb_cnt); | 1941 | ubifs_assert(c, end_lnum >= c->main_first && end_lnum < c->leb_cnt); |
| 1940 | 1942 | ||
| 1941 | if (!c->nroot) { | 1943 | if (!c->nroot) { |
| 1942 | err = ubifs_read_nnode(c, NULL, 0); | 1944 | err = ubifs_read_nnode(c, NULL, 0); |
| @@ -2055,7 +2057,7 @@ again: | |||
| 2055 | iip = pnode->iip; | 2057 | iip = pnode->iip; |
| 2056 | while (1) { | 2058 | while (1) { |
| 2057 | h -= 1; | 2059 | h -= 1; |
| 2058 | ubifs_assert(h >= 0); | 2060 | ubifs_assert(c, h >= 0); |
| 2059 | nnode = path[h].ptr.nnode; | 2061 | nnode = path[h].ptr.nnode; |
| 2060 | if (iip + 1 < UBIFS_LPT_FANOUT) | 2062 | if (iip + 1 < UBIFS_LPT_FANOUT) |
| 2061 | break; | 2063 | break; |
| @@ -2234,7 +2236,7 @@ int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode, | |||
| 2234 | return 0; | 2236 | return 0; |
| 2235 | 2237 | ||
| 2236 | while (cnode) { | 2238 | while (cnode) { |
| 2237 | ubifs_assert(row >= 0); | 2239 | ubifs_assert(c, row >= 0); |
| 2238 | nnode = cnode->parent; | 2240 | nnode = cnode->parent; |
| 2239 | if (cnode->level) { | 2241 | if (cnode->level) { |
| 2240 | /* cnode is a nnode */ | 2242 | /* cnode is a nnode */ |
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index 78da65b2fb85..7ce30994bbba 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c | |||
| @@ -34,13 +34,14 @@ static int dbg_populate_lsave(struct ubifs_info *c); | |||
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | * first_dirty_cnode - find first dirty cnode. | 36 | * first_dirty_cnode - find first dirty cnode. |
| 37 | * @c: UBIFS file-system description object | ||
| 37 | * @nnode: nnode at which to start | 38 | * @nnode: nnode at which to start |
| 38 | * | 39 | * |
| 39 | * This function returns the first dirty cnode or %NULL if there is not one. | 40 | * This function returns the first dirty cnode or %NULL if there is not one. |
| 40 | */ | 41 | */ |
| 41 | static struct ubifs_cnode *first_dirty_cnode(struct ubifs_nnode *nnode) | 42 | static struct ubifs_cnode *first_dirty_cnode(const struct ubifs_info *c, struct ubifs_nnode *nnode) |
| 42 | { | 43 | { |
| 43 | ubifs_assert(nnode); | 44 | ubifs_assert(c, nnode); |
| 44 | while (1) { | 45 | while (1) { |
| 45 | int i, cont = 0; | 46 | int i, cont = 0; |
| 46 | 47 | ||
| @@ -64,16 +65,17 @@ static struct ubifs_cnode *first_dirty_cnode(struct ubifs_nnode *nnode) | |||
| 64 | 65 | ||
| 65 | /** | 66 | /** |
| 66 | * next_dirty_cnode - find next dirty cnode. | 67 | * next_dirty_cnode - find next dirty cnode. |
| 68 | * @c: UBIFS file-system description object | ||
| 67 | * @cnode: cnode from which to begin searching | 69 | * @cnode: cnode from which to begin searching |
| 68 | * | 70 | * |
| 69 | * This function returns the next dirty cnode or %NULL if there is not one. | 71 | * This function returns the next dirty cnode or %NULL if there is not one. |
| 70 | */ | 72 | */ |
| 71 | static struct ubifs_cnode *next_dirty_cnode(struct ubifs_cnode *cnode) | 73 | static struct ubifs_cnode *next_dirty_cnode(const struct ubifs_info *c, struct ubifs_cnode *cnode) |
| 72 | { | 74 | { |
| 73 | struct ubifs_nnode *nnode; | 75 | struct ubifs_nnode *nnode; |
| 74 | int i; | 76 | int i; |
| 75 | 77 | ||
| 76 | ubifs_assert(cnode); | 78 | ubifs_assert(c, cnode); |
| 77 | nnode = cnode->parent; | 79 | nnode = cnode->parent; |
| 78 | if (!nnode) | 80 | if (!nnode) |
| 79 | return NULL; | 81 | return NULL; |
| @@ -83,7 +85,7 @@ static struct ubifs_cnode *next_dirty_cnode(struct ubifs_cnode *cnode) | |||
| 83 | if (cnode->level == 0) | 85 | if (cnode->level == 0) |
| 84 | return cnode; /* cnode is a pnode */ | 86 | return cnode; /* cnode is a pnode */ |
| 85 | /* cnode is a nnode */ | 87 | /* cnode is a nnode */ |
| 86 | return first_dirty_cnode((struct ubifs_nnode *)cnode); | 88 | return first_dirty_cnode(c, (struct ubifs_nnode *)cnode); |
| 87 | } | 89 | } |
| 88 | } | 90 | } |
| 89 | return (struct ubifs_cnode *)nnode; | 91 | return (struct ubifs_cnode *)nnode; |
| @@ -106,15 +108,15 @@ static int get_cnodes_to_commit(struct ubifs_info *c) | |||
| 106 | if (!test_bit(DIRTY_CNODE, &c->nroot->flags)) | 108 | if (!test_bit(DIRTY_CNODE, &c->nroot->flags)) |
| 107 | return 0; | 109 | return 0; |
| 108 | 110 | ||
| 109 | c->lpt_cnext = first_dirty_cnode(c->nroot); | 111 | c->lpt_cnext = first_dirty_cnode(c, c->nroot); |
| 110 | cnode = c->lpt_cnext; | 112 | cnode = c->lpt_cnext; |
| 111 | if (!cnode) | 113 | if (!cnode) |
| 112 | return 0; | 114 | return 0; |
| 113 | cnt += 1; | 115 | cnt += 1; |
| 114 | while (1) { | 116 | while (1) { |
| 115 | ubifs_assert(!test_bit(COW_CNODE, &cnode->flags)); | 117 | ubifs_assert(c, !test_bit(COW_CNODE, &cnode->flags)); |
| 116 | __set_bit(COW_CNODE, &cnode->flags); | 118 | __set_bit(COW_CNODE, &cnode->flags); |
| 117 | cnext = next_dirty_cnode(cnode); | 119 | cnext = next_dirty_cnode(c, cnode); |
| 118 | if (!cnext) { | 120 | if (!cnext) { |
| 119 | cnode->cnext = c->lpt_cnext; | 121 | cnode->cnext = c->lpt_cnext; |
| 120 | break; | 122 | break; |
| @@ -125,7 +127,7 @@ static int get_cnodes_to_commit(struct ubifs_info *c) | |||
| 125 | } | 127 | } |
| 126 | dbg_cmt("committing %d cnodes", cnt); | 128 | dbg_cmt("committing %d cnodes", cnt); |
| 127 | dbg_lp("committing %d cnodes", cnt); | 129 | dbg_lp("committing %d cnodes", cnt); |
| 128 | ubifs_assert(cnt == c->dirty_nn_cnt + c->dirty_pn_cnt); | 130 | ubifs_assert(c, cnt == c->dirty_nn_cnt + c->dirty_pn_cnt); |
| 129 | return cnt; | 131 | return cnt; |
| 130 | } | 132 | } |
| 131 | 133 | ||
| @@ -141,7 +143,7 @@ static void upd_ltab(struct ubifs_info *c, int lnum, int free, int dirty) | |||
| 141 | dbg_lp("LEB %d free %d dirty %d to %d +%d", | 143 | dbg_lp("LEB %d free %d dirty %d to %d +%d", |
| 142 | lnum, c->ltab[lnum - c->lpt_first].free, | 144 | lnum, c->ltab[lnum - c->lpt_first].free, |
| 143 | c->ltab[lnum - c->lpt_first].dirty, free, dirty); | 145 | c->ltab[lnum - c->lpt_first].dirty, free, dirty); |
| 144 | ubifs_assert(lnum >= c->lpt_first && lnum <= c->lpt_last); | 146 | ubifs_assert(c, lnum >= c->lpt_first && lnum <= c->lpt_last); |
| 145 | c->ltab[lnum - c->lpt_first].free = free; | 147 | c->ltab[lnum - c->lpt_first].free = free; |
| 146 | c->ltab[lnum - c->lpt_first].dirty += dirty; | 148 | c->ltab[lnum - c->lpt_first].dirty += dirty; |
| 147 | } | 149 | } |
| @@ -237,7 +239,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 237 | if (err) | 239 | if (err) |
| 238 | goto no_space; | 240 | goto no_space; |
| 239 | offs = 0; | 241 | offs = 0; |
| 240 | ubifs_assert(lnum >= c->lpt_first && | 242 | ubifs_assert(c, lnum >= c->lpt_first && |
| 241 | lnum <= c->lpt_last); | 243 | lnum <= c->lpt_last); |
| 242 | /* Try to place lsave and ltab nicely */ | 244 | /* Try to place lsave and ltab nicely */ |
| 243 | if (!done_lsave) { | 245 | if (!done_lsave) { |
| @@ -280,7 +282,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 280 | if (err) | 282 | if (err) |
| 281 | goto no_space; | 283 | goto no_space; |
| 282 | offs = 0; | 284 | offs = 0; |
| 283 | ubifs_assert(lnum >= c->lpt_first && | 285 | ubifs_assert(c, lnum >= c->lpt_first && |
| 284 | lnum <= c->lpt_last); | 286 | lnum <= c->lpt_last); |
| 285 | } | 287 | } |
| 286 | done_lsave = 1; | 288 | done_lsave = 1; |
| @@ -300,7 +302,7 @@ static int layout_cnodes(struct ubifs_info *c) | |||
| 300 | if (err) | 302 | if (err) |
| 301 | goto no_space; | 303 | goto no_space; |
| 302 | offs = 0; | 304 | offs = 0; |
| 303 | ubifs_assert(lnum >= c->lpt_first && | 305 | ubifs_assert(c, lnum >= c->lpt_first && |
| 304 | lnum <= c->lpt_last); | 306 | lnum <= c->lpt_last); |
| 305 | } | 307 | } |
| 306 | c->ltab_lnum = lnum; | 308 | c->ltab_lnum = lnum; |
| @@ -423,7 +425,7 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 423 | if (err) | 425 | if (err) |
| 424 | goto no_space; | 426 | goto no_space; |
| 425 | offs = from = 0; | 427 | offs = from = 0; |
| 426 | ubifs_assert(lnum >= c->lpt_first && | 428 | ubifs_assert(c, lnum >= c->lpt_first && |
| 427 | lnum <= c->lpt_last); | 429 | lnum <= c->lpt_last); |
| 428 | err = ubifs_leb_unmap(c, lnum); | 430 | err = ubifs_leb_unmap(c, lnum); |
| 429 | if (err) | 431 | if (err) |
| @@ -480,7 +482,7 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 480 | if (err) | 482 | if (err) |
| 481 | goto no_space; | 483 | goto no_space; |
| 482 | offs = from = 0; | 484 | offs = from = 0; |
| 483 | ubifs_assert(lnum >= c->lpt_first && | 485 | ubifs_assert(c, lnum >= c->lpt_first && |
| 484 | lnum <= c->lpt_last); | 486 | lnum <= c->lpt_last); |
| 485 | err = ubifs_leb_unmap(c, lnum); | 487 | err = ubifs_leb_unmap(c, lnum); |
| 486 | if (err) | 488 | if (err) |
| @@ -506,7 +508,7 @@ static int write_cnodes(struct ubifs_info *c) | |||
| 506 | if (err) | 508 | if (err) |
| 507 | goto no_space; | 509 | goto no_space; |
| 508 | offs = from = 0; | 510 | offs = from = 0; |
| 509 | ubifs_assert(lnum >= c->lpt_first && | 511 | ubifs_assert(c, lnum >= c->lpt_first && |
| 510 | lnum <= c->lpt_last); | 512 | lnum <= c->lpt_last); |
| 511 | err = ubifs_leb_unmap(c, lnum); | 513 | err = ubifs_leb_unmap(c, lnum); |
| 512 | if (err) | 514 | if (err) |
| @@ -806,7 +808,7 @@ static void populate_lsave(struct ubifs_info *c) | |||
| 806 | struct ubifs_lpt_heap *heap; | 808 | struct ubifs_lpt_heap *heap; |
| 807 | int i, cnt = 0; | 809 | int i, cnt = 0; |
| 808 | 810 | ||
| 809 | ubifs_assert(c->big_lpt); | 811 | ubifs_assert(c, c->big_lpt); |
| 810 | if (!(c->lpt_drty_flgs & LSAVE_DIRTY)) { | 812 | if (!(c->lpt_drty_flgs & LSAVE_DIRTY)) { |
| 811 | c->lpt_drty_flgs |= LSAVE_DIRTY; | 813 | c->lpt_drty_flgs |= LSAVE_DIRTY; |
| 812 | ubifs_add_lpt_dirt(c, c->lsave_lnum, c->lsave_sz); | 814 | ubifs_add_lpt_dirt(c, c->lsave_lnum, c->lsave_sz); |
| @@ -1095,8 +1097,8 @@ static int get_lpt_node_type(const struct ubifs_info *c, uint8_t *buf, | |||
| 1095 | uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES; | 1097 | uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES; |
| 1096 | int pos = 0, node_type; | 1098 | int pos = 0, node_type; |
| 1097 | 1099 | ||
| 1098 | node_type = ubifs_unpack_bits(&addr, &pos, UBIFS_LPT_TYPE_BITS); | 1100 | node_type = ubifs_unpack_bits(c, &addr, &pos, UBIFS_LPT_TYPE_BITS); |
| 1099 | *node_num = ubifs_unpack_bits(&addr, &pos, c->pcnt_bits); | 1101 | *node_num = ubifs_unpack_bits(c, &addr, &pos, c->pcnt_bits); |
| 1100 | return node_type; | 1102 | return node_type; |
| 1101 | } | 1103 | } |
| 1102 | 1104 | ||
| @@ -1116,7 +1118,7 @@ static int is_a_node(const struct ubifs_info *c, uint8_t *buf, int len) | |||
| 1116 | 1118 | ||
| 1117 | if (len < UBIFS_LPT_CRC_BYTES + (UBIFS_LPT_TYPE_BITS + 7) / 8) | 1119 | if (len < UBIFS_LPT_CRC_BYTES + (UBIFS_LPT_TYPE_BITS + 7) / 8) |
| 1118 | return 0; | 1120 | return 0; |
| 1119 | node_type = ubifs_unpack_bits(&addr, &pos, UBIFS_LPT_TYPE_BITS); | 1121 | node_type = ubifs_unpack_bits(c, &addr, &pos, UBIFS_LPT_TYPE_BITS); |
| 1120 | if (node_type == UBIFS_LPT_NOT_A_NODE) | 1122 | if (node_type == UBIFS_LPT_NOT_A_NODE) |
| 1121 | return 0; | 1123 | return 0; |
| 1122 | node_len = get_lpt_node_len(c, node_type); | 1124 | node_len = get_lpt_node_len(c, node_type); |
| @@ -1124,7 +1126,7 @@ static int is_a_node(const struct ubifs_info *c, uint8_t *buf, int len) | |||
| 1124 | return 0; | 1126 | return 0; |
| 1125 | pos = 0; | 1127 | pos = 0; |
| 1126 | addr = buf; | 1128 | addr = buf; |
| 1127 | crc = ubifs_unpack_bits(&addr, &pos, UBIFS_LPT_CRC_BITS); | 1129 | crc = ubifs_unpack_bits(c, &addr, &pos, UBIFS_LPT_CRC_BITS); |
| 1128 | calc_crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, | 1130 | calc_crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, |
| 1129 | node_len - UBIFS_LPT_CRC_BYTES); | 1131 | node_len - UBIFS_LPT_CRC_BYTES); |
| 1130 | if (crc != calc_crc) | 1132 | if (crc != calc_crc) |
| @@ -1170,7 +1172,7 @@ static int lpt_gc_lnum(struct ubifs_info *c, int lnum) | |||
| 1170 | node_type = get_lpt_node_type(c, buf, &node_num); | 1172 | node_type = get_lpt_node_type(c, buf, &node_num); |
| 1171 | node_len = get_lpt_node_len(c, node_type); | 1173 | node_len = get_lpt_node_len(c, node_type); |
| 1172 | offs = c->leb_size - len; | 1174 | offs = c->leb_size - len; |
| 1173 | ubifs_assert(node_len != 0); | 1175 | ubifs_assert(c, node_len != 0); |
| 1174 | mutex_lock(&c->lp_mutex); | 1176 | mutex_lock(&c->lp_mutex); |
| 1175 | err = make_node_dirty(c, node_type, node_num, lnum, offs); | 1177 | err = make_node_dirty(c, node_type, node_num, lnum, offs); |
| 1176 | mutex_unlock(&c->lp_mutex); | 1178 | mutex_unlock(&c->lp_mutex); |
| @@ -1195,7 +1197,7 @@ static int lpt_gc(struct ubifs_info *c) | |||
| 1195 | 1197 | ||
| 1196 | mutex_lock(&c->lp_mutex); | 1198 | mutex_lock(&c->lp_mutex); |
| 1197 | for (i = 0; i < c->lpt_lebs; i++) { | 1199 | for (i = 0; i < c->lpt_lebs; i++) { |
| 1198 | ubifs_assert(!c->ltab[i].tgc); | 1200 | ubifs_assert(c, !c->ltab[i].tgc); |
| 1199 | if (i + c->lpt_first == c->nhead_lnum || | 1201 | if (i + c->lpt_first == c->nhead_lnum || |
| 1200 | c->ltab[i].free + c->ltab[i].dirty == c->leb_size) | 1202 | c->ltab[i].free + c->ltab[i].dirty == c->leb_size) |
| 1201 | continue; | 1203 | continue; |
| @@ -1271,7 +1273,7 @@ int ubifs_lpt_start_commit(struct ubifs_info *c) | |||
| 1271 | populate_lsave(c); | 1273 | populate_lsave(c); |
| 1272 | 1274 | ||
| 1273 | cnt = get_cnodes_to_commit(c); | 1275 | cnt = get_cnodes_to_commit(c); |
| 1274 | ubifs_assert(cnt != 0); | 1276 | ubifs_assert(c, cnt != 0); |
| 1275 | 1277 | ||
| 1276 | err = layout_cnodes(c); | 1278 | err = layout_cnodes(c); |
| 1277 | if (err) | 1279 | if (err) |
diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c index c6a5e39e2ba5..9df4a41bba52 100644 --- a/fs/ubifs/master.c +++ b/fs/ubifs/master.c | |||
| @@ -360,7 +360,7 @@ int ubifs_write_master(struct ubifs_info *c) | |||
| 360 | { | 360 | { |
| 361 | int err, lnum, offs, len; | 361 | int err, lnum, offs, len; |
| 362 | 362 | ||
| 363 | ubifs_assert(!c->ro_media && !c->ro_mount); | 363 | ubifs_assert(c, !c->ro_media && !c->ro_mount); |
| 364 | if (c->ro_error) | 364 | if (c->ro_error) |
| 365 | return -EROFS; | 365 | return -EROFS; |
| 366 | 366 | ||
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h index caf83d68fb38..f5d180c0c52e 100644 --- a/fs/ubifs/misc.h +++ b/fs/ubifs/misc.h | |||
| @@ -105,25 +105,27 @@ static inline struct ubifs_inode *ubifs_inode(const struct inode *inode) | |||
| 105 | /** | 105 | /** |
| 106 | * ubifs_compr_present - check if compressor was compiled in. | 106 | * ubifs_compr_present - check if compressor was compiled in. |
| 107 | * @compr_type: compressor type to check | 107 | * @compr_type: compressor type to check |
| 108 | * @c: the UBIFS file-system description object | ||
| 108 | * | 109 | * |
| 109 | * This function returns %1 of compressor of type @compr_type is present, and | 110 | * This function returns %1 of compressor of type @compr_type is present, and |
| 110 | * %0 if not. | 111 | * %0 if not. |
| 111 | */ | 112 | */ |
| 112 | static inline int ubifs_compr_present(int compr_type) | 113 | static inline int ubifs_compr_present(struct ubifs_info *c, int compr_type) |
| 113 | { | 114 | { |
| 114 | ubifs_assert(compr_type >= 0 && compr_type < UBIFS_COMPR_TYPES_CNT); | 115 | ubifs_assert(c, compr_type >= 0 && compr_type < UBIFS_COMPR_TYPES_CNT); |
| 115 | return !!ubifs_compressors[compr_type]->capi_name; | 116 | return !!ubifs_compressors[compr_type]->capi_name; |
| 116 | } | 117 | } |
| 117 | 118 | ||
| 118 | /** | 119 | /** |
| 119 | * ubifs_compr_name - get compressor name string by its type. | 120 | * ubifs_compr_name - get compressor name string by its type. |
| 120 | * @compr_type: compressor type | 121 | * @compr_type: compressor type |
| 122 | * @c: the UBIFS file-system description object | ||
| 121 | * | 123 | * |
| 122 | * This function returns compressor type string. | 124 | * This function returns compressor type string. |
| 123 | */ | 125 | */ |
| 124 | static inline const char *ubifs_compr_name(int compr_type) | 126 | static inline const char *ubifs_compr_name(struct ubifs_info *c, int compr_type) |
| 125 | { | 127 | { |
| 126 | ubifs_assert(compr_type >= 0 && compr_type < UBIFS_COMPR_TYPES_CNT); | 128 | ubifs_assert(c, compr_type >= 0 && compr_type < UBIFS_COMPR_TYPES_CNT); |
| 127 | return ubifs_compressors[compr_type]->name; | 129 | return ubifs_compressors[compr_type]->name; |
| 128 | } | 130 | } |
| 129 | 131 | ||
| @@ -262,8 +264,8 @@ static inline void ubifs_get_lprops(struct ubifs_info *c) | |||
| 262 | */ | 264 | */ |
| 263 | static inline void ubifs_release_lprops(struct ubifs_info *c) | 265 | static inline void ubifs_release_lprops(struct ubifs_info *c) |
| 264 | { | 266 | { |
| 265 | ubifs_assert(mutex_is_locked(&c->lp_mutex)); | 267 | ubifs_assert(c, mutex_is_locked(&c->lp_mutex)); |
| 266 | ubifs_assert(c->lst.empty_lebs >= 0 && | 268 | ubifs_assert(c, c->lst.empty_lebs >= 0 && |
| 267 | c->lst.empty_lebs <= c->main_lebs); | 269 | c->lst.empty_lebs <= c->main_lebs); |
| 268 | mutex_unlock(&c->lp_mutex); | 270 | mutex_unlock(&c->lp_mutex); |
| 269 | } | 271 | } |
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c index caf2d123e9ee..8f70494efb0c 100644 --- a/fs/ubifs/orphan.c +++ b/fs/ubifs/orphan.c | |||
| @@ -172,8 +172,8 @@ int ubifs_orphan_start_commit(struct ubifs_info *c) | |||
| 172 | spin_lock(&c->orphan_lock); | 172 | spin_lock(&c->orphan_lock); |
| 173 | last = &c->orph_cnext; | 173 | last = &c->orph_cnext; |
| 174 | list_for_each_entry(orphan, &c->orph_new, new_list) { | 174 | list_for_each_entry(orphan, &c->orph_new, new_list) { |
| 175 | ubifs_assert(orphan->new); | 175 | ubifs_assert(c, orphan->new); |
| 176 | ubifs_assert(!orphan->cmt); | 176 | ubifs_assert(c, !orphan->cmt); |
| 177 | orphan->new = 0; | 177 | orphan->new = 0; |
| 178 | orphan->cmt = 1; | 178 | orphan->cmt = 1; |
| 179 | *last = orphan; | 179 | *last = orphan; |
| @@ -244,7 +244,7 @@ static int do_write_orph_node(struct ubifs_info *c, int len, int atomic) | |||
| 244 | int err = 0; | 244 | int err = 0; |
| 245 | 245 | ||
| 246 | if (atomic) { | 246 | if (atomic) { |
| 247 | ubifs_assert(c->ohead_offs == 0); | 247 | ubifs_assert(c, c->ohead_offs == 0); |
| 248 | ubifs_prepare_node(c, c->orph_buf, len, 1); | 248 | ubifs_prepare_node(c, c->orph_buf, len, 1); |
| 249 | len = ALIGN(len, c->min_io_size); | 249 | len = ALIGN(len, c->min_io_size); |
| 250 | err = ubifs_leb_change(c, c->ohead_lnum, c->orph_buf, len); | 250 | err = ubifs_leb_change(c, c->ohead_lnum, c->orph_buf, len); |
| @@ -276,7 +276,7 @@ static int write_orph_node(struct ubifs_info *c, int atomic) | |||
| 276 | struct ubifs_orph_node *orph; | 276 | struct ubifs_orph_node *orph; |
| 277 | int gap, err, len, cnt, i; | 277 | int gap, err, len, cnt, i; |
| 278 | 278 | ||
| 279 | ubifs_assert(c->cmt_orphans > 0); | 279 | ubifs_assert(c, c->cmt_orphans > 0); |
| 280 | gap = c->leb_size - c->ohead_offs; | 280 | gap = c->leb_size - c->ohead_offs; |
| 281 | if (gap < UBIFS_ORPH_NODE_SZ + sizeof(__le64)) { | 281 | if (gap < UBIFS_ORPH_NODE_SZ + sizeof(__le64)) { |
| 282 | c->ohead_lnum += 1; | 282 | c->ohead_lnum += 1; |
| @@ -295,14 +295,14 @@ static int write_orph_node(struct ubifs_info *c, int atomic) | |||
| 295 | if (cnt > c->cmt_orphans) | 295 | if (cnt > c->cmt_orphans) |
| 296 | cnt = c->cmt_orphans; | 296 | cnt = c->cmt_orphans; |
| 297 | len = UBIFS_ORPH_NODE_SZ + cnt * sizeof(__le64); | 297 | len = UBIFS_ORPH_NODE_SZ + cnt * sizeof(__le64); |
| 298 | ubifs_assert(c->orph_buf); | 298 | ubifs_assert(c, c->orph_buf); |
| 299 | orph = c->orph_buf; | 299 | orph = c->orph_buf; |
| 300 | orph->ch.node_type = UBIFS_ORPH_NODE; | 300 | orph->ch.node_type = UBIFS_ORPH_NODE; |
| 301 | spin_lock(&c->orphan_lock); | 301 | spin_lock(&c->orphan_lock); |
| 302 | cnext = c->orph_cnext; | 302 | cnext = c->orph_cnext; |
| 303 | for (i = 0; i < cnt; i++) { | 303 | for (i = 0; i < cnt; i++) { |
| 304 | orphan = cnext; | 304 | orphan = cnext; |
| 305 | ubifs_assert(orphan->cmt); | 305 | ubifs_assert(c, orphan->cmt); |
| 306 | orph->inos[i] = cpu_to_le64(orphan->inum); | 306 | orph->inos[i] = cpu_to_le64(orphan->inum); |
| 307 | orphan->cmt = 0; | 307 | orphan->cmt = 0; |
| 308 | cnext = orphan->cnext; | 308 | cnext = orphan->cnext; |
| @@ -316,9 +316,9 @@ static int write_orph_node(struct ubifs_info *c, int atomic) | |||
| 316 | else | 316 | else |
| 317 | /* Mark the last node of the commit */ | 317 | /* Mark the last node of the commit */ |
| 318 | orph->cmt_no = cpu_to_le64((c->cmt_no) | (1ULL << 63)); | 318 | orph->cmt_no = cpu_to_le64((c->cmt_no) | (1ULL << 63)); |
| 319 | ubifs_assert(c->ohead_offs + len <= c->leb_size); | 319 | ubifs_assert(c, c->ohead_offs + len <= c->leb_size); |
| 320 | ubifs_assert(c->ohead_lnum >= c->orph_first); | 320 | ubifs_assert(c, c->ohead_lnum >= c->orph_first); |
| 321 | ubifs_assert(c->ohead_lnum <= c->orph_last); | 321 | ubifs_assert(c, c->ohead_lnum <= c->orph_last); |
| 322 | err = do_write_orph_node(c, len, atomic); | 322 | err = do_write_orph_node(c, len, atomic); |
| 323 | c->ohead_offs += ALIGN(len, c->min_io_size); | 323 | c->ohead_offs += ALIGN(len, c->min_io_size); |
| 324 | c->ohead_offs = ALIGN(c->ohead_offs, 8); | 324 | c->ohead_offs = ALIGN(c->ohead_offs, 8); |
| @@ -388,7 +388,7 @@ static int consolidate(struct ubifs_info *c) | |||
| 388 | cnt += 1; | 388 | cnt += 1; |
| 389 | } | 389 | } |
| 390 | *last = NULL; | 390 | *last = NULL; |
| 391 | ubifs_assert(cnt == c->tot_orphans - c->new_orphans); | 391 | ubifs_assert(c, cnt == c->tot_orphans - c->new_orphans); |
| 392 | c->cmt_orphans = cnt; | 392 | c->cmt_orphans = cnt; |
| 393 | c->ohead_lnum = c->orph_first; | 393 | c->ohead_lnum = c->orph_first; |
| 394 | c->ohead_offs = 0; | 394 | c->ohead_offs = 0; |
| @@ -415,7 +415,7 @@ static int commit_orphans(struct ubifs_info *c) | |||
| 415 | { | 415 | { |
| 416 | int avail, atomic = 0, err; | 416 | int avail, atomic = 0, err; |
| 417 | 417 | ||
| 418 | ubifs_assert(c->cmt_orphans > 0); | 418 | ubifs_assert(c, c->cmt_orphans > 0); |
| 419 | avail = avail_orphs(c); | 419 | avail = avail_orphs(c); |
| 420 | if (avail < c->cmt_orphans) { | 420 | if (avail < c->cmt_orphans) { |
| 421 | /* Not enough space to write new orphans, so consolidate */ | 421 | /* Not enough space to write new orphans, so consolidate */ |
| @@ -446,8 +446,8 @@ static void erase_deleted(struct ubifs_info *c) | |||
| 446 | while (dnext) { | 446 | while (dnext) { |
| 447 | orphan = dnext; | 447 | orphan = dnext; |
| 448 | dnext = orphan->dnext; | 448 | dnext = orphan->dnext; |
| 449 | ubifs_assert(!orphan->new); | 449 | ubifs_assert(c, !orphan->new); |
| 450 | ubifs_assert(orphan->del); | 450 | ubifs_assert(c, orphan->del); |
| 451 | rb_erase(&orphan->rb, &c->orph_tree); | 451 | rb_erase(&orphan->rb, &c->orph_tree); |
| 452 | list_del(&orphan->list); | 452 | list_del(&orphan->list); |
| 453 | c->tot_orphans -= 1; | 453 | c->tot_orphans -= 1; |
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c index 3af4472061cc..984e30e83c0b 100644 --- a/fs/ubifs/recovery.c +++ b/fs/ubifs/recovery.c | |||
| @@ -444,7 +444,7 @@ static void clean_buf(const struct ubifs_info *c, void **buf, int lnum, | |||
| 444 | 444 | ||
| 445 | dbg_rcvry("cleaning corruption at %d:%d", lnum, *offs); | 445 | dbg_rcvry("cleaning corruption at %d:%d", lnum, *offs); |
| 446 | 446 | ||
| 447 | ubifs_assert(!(*offs & 7)); | 447 | ubifs_assert(c, !(*offs & 7)); |
| 448 | empty_offs = ALIGN(*offs, c->min_io_size); | 448 | empty_offs = ALIGN(*offs, c->min_io_size); |
| 449 | pad_len = empty_offs - *offs; | 449 | pad_len = empty_offs - *offs; |
| 450 | ubifs_pad(c, *buf, pad_len); | 450 | ubifs_pad(c, *buf, pad_len); |
| @@ -644,7 +644,7 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, | |||
| 644 | if (IS_ERR(sleb)) | 644 | if (IS_ERR(sleb)) |
| 645 | return sleb; | 645 | return sleb; |
| 646 | 646 | ||
| 647 | ubifs_assert(len >= 8); | 647 | ubifs_assert(c, len >= 8); |
| 648 | while (len >= 8) { | 648 | while (len >= 8) { |
| 649 | dbg_scan("look at LEB %d:%d (%d bytes left)", | 649 | dbg_scan("look at LEB %d:%d (%d bytes left)", |
| 650 | lnum, offs, len); | 650 | lnum, offs, len); |
| @@ -966,7 +966,7 @@ int ubifs_recover_inl_heads(struct ubifs_info *c, void *sbuf) | |||
| 966 | { | 966 | { |
| 967 | int err; | 967 | int err; |
| 968 | 968 | ||
| 969 | ubifs_assert(!c->ro_mount || c->remounting_rw); | 969 | ubifs_assert(c, !c->ro_mount || c->remounting_rw); |
| 970 | 970 | ||
| 971 | dbg_rcvry("checking index head at %d:%d", c->ihead_lnum, c->ihead_offs); | 971 | dbg_rcvry("checking index head at %d:%d", c->ihead_lnum, c->ihead_offs); |
| 972 | err = recover_head(c, c->ihead_lnum, c->ihead_offs, sbuf); | 972 | err = recover_head(c, c->ihead_lnum, c->ihead_offs, sbuf); |
| @@ -1187,8 +1187,8 @@ int ubifs_rcvry_gc_commit(struct ubifs_info *c) | |||
| 1187 | return grab_empty_leb(c); | 1187 | return grab_empty_leb(c); |
| 1188 | } | 1188 | } |
| 1189 | 1189 | ||
| 1190 | ubifs_assert(!(lp.flags & LPROPS_INDEX)); | 1190 | ubifs_assert(c, !(lp.flags & LPROPS_INDEX)); |
| 1191 | ubifs_assert(lp.free + lp.dirty >= wbuf->offs); | 1191 | ubifs_assert(c, lp.free + lp.dirty >= wbuf->offs); |
| 1192 | 1192 | ||
| 1193 | /* | 1193 | /* |
| 1194 | * We run the commit before garbage collection otherwise subsequent | 1194 | * We run the commit before garbage collection otherwise subsequent |
| @@ -1216,7 +1216,7 @@ int ubifs_rcvry_gc_commit(struct ubifs_info *c) | |||
| 1216 | return err; | 1216 | return err; |
| 1217 | } | 1217 | } |
| 1218 | 1218 | ||
| 1219 | ubifs_assert(err == LEB_RETAINED); | 1219 | ubifs_assert(c, err == LEB_RETAINED); |
| 1220 | if (err != LEB_RETAINED) | 1220 | if (err != LEB_RETAINED) |
| 1221 | return -EINVAL; | 1221 | return -EINVAL; |
| 1222 | 1222 | ||
| @@ -1507,7 +1507,7 @@ int ubifs_recover_size(struct ubifs_info *c) | |||
| 1507 | struct inode *inode; | 1507 | struct inode *inode; |
| 1508 | struct ubifs_inode *ui; | 1508 | struct ubifs_inode *ui; |
| 1509 | 1509 | ||
| 1510 | ubifs_assert(!e->inode); | 1510 | ubifs_assert(c, !e->inode); |
| 1511 | 1511 | ||
| 1512 | inode = ubifs_iget(c->vfs_sb, e->inum); | 1512 | inode = ubifs_iget(c->vfs_sb, e->inum); |
| 1513 | if (IS_ERR(inode)) | 1513 | if (IS_ERR(inode)) |
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c index 85c2a43082b7..4844538eb926 100644 --- a/fs/ubifs/replay.c +++ b/fs/ubifs/replay.c | |||
| @@ -273,6 +273,7 @@ static int apply_replay_entry(struct ubifs_info *c, struct replay_entry *r) | |||
| 273 | static int replay_entries_cmp(void *priv, struct list_head *a, | 273 | static int replay_entries_cmp(void *priv, struct list_head *a, |
| 274 | struct list_head *b) | 274 | struct list_head *b) |
| 275 | { | 275 | { |
| 276 | struct ubifs_info *c = priv; | ||
| 276 | struct replay_entry *ra, *rb; | 277 | struct replay_entry *ra, *rb; |
| 277 | 278 | ||
| 278 | cond_resched(); | 279 | cond_resched(); |
| @@ -281,7 +282,7 @@ static int replay_entries_cmp(void *priv, struct list_head *a, | |||
| 281 | 282 | ||
| 282 | ra = list_entry(a, struct replay_entry, list); | 283 | ra = list_entry(a, struct replay_entry, list); |
| 283 | rb = list_entry(b, struct replay_entry, list); | 284 | rb = list_entry(b, struct replay_entry, list); |
| 284 | ubifs_assert(ra->sqnum != rb->sqnum); | 285 | ubifs_assert(c, ra->sqnum != rb->sqnum); |
| 285 | if (ra->sqnum > rb->sqnum) | 286 | if (ra->sqnum > rb->sqnum) |
| 286 | return 1; | 287 | return 1; |
| 287 | return -1; | 288 | return -1; |
| @@ -668,9 +669,9 @@ static int replay_bud(struct ubifs_info *c, struct bud_entry *b) | |||
| 668 | goto out; | 669 | goto out; |
| 669 | } | 670 | } |
| 670 | 671 | ||
| 671 | ubifs_assert(ubifs_search_bud(c, lnum)); | 672 | ubifs_assert(c, ubifs_search_bud(c, lnum)); |
| 672 | ubifs_assert(sleb->endpt - offs >= used); | 673 | ubifs_assert(c, sleb->endpt - offs >= used); |
| 673 | ubifs_assert(sleb->endpt % c->min_io_size == 0); | 674 | ubifs_assert(c, sleb->endpt % c->min_io_size == 0); |
| 674 | 675 | ||
| 675 | b->dirty = sleb->endpt - offs - used; | 676 | b->dirty = sleb->endpt - offs - used; |
| 676 | b->free = c->leb_size - sleb->endpt; | 677 | b->free = c->leb_size - sleb->endpt; |
| @@ -706,7 +707,7 @@ static int replay_buds(struct ubifs_info *c) | |||
| 706 | if (err) | 707 | if (err) |
| 707 | return err; | 708 | return err; |
| 708 | 709 | ||
| 709 | ubifs_assert(b->sqnum > prev_sqnum); | 710 | ubifs_assert(c, b->sqnum > prev_sqnum); |
| 710 | prev_sqnum = b->sqnum; | 711 | prev_sqnum = b->sqnum; |
| 711 | } | 712 | } |
| 712 | 713 | ||
| @@ -1067,7 +1068,7 @@ int ubifs_replay_journal(struct ubifs_info *c) | |||
| 1067 | c->bi.uncommitted_idx = atomic_long_read(&c->dirty_zn_cnt); | 1068 | c->bi.uncommitted_idx = atomic_long_read(&c->dirty_zn_cnt); |
| 1068 | c->bi.uncommitted_idx *= c->max_idx_node_sz; | 1069 | c->bi.uncommitted_idx *= c->max_idx_node_sz; |
| 1069 | 1070 | ||
| 1070 | ubifs_assert(c->bud_bytes <= c->max_bud_bytes || c->need_recovery); | 1071 | ubifs_assert(c, c->bud_bytes <= c->max_bud_bytes || c->need_recovery); |
| 1071 | dbg_mnt("finished, log head LEB %d:%d, max_sqnum %llu, highest_inum %lu", | 1072 | dbg_mnt("finished, log head LEB %d:%d, max_sqnum %llu, highest_inum %lu", |
| 1072 | c->lhead_lnum, c->lhead_offs, c->max_sqnum, | 1073 | c->lhead_lnum, c->lhead_offs, c->max_sqnum, |
| 1073 | (unsigned long)c->highest_inum); | 1074 | (unsigned long)c->highest_inum); |
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index fa0a982a6797..bf17f58908ff 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c | |||
| @@ -563,7 +563,7 @@ int ubifs_read_superblock(struct ubifs_info *c) | |||
| 563 | * due to the unavailability of time-travelling equipment. | 563 | * due to the unavailability of time-travelling equipment. |
| 564 | */ | 564 | */ |
| 565 | if (c->fmt_version > UBIFS_FORMAT_VERSION) { | 565 | if (c->fmt_version > UBIFS_FORMAT_VERSION) { |
| 566 | ubifs_assert(!c->ro_media || c->ro_mount); | 566 | ubifs_assert(c, !c->ro_media || c->ro_mount); |
| 567 | if (!c->ro_mount || | 567 | if (!c->ro_mount || |
| 568 | c->ro_compat_version > UBIFS_RO_COMPAT_VERSION) { | 568 | c->ro_compat_version > UBIFS_RO_COMPAT_VERSION) { |
| 569 | ubifs_err(c, "on-flash format version is w%d/r%d, but software only supports up to version w%d/r%d", | 569 | ubifs_err(c, "on-flash format version is w%d/r%d, but software only supports up to version w%d/r%d", |
| @@ -705,9 +705,9 @@ static int fixup_leb(struct ubifs_info *c, int lnum, int len) | |||
| 705 | { | 705 | { |
| 706 | int err; | 706 | int err; |
| 707 | 707 | ||
| 708 | ubifs_assert(len >= 0); | 708 | ubifs_assert(c, len >= 0); |
| 709 | ubifs_assert(len % c->min_io_size == 0); | 709 | ubifs_assert(c, len % c->min_io_size == 0); |
| 710 | ubifs_assert(len < c->leb_size); | 710 | ubifs_assert(c, len < c->leb_size); |
| 711 | 711 | ||
| 712 | if (len == 0) { | 712 | if (len == 0) { |
| 713 | dbg_mnt("unmap empty LEB %d", lnum); | 713 | dbg_mnt("unmap empty LEB %d", lnum); |
| @@ -817,8 +817,8 @@ int ubifs_fixup_free_space(struct ubifs_info *c) | |||
| 817 | int err; | 817 | int err; |
| 818 | struct ubifs_sb_node *sup; | 818 | struct ubifs_sb_node *sup; |
| 819 | 819 | ||
| 820 | ubifs_assert(c->space_fixup); | 820 | ubifs_assert(c, c->space_fixup); |
| 821 | ubifs_assert(!c->ro_mount); | 821 | ubifs_assert(c, !c->ro_mount); |
| 822 | 822 | ||
| 823 | ubifs_msg(c, "start fixing up free space"); | 823 | ubifs_msg(c, "start fixing up free space"); |
| 824 | 824 | ||
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c index 16f03d9929e5..ea88926163f4 100644 --- a/fs/ubifs/scan.c +++ b/fs/ubifs/scan.c | |||
| @@ -176,7 +176,7 @@ void ubifs_end_scan(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, | |||
| 176 | int lnum, int offs) | 176 | int lnum, int offs) |
| 177 | { | 177 | { |
| 178 | dbg_scan("stop scanning LEB %d at offset %d", lnum, offs); | 178 | dbg_scan("stop scanning LEB %d at offset %d", lnum, offs); |
| 179 | ubifs_assert(offs % c->min_io_size == 0); | 179 | ubifs_assert(c, offs % c->min_io_size == 0); |
| 180 | 180 | ||
| 181 | sleb->endpt = ALIGN(offs, c->min_io_size); | 181 | sleb->endpt = ALIGN(offs, c->min_io_size); |
| 182 | } | 182 | } |
diff --git a/fs/ubifs/shrinker.c b/fs/ubifs/shrinker.c index 9d10cbdec2cc..5eb5958723d4 100644 --- a/fs/ubifs/shrinker.c +++ b/fs/ubifs/shrinker.c | |||
| @@ -73,8 +73,8 @@ static int shrink_tnc(struct ubifs_info *c, int nr, int age, int *contention) | |||
| 73 | struct ubifs_znode *znode, *zprev; | 73 | struct ubifs_znode *znode, *zprev; |
| 74 | time64_t time = ktime_get_seconds(); | 74 | time64_t time = ktime_get_seconds(); |
| 75 | 75 | ||
| 76 | ubifs_assert(mutex_is_locked(&c->umount_mutex)); | 76 | ubifs_assert(c, mutex_is_locked(&c->umount_mutex)); |
| 77 | ubifs_assert(mutex_is_locked(&c->tnc_mutex)); | 77 | ubifs_assert(c, mutex_is_locked(&c->tnc_mutex)); |
| 78 | 78 | ||
| 79 | if (!c->zroot.znode || atomic_long_read(&c->clean_zn_cnt) == 0) | 79 | if (!c->zroot.znode || atomic_long_read(&c->clean_zn_cnt) == 0) |
| 80 | return 0; | 80 | return 0; |
| @@ -89,7 +89,7 @@ static int shrink_tnc(struct ubifs_info *c, int nr, int age, int *contention) | |||
| 89 | * changed only when the 'c->tnc_mutex' is held. | 89 | * changed only when the 'c->tnc_mutex' is held. |
| 90 | */ | 90 | */ |
| 91 | zprev = NULL; | 91 | zprev = NULL; |
| 92 | znode = ubifs_tnc_levelorder_next(c->zroot.znode, NULL); | 92 | znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, NULL); |
| 93 | while (znode && total_freed < nr && | 93 | while (znode && total_freed < nr && |
| 94 | atomic_long_read(&c->clean_zn_cnt) > 0) { | 94 | atomic_long_read(&c->clean_zn_cnt) > 0) { |
| 95 | int freed; | 95 | int freed; |
| @@ -125,7 +125,7 @@ static int shrink_tnc(struct ubifs_info *c, int nr, int age, int *contention) | |||
| 125 | else | 125 | else |
| 126 | c->zroot.znode = NULL; | 126 | c->zroot.znode = NULL; |
| 127 | 127 | ||
| 128 | freed = ubifs_destroy_tnc_subtree(znode); | 128 | freed = ubifs_destroy_tnc_subtree(c, znode); |
| 129 | atomic_long_sub(freed, &ubifs_clean_zn_cnt); | 129 | atomic_long_sub(freed, &ubifs_clean_zn_cnt); |
| 130 | atomic_long_sub(freed, &c->clean_zn_cnt); | 130 | atomic_long_sub(freed, &c->clean_zn_cnt); |
| 131 | total_freed += freed; | 131 | total_freed += freed; |
| @@ -136,7 +136,7 @@ static int shrink_tnc(struct ubifs_info *c, int nr, int age, int *contention) | |||
| 136 | break; | 136 | break; |
| 137 | 137 | ||
| 138 | zprev = znode; | 138 | zprev = znode; |
| 139 | znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode); | 139 | znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, znode); |
| 140 | cond_resched(); | 140 | cond_resched(); |
| 141 | } | 141 | } |
| 142 | 142 | ||
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 61579d6306f5..df73b0e1c2f7 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
| @@ -89,9 +89,9 @@ static int validate_inode(struct ubifs_info *c, const struct inode *inode) | |||
| 89 | if (ui->xattr && !S_ISREG(inode->i_mode)) | 89 | if (ui->xattr && !S_ISREG(inode->i_mode)) |
| 90 | return 5; | 90 | return 5; |
| 91 | 91 | ||
| 92 | if (!ubifs_compr_present(ui->compr_type)) { | 92 | if (!ubifs_compr_present(c, ui->compr_type)) { |
| 93 | ubifs_warn(c, "inode %lu uses '%s' compression, but it was not compiled in", | 93 | ubifs_warn(c, "inode %lu uses '%s' compression, but it was not compiled in", |
| 94 | inode->i_ino, ubifs_compr_name(ui->compr_type)); | 94 | inode->i_ino, ubifs_compr_name(c, ui->compr_type)); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | err = dbg_check_dir(c, inode); | 97 | err = dbg_check_dir(c, inode); |
| @@ -296,7 +296,7 @@ static int ubifs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
| 296 | struct ubifs_info *c = inode->i_sb->s_fs_info; | 296 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
| 297 | struct ubifs_inode *ui = ubifs_inode(inode); | 297 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 298 | 298 | ||
| 299 | ubifs_assert(!ui->xattr); | 299 | ubifs_assert(c, !ui->xattr); |
| 300 | if (is_bad_inode(inode)) | 300 | if (is_bad_inode(inode)) |
| 301 | return 0; | 301 | return 0; |
| 302 | 302 | ||
| @@ -349,7 +349,7 @@ static void ubifs_evict_inode(struct inode *inode) | |||
| 349 | goto out; | 349 | goto out; |
| 350 | 350 | ||
| 351 | dbg_gen("inode %lu, mode %#x", inode->i_ino, (int)inode->i_mode); | 351 | dbg_gen("inode %lu, mode %#x", inode->i_ino, (int)inode->i_mode); |
| 352 | ubifs_assert(!atomic_read(&inode->i_count)); | 352 | ubifs_assert(c, !atomic_read(&inode->i_count)); |
| 353 | 353 | ||
| 354 | truncate_inode_pages_final(&inode->i_data); | 354 | truncate_inode_pages_final(&inode->i_data); |
| 355 | 355 | ||
| @@ -384,9 +384,10 @@ done: | |||
| 384 | 384 | ||
| 385 | static void ubifs_dirty_inode(struct inode *inode, int flags) | 385 | static void ubifs_dirty_inode(struct inode *inode, int flags) |
| 386 | { | 386 | { |
| 387 | struct ubifs_info *c = inode->i_sb->s_fs_info; | ||
| 387 | struct ubifs_inode *ui = ubifs_inode(inode); | 388 | struct ubifs_inode *ui = ubifs_inode(inode); |
| 388 | 389 | ||
| 389 | ubifs_assert(mutex_is_locked(&ui->ui_mutex)); | 390 | ubifs_assert(c, mutex_is_locked(&ui->ui_mutex)); |
| 390 | if (!ui->dirty) { | 391 | if (!ui->dirty) { |
| 391 | ui->dirty = 1; | 392 | ui->dirty = 1; |
| 392 | dbg_gen("inode %lu", inode->i_ino); | 393 | dbg_gen("inode %lu", inode->i_ino); |
| @@ -416,7 +417,7 @@ static int ubifs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 416 | buf->f_namelen = UBIFS_MAX_NLEN; | 417 | buf->f_namelen = UBIFS_MAX_NLEN; |
| 417 | buf->f_fsid.val[0] = le32_to_cpu(uuid[0]) ^ le32_to_cpu(uuid[2]); | 418 | buf->f_fsid.val[0] = le32_to_cpu(uuid[0]) ^ le32_to_cpu(uuid[2]); |
| 418 | buf->f_fsid.val[1] = le32_to_cpu(uuid[1]) ^ le32_to_cpu(uuid[3]); | 419 | buf->f_fsid.val[1] = le32_to_cpu(uuid[1]) ^ le32_to_cpu(uuid[3]); |
| 419 | ubifs_assert(buf->f_bfree <= c->block_cnt); | 420 | ubifs_assert(c, buf->f_bfree <= c->block_cnt); |
| 420 | return 0; | 421 | return 0; |
| 421 | } | 422 | } |
| 422 | 423 | ||
| @@ -441,7 +442,7 @@ static int ubifs_show_options(struct seq_file *s, struct dentry *root) | |||
| 441 | 442 | ||
| 442 | if (c->mount_opts.override_compr) { | 443 | if (c->mount_opts.override_compr) { |
| 443 | seq_printf(s, ",compr=%s", | 444 | seq_printf(s, ",compr=%s", |
| 444 | ubifs_compr_name(c->mount_opts.compr_type)); | 445 | ubifs_compr_name(c, c->mount_opts.compr_type)); |
| 445 | } | 446 | } |
| 446 | 447 | ||
| 447 | seq_printf(s, ",ubi=%d,vol=%d", c->vi.ubi_num, c->vi.vol_id); | 448 | seq_printf(s, ",ubi=%d,vol=%d", c->vi.ubi_num, c->vi.vol_id); |
| @@ -1103,7 +1104,7 @@ static void destroy_journal(struct ubifs_info *c) | |||
| 1103 | */ | 1104 | */ |
| 1104 | static void bu_init(struct ubifs_info *c) | 1105 | static void bu_init(struct ubifs_info *c) |
| 1105 | { | 1106 | { |
| 1106 | ubifs_assert(c->bulk_read == 1); | 1107 | ubifs_assert(c, c->bulk_read == 1); |
| 1107 | 1108 | ||
| 1108 | if (c->bu.buf) | 1109 | if (c->bu.buf) |
| 1109 | return; /* Already initialized */ | 1110 | return; /* Already initialized */ |
| @@ -1134,7 +1135,7 @@ again: | |||
| 1134 | */ | 1135 | */ |
| 1135 | static int check_free_space(struct ubifs_info *c) | 1136 | static int check_free_space(struct ubifs_info *c) |
| 1136 | { | 1137 | { |
| 1137 | ubifs_assert(c->dark_wm > 0); | 1138 | ubifs_assert(c, c->dark_wm > 0); |
| 1138 | if (c->lst.total_free + c->lst.total_dirty < c->dark_wm) { | 1139 | if (c->lst.total_free + c->lst.total_dirty < c->dark_wm) { |
| 1139 | ubifs_err(c, "insufficient free space to mount in R/W mode"); | 1140 | ubifs_err(c, "insufficient free space to mount in R/W mode"); |
| 1140 | ubifs_dump_budg(c, &c->bi); | 1141 | ubifs_dump_budg(c, &c->bi); |
| @@ -1234,9 +1235,9 @@ static int mount_ubifs(struct ubifs_info *c) | |||
| 1234 | * Make sure the compressor which is set as default in the superblock | 1235 | * Make sure the compressor which is set as default in the superblock |
| 1235 | * or overridden by mount options is actually compiled in. | 1236 | * or overridden by mount options is actually compiled in. |
| 1236 | */ | 1237 | */ |
| 1237 | if (!ubifs_compr_present(c->default_compr)) { | 1238 | if (!ubifs_compr_present(c, c->default_compr)) { |
| 1238 | ubifs_err(c, "'compressor \"%s\" is not compiled in", | 1239 | ubifs_err(c, "'compressor \"%s\" is not compiled in", |
| 1239 | ubifs_compr_name(c->default_compr)); | 1240 | ubifs_compr_name(c, c->default_compr)); |
| 1240 | err = -ENOTSUPP; | 1241 | err = -ENOTSUPP; |
| 1241 | goto out_free; | 1242 | goto out_free; |
| 1242 | } | 1243 | } |
| @@ -1396,10 +1397,10 @@ static int mount_ubifs(struct ubifs_info *c) | |||
| 1396 | * the journal head LEBs may also be accounted as | 1397 | * the journal head LEBs may also be accounted as |
| 1397 | * "empty taken" if they are empty. | 1398 | * "empty taken" if they are empty. |
| 1398 | */ | 1399 | */ |
| 1399 | ubifs_assert(c->lst.taken_empty_lebs > 0); | 1400 | ubifs_assert(c, c->lst.taken_empty_lebs > 0); |
| 1400 | } | 1401 | } |
| 1401 | } else | 1402 | } else |
| 1402 | ubifs_assert(c->lst.taken_empty_lebs > 0); | 1403 | ubifs_assert(c, c->lst.taken_empty_lebs > 0); |
| 1403 | 1404 | ||
| 1404 | err = dbg_check_filesystem(c); | 1405 | err = dbg_check_filesystem(c); |
| 1405 | if (err) | 1406 | if (err) |
| @@ -1429,7 +1430,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
| 1429 | UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION, c->uuid, | 1430 | UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION, c->uuid, |
| 1430 | c->big_lpt ? ", big LPT model" : ", small LPT model"); | 1431 | c->big_lpt ? ", big LPT model" : ", small LPT model"); |
| 1431 | 1432 | ||
| 1432 | dbg_gen("default compressor: %s", ubifs_compr_name(c->default_compr)); | 1433 | dbg_gen("default compressor: %s", ubifs_compr_name(c, c->default_compr)); |
| 1433 | dbg_gen("data journal heads: %d", | 1434 | dbg_gen("data journal heads: %d", |
| 1434 | c->jhead_cnt - NONDATA_JHEADS_CNT); | 1435 | c->jhead_cnt - NONDATA_JHEADS_CNT); |
| 1435 | dbg_gen("log LEBs: %d (%d - %d)", | 1436 | dbg_gen("log LEBs: %d (%d - %d)", |
| @@ -1610,7 +1611,7 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
| 1610 | goto out; | 1611 | goto out; |
| 1611 | } else { | 1612 | } else { |
| 1612 | /* A readonly mount is not allowed to have orphans */ | 1613 | /* A readonly mount is not allowed to have orphans */ |
| 1613 | ubifs_assert(c->tot_orphans == 0); | 1614 | ubifs_assert(c, c->tot_orphans == 0); |
| 1614 | err = ubifs_clear_orphans(c); | 1615 | err = ubifs_clear_orphans(c); |
| 1615 | if (err) | 1616 | if (err) |
| 1616 | goto out; | 1617 | goto out; |
| @@ -1727,8 +1728,8 @@ static void ubifs_remount_ro(struct ubifs_info *c) | |||
| 1727 | { | 1728 | { |
| 1728 | int i, err; | 1729 | int i, err; |
| 1729 | 1730 | ||
| 1730 | ubifs_assert(!c->need_recovery); | 1731 | ubifs_assert(c, !c->need_recovery); |
| 1731 | ubifs_assert(!c->ro_mount); | 1732 | ubifs_assert(c, !c->ro_mount); |
| 1732 | 1733 | ||
| 1733 | mutex_lock(&c->umount_mutex); | 1734 | mutex_lock(&c->umount_mutex); |
| 1734 | if (c->bgt) { | 1735 | if (c->bgt) { |
| @@ -1778,9 +1779,9 @@ static void ubifs_put_super(struct super_block *sb) | |||
| 1778 | * to write them back because of I/O errors. | 1779 | * to write them back because of I/O errors. |
| 1779 | */ | 1780 | */ |
| 1780 | if (!c->ro_error) { | 1781 | if (!c->ro_error) { |
| 1781 | ubifs_assert(c->bi.idx_growth == 0); | 1782 | ubifs_assert(c, c->bi.idx_growth == 0); |
| 1782 | ubifs_assert(c->bi.dd_growth == 0); | 1783 | ubifs_assert(c, c->bi.dd_growth == 0); |
| 1783 | ubifs_assert(c->bi.data_growth == 0); | 1784 | ubifs_assert(c, c->bi.data_growth == 0); |
| 1784 | } | 1785 | } |
| 1785 | 1786 | ||
| 1786 | /* | 1787 | /* |
| @@ -1887,7 +1888,7 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data) | |||
| 1887 | mutex_unlock(&c->bu_mutex); | 1888 | mutex_unlock(&c->bu_mutex); |
| 1888 | } | 1889 | } |
| 1889 | 1890 | ||
| 1890 | ubifs_assert(c->lst.taken_empty_lebs > 0); | 1891 | ubifs_assert(c, c->lst.taken_empty_lebs > 0); |
| 1891 | return 0; | 1892 | return 0; |
| 1892 | } | 1893 | } |
| 1893 | 1894 | ||
| @@ -2063,7 +2064,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 2063 | mutex_lock(&c->umount_mutex); | 2064 | mutex_lock(&c->umount_mutex); |
| 2064 | err = mount_ubifs(c); | 2065 | err = mount_ubifs(c); |
| 2065 | if (err) { | 2066 | if (err) { |
| 2066 | ubifs_assert(err < 0); | 2067 | ubifs_assert(c, err < 0); |
| 2067 | goto out_unlock; | 2068 | goto out_unlock; |
| 2068 | } | 2069 | } |
| 2069 | 2070 | ||
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index 6c497fb48b98..bf416e512743 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
| @@ -211,7 +211,7 @@ static struct ubifs_znode *copy_znode(struct ubifs_info *c, | |||
| 211 | __set_bit(DIRTY_ZNODE, &zn->flags); | 211 | __set_bit(DIRTY_ZNODE, &zn->flags); |
| 212 | __clear_bit(COW_ZNODE, &zn->flags); | 212 | __clear_bit(COW_ZNODE, &zn->flags); |
| 213 | 213 | ||
| 214 | ubifs_assert(!ubifs_zn_obsolete(znode)); | 214 | ubifs_assert(c, !ubifs_zn_obsolete(znode)); |
| 215 | __set_bit(OBSOLETE_ZNODE, &znode->flags); | 215 | __set_bit(OBSOLETE_ZNODE, &znode->flags); |
| 216 | 216 | ||
| 217 | if (znode->level != 0) { | 217 | if (znode->level != 0) { |
| @@ -321,9 +321,9 @@ static int lnc_add(struct ubifs_info *c, struct ubifs_zbranch *zbr, | |||
| 321 | void *lnc_node; | 321 | void *lnc_node; |
| 322 | const struct ubifs_dent_node *dent = node; | 322 | const struct ubifs_dent_node *dent = node; |
| 323 | 323 | ||
| 324 | ubifs_assert(!zbr->leaf); | 324 | ubifs_assert(c, !zbr->leaf); |
| 325 | ubifs_assert(zbr->len != 0); | 325 | ubifs_assert(c, zbr->len != 0); |
| 326 | ubifs_assert(is_hash_key(c, &zbr->key)); | 326 | ubifs_assert(c, is_hash_key(c, &zbr->key)); |
| 327 | 327 | ||
| 328 | err = ubifs_validate_entry(c, dent); | 328 | err = ubifs_validate_entry(c, dent); |
| 329 | if (err) { | 329 | if (err) { |
| @@ -355,8 +355,8 @@ static int lnc_add_directly(struct ubifs_info *c, struct ubifs_zbranch *zbr, | |||
| 355 | { | 355 | { |
| 356 | int err; | 356 | int err; |
| 357 | 357 | ||
| 358 | ubifs_assert(!zbr->leaf); | 358 | ubifs_assert(c, !zbr->leaf); |
| 359 | ubifs_assert(zbr->len != 0); | 359 | ubifs_assert(c, zbr->len != 0); |
| 360 | 360 | ||
| 361 | err = ubifs_validate_entry(c, node); | 361 | err = ubifs_validate_entry(c, node); |
| 362 | if (err) { | 362 | if (err) { |
| @@ -398,11 +398,11 @@ static int tnc_read_hashed_node(struct ubifs_info *c, struct ubifs_zbranch *zbr, | |||
| 398 | { | 398 | { |
| 399 | int err; | 399 | int err; |
| 400 | 400 | ||
| 401 | ubifs_assert(is_hash_key(c, &zbr->key)); | 401 | ubifs_assert(c, is_hash_key(c, &zbr->key)); |
| 402 | 402 | ||
| 403 | if (zbr->leaf) { | 403 | if (zbr->leaf) { |
| 404 | /* Read from the leaf node cache */ | 404 | /* Read from the leaf node cache */ |
| 405 | ubifs_assert(zbr->len != 0); | 405 | ubifs_assert(c, zbr->len != 0); |
| 406 | memcpy(node, zbr->leaf, zbr->len); | 406 | memcpy(node, zbr->leaf, zbr->len); |
| 407 | return 0; | 407 | return 0; |
| 408 | } | 408 | } |
| @@ -721,7 +721,7 @@ static int resolve_collision(struct ubifs_info *c, const union ubifs_key *key, | |||
| 721 | while (1) { | 721 | while (1) { |
| 722 | err = tnc_prev(c, zn, n); | 722 | err = tnc_prev(c, zn, n); |
| 723 | if (err == -ENOENT) { | 723 | if (err == -ENOENT) { |
| 724 | ubifs_assert(*n == 0); | 724 | ubifs_assert(c, *n == 0); |
| 725 | *n = -1; | 725 | *n = -1; |
| 726 | return 0; | 726 | return 0; |
| 727 | } | 727 | } |
| @@ -761,12 +761,12 @@ static int resolve_collision(struct ubifs_info *c, const union ubifs_key *key, | |||
| 761 | err = tnc_next(c, zn, n); | 761 | err = tnc_next(c, zn, n); |
| 762 | if (err) { | 762 | if (err) { |
| 763 | /* Should be impossible */ | 763 | /* Should be impossible */ |
| 764 | ubifs_assert(0); | 764 | ubifs_assert(c, 0); |
| 765 | if (err == -ENOENT) | 765 | if (err == -ENOENT) |
| 766 | err = -EINVAL; | 766 | err = -EINVAL; |
| 767 | return err; | 767 | return err; |
| 768 | } | 768 | } |
| 769 | ubifs_assert(*n == 0); | 769 | ubifs_assert(c, *n == 0); |
| 770 | *n = -1; | 770 | *n = -1; |
| 771 | } | 771 | } |
| 772 | return 0; | 772 | return 0; |
| @@ -778,7 +778,7 @@ static int resolve_collision(struct ubifs_info *c, const union ubifs_key *key, | |||
| 778 | return 0; | 778 | return 0; |
| 779 | if (err == NAME_MATCHES) | 779 | if (err == NAME_MATCHES) |
| 780 | return 1; | 780 | return 1; |
| 781 | ubifs_assert(err == NAME_GREATER); | 781 | ubifs_assert(c, err == NAME_GREATER); |
| 782 | } | 782 | } |
| 783 | } else { | 783 | } else { |
| 784 | int nn = *n; | 784 | int nn = *n; |
| @@ -802,7 +802,7 @@ static int resolve_collision(struct ubifs_info *c, const union ubifs_key *key, | |||
| 802 | *n = nn; | 802 | *n = nn; |
| 803 | if (err == NAME_MATCHES) | 803 | if (err == NAME_MATCHES) |
| 804 | return 1; | 804 | return 1; |
| 805 | ubifs_assert(err == NAME_LESS); | 805 | ubifs_assert(c, err == NAME_LESS); |
| 806 | } | 806 | } |
| 807 | } | 807 | } |
| 808 | } | 808 | } |
| @@ -843,7 +843,7 @@ static int fallible_matches_name(struct ubifs_info *c, | |||
| 843 | err = NOT_ON_MEDIA; | 843 | err = NOT_ON_MEDIA; |
| 844 | goto out_free; | 844 | goto out_free; |
| 845 | } | 845 | } |
| 846 | ubifs_assert(err == 1); | 846 | ubifs_assert(c, err == 1); |
| 847 | 847 | ||
| 848 | err = lnc_add_directly(c, zbr, dent); | 848 | err = lnc_add_directly(c, zbr, dent); |
| 849 | if (err) | 849 | if (err) |
| @@ -923,7 +923,7 @@ static int fallible_resolve_collision(struct ubifs_info *c, | |||
| 923 | while (1) { | 923 | while (1) { |
| 924 | err = tnc_prev(c, zn, n); | 924 | err = tnc_prev(c, zn, n); |
| 925 | if (err == -ENOENT) { | 925 | if (err == -ENOENT) { |
| 926 | ubifs_assert(*n == 0); | 926 | ubifs_assert(c, *n == 0); |
| 927 | *n = -1; | 927 | *n = -1; |
| 928 | break; | 928 | break; |
| 929 | } | 929 | } |
| @@ -935,12 +935,12 @@ static int fallible_resolve_collision(struct ubifs_info *c, | |||
| 935 | err = tnc_next(c, zn, n); | 935 | err = tnc_next(c, zn, n); |
| 936 | if (err) { | 936 | if (err) { |
| 937 | /* Should be impossible */ | 937 | /* Should be impossible */ |
| 938 | ubifs_assert(0); | 938 | ubifs_assert(c, 0); |
| 939 | if (err == -ENOENT) | 939 | if (err == -ENOENT) |
| 940 | err = -EINVAL; | 940 | err = -EINVAL; |
| 941 | return err; | 941 | return err; |
| 942 | } | 942 | } |
| 943 | ubifs_assert(*n == 0); | 943 | ubifs_assert(c, *n == 0); |
| 944 | *n = -1; | 944 | *n = -1; |
| 945 | } | 945 | } |
| 946 | break; | 946 | break; |
| @@ -1100,8 +1100,8 @@ static struct ubifs_znode *dirty_cow_bottom_up(struct ubifs_info *c, | |||
| 1100 | struct ubifs_znode *zp; | 1100 | struct ubifs_znode *zp; |
| 1101 | int *path = c->bottom_up_buf, p = 0; | 1101 | int *path = c->bottom_up_buf, p = 0; |
| 1102 | 1102 | ||
| 1103 | ubifs_assert(c->zroot.znode); | 1103 | ubifs_assert(c, c->zroot.znode); |
| 1104 | ubifs_assert(znode); | 1104 | ubifs_assert(c, znode); |
| 1105 | if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) { | 1105 | if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) { |
| 1106 | kfree(c->bottom_up_buf); | 1106 | kfree(c->bottom_up_buf); |
| 1107 | c->bottom_up_buf = kmalloc_array(c->zroot.znode->level, | 1107 | c->bottom_up_buf = kmalloc_array(c->zroot.znode->level, |
| @@ -1120,7 +1120,7 @@ static struct ubifs_znode *dirty_cow_bottom_up(struct ubifs_info *c, | |||
| 1120 | if (!zp) | 1120 | if (!zp) |
| 1121 | break; | 1121 | break; |
| 1122 | n = znode->iip; | 1122 | n = znode->iip; |
| 1123 | ubifs_assert(p < c->zroot.znode->level); | 1123 | ubifs_assert(c, p < c->zroot.znode->level); |
| 1124 | path[p++] = n; | 1124 | path[p++] = n; |
| 1125 | if (!zp->cnext && ubifs_zn_dirty(znode)) | 1125 | if (!zp->cnext && ubifs_zn_dirty(znode)) |
| 1126 | break; | 1126 | break; |
| @@ -1134,18 +1134,18 @@ static struct ubifs_znode *dirty_cow_bottom_up(struct ubifs_info *c, | |||
| 1134 | 1134 | ||
| 1135 | zp = znode->parent; | 1135 | zp = znode->parent; |
| 1136 | if (zp) { | 1136 | if (zp) { |
| 1137 | ubifs_assert(path[p - 1] >= 0); | 1137 | ubifs_assert(c, path[p - 1] >= 0); |
| 1138 | ubifs_assert(path[p - 1] < zp->child_cnt); | 1138 | ubifs_assert(c, path[p - 1] < zp->child_cnt); |
| 1139 | zbr = &zp->zbranch[path[--p]]; | 1139 | zbr = &zp->zbranch[path[--p]]; |
| 1140 | znode = dirty_cow_znode(c, zbr); | 1140 | znode = dirty_cow_znode(c, zbr); |
| 1141 | } else { | 1141 | } else { |
| 1142 | ubifs_assert(znode == c->zroot.znode); | 1142 | ubifs_assert(c, znode == c->zroot.znode); |
| 1143 | znode = dirty_cow_znode(c, &c->zroot); | 1143 | znode = dirty_cow_znode(c, &c->zroot); |
| 1144 | } | 1144 | } |
| 1145 | if (IS_ERR(znode) || !p) | 1145 | if (IS_ERR(znode) || !p) |
| 1146 | break; | 1146 | break; |
| 1147 | ubifs_assert(path[p - 1] >= 0); | 1147 | ubifs_assert(c, path[p - 1] >= 0); |
| 1148 | ubifs_assert(path[p - 1] < znode->child_cnt); | 1148 | ubifs_assert(c, path[p - 1] < znode->child_cnt); |
| 1149 | znode = znode->zbranch[path[p - 1]].znode; | 1149 | znode = znode->zbranch[path[p - 1]].znode; |
| 1150 | } | 1150 | } |
| 1151 | 1151 | ||
| @@ -1182,7 +1182,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key, | |||
| 1182 | time64_t time = ktime_get_seconds(); | 1182 | time64_t time = ktime_get_seconds(); |
| 1183 | 1183 | ||
| 1184 | dbg_tnck(key, "search key "); | 1184 | dbg_tnck(key, "search key "); |
| 1185 | ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); | 1185 | ubifs_assert(c, key_type(c, key) < UBIFS_INVALID_KEY); |
| 1186 | 1186 | ||
| 1187 | znode = c->zroot.znode; | 1187 | znode = c->zroot.znode; |
| 1188 | if (unlikely(!znode)) { | 1188 | if (unlikely(!znode)) { |
| @@ -1658,9 +1658,9 @@ static int read_wbuf(struct ubifs_wbuf *wbuf, void *buf, int len, int lnum, | |||
| 1658 | int rlen, overlap; | 1658 | int rlen, overlap; |
| 1659 | 1659 | ||
| 1660 | dbg_io("LEB %d:%d, length %d", lnum, offs, len); | 1660 | dbg_io("LEB %d:%d, length %d", lnum, offs, len); |
| 1661 | ubifs_assert(wbuf && lnum >= 0 && lnum < c->leb_cnt && offs >= 0); | 1661 | ubifs_assert(c, wbuf && lnum >= 0 && lnum < c->leb_cnt && offs >= 0); |
| 1662 | ubifs_assert(!(offs & 7) && offs < c->leb_size); | 1662 | ubifs_assert(c, !(offs & 7) && offs < c->leb_size); |
| 1663 | ubifs_assert(offs + len <= c->leb_size); | 1663 | ubifs_assert(c, offs + len <= c->leb_size); |
| 1664 | 1664 | ||
| 1665 | spin_lock(&wbuf->lock); | 1665 | spin_lock(&wbuf->lock); |
| 1666 | overlap = (lnum == wbuf->lnum && offs + len > wbuf->offs); | 1666 | overlap = (lnum == wbuf->lnum && offs + len > wbuf->offs); |
| @@ -1824,7 +1824,7 @@ static int do_lookup_nm(struct ubifs_info *c, const union ubifs_key *key, | |||
| 1824 | goto out_unlock; | 1824 | goto out_unlock; |
| 1825 | } | 1825 | } |
| 1826 | 1826 | ||
| 1827 | ubifs_assert(n >= 0); | 1827 | ubifs_assert(c, n >= 0); |
| 1828 | 1828 | ||
| 1829 | err = resolve_collision(c, key, &znode, &n, nm); | 1829 | err = resolve_collision(c, key, &znode, &n, nm); |
| 1830 | dbg_tnc("rc returned %d, znode %p, n %d", err, znode, n); | 1830 | dbg_tnc("rc returned %d, znode %p, n %d", err, znode, n); |
| @@ -1922,7 +1922,7 @@ static int do_lookup_dh(struct ubifs_info *c, const union ubifs_key *key, | |||
| 1922 | struct ubifs_znode *znode; | 1922 | struct ubifs_znode *znode; |
| 1923 | union ubifs_key start_key; | 1923 | union ubifs_key start_key; |
| 1924 | 1924 | ||
| 1925 | ubifs_assert(is_hash_key(c, key)); | 1925 | ubifs_assert(c, is_hash_key(c, key)); |
| 1926 | 1926 | ||
| 1927 | lowest_dent_key(c, &start_key, key_inum(c, key)); | 1927 | lowest_dent_key(c, &start_key, key_inum(c, key)); |
| 1928 | 1928 | ||
| @@ -1993,8 +1993,8 @@ static void correct_parent_keys(const struct ubifs_info *c, | |||
| 1993 | { | 1993 | { |
| 1994 | union ubifs_key *key, *key1; | 1994 | union ubifs_key *key, *key1; |
| 1995 | 1995 | ||
| 1996 | ubifs_assert(znode->parent); | 1996 | ubifs_assert(c, znode->parent); |
| 1997 | ubifs_assert(znode->iip == 0); | 1997 | ubifs_assert(c, znode->iip == 0); |
| 1998 | 1998 | ||
| 1999 | key = &znode->zbranch[0].key; | 1999 | key = &znode->zbranch[0].key; |
| 2000 | key1 = &znode->parent->zbranch[0].key; | 2000 | key1 = &znode->parent->zbranch[0].key; |
| @@ -2011,6 +2011,7 @@ static void correct_parent_keys(const struct ubifs_info *c, | |||
| 2011 | 2011 | ||
| 2012 | /** | 2012 | /** |
| 2013 | * insert_zbranch - insert a zbranch into a znode. | 2013 | * insert_zbranch - insert a zbranch into a znode. |
| 2014 | * @c: UBIFS file-system description object | ||
| 2014 | * @znode: znode into which to insert | 2015 | * @znode: znode into which to insert |
| 2015 | * @zbr: zbranch to insert | 2016 | * @zbr: zbranch to insert |
| 2016 | * @n: slot number to insert to | 2017 | * @n: slot number to insert to |
| @@ -2020,12 +2021,12 @@ static void correct_parent_keys(const struct ubifs_info *c, | |||
| 2020 | * zbranch has to be inserted to the @znode->zbranches[]' array at the @n-th | 2021 | * zbranch has to be inserted to the @znode->zbranches[]' array at the @n-th |
| 2021 | * slot, zbranches starting from @n have to be moved right. | 2022 | * slot, zbranches starting from @n have to be moved right. |
| 2022 | */ | 2023 | */ |
| 2023 | static void insert_zbranch(struct ubifs_znode *znode, | 2024 | static void insert_zbranch(struct ubifs_info *c, struct ubifs_znode *znode, |
| 2024 | const struct ubifs_zbranch *zbr, int n) | 2025 | const struct ubifs_zbranch *zbr, int n) |
| 2025 | { | 2026 | { |
| 2026 | int i; | 2027 | int i; |
| 2027 | 2028 | ||
| 2028 | ubifs_assert(ubifs_zn_dirty(znode)); | 2029 | ubifs_assert(c, ubifs_zn_dirty(znode)); |
| 2029 | 2030 | ||
| 2030 | if (znode->level) { | 2031 | if (znode->level) { |
| 2031 | for (i = znode->child_cnt; i > n; i--) { | 2032 | for (i = znode->child_cnt; i > n; i--) { |
| @@ -2079,16 +2080,16 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode, | |||
| 2079 | int i, keep, move, appending = 0; | 2080 | int i, keep, move, appending = 0; |
| 2080 | union ubifs_key *key = &zbr->key, *key1; | 2081 | union ubifs_key *key = &zbr->key, *key1; |
| 2081 | 2082 | ||
| 2082 | ubifs_assert(n >= 0 && n <= c->fanout); | 2083 | ubifs_assert(c, n >= 0 && n <= c->fanout); |
| 2083 | 2084 | ||
| 2084 | /* Implement naive insert for now */ | 2085 | /* Implement naive insert for now */ |
| 2085 | again: | 2086 | again: |
| 2086 | zp = znode->parent; | 2087 | zp = znode->parent; |
| 2087 | if (znode->child_cnt < c->fanout) { | 2088 | if (znode->child_cnt < c->fanout) { |
| 2088 | ubifs_assert(n != c->fanout); | 2089 | ubifs_assert(c, n != c->fanout); |
| 2089 | dbg_tnck(key, "inserted at %d level %d, key ", n, znode->level); | 2090 | dbg_tnck(key, "inserted at %d level %d, key ", n, znode->level); |
| 2090 | 2091 | ||
| 2091 | insert_zbranch(znode, zbr, n); | 2092 | insert_zbranch(c, znode, zbr, n); |
| 2092 | 2093 | ||
| 2093 | /* Ensure parent's key is correct */ | 2094 | /* Ensure parent's key is correct */ |
| 2094 | if (n == 0 && zp && znode->iip == 0) | 2095 | if (n == 0 && zp && znode->iip == 0) |
| @@ -2197,7 +2198,7 @@ do_split: | |||
| 2197 | /* Insert new key and branch */ | 2198 | /* Insert new key and branch */ |
| 2198 | dbg_tnck(key, "inserting at %d level %d, key ", n, zn->level); | 2199 | dbg_tnck(key, "inserting at %d level %d, key ", n, zn->level); |
| 2199 | 2200 | ||
| 2200 | insert_zbranch(zi, zbr, n); | 2201 | insert_zbranch(c, zi, zbr, n); |
| 2201 | 2202 | ||
| 2202 | /* Insert new znode (produced by spitting) into the parent */ | 2203 | /* Insert new znode (produced by spitting) into the parent */ |
| 2203 | if (zp) { | 2204 | if (zp) { |
| @@ -2495,8 +2496,8 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n) | |||
| 2495 | int i, err; | 2496 | int i, err; |
| 2496 | 2497 | ||
| 2497 | /* Delete without merge for now */ | 2498 | /* Delete without merge for now */ |
| 2498 | ubifs_assert(znode->level == 0); | 2499 | ubifs_assert(c, znode->level == 0); |
| 2499 | ubifs_assert(n >= 0 && n < c->fanout); | 2500 | ubifs_assert(c, n >= 0 && n < c->fanout); |
| 2500 | dbg_tnck(&znode->zbranch[n].key, "deleting key "); | 2501 | dbg_tnck(&znode->zbranch[n].key, "deleting key "); |
| 2501 | 2502 | ||
| 2502 | zbr = &znode->zbranch[n]; | 2503 | zbr = &znode->zbranch[n]; |
| @@ -2522,8 +2523,8 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n) | |||
| 2522 | */ | 2523 | */ |
| 2523 | 2524 | ||
| 2524 | do { | 2525 | do { |
| 2525 | ubifs_assert(!ubifs_zn_obsolete(znode)); | 2526 | ubifs_assert(c, !ubifs_zn_obsolete(znode)); |
| 2526 | ubifs_assert(ubifs_zn_dirty(znode)); | 2527 | ubifs_assert(c, ubifs_zn_dirty(znode)); |
| 2527 | 2528 | ||
| 2528 | zp = znode->parent; | 2529 | zp = znode->parent; |
| 2529 | n = znode->iip; | 2530 | n = znode->iip; |
| @@ -2545,7 +2546,7 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n) | |||
| 2545 | 2546 | ||
| 2546 | /* Remove from znode, entry n - 1 */ | 2547 | /* Remove from znode, entry n - 1 */ |
| 2547 | znode->child_cnt -= 1; | 2548 | znode->child_cnt -= 1; |
| 2548 | ubifs_assert(znode->level != 0); | 2549 | ubifs_assert(c, znode->level != 0); |
| 2549 | for (i = n; i < znode->child_cnt; i++) { | 2550 | for (i = n; i < znode->child_cnt; i++) { |
| 2550 | znode->zbranch[i] = znode->zbranch[i + 1]; | 2551 | znode->zbranch[i] = znode->zbranch[i + 1]; |
| 2551 | if (znode->zbranch[i].znode) | 2552 | if (znode->zbranch[i].znode) |
| @@ -2578,8 +2579,8 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n) | |||
| 2578 | c->zroot.offs = zbr->offs; | 2579 | c->zroot.offs = zbr->offs; |
| 2579 | c->zroot.len = zbr->len; | 2580 | c->zroot.len = zbr->len; |
| 2580 | c->zroot.znode = znode; | 2581 | c->zroot.znode = znode; |
| 2581 | ubifs_assert(!ubifs_zn_obsolete(zp)); | 2582 | ubifs_assert(c, !ubifs_zn_obsolete(zp)); |
| 2582 | ubifs_assert(ubifs_zn_dirty(zp)); | 2583 | ubifs_assert(c, ubifs_zn_dirty(zp)); |
| 2583 | atomic_long_dec(&c->dirty_zn_cnt); | 2584 | atomic_long_dec(&c->dirty_zn_cnt); |
| 2584 | 2585 | ||
| 2585 | if (zp->cnext) { | 2586 | if (zp->cnext) { |
| @@ -2944,7 +2945,7 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c, | |||
| 2944 | union ubifs_key *dkey; | 2945 | union ubifs_key *dkey; |
| 2945 | 2946 | ||
| 2946 | dbg_tnck(key, "key "); | 2947 | dbg_tnck(key, "key "); |
| 2947 | ubifs_assert(is_hash_key(c, key)); | 2948 | ubifs_assert(c, is_hash_key(c, key)); |
| 2948 | 2949 | ||
| 2949 | mutex_lock(&c->tnc_mutex); | 2950 | mutex_lock(&c->tnc_mutex); |
| 2950 | err = ubifs_lookup_level0(c, key, &znode, &n); | 2951 | err = ubifs_lookup_level0(c, key, &znode, &n); |
| @@ -3031,7 +3032,7 @@ static void tnc_destroy_cnext(struct ubifs_info *c) | |||
| 3031 | 3032 | ||
| 3032 | if (!c->cnext) | 3033 | if (!c->cnext) |
| 3033 | return; | 3034 | return; |
| 3034 | ubifs_assert(c->cmt_state == COMMIT_BROKEN); | 3035 | ubifs_assert(c, c->cmt_state == COMMIT_BROKEN); |
| 3035 | cnext = c->cnext; | 3036 | cnext = c->cnext; |
| 3036 | do { | 3037 | do { |
| 3037 | struct ubifs_znode *znode = cnext; | 3038 | struct ubifs_znode *znode = cnext; |
| @@ -3053,8 +3054,8 @@ void ubifs_tnc_close(struct ubifs_info *c) | |||
| 3053 | long n, freed; | 3054 | long n, freed; |
| 3054 | 3055 | ||
| 3055 | n = atomic_long_read(&c->clean_zn_cnt); | 3056 | n = atomic_long_read(&c->clean_zn_cnt); |
| 3056 | freed = ubifs_destroy_tnc_subtree(c->zroot.znode); | 3057 | freed = ubifs_destroy_tnc_subtree(c, c->zroot.znode); |
| 3057 | ubifs_assert(freed == n); | 3058 | ubifs_assert(c, freed == n); |
| 3058 | atomic_long_sub(n, &ubifs_clean_zn_cnt); | 3059 | atomic_long_sub(n, &ubifs_clean_zn_cnt); |
| 3059 | } | 3060 | } |
| 3060 | kfree(c->gap_lebs); | 3061 | kfree(c->gap_lebs); |
| @@ -3167,7 +3168,7 @@ static struct ubifs_znode *lookup_znode(struct ubifs_info *c, | |||
| 3167 | struct ubifs_znode *znode, *zn; | 3168 | struct ubifs_znode *znode, *zn; |
| 3168 | int n, nn; | 3169 | int n, nn; |
| 3169 | 3170 | ||
| 3170 | ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); | 3171 | ubifs_assert(c, key_type(c, key) < UBIFS_INVALID_KEY); |
| 3171 | 3172 | ||
| 3172 | /* | 3173 | /* |
| 3173 | * The arguments have probably been read off flash, so don't assume | 3174 | * The arguments have probably been read off flash, so don't assume |
| @@ -3206,7 +3207,7 @@ static struct ubifs_znode *lookup_znode(struct ubifs_info *c, | |||
| 3206 | if (IS_ERR(znode)) | 3207 | if (IS_ERR(znode)) |
| 3207 | return znode; | 3208 | return znode; |
| 3208 | ubifs_search_zbranch(c, znode, key, &n); | 3209 | ubifs_search_zbranch(c, znode, key, &n); |
| 3209 | ubifs_assert(n >= 0); | 3210 | ubifs_assert(c, n >= 0); |
| 3210 | } | 3211 | } |
| 3211 | if (znode->level == level + 1) | 3212 | if (znode->level == level + 1) |
| 3212 | break; | 3213 | break; |
| @@ -3497,7 +3498,7 @@ int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode, | |||
| 3497 | if (err < 0) | 3498 | if (err < 0) |
| 3498 | goto out_unlock; | 3499 | goto out_unlock; |
| 3499 | 3500 | ||
| 3500 | ubifs_assert(err == 0); | 3501 | ubifs_assert(c, err == 0); |
| 3501 | key = &znode->zbranch[n].key; | 3502 | key = &znode->zbranch[n].key; |
| 3502 | if (!key_in_range(c, key, &from_key, &to_key)) | 3503 | if (!key_in_range(c, key, &from_key, &to_key)) |
| 3503 | goto out_unlock; | 3504 | goto out_unlock; |
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c index a9df94ad46a3..dba87d09b989 100644 --- a/fs/ubifs/tnc_commit.c +++ b/fs/ubifs/tnc_commit.c | |||
| @@ -87,8 +87,8 @@ static int make_idx_node(struct ubifs_info *c, struct ubifs_idx_node *idx, | |||
| 87 | 87 | ||
| 88 | atomic_long_dec(&c->dirty_zn_cnt); | 88 | atomic_long_dec(&c->dirty_zn_cnt); |
| 89 | 89 | ||
| 90 | ubifs_assert(ubifs_zn_dirty(znode)); | 90 | ubifs_assert(c, ubifs_zn_dirty(znode)); |
| 91 | ubifs_assert(ubifs_zn_cow(znode)); | 91 | ubifs_assert(c, ubifs_zn_cow(znode)); |
| 92 | 92 | ||
| 93 | /* | 93 | /* |
| 94 | * Note, unlike 'write_index()' we do not add memory barriers here | 94 | * Note, unlike 'write_index()' we do not add memory barriers here |
| @@ -115,9 +115,9 @@ static int fill_gap(struct ubifs_info *c, int lnum, int gap_start, int gap_end, | |||
| 115 | { | 115 | { |
| 116 | int len, gap_remains, gap_pos, written, pad_len; | 116 | int len, gap_remains, gap_pos, written, pad_len; |
| 117 | 117 | ||
| 118 | ubifs_assert((gap_start & 7) == 0); | 118 | ubifs_assert(c, (gap_start & 7) == 0); |
| 119 | ubifs_assert((gap_end & 7) == 0); | 119 | ubifs_assert(c, (gap_end & 7) == 0); |
| 120 | ubifs_assert(gap_end >= gap_start); | 120 | ubifs_assert(c, gap_end >= gap_start); |
| 121 | 121 | ||
| 122 | gap_remains = gap_end - gap_start; | 122 | gap_remains = gap_end - gap_start; |
| 123 | if (!gap_remains) | 123 | if (!gap_remains) |
| @@ -131,7 +131,7 @@ static int fill_gap(struct ubifs_info *c, int lnum, int gap_start, int gap_end, | |||
| 131 | const int alen = ALIGN(len, 8); | 131 | const int alen = ALIGN(len, 8); |
| 132 | int err; | 132 | int err; |
| 133 | 133 | ||
| 134 | ubifs_assert(alen <= gap_remains); | 134 | ubifs_assert(c, alen <= gap_remains); |
| 135 | err = make_idx_node(c, c->ileb_buf + gap_pos, znode, | 135 | err = make_idx_node(c, c->ileb_buf + gap_pos, znode, |
| 136 | lnum, gap_pos, len); | 136 | lnum, gap_pos, len); |
| 137 | if (err) | 137 | if (err) |
| @@ -259,7 +259,7 @@ static int layout_leb_in_gaps(struct ubifs_info *c, int *p) | |||
| 259 | struct ubifs_idx_node *idx; | 259 | struct ubifs_idx_node *idx; |
| 260 | int in_use, level; | 260 | int in_use, level; |
| 261 | 261 | ||
| 262 | ubifs_assert(snod->type == UBIFS_IDX_NODE); | 262 | ubifs_assert(c, snod->type == UBIFS_IDX_NODE); |
| 263 | idx = snod->node; | 263 | idx = snod->node; |
| 264 | key_read(c, ubifs_idx_key(c, idx), &snod->key); | 264 | key_read(c, ubifs_idx_key(c, idx), &snod->key); |
| 265 | level = le16_to_cpu(idx->level); | 265 | level = le16_to_cpu(idx->level); |
| @@ -373,7 +373,7 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt) | |||
| 373 | 373 | ||
| 374 | p = c->gap_lebs; | 374 | p = c->gap_lebs; |
| 375 | do { | 375 | do { |
| 376 | ubifs_assert(p < c->gap_lebs + c->lst.idx_lebs); | 376 | ubifs_assert(c, p < c->gap_lebs + c->lst.idx_lebs); |
| 377 | written = layout_leb_in_gaps(c, p); | 377 | written = layout_leb_in_gaps(c, p); |
| 378 | if (written < 0) { | 378 | if (written < 0) { |
| 379 | err = written; | 379 | err = written; |
| @@ -639,7 +639,7 @@ static int get_znodes_to_commit(struct ubifs_info *c) | |||
| 639 | } | 639 | } |
| 640 | cnt += 1; | 640 | cnt += 1; |
| 641 | while (1) { | 641 | while (1) { |
| 642 | ubifs_assert(!ubifs_zn_cow(znode)); | 642 | ubifs_assert(c, !ubifs_zn_cow(znode)); |
| 643 | __set_bit(COW_ZNODE, &znode->flags); | 643 | __set_bit(COW_ZNODE, &znode->flags); |
| 644 | znode->alt = 0; | 644 | znode->alt = 0; |
| 645 | cnext = find_next_dirty(znode); | 645 | cnext = find_next_dirty(znode); |
| @@ -652,7 +652,7 @@ static int get_znodes_to_commit(struct ubifs_info *c) | |||
| 652 | cnt += 1; | 652 | cnt += 1; |
| 653 | } | 653 | } |
| 654 | dbg_cmt("committing %d znodes", cnt); | 654 | dbg_cmt("committing %d znodes", cnt); |
| 655 | ubifs_assert(cnt == atomic_long_read(&c->dirty_zn_cnt)); | 655 | ubifs_assert(c, cnt == atomic_long_read(&c->dirty_zn_cnt)); |
| 656 | return cnt; | 656 | return cnt; |
| 657 | } | 657 | } |
| 658 | 658 | ||
| @@ -760,7 +760,7 @@ int ubifs_tnc_start_commit(struct ubifs_info *c, struct ubifs_zbranch *zroot) | |||
| 760 | err = layout_commit(c, no_space, cnt); | 760 | err = layout_commit(c, no_space, cnt); |
| 761 | if (err) | 761 | if (err) |
| 762 | goto out_free; | 762 | goto out_free; |
| 763 | ubifs_assert(atomic_long_read(&c->dirty_zn_cnt) == 0); | 763 | ubifs_assert(c, atomic_long_read(&c->dirty_zn_cnt) == 0); |
| 764 | err = free_unused_idx_lebs(c); | 764 | err = free_unused_idx_lebs(c); |
| 765 | if (err) | 765 | if (err) |
| 766 | goto out; | 766 | goto out; |
| @@ -781,7 +781,7 @@ int ubifs_tnc_start_commit(struct ubifs_info *c, struct ubifs_zbranch *zroot) | |||
| 781 | * budgeting subsystem to assume the index is already committed, | 781 | * budgeting subsystem to assume the index is already committed, |
| 782 | * even though it is not. | 782 | * even though it is not. |
| 783 | */ | 783 | */ |
| 784 | ubifs_assert(c->bi.min_idx_lebs == ubifs_calc_min_idx_lebs(c)); | 784 | ubifs_assert(c, c->bi.min_idx_lebs == ubifs_calc_min_idx_lebs(c)); |
| 785 | c->bi.old_idx_sz = c->calc_idx_sz; | 785 | c->bi.old_idx_sz = c->calc_idx_sz; |
| 786 | c->bi.uncommitted_idx = 0; | 786 | c->bi.uncommitted_idx = 0; |
| 787 | c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c); | 787 | c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c); |
| @@ -887,8 +887,8 @@ static int write_index(struct ubifs_info *c) | |||
| 887 | /* Grab some stuff from znode while we still can */ | 887 | /* Grab some stuff from znode while we still can */ |
| 888 | cnext = znode->cnext; | 888 | cnext = znode->cnext; |
| 889 | 889 | ||
| 890 | ubifs_assert(ubifs_zn_dirty(znode)); | 890 | ubifs_assert(c, ubifs_zn_dirty(znode)); |
| 891 | ubifs_assert(ubifs_zn_cow(znode)); | 891 | ubifs_assert(c, ubifs_zn_cow(znode)); |
| 892 | 892 | ||
| 893 | /* | 893 | /* |
| 894 | * It is important that other threads should see %DIRTY_ZNODE | 894 | * It is important that other threads should see %DIRTY_ZNODE |
diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c index 49f647bc88f0..d90ee01076a9 100644 --- a/fs/ubifs/tnc_misc.c +++ b/fs/ubifs/tnc_misc.c | |||
| @@ -31,19 +31,21 @@ | |||
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | * ubifs_tnc_levelorder_next - next TNC tree element in levelorder traversal. | 33 | * ubifs_tnc_levelorder_next - next TNC tree element in levelorder traversal. |
| 34 | * @c: UBIFS file-system description object | ||
| 34 | * @zr: root of the subtree to traverse | 35 | * @zr: root of the subtree to traverse |
| 35 | * @znode: previous znode | 36 | * @znode: previous znode |
| 36 | * | 37 | * |
| 37 | * This function implements levelorder TNC traversal. The LNC is ignored. | 38 | * This function implements levelorder TNC traversal. The LNC is ignored. |
| 38 | * Returns the next element or %NULL if @znode is already the last one. | 39 | * Returns the next element or %NULL if @znode is already the last one. |
| 39 | */ | 40 | */ |
| 40 | struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr, | 41 | struct ubifs_znode *ubifs_tnc_levelorder_next(const struct ubifs_info *c, |
| 42 | struct ubifs_znode *zr, | ||
| 41 | struct ubifs_znode *znode) | 43 | struct ubifs_znode *znode) |
| 42 | { | 44 | { |
| 43 | int level, iip, level_search = 0; | 45 | int level, iip, level_search = 0; |
| 44 | struct ubifs_znode *zn; | 46 | struct ubifs_znode *zn; |
| 45 | 47 | ||
| 46 | ubifs_assert(zr); | 48 | ubifs_assert(c, zr); |
| 47 | 49 | ||
| 48 | if (unlikely(!znode)) | 50 | if (unlikely(!znode)) |
| 49 | return zr; | 51 | return zr; |
| @@ -58,7 +60,7 @@ struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr, | |||
| 58 | 60 | ||
| 59 | iip = znode->iip; | 61 | iip = znode->iip; |
| 60 | while (1) { | 62 | while (1) { |
| 61 | ubifs_assert(znode->level <= zr->level); | 63 | ubifs_assert(c, znode->level <= zr->level); |
| 62 | 64 | ||
| 63 | /* | 65 | /* |
| 64 | * First walk up until there is a znode with next branch to | 66 | * First walk up until there is a znode with next branch to |
| @@ -85,7 +87,7 @@ struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr, | |||
| 85 | level_search = 1; | 87 | level_search = 1; |
| 86 | iip = -1; | 88 | iip = -1; |
| 87 | znode = ubifs_tnc_find_child(zr, 0); | 89 | znode = ubifs_tnc_find_child(zr, 0); |
| 88 | ubifs_assert(znode); | 90 | ubifs_assert(c, znode); |
| 89 | } | 91 | } |
| 90 | 92 | ||
| 91 | /* Switch to the next index */ | 93 | /* Switch to the next index */ |
| @@ -111,7 +113,7 @@ struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr, | |||
| 111 | } | 113 | } |
| 112 | 114 | ||
| 113 | if (zn) { | 115 | if (zn) { |
| 114 | ubifs_assert(zn->level >= 0); | 116 | ubifs_assert(c, zn->level >= 0); |
| 115 | return zn; | 117 | return zn; |
| 116 | } | 118 | } |
| 117 | } | 119 | } |
| @@ -140,7 +142,7 @@ int ubifs_search_zbranch(const struct ubifs_info *c, | |||
| 140 | int uninitialized_var(cmp); | 142 | int uninitialized_var(cmp); |
| 141 | const struct ubifs_zbranch *zbr = &znode->zbranch[0]; | 143 | const struct ubifs_zbranch *zbr = &znode->zbranch[0]; |
| 142 | 144 | ||
| 143 | ubifs_assert(end > beg); | 145 | ubifs_assert(c, end > beg); |
| 144 | 146 | ||
| 145 | while (end > beg) { | 147 | while (end > beg) { |
| 146 | mid = (beg + end) >> 1; | 148 | mid = (beg + end) >> 1; |
| @@ -158,13 +160,13 @@ int ubifs_search_zbranch(const struct ubifs_info *c, | |||
| 158 | *n = end - 1; | 160 | *n = end - 1; |
| 159 | 161 | ||
| 160 | /* The insert point is after *n */ | 162 | /* The insert point is after *n */ |
| 161 | ubifs_assert(*n >= -1 && *n < znode->child_cnt); | 163 | ubifs_assert(c, *n >= -1 && *n < znode->child_cnt); |
| 162 | if (*n == -1) | 164 | if (*n == -1) |
| 163 | ubifs_assert(keys_cmp(c, key, &zbr[0].key) < 0); | 165 | ubifs_assert(c, keys_cmp(c, key, &zbr[0].key) < 0); |
| 164 | else | 166 | else |
| 165 | ubifs_assert(keys_cmp(c, key, &zbr[*n].key) > 0); | 167 | ubifs_assert(c, keys_cmp(c, key, &zbr[*n].key) > 0); |
| 166 | if (*n + 1 < znode->child_cnt) | 168 | if (*n + 1 < znode->child_cnt) |
| 167 | ubifs_assert(keys_cmp(c, key, &zbr[*n + 1].key) < 0); | 169 | ubifs_assert(c, keys_cmp(c, key, &zbr[*n + 1].key) < 0); |
| 168 | 170 | ||
| 169 | return 0; | 171 | return 0; |
| 170 | } | 172 | } |
| @@ -195,16 +197,18 @@ struct ubifs_znode *ubifs_tnc_postorder_first(struct ubifs_znode *znode) | |||
| 195 | 197 | ||
| 196 | /** | 198 | /** |
| 197 | * ubifs_tnc_postorder_next - next TNC tree element in postorder traversal. | 199 | * ubifs_tnc_postorder_next - next TNC tree element in postorder traversal. |
| 200 | * @c: UBIFS file-system description object | ||
| 198 | * @znode: previous znode | 201 | * @znode: previous znode |
| 199 | * | 202 | * |
| 200 | * This function implements postorder TNC traversal. The LNC is ignored. | 203 | * This function implements postorder TNC traversal. The LNC is ignored. |
| 201 | * Returns the next element or %NULL if @znode is already the last one. | 204 | * Returns the next element or %NULL if @znode is already the last one. |
| 202 | */ | 205 | */ |
| 203 | struct ubifs_znode *ubifs_tnc_postorder_next(struct ubifs_znode *znode) | 206 | struct ubifs_znode *ubifs_tnc_postorder_next(const struct ubifs_info *c, |
| 207 | struct ubifs_znode *znode) | ||
| 204 | { | 208 | { |
| 205 | struct ubifs_znode *zn; | 209 | struct ubifs_znode *zn; |
| 206 | 210 | ||
| 207 | ubifs_assert(znode); | 211 | ubifs_assert(c, znode); |
| 208 | if (unlikely(!znode->parent)) | 212 | if (unlikely(!znode->parent)) |
| 209 | return NULL; | 213 | return NULL; |
| 210 | 214 | ||
| @@ -220,18 +224,20 @@ struct ubifs_znode *ubifs_tnc_postorder_next(struct ubifs_znode *znode) | |||
| 220 | 224 | ||
| 221 | /** | 225 | /** |
| 222 | * ubifs_destroy_tnc_subtree - destroy all znodes connected to a subtree. | 226 | * ubifs_destroy_tnc_subtree - destroy all znodes connected to a subtree. |
| 227 | * @c: UBIFS file-system description object | ||
| 223 | * @znode: znode defining subtree to destroy | 228 | * @znode: znode defining subtree to destroy |
| 224 | * | 229 | * |
| 225 | * This function destroys subtree of the TNC tree. Returns number of clean | 230 | * This function destroys subtree of the TNC tree. Returns number of clean |
| 226 | * znodes in the subtree. | 231 | * znodes in the subtree. |
| 227 | */ | 232 | */ |
| 228 | long ubifs_destroy_tnc_subtree(struct ubifs_znode *znode) | 233 | long ubifs_destroy_tnc_subtree(const struct ubifs_info *c, |
| 234 | struct ubifs_znode *znode) | ||
| 229 | { | 235 | { |
| 230 | struct ubifs_znode *zn = ubifs_tnc_postorder_first(znode); | 236 | struct ubifs_znode *zn = ubifs_tnc_postorder_first(znode); |
| 231 | long clean_freed = 0; | 237 | long clean_freed = 0; |
| 232 | int n; | 238 | int n; |
| 233 | 239 | ||
| 234 | ubifs_assert(zn); | 240 | ubifs_assert(c, zn); |
| 235 | while (1) { | 241 | while (1) { |
| 236 | for (n = 0; n < zn->child_cnt; n++) { | 242 | for (n = 0; n < zn->child_cnt; n++) { |
| 237 | if (!zn->zbranch[n].znode) | 243 | if (!zn->zbranch[n].znode) |
| @@ -252,7 +258,7 @@ long ubifs_destroy_tnc_subtree(struct ubifs_znode *znode) | |||
| 252 | return clean_freed; | 258 | return clean_freed; |
| 253 | } | 259 | } |
| 254 | 260 | ||
| 255 | zn = ubifs_tnc_postorder_next(zn); | 261 | zn = ubifs_tnc_postorder_next(c, zn); |
| 256 | } | 262 | } |
| 257 | } | 263 | } |
| 258 | 264 | ||
| @@ -410,7 +416,7 @@ struct ubifs_znode *ubifs_load_znode(struct ubifs_info *c, | |||
| 410 | int err; | 416 | int err; |
| 411 | struct ubifs_znode *znode; | 417 | struct ubifs_znode *znode; |
| 412 | 418 | ||
| 413 | ubifs_assert(!zbr->znode); | 419 | ubifs_assert(c, !zbr->znode); |
| 414 | /* | 420 | /* |
| 415 | * A slab cache is not presently used for znodes because the znode size | 421 | * A slab cache is not presently used for znodes because the znode size |
| 416 | * depends on the fanout which is stored in the superblock. | 422 | * depends on the fanout which is stored in the superblock. |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 829308651a5e..d17e895ee87f 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
| @@ -1608,14 +1608,17 @@ int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu); | |||
| 1608 | int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu); | 1608 | int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu); |
| 1609 | 1609 | ||
| 1610 | /* tnc_misc.c */ | 1610 | /* tnc_misc.c */ |
| 1611 | struct ubifs_znode *ubifs_tnc_levelorder_next(struct ubifs_znode *zr, | 1611 | struct ubifs_znode *ubifs_tnc_levelorder_next(const struct ubifs_info *c, |
| 1612 | struct ubifs_znode *zr, | ||
| 1612 | struct ubifs_znode *znode); | 1613 | struct ubifs_znode *znode); |
| 1613 | int ubifs_search_zbranch(const struct ubifs_info *c, | 1614 | int ubifs_search_zbranch(const struct ubifs_info *c, |
| 1614 | const struct ubifs_znode *znode, | 1615 | const struct ubifs_znode *znode, |
| 1615 | const union ubifs_key *key, int *n); | 1616 | const union ubifs_key *key, int *n); |
| 1616 | struct ubifs_znode *ubifs_tnc_postorder_first(struct ubifs_znode *znode); | 1617 | struct ubifs_znode *ubifs_tnc_postorder_first(struct ubifs_znode *znode); |
| 1617 | struct ubifs_znode *ubifs_tnc_postorder_next(struct ubifs_znode *znode); | 1618 | struct ubifs_znode *ubifs_tnc_postorder_next(const struct ubifs_info *c, |
| 1618 | long ubifs_destroy_tnc_subtree(struct ubifs_znode *zr); | 1619 | struct ubifs_znode *znode); |
| 1620 | long ubifs_destroy_tnc_subtree(const struct ubifs_info *c, | ||
| 1621 | struct ubifs_znode *zr); | ||
| 1619 | struct ubifs_znode *ubifs_load_znode(struct ubifs_info *c, | 1622 | struct ubifs_znode *ubifs_load_znode(struct ubifs_info *c, |
| 1620 | struct ubifs_zbranch *zbr, | 1623 | struct ubifs_zbranch *zbr, |
| 1621 | struct ubifs_znode *parent, int iip); | 1624 | struct ubifs_znode *parent, int iip); |
| @@ -1698,7 +1701,7 @@ struct ubifs_nnode *ubifs_get_nnode(struct ubifs_info *c, | |||
| 1698 | int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip); | 1701 | int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip); |
| 1699 | void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty); | 1702 | void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty); |
| 1700 | void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode); | 1703 | void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode); |
| 1701 | uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits); | 1704 | uint32_t ubifs_unpack_bits(const struct ubifs_info *c, uint8_t **addr, int *pos, int nrbits); |
| 1702 | struct ubifs_nnode *ubifs_first_nnode(struct ubifs_info *c, int *hght); | 1705 | struct ubifs_nnode *ubifs_first_nnode(struct ubifs_info *c, int *hght); |
| 1703 | /* Needed only in debugging code in lpt_commit.c */ | 1706 | /* Needed only in debugging code in lpt_commit.c */ |
| 1704 | int ubifs_unpack_nnode(const struct ubifs_info *c, void *buf, | 1707 | int ubifs_unpack_nnode(const struct ubifs_info *c, void *buf, |
| @@ -1818,14 +1821,16 @@ static inline int ubifs_encrypt(const struct inode *inode, | |||
| 1818 | unsigned int in_len, unsigned int *out_len, | 1821 | unsigned int in_len, unsigned int *out_len, |
| 1819 | int block) | 1822 | int block) |
| 1820 | { | 1823 | { |
| 1821 | ubifs_assert(0); | 1824 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
| 1825 | ubifs_assert(c, 0); | ||
| 1822 | return -EOPNOTSUPP; | 1826 | return -EOPNOTSUPP; |
| 1823 | } | 1827 | } |
| 1824 | static inline int ubifs_decrypt(const struct inode *inode, | 1828 | static inline int ubifs_decrypt(const struct inode *inode, |
| 1825 | struct ubifs_data_node *dn, | 1829 | struct ubifs_data_node *dn, |
| 1826 | unsigned int *out_len, int block) | 1830 | unsigned int *out_len, int block) |
| 1827 | { | 1831 | { |
| 1828 | ubifs_assert(0); | 1832 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
| 1833 | ubifs_assert(c, 0); | ||
| 1829 | return -EOPNOTSUPP; | 1834 | return -EOPNOTSUPP; |
| 1830 | } | 1835 | } |
| 1831 | #else | 1836 | #else |
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index 09e37e63bddd..61afdfee4b28 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c | |||
| @@ -223,7 +223,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host, | |||
| 223 | struct ubifs_budget_req req = { .dirtied_ino = 2, | 223 | struct ubifs_budget_req req = { .dirtied_ino = 2, |
| 224 | .dirtied_ino_d = ALIGN(size, 8) + ALIGN(host_ui->data_len, 8) }; | 224 | .dirtied_ino_d = ALIGN(size, 8) + ALIGN(host_ui->data_len, 8) }; |
| 225 | 225 | ||
| 226 | ubifs_assert(ui->data_len == inode->i_size); | 226 | ubifs_assert(c, ui->data_len == inode->i_size); |
| 227 | err = ubifs_budget_space(c, &req); | 227 | err = ubifs_budget_space(c, &req); |
| 228 | if (err) | 228 | if (err) |
| 229 | return err; | 229 | return err; |
| @@ -305,7 +305,7 @@ int ubifs_xattr_set(struct inode *host, const char *name, const void *value, | |||
| 305 | int err; | 305 | int err; |
| 306 | 306 | ||
| 307 | if (check_lock) | 307 | if (check_lock) |
| 308 | ubifs_assert(inode_is_locked(host)); | 308 | ubifs_assert(c, inode_is_locked(host)); |
| 309 | 309 | ||
| 310 | if (size > UBIFS_MAX_INO_DATA) | 310 | if (size > UBIFS_MAX_INO_DATA) |
| 311 | return -ERANGE; | 311 | return -ERANGE; |
| @@ -388,8 +388,8 @@ ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf, | |||
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | ui = ubifs_inode(inode); | 390 | ui = ubifs_inode(inode); |
| 391 | ubifs_assert(inode->i_size == ui->data_len); | 391 | ubifs_assert(c, inode->i_size == ui->data_len); |
| 392 | ubifs_assert(ubifs_inode(host)->xattr_size > ui->data_len); | 392 | ubifs_assert(c, ubifs_inode(host)->xattr_size > ui->data_len); |
| 393 | 393 | ||
| 394 | mutex_lock(&ui->ui_mutex); | 394 | mutex_lock(&ui->ui_mutex); |
| 395 | if (buf) { | 395 | if (buf) { |
| @@ -476,7 +476,7 @@ ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
| 476 | return err; | 476 | return err; |
| 477 | } | 477 | } |
| 478 | 478 | ||
| 479 | ubifs_assert(written <= size); | 479 | ubifs_assert(c, written <= size); |
| 480 | return written; | 480 | return written; |
| 481 | } | 481 | } |
| 482 | 482 | ||
| @@ -489,7 +489,7 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host, | |||
| 489 | struct ubifs_budget_req req = { .dirtied_ino = 2, .mod_dent = 1, | 489 | struct ubifs_budget_req req = { .dirtied_ino = 2, .mod_dent = 1, |
| 490 | .dirtied_ino_d = ALIGN(host_ui->data_len, 8) }; | 490 | .dirtied_ino_d = ALIGN(host_ui->data_len, 8) }; |
| 491 | 491 | ||
| 492 | ubifs_assert(ui->data_len == inode->i_size); | 492 | ubifs_assert(c, ui->data_len == inode->i_size); |
| 493 | 493 | ||
| 494 | err = ubifs_budget_space(c, &req); | 494 | err = ubifs_budget_space(c, &req); |
| 495 | if (err) | 495 | if (err) |
| @@ -559,7 +559,7 @@ static int ubifs_xattr_remove(struct inode *host, const char *name) | |||
| 559 | union ubifs_key key; | 559 | union ubifs_key key; |
| 560 | int err; | 560 | int err; |
| 561 | 561 | ||
| 562 | ubifs_assert(inode_is_locked(host)); | 562 | ubifs_assert(c, inode_is_locked(host)); |
| 563 | 563 | ||
| 564 | if (!host->i_nlink) | 564 | if (!host->i_nlink) |
| 565 | return -ENOENT; | 565 | return -ENOENT; |
| @@ -585,7 +585,7 @@ static int ubifs_xattr_remove(struct inode *host, const char *name) | |||
| 585 | goto out_free; | 585 | goto out_free; |
| 586 | } | 586 | } |
| 587 | 587 | ||
| 588 | ubifs_assert(inode->i_nlink == 1); | 588 | ubifs_assert(c, inode->i_nlink == 1); |
| 589 | clear_nlink(inode); | 589 | clear_nlink(inode); |
| 590 | err = remove_xattr(c, host, inode, &nm); | 590 | err = remove_xattr(c, host, inode, &nm); |
| 591 | if (err) | 591 | if (err) |
