Lines Matching full:c
5 * Copyright (C) 2006-2008 Nokia Corporation.
41 * @c: the UBIFS file-system description object
44 * properties of the flash and whether LPT is "big" (c->big_lpt).
46 static void do_calc_lpt_geom(struct ubifs_info *c) in do_calc_lpt_geom() argument
51 n = c->main_lebs + c->max_leb_cnt - c->leb_cnt; in do_calc_lpt_geom()
54 c->lpt_hght = 1; in do_calc_lpt_geom()
57 c->lpt_hght += 1; in do_calc_lpt_geom()
61 c->pnode_cnt = DIV_ROUND_UP(c->main_lebs, UBIFS_LPT_FANOUT); in do_calc_lpt_geom()
63 n = DIV_ROUND_UP(c->pnode_cnt, UBIFS_LPT_FANOUT); in do_calc_lpt_geom()
64 c->nnode_cnt = n; in do_calc_lpt_geom()
65 for (i = 1; i < c->lpt_hght; i++) { in do_calc_lpt_geom()
67 c->nnode_cnt += n; in do_calc_lpt_geom()
70 c->space_bits = fls(c->leb_size) - 3; in do_calc_lpt_geom()
71 c->lpt_lnum_bits = fls(c->lpt_lebs); in do_calc_lpt_geom()
72 c->lpt_offs_bits = fls(c->leb_size - 1); in do_calc_lpt_geom()
73 c->lpt_spc_bits = fls(c->leb_size); in do_calc_lpt_geom()
75 n = DIV_ROUND_UP(c->max_leb_cnt, UBIFS_LPT_FANOUT); in do_calc_lpt_geom()
76 c->pcnt_bits = fls(n - 1); in do_calc_lpt_geom()
78 c->lnum_bits = fls(c->max_leb_cnt - 1); in do_calc_lpt_geom()
81 (c->big_lpt ? c->pcnt_bits : 0) + in do_calc_lpt_geom()
82 (c->space_bits * 2 + 1) * UBIFS_LPT_FANOUT; in do_calc_lpt_geom()
83 c->pnode_sz = (bits + 7) / 8; in do_calc_lpt_geom()
86 (c->big_lpt ? c->pcnt_bits : 0) + in do_calc_lpt_geom()
87 (c->lpt_lnum_bits + c->lpt_offs_bits) * UBIFS_LPT_FANOUT; in do_calc_lpt_geom()
88 c->nnode_sz = (bits + 7) / 8; in do_calc_lpt_geom()
91 c->lpt_lebs * c->lpt_spc_bits * 2; in do_calc_lpt_geom()
92 c->ltab_sz = (bits + 7) / 8; in do_calc_lpt_geom()
95 c->lnum_bits * c->lsave_cnt; in do_calc_lpt_geom()
96 c->lsave_sz = (bits + 7) / 8; in do_calc_lpt_geom()
99 c->lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; in do_calc_lpt_geom()
100 c->lpt_sz += (long long)c->nnode_cnt * c->nnode_sz; in do_calc_lpt_geom()
101 c->lpt_sz += c->ltab_sz; in do_calc_lpt_geom()
102 if (c->big_lpt) in do_calc_lpt_geom()
103 c->lpt_sz += c->lsave_sz; in do_calc_lpt_geom()
106 sz = c->lpt_sz; in do_calc_lpt_geom()
107 per_leb_wastage = max_t(int, c->pnode_sz, c->nnode_sz); in do_calc_lpt_geom()
110 while (sz > c->leb_size) { in do_calc_lpt_geom()
112 sz -= c->leb_size; in do_calc_lpt_geom()
115 tot_wastage += ALIGN(sz, c->min_io_size) - sz; in do_calc_lpt_geom()
116 c->lpt_sz += tot_wastage; in do_calc_lpt_geom()
121 * @c: the UBIFS file-system description object
125 int ubifs_calc_lpt_geom(struct ubifs_info *c) in ubifs_calc_lpt_geom() argument
130 do_calc_lpt_geom(c); in ubifs_calc_lpt_geom()
133 sz = c->lpt_sz * 2; /* Must have at least 2 times the size */ in ubifs_calc_lpt_geom()
134 lebs_needed = div_u64(sz + c->leb_size - 1, c->leb_size); in ubifs_calc_lpt_geom()
135 if (lebs_needed > c->lpt_lebs) { in ubifs_calc_lpt_geom()
136 ubifs_err(c, "too few LPT LEBs"); in ubifs_calc_lpt_geom()
141 if (c->ltab_sz > c->leb_size) { in ubifs_calc_lpt_geom()
142 ubifs_err(c, "LPT ltab too big"); in ubifs_calc_lpt_geom()
146 c->check_lpt_free = c->big_lpt; in ubifs_calc_lpt_geom()
152 * @c: the UBIFS file-system description object
162 static int calc_dflt_lpt_geom(struct ubifs_info *c, int *main_lebs, in calc_dflt_lpt_geom() argument
169 c->lpt_lebs = UBIFS_MIN_LPT_LEBS; in calc_dflt_lpt_geom()
170 c->main_lebs = *main_lebs - c->lpt_lebs; in calc_dflt_lpt_geom()
171 if (c->main_lebs <= 0) in calc_dflt_lpt_geom()
175 c->big_lpt = 0; in calc_dflt_lpt_geom()
181 do_calc_lpt_geom(c); in calc_dflt_lpt_geom()
184 if (c->lpt_sz > c->leb_size) { in calc_dflt_lpt_geom()
186 c->big_lpt = 1; in calc_dflt_lpt_geom()
187 do_calc_lpt_geom(c); in calc_dflt_lpt_geom()
192 sz = c->lpt_sz * 4; /* Allow 4 times the size */ in calc_dflt_lpt_geom()
193 lebs_needed = div_u64(sz + c->leb_size - 1, c->leb_size); in calc_dflt_lpt_geom()
194 if (lebs_needed > c->lpt_lebs) { in calc_dflt_lpt_geom()
196 c->lpt_lebs = lebs_needed; in calc_dflt_lpt_geom()
197 c->main_lebs = *main_lebs - c->lpt_lebs; in calc_dflt_lpt_geom()
198 if (c->main_lebs <= 0) in calc_dflt_lpt_geom()
200 do_calc_lpt_geom(c); in calc_dflt_lpt_geom()
203 if (c->ltab_sz > c->leb_size) { in calc_dflt_lpt_geom()
204 ubifs_err(c, "LPT ltab too big"); in calc_dflt_lpt_geom()
207 *main_lebs = c->main_lebs; in calc_dflt_lpt_geom()
208 *big_lpt = c->big_lpt; in calc_dflt_lpt_geom()
216 * @c: UBIFS file-system description object
222 static void pack_bits(const struct ubifs_info *c, uint8_t **addr, int *pos, uint32_t val, int nrbit… in pack_bits() argument
227 ubifs_assert(c, nrbits > 0); in pack_bits()
228 ubifs_assert(c, nrbits <= 32); in pack_bits()
229 ubifs_assert(c, *pos >= 0); in pack_bits()
230 ubifs_assert(c, *pos < 8); in pack_bits()
231 ubifs_assert(c, (val >> nrbits) == 0 || nrbits == 32); in pack_bits()
266 * @c: UBIFS file-system description object
273 uint32_t ubifs_unpack_bits(const struct ubifs_info *c, uint8_t **addr, int *pos, int nrbits) in ubifs_unpack_bits() argument
281 ubifs_assert(c, nrbits > 0); in ubifs_unpack_bits()
282 ubifs_assert(c, nrbits <= 32); in ubifs_unpack_bits()
283 ubifs_assert(c, *pos >= 0); in ubifs_unpack_bits()
284 ubifs_assert(c, *pos < 8); in ubifs_unpack_bits()
330 ubifs_assert(c, (val >> nrbits) == 0 || nrbits - b == 32); in ubifs_unpack_bits()
336 * @c: UBIFS file-system description object
340 void ubifs_pack_pnode(struct ubifs_info *c, void *buf, in ubifs_pack_pnode() argument
347 pack_bits(c, &addr, &pos, UBIFS_LPT_PNODE, UBIFS_LPT_TYPE_BITS); in ubifs_pack_pnode()
348 if (c->big_lpt) in ubifs_pack_pnode()
349 pack_bits(c, &addr, &pos, pnode->num, c->pcnt_bits); in ubifs_pack_pnode()
351 pack_bits(c, &addr, &pos, pnode->lprops[i].free >> 3, in ubifs_pack_pnode()
352 c->space_bits); in ubifs_pack_pnode()
353 pack_bits(c, &addr, &pos, pnode->lprops[i].dirty >> 3, in ubifs_pack_pnode()
354 c->space_bits); in ubifs_pack_pnode()
356 pack_bits(c, &addr, &pos, 1, 1); in ubifs_pack_pnode()
358 pack_bits(c, &addr, &pos, 0, 1); in ubifs_pack_pnode()
361 c->pnode_sz - UBIFS_LPT_CRC_BYTES); in ubifs_pack_pnode()
364 pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS); in ubifs_pack_pnode()
369 * @c: UBIFS file-system description object
373 void ubifs_pack_nnode(struct ubifs_info *c, void *buf, in ubifs_pack_nnode() argument
380 pack_bits(c, &addr, &pos, UBIFS_LPT_NNODE, UBIFS_LPT_TYPE_BITS); in ubifs_pack_nnode()
381 if (c->big_lpt) in ubifs_pack_nnode()
382 pack_bits(c, &addr, &pos, nnode->num, c->pcnt_bits); in ubifs_pack_nnode()
387 lnum = c->lpt_last + 1; in ubifs_pack_nnode()
388 pack_bits(c, &addr, &pos, lnum - c->lpt_first, c->lpt_lnum_bits); in ubifs_pack_nnode()
389 pack_bits(c, &addr, &pos, nnode->nbranch[i].offs, in ubifs_pack_nnode()
390 c->lpt_offs_bits); in ubifs_pack_nnode()
393 c->nnode_sz - UBIFS_LPT_CRC_BYTES); in ubifs_pack_nnode()
396 pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS); in ubifs_pack_nnode()
401 * @c: UBIFS file-system description object
405 void ubifs_pack_ltab(struct ubifs_info *c, void *buf, in ubifs_pack_ltab() argument
412 pack_bits(c, &addr, &pos, UBIFS_LPT_LTAB, UBIFS_LPT_TYPE_BITS); in ubifs_pack_ltab()
413 for (i = 0; i < c->lpt_lebs; i++) { in ubifs_pack_ltab()
414 pack_bits(c, &addr, &pos, ltab[i].free, c->lpt_spc_bits); in ubifs_pack_ltab()
415 pack_bits(c, &addr, &pos, ltab[i].dirty, c->lpt_spc_bits); in ubifs_pack_ltab()
418 c->ltab_sz - UBIFS_LPT_CRC_BYTES); in ubifs_pack_ltab()
421 pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS); in ubifs_pack_ltab()
426 * @c: UBIFS file-system description object
430 void ubifs_pack_lsave(struct ubifs_info *c, void *buf, int *lsave) in ubifs_pack_lsave() argument
436 pack_bits(c, &addr, &pos, UBIFS_LPT_LSAVE, UBIFS_LPT_TYPE_BITS); in ubifs_pack_lsave()
437 for (i = 0; i < c->lsave_cnt; i++) in ubifs_pack_lsave()
438 pack_bits(c, &addr, &pos, lsave[i], c->lnum_bits); in ubifs_pack_lsave()
440 c->lsave_sz - UBIFS_LPT_CRC_BYTES); in ubifs_pack_lsave()
443 pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS); in ubifs_pack_lsave()
448 * @c: UBIFS file-system description object
452 void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty) in ubifs_add_lpt_dirt() argument
457 lnum, dirty, c->ltab[lnum - c->lpt_first].dirty); in ubifs_add_lpt_dirt()
458 ubifs_assert(c, lnum >= c->lpt_first && lnum <= c->lpt_last); in ubifs_add_lpt_dirt()
459 c->ltab[lnum - c->lpt_first].dirty += dirty; in ubifs_add_lpt_dirt()
464 * @c: UBIFS file-system description object
469 static void set_ltab(struct ubifs_info *c, int lnum, int free, int dirty) in set_ltab() argument
472 lnum, c->ltab[lnum - c->lpt_first].free, in set_ltab()
473 c->ltab[lnum - c->lpt_first].dirty, free, dirty); in set_ltab()
474 ubifs_assert(c, lnum >= c->lpt_first && lnum <= c->lpt_last); in set_ltab()
475 c->ltab[lnum - c->lpt_first].free = free; in set_ltab()
476 c->ltab[lnum - c->lpt_first].dirty = dirty; in set_ltab()
481 * @c: UBIFS file-system description object
484 void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode) in ubifs_add_nnode_dirt() argument
489 ubifs_add_lpt_dirt(c, np->nbranch[nnode->iip].lnum, in ubifs_add_nnode_dirt()
490 c->nnode_sz); in ubifs_add_nnode_dirt()
492 ubifs_add_lpt_dirt(c, c->lpt_lnum, c->nnode_sz); in ubifs_add_nnode_dirt()
493 if (!(c->lpt_drty_flgs & LTAB_DIRTY)) { in ubifs_add_nnode_dirt()
494 c->lpt_drty_flgs |= LTAB_DIRTY; in ubifs_add_nnode_dirt()
495 ubifs_add_lpt_dirt(c, c->ltab_lnum, c->ltab_sz); in ubifs_add_nnode_dirt()
502 * @c: UBIFS file-system description object
505 static void add_pnode_dirt(struct ubifs_info *c, struct ubifs_pnode *pnode) in add_pnode_dirt() argument
507 ubifs_add_lpt_dirt(c, pnode->parent->nbranch[pnode->iip].lnum, in add_pnode_dirt()
508 c->pnode_sz); in add_pnode_dirt()
538 * @c: UBIFS file-system description object
548 static int calc_nnode_num_from_parent(const struct ubifs_info *c, in calc_nnode_num_from_parent() argument
555 shft = (c->lpt_hght - parent->level) * UBIFS_LPT_FANOUT_SHIFT; in calc_nnode_num_from_parent()
563 * @c: UBIFS file-system description object
573 static int calc_pnode_num_from_parent(const struct ubifs_info *c, in calc_pnode_num_from_parent() argument
576 int i, n = c->lpt_hght - 1, pnum = parent->num, num = 0; in calc_pnode_num_from_parent()
590 * @c: UBIFS file-system description object
599 int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, in ubifs_create_dflt_lpt() argument
611 err = calc_dflt_lpt_geom(c, main_lebs, big_lpt); in ubifs_create_dflt_lpt()
614 *lpt_lebs = c->lpt_lebs; in ubifs_create_dflt_lpt()
617 c->lpt_first = lpt_first; in ubifs_create_dflt_lpt()
619 c->lpt_last = lpt_first + c->lpt_lebs - 1; in ubifs_create_dflt_lpt()
621 c->main_first = c->leb_cnt - *main_lebs; in ubifs_create_dflt_lpt()
623 desc = ubifs_hash_get_desc(c); in ubifs_create_dflt_lpt()
627 lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_KERNEL); in ubifs_create_dflt_lpt()
630 buf = vmalloc(c->leb_size); in ubifs_create_dflt_lpt()
632 c->lpt_lebs)); in ubifs_create_dflt_lpt()
638 ubifs_assert(c, !c->ltab); in ubifs_create_dflt_lpt()
639 c->ltab = ltab; /* Needed by set_ltab */ in ubifs_create_dflt_lpt()
642 for (i = 0; i < c->lpt_lebs; i++) { in ubifs_create_dflt_lpt()
643 ltab[i].free = c->leb_size; in ubifs_create_dflt_lpt()
652 cnt = c->pnode_cnt; in ubifs_create_dflt_lpt()
658 node_sz = ALIGN(ubifs_idx_node_sz(c, 1), 8); in ubifs_create_dflt_lpt()
659 iopos = ALIGN(node_sz, c->min_io_size); in ubifs_create_dflt_lpt()
660 pnode->lprops[0].free = c->leb_size - iopos; in ubifs_create_dflt_lpt()
665 iopos = ALIGN(node_sz, c->min_io_size); in ubifs_create_dflt_lpt()
666 pnode->lprops[1].free = c->leb_size - iopos; in ubifs_create_dflt_lpt()
670 pnode->lprops[i].free = c->leb_size; in ubifs_create_dflt_lpt()
673 ubifs_pack_pnode(c, p, pnode); in ubifs_create_dflt_lpt()
674 err = ubifs_shash_update(c, desc, p, c->pnode_sz); in ubifs_create_dflt_lpt()
678 p += c->pnode_sz; in ubifs_create_dflt_lpt()
679 len = c->pnode_sz; in ubifs_create_dflt_lpt()
683 pnode->lprops[0].free = c->leb_size; in ubifs_create_dflt_lpt()
687 pnode->lprops[1].free = c->leb_size; in ubifs_create_dflt_lpt()
697 bsz = c->pnode_sz; /* Size of nodes in level below */ in ubifs_create_dflt_lpt()
701 if (len + c->pnode_sz > c->leb_size) { in ubifs_create_dflt_lpt()
702 alen = ALIGN(len, c->min_io_size); in ubifs_create_dflt_lpt()
703 set_ltab(c, lnum, c->leb_size - alen, alen - len); in ubifs_create_dflt_lpt()
705 err = ubifs_leb_change(c, lnum++, buf, alen); in ubifs_create_dflt_lpt()
711 ubifs_pack_pnode(c, p, pnode); in ubifs_create_dflt_lpt()
712 err = ubifs_shash_update(c, desc, p, c->pnode_sz); in ubifs_create_dflt_lpt()
716 p += c->pnode_sz; in ubifs_create_dflt_lpt()
717 len += c->pnode_sz; in ubifs_create_dflt_lpt()
734 if (len + c->nnode_sz > c->leb_size) { in ubifs_create_dflt_lpt()
735 alen = ALIGN(len, c->min_io_size); in ubifs_create_dflt_lpt()
736 set_ltab(c, lnum, c->leb_size - alen, in ubifs_create_dflt_lpt()
739 err = ubifs_leb_change(c, lnum++, buf, alen); in ubifs_create_dflt_lpt()
747 c->lpt_lnum = lnum; in ubifs_create_dflt_lpt()
748 c->lpt_offs = len; in ubifs_create_dflt_lpt()
753 if (boffs + bsz > c->leb_size) { in ubifs_create_dflt_lpt()
767 ubifs_pack_nnode(c, p, nnode); in ubifs_create_dflt_lpt()
768 p += c->nnode_sz; in ubifs_create_dflt_lpt()
769 len += c->nnode_sz; in ubifs_create_dflt_lpt()
776 bsz = c->nnode_sz; in ubifs_create_dflt_lpt()
782 if (len + c->lsave_sz > c->leb_size) { in ubifs_create_dflt_lpt()
783 alen = ALIGN(len, c->min_io_size); in ubifs_create_dflt_lpt()
784 set_ltab(c, lnum, c->leb_size - alen, alen - len); in ubifs_create_dflt_lpt()
786 err = ubifs_leb_change(c, lnum++, buf, alen); in ubifs_create_dflt_lpt()
793 c->lsave_lnum = lnum; in ubifs_create_dflt_lpt()
794 c->lsave_offs = len; in ubifs_create_dflt_lpt()
796 for (i = 0; i < c->lsave_cnt && i < *main_lebs; i++) in ubifs_create_dflt_lpt()
797 lsave[i] = c->main_first + i; in ubifs_create_dflt_lpt()
798 for (; i < c->lsave_cnt; i++) in ubifs_create_dflt_lpt()
799 lsave[i] = c->main_first; in ubifs_create_dflt_lpt()
801 ubifs_pack_lsave(c, p, lsave); in ubifs_create_dflt_lpt()
802 p += c->lsave_sz; in ubifs_create_dflt_lpt()
803 len += c->lsave_sz; in ubifs_create_dflt_lpt()
807 if (len + c->ltab_sz > c->leb_size) { in ubifs_create_dflt_lpt()
808 alen = ALIGN(len, c->min_io_size); in ubifs_create_dflt_lpt()
809 set_ltab(c, lnum, c->leb_size - alen, alen - len); in ubifs_create_dflt_lpt()
811 err = ubifs_leb_change(c, lnum++, buf, alen); in ubifs_create_dflt_lpt()
818 c->ltab_lnum = lnum; in ubifs_create_dflt_lpt()
819 c->ltab_offs = len; in ubifs_create_dflt_lpt()
822 len += c->ltab_sz; in ubifs_create_dflt_lpt()
823 alen = ALIGN(len, c->min_io_size); in ubifs_create_dflt_lpt()
824 set_ltab(c, lnum, c->leb_size - alen, alen - len); in ubifs_create_dflt_lpt()
826 ubifs_pack_ltab(c, p, ltab); in ubifs_create_dflt_lpt()
827 p += c->ltab_sz; in ubifs_create_dflt_lpt()
831 err = ubifs_leb_change(c, lnum, buf, alen); in ubifs_create_dflt_lpt()
835 err = ubifs_shash_final(c, desc, hash); in ubifs_create_dflt_lpt()
839 c->nhead_lnum = lnum; in ubifs_create_dflt_lpt()
840 c->nhead_offs = ALIGN(len, c->min_io_size); in ubifs_create_dflt_lpt()
842 dbg_lp("space_bits %d", c->space_bits); in ubifs_create_dflt_lpt()
843 dbg_lp("lpt_lnum_bits %d", c->lpt_lnum_bits); in ubifs_create_dflt_lpt()
844 dbg_lp("lpt_offs_bits %d", c->lpt_offs_bits); in ubifs_create_dflt_lpt()
845 dbg_lp("lpt_spc_bits %d", c->lpt_spc_bits); in ubifs_create_dflt_lpt()
846 dbg_lp("pcnt_bits %d", c->pcnt_bits); in ubifs_create_dflt_lpt()
847 dbg_lp("lnum_bits %d", c->lnum_bits); in ubifs_create_dflt_lpt()
848 dbg_lp("pnode_sz %d", c->pnode_sz); in ubifs_create_dflt_lpt()
849 dbg_lp("nnode_sz %d", c->nnode_sz); in ubifs_create_dflt_lpt()
850 dbg_lp("ltab_sz %d", c->ltab_sz); in ubifs_create_dflt_lpt()
851 dbg_lp("lsave_sz %d", c->lsave_sz); in ubifs_create_dflt_lpt()
852 dbg_lp("lsave_cnt %d", c->lsave_cnt); in ubifs_create_dflt_lpt()
853 dbg_lp("lpt_hght %d", c->lpt_hght); in ubifs_create_dflt_lpt()
854 dbg_lp("big_lpt %d", c->big_lpt); in ubifs_create_dflt_lpt()
855 dbg_lp("LPT root is at %d:%d", c->lpt_lnum, c->lpt_offs); in ubifs_create_dflt_lpt()
856 dbg_lp("LPT head is at %d:%d", c->nhead_lnum, c->nhead_offs); in ubifs_create_dflt_lpt()
857 dbg_lp("LPT ltab is at %d:%d", c->ltab_lnum, c->ltab_offs); in ubifs_create_dflt_lpt()
858 if (c->big_lpt) in ubifs_create_dflt_lpt()
859 dbg_lp("LPT lsave is at %d:%d", c->lsave_lnum, c->lsave_offs); in ubifs_create_dflt_lpt()
861 c->ltab = NULL; in ubifs_create_dflt_lpt()
873 * @c: UBIFS file-system description object
879 static void update_cats(struct ubifs_info *c, struct ubifs_pnode *pnode) in update_cats() argument
889 ubifs_add_to_cat(c, &pnode->lprops[i], cat); in update_cats()
895 * @c: UBIFS file-system description object
903 static void replace_cats(struct ubifs_info *c, struct ubifs_pnode *old_pnode, in replace_cats() argument
911 ubifs_replace_cat(c, &old_pnode->lprops[i], in replace_cats()
918 * @c: UBIFS file-system description object
924 static int check_lpt_crc(const struct ubifs_info *c, void *buf, int len) in check_lpt_crc() argument
930 crc = ubifs_unpack_bits(c, &addr, &pos, UBIFS_LPT_CRC_BITS); in check_lpt_crc()
934 ubifs_err(c, "invalid crc in LPT node: crc %hx calc %hx", in check_lpt_crc()
944 * @c: UBIFS file-system description object
951 static int check_lpt_type(const struct ubifs_info *c, uint8_t **addr, in check_lpt_type() argument
956 node_type = ubifs_unpack_bits(c, addr, pos, UBIFS_LPT_TYPE_BITS); in check_lpt_type()
958 ubifs_err(c, "invalid type (%d) in LPT node type %d", in check_lpt_type()
968 * @c: UBIFS file-system description object
974 static int unpack_pnode(const struct ubifs_info *c, void *buf, in unpack_pnode() argument
980 err = check_lpt_type(c, &addr, &pos, UBIFS_LPT_PNODE); in unpack_pnode()
983 if (c->big_lpt) in unpack_pnode()
984 pnode->num = ubifs_unpack_bits(c, &addr, &pos, c->pcnt_bits); in unpack_pnode()
988 lprops->free = ubifs_unpack_bits(c, &addr, &pos, c->space_bits); in unpack_pnode()
990 lprops->dirty = ubifs_unpack_bits(c, &addr, &pos, c->space_bits); in unpack_pnode()
993 if (ubifs_unpack_bits(c, &addr, &pos, 1)) in unpack_pnode()
997 lprops->flags |= ubifs_categorize_lprops(c, lprops); in unpack_pnode()
999 err = check_lpt_crc(c, buf, c->pnode_sz); in unpack_pnode()
1005 * @c: UBIFS file-system description object
1011 int ubifs_unpack_nnode(const struct ubifs_info *c, void *buf, in ubifs_unpack_nnode() argument
1017 err = check_lpt_type(c, &addr, &pos, UBIFS_LPT_NNODE); in ubifs_unpack_nnode()
1020 if (c->big_lpt) in ubifs_unpack_nnode()
1021 nnode->num = ubifs_unpack_bits(c, &addr, &pos, c->pcnt_bits); in ubifs_unpack_nnode()
1025 lnum = ubifs_unpack_bits(c, &addr, &pos, c->lpt_lnum_bits) + in ubifs_unpack_nnode()
1026 c->lpt_first; in ubifs_unpack_nnode()
1027 if (lnum == c->lpt_last + 1) in ubifs_unpack_nnode()
1030 nnode->nbranch[i].offs = ubifs_unpack_bits(c, &addr, &pos, in ubifs_unpack_nnode()
1031 c->lpt_offs_bits); in ubifs_unpack_nnode()
1033 err = check_lpt_crc(c, buf, c->nnode_sz); in ubifs_unpack_nnode()
1039 * @c: UBIFS file-system description object
1044 static int unpack_ltab(const struct ubifs_info *c, void *buf) in unpack_ltab() argument
1049 err = check_lpt_type(c, &addr, &pos, UBIFS_LPT_LTAB); in unpack_ltab()
1052 for (i = 0; i < c->lpt_lebs; i++) { in unpack_ltab()
1053 int free = ubifs_unpack_bits(c, &addr, &pos, c->lpt_spc_bits); in unpack_ltab()
1054 int dirty = ubifs_unpack_bits(c, &addr, &pos, c->lpt_spc_bits); in unpack_ltab()
1056 if (free < 0 || free > c->leb_size || dirty < 0 || in unpack_ltab()
1057 dirty > c->leb_size || free + dirty > c->leb_size) in unpack_ltab()
1060 c->ltab[i].free = free; in unpack_ltab()
1061 c->ltab[i].dirty = dirty; in unpack_ltab()
1062 c->ltab[i].tgc = 0; in unpack_ltab()
1063 c->ltab[i].cmt = 0; in unpack_ltab()
1065 err = check_lpt_crc(c, buf, c->ltab_sz); in unpack_ltab()
1071 * @c: UBIFS file-system description object
1076 static int unpack_lsave(const struct ubifs_info *c, void *buf) in unpack_lsave() argument
1081 err = check_lpt_type(c, &addr, &pos, UBIFS_LPT_LSAVE); in unpack_lsave()
1084 for (i = 0; i < c->lsave_cnt; i++) { in unpack_lsave()
1085 int lnum = ubifs_unpack_bits(c, &addr, &pos, c->lnum_bits); in unpack_lsave()
1087 if (lnum < c->main_first || lnum >= c->leb_cnt) in unpack_lsave()
1089 c->lsave[i] = lnum; in unpack_lsave()
1091 err = check_lpt_crc(c, buf, c->lsave_sz); in unpack_lsave()
1097 * @c: UBIFS file-system description object
1104 static int validate_nnode(const struct ubifs_info *c, struct ubifs_nnode *nnode, in validate_nnode() argument
1109 if (c->big_lpt) { in validate_nnode()
1110 int num = calc_nnode_num_from_parent(c, parent, iip); in validate_nnode()
1115 lvl = parent ? parent->level - 1 : c->lpt_hght; in validate_nnode()
1119 max_offs = c->leb_size - c->pnode_sz; in validate_nnode()
1121 max_offs = c->leb_size - c->nnode_sz; in validate_nnode()
1131 if (lnum < c->lpt_first || lnum > c->lpt_last) in validate_nnode()
1141 * @c: UBIFS file-system description object
1148 static int validate_pnode(const struct ubifs_info *c, struct ubifs_pnode *pnode, in validate_pnode() argument
1153 if (c->big_lpt) { in validate_pnode()
1154 int num = calc_pnode_num_from_parent(c, parent, iip); in validate_pnode()
1163 if (free < 0 || free > c->leb_size || free % c->min_io_size || in validate_pnode()
1166 if (dirty < 0 || dirty > c->leb_size || (dirty & 7)) in validate_pnode()
1168 if (dirty + free > c->leb_size) in validate_pnode()
1176 * @c: UBIFS file-system description object
1182 static void set_pnode_lnum(const struct ubifs_info *c, in set_pnode_lnum() argument
1187 lnum = (pnode->num << UBIFS_LPT_FANOUT_SHIFT) + c->main_first; in set_pnode_lnum()
1189 if (lnum >= c->leb_cnt) in set_pnode_lnum()
1197 * @c: UBIFS file-system description object
1203 int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) in ubifs_read_nnode() argument
1207 void *buf = c->lpt_nod_buf; in ubifs_read_nnode()
1215 lnum = c->lpt_lnum; in ubifs_read_nnode()
1216 offs = c->lpt_offs; in ubifs_read_nnode()
1230 if (c->big_lpt) in ubifs_read_nnode()
1231 nnode->num = calc_nnode_num_from_parent(c, parent, iip); in ubifs_read_nnode()
1233 err = ubifs_leb_read(c, lnum, buf, offs, c->nnode_sz, 1); in ubifs_read_nnode()
1236 err = ubifs_unpack_nnode(c, buf, nnode); in ubifs_read_nnode()
1240 err = validate_nnode(c, nnode, parent, iip); in ubifs_read_nnode()
1243 if (!c->big_lpt) in ubifs_read_nnode()
1244 nnode->num = calc_nnode_num_from_parent(c, parent, iip); in ubifs_read_nnode()
1249 c->nroot = nnode; in ubifs_read_nnode()
1250 nnode->level = c->lpt_hght; in ubifs_read_nnode()
1257 ubifs_err(c, "error %d reading nnode at %d:%d", err, lnum, offs); in ubifs_read_nnode()
1265 * @c: UBIFS file-system description object
1271 static int read_pnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) in read_pnode() argument
1275 void *buf = c->lpt_nod_buf; in read_pnode()
1293 if (c->big_lpt) in read_pnode()
1294 pnode->num = calc_pnode_num_from_parent(c, parent, iip); in read_pnode()
1298 lprops->free = c->leb_size; in read_pnode()
1299 lprops->flags = ubifs_categorize_lprops(c, lprops); in read_pnode()
1302 err = ubifs_leb_read(c, lnum, buf, offs, c->pnode_sz, 1); in read_pnode()
1305 err = unpack_pnode(c, buf, pnode); in read_pnode()
1309 err = validate_pnode(c, pnode, parent, iip); in read_pnode()
1312 if (!c->big_lpt) in read_pnode()
1313 pnode->num = calc_pnode_num_from_parent(c, parent, iip); in read_pnode()
1317 set_pnode_lnum(c, pnode); in read_pnode()
1318 c->pnodes_have += 1; in read_pnode()
1322 ubifs_err(c, "error %d reading pnode at %d:%d", err, lnum, offs); in read_pnode()
1323 ubifs_dump_pnode(c, pnode, parent, iip); in read_pnode()
1325 ubifs_err(c, "calc num: %d", calc_pnode_num_from_parent(c, parent, iip)); in read_pnode()
1332 * @c: UBIFS file-system description object
1336 static int read_ltab(struct ubifs_info *c) in read_ltab() argument
1341 buf = vmalloc(c->ltab_sz); in read_ltab()
1344 err = ubifs_leb_read(c, c->ltab_lnum, buf, c->ltab_offs, c->ltab_sz, 1); in read_ltab()
1347 err = unpack_ltab(c, buf); in read_ltab()
1355 * @c: UBIFS file-system description object
1359 static int read_lsave(struct ubifs_info *c) in read_lsave() argument
1364 buf = vmalloc(c->lsave_sz); in read_lsave()
1367 err = ubifs_leb_read(c, c->lsave_lnum, buf, c->lsave_offs, in read_lsave()
1368 c->lsave_sz, 1); in read_lsave()
1371 err = unpack_lsave(c, buf); in read_lsave()
1374 for (i = 0; i < c->lsave_cnt; i++) { in read_lsave()
1375 int lnum = c->lsave[i]; in read_lsave()
1382 if (lnum >= c->leb_cnt) in read_lsave()
1384 lprops = ubifs_lpt_lookup(c, lnum); in read_lsave()
1397 * @c: UBIFS file-system description object
1404 struct ubifs_nnode *ubifs_get_nnode(struct ubifs_info *c, in ubifs_get_nnode() argument
1415 err = ubifs_read_nnode(c, parent, iip); in ubifs_get_nnode()
1423 * @c: UBIFS file-system description object
1430 struct ubifs_pnode *ubifs_get_pnode(struct ubifs_info *c, in ubifs_get_pnode() argument
1441 err = read_pnode(c, parent, iip); in ubifs_get_pnode()
1444 update_cats(c, branch->pnode); in ubifs_get_pnode()
1450 * @c: UBIFS file-system description object
1456 struct ubifs_pnode *ubifs_pnode_lookup(struct ubifs_info *c, int i) in ubifs_pnode_lookup() argument
1461 if (!c->nroot) { in ubifs_pnode_lookup()
1462 err = ubifs_read_nnode(c, NULL, 0); in ubifs_pnode_lookup()
1467 nnode = c->nroot; in ubifs_pnode_lookup()
1468 shft = c->lpt_hght * UBIFS_LPT_FANOUT_SHIFT; in ubifs_pnode_lookup()
1469 for (h = 1; h < c->lpt_hght; h++) { in ubifs_pnode_lookup()
1472 nnode = ubifs_get_nnode(c, nnode, iip); in ubifs_pnode_lookup()
1477 return ubifs_get_pnode(c, nnode, iip); in ubifs_pnode_lookup()
1482 * @c: UBIFS file-system description object
1488 struct ubifs_lprops *ubifs_lpt_lookup(struct ubifs_info *c, int lnum) in ubifs_lpt_lookup() argument
1493 i = lnum - c->main_first; in ubifs_lpt_lookup()
1494 pnode = ubifs_pnode_lookup(c, i >> UBIFS_LPT_FANOUT_SHIFT); in ubifs_lpt_lookup()
1506 * @c: UBIFS file-system description object
1511 static struct ubifs_nnode *dirty_cow_nnode(struct ubifs_info *c, in dirty_cow_nnode() argument
1520 c->dirty_nn_cnt += 1; in dirty_cow_nnode()
1521 ubifs_add_nnode_dirt(c, nnode); in dirty_cow_nnode()
1543 ubifs_assert(c, !test_bit(OBSOLETE_CNODE, &nnode->flags)); in dirty_cow_nnode()
1546 c->dirty_nn_cnt += 1; in dirty_cow_nnode()
1547 ubifs_add_nnode_dirt(c, nnode); in dirty_cow_nnode()
1551 c->nroot = n; in dirty_cow_nnode()
1557 * @c: UBIFS file-system description object
1562 static struct ubifs_pnode *dirty_cow_pnode(struct ubifs_info *c, in dirty_cow_pnode() argument
1570 c->dirty_pn_cnt += 1; in dirty_cow_pnode()
1571 add_pnode_dirt(c, pnode); in dirty_cow_pnode()
1584 replace_cats(c, pnode, p); in dirty_cow_pnode()
1586 ubifs_assert(c, !test_bit(OBSOLETE_CNODE, &pnode->flags)); in dirty_cow_pnode()
1589 c->dirty_pn_cnt += 1; in dirty_cow_pnode()
1590 add_pnode_dirt(c, pnode); in dirty_cow_pnode()
1597 * @c: UBIFS file-system description object
1603 struct ubifs_lprops *ubifs_lpt_lookup_dirty(struct ubifs_info *c, int lnum) in ubifs_lpt_lookup_dirty() argument
1609 if (!c->nroot) { in ubifs_lpt_lookup_dirty()
1610 err = ubifs_read_nnode(c, NULL, 0); in ubifs_lpt_lookup_dirty()
1614 nnode = c->nroot; in ubifs_lpt_lookup_dirty()
1615 nnode = dirty_cow_nnode(c, nnode); in ubifs_lpt_lookup_dirty()
1618 i = lnum - c->main_first; in ubifs_lpt_lookup_dirty()
1619 shft = c->lpt_hght * UBIFS_LPT_FANOUT_SHIFT; in ubifs_lpt_lookup_dirty()
1620 for (h = 1; h < c->lpt_hght; h++) { in ubifs_lpt_lookup_dirty()
1623 nnode = ubifs_get_nnode(c, nnode, iip); in ubifs_lpt_lookup_dirty()
1626 nnode = dirty_cow_nnode(c, nnode); in ubifs_lpt_lookup_dirty()
1631 pnode = ubifs_get_pnode(c, nnode, iip); in ubifs_lpt_lookup_dirty()
1634 pnode = dirty_cow_pnode(c, pnode); in ubifs_lpt_lookup_dirty()
1641 ubifs_assert(c, test_bit(DIRTY_CNODE, &pnode->flags)); in ubifs_lpt_lookup_dirty()
1647 * @c: UBIFS file-system description object
1653 int ubifs_lpt_calc_hash(struct ubifs_info *c, u8 *hash) in ubifs_lpt_calc_hash() argument
1659 int bufsiz = max_t(int, c->nnode_sz, c->pnode_sz); in ubifs_lpt_calc_hash()
1663 if (!ubifs_authenticated(c)) in ubifs_lpt_calc_hash()
1666 if (!c->nroot) { in ubifs_lpt_calc_hash()
1667 err = ubifs_read_nnode(c, NULL, 0); in ubifs_lpt_calc_hash()
1672 desc = ubifs_hash_get_desc(c); in ubifs_lpt_calc_hash()
1682 cnode = (struct ubifs_cnode *)c->nroot; in ubifs_lpt_calc_hash()
1695 nnode = ubifs_get_nnode(c, nn, iip); in ubifs_lpt_calc_hash()
1714 pnode = ubifs_get_pnode(c, nn, i); in ubifs_lpt_calc_hash()
1720 ubifs_pack_pnode(c, buf, pnode); in ubifs_lpt_calc_hash()
1721 err = ubifs_shash_update(c, desc, buf, in ubifs_lpt_calc_hash()
1722 c->pnode_sz); in ubifs_lpt_calc_hash()
1732 err = ubifs_shash_final(c, desc, hash); in ubifs_lpt_calc_hash()
1742 * @c: UBIFS file-system description object
1748 static int lpt_check_hash(struct ubifs_info *c) in lpt_check_hash() argument
1753 if (!ubifs_authenticated(c)) in lpt_check_hash()
1756 err = ubifs_lpt_calc_hash(c, hash); in lpt_check_hash()
1760 if (ubifs_check_hash(c, c->mst_node->hash_lpt, hash)) { in lpt_check_hash()
1762 ubifs_err(c, "Failed to authenticate LPT"); in lpt_check_hash()
1772 * @c: UBIFS file-system description object
1776 static int lpt_init_rd(struct ubifs_info *c) in lpt_init_rd() argument
1780 c->ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops), in lpt_init_rd()
1781 c->lpt_lebs)); in lpt_init_rd()
1782 if (!c->ltab) in lpt_init_rd()
1785 i = max_t(int, c->nnode_sz, c->pnode_sz); in lpt_init_rd()
1786 c->lpt_nod_buf = kmalloc(i, GFP_KERNEL); in lpt_init_rd()
1787 if (!c->lpt_nod_buf) in lpt_init_rd()
1791 c->lpt_heap[i].arr = kmalloc_array(LPT_HEAP_SZ, in lpt_init_rd()
1794 if (!c->lpt_heap[i].arr) in lpt_init_rd()
1796 c->lpt_heap[i].cnt = 0; in lpt_init_rd()
1797 c->lpt_heap[i].max_cnt = LPT_HEAP_SZ; in lpt_init_rd()
1800 c->dirty_idx.arr = kmalloc_array(LPT_HEAP_SZ, sizeof(void *), in lpt_init_rd()
1802 if (!c->dirty_idx.arr) in lpt_init_rd()
1804 c->dirty_idx.cnt = 0; in lpt_init_rd()
1805 c->dirty_idx.max_cnt = LPT_HEAP_SZ; in lpt_init_rd()
1807 err = read_ltab(c); in lpt_init_rd()
1811 err = lpt_check_hash(c); in lpt_init_rd()
1815 dbg_lp("space_bits %d", c->space_bits); in lpt_init_rd()
1816 dbg_lp("lpt_lnum_bits %d", c->lpt_lnum_bits); in lpt_init_rd()
1817 dbg_lp("lpt_offs_bits %d", c->lpt_offs_bits); in lpt_init_rd()
1818 dbg_lp("lpt_spc_bits %d", c->lpt_spc_bits); in lpt_init_rd()
1819 dbg_lp("pcnt_bits %d", c->pcnt_bits); in lpt_init_rd()
1820 dbg_lp("lnum_bits %d", c->lnum_bits); in lpt_init_rd()
1821 dbg_lp("pnode_sz %d", c->pnode_sz); in lpt_init_rd()
1822 dbg_lp("nnode_sz %d", c->nnode_sz); in lpt_init_rd()
1823 dbg_lp("ltab_sz %d", c->ltab_sz); in lpt_init_rd()
1824 dbg_lp("lsave_sz %d", c->lsave_sz); in lpt_init_rd()
1825 dbg_lp("lsave_cnt %d", c->lsave_cnt); in lpt_init_rd()
1826 dbg_lp("lpt_hght %d", c->lpt_hght); in lpt_init_rd()
1827 dbg_lp("big_lpt %d", c->big_lpt); in lpt_init_rd()
1828 dbg_lp("LPT root is at %d:%d", c->lpt_lnum, c->lpt_offs); in lpt_init_rd()
1829 dbg_lp("LPT head is at %d:%d", c->nhead_lnum, c->nhead_offs); in lpt_init_rd()
1830 dbg_lp("LPT ltab is at %d:%d", c->ltab_lnum, c->ltab_offs); in lpt_init_rd()
1831 if (c->big_lpt) in lpt_init_rd()
1832 dbg_lp("LPT lsave is at %d:%d", c->lsave_lnum, c->lsave_offs); in lpt_init_rd()
1839 * @c: UBIFS file-system description object
1845 static int lpt_init_wr(struct ubifs_info *c) in lpt_init_wr() argument
1849 c->ltab_cmt = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops), in lpt_init_wr()
1850 c->lpt_lebs)); in lpt_init_wr()
1851 if (!c->ltab_cmt) in lpt_init_wr()
1854 c->lpt_buf = vmalloc(c->leb_size); in lpt_init_wr()
1855 if (!c->lpt_buf) in lpt_init_wr()
1858 if (c->big_lpt) { in lpt_init_wr()
1859 c->lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_NOFS); in lpt_init_wr()
1860 if (!c->lsave) in lpt_init_wr()
1862 err = read_lsave(c); in lpt_init_wr()
1867 for (i = 0; i < c->lpt_lebs; i++) in lpt_init_wr()
1868 if (c->ltab[i].free == c->leb_size) { in lpt_init_wr()
1869 err = ubifs_leb_unmap(c, i + c->lpt_first); in lpt_init_wr()
1879 * @c: UBIFS file-system description object
1889 int ubifs_lpt_init(struct ubifs_info *c, int rd, int wr) in ubifs_lpt_init() argument
1894 err = lpt_init_rd(c); in ubifs_lpt_init()
1900 err = lpt_init_wr(c); in ubifs_lpt_init()
1909 ubifs_lpt_free(c, 1); in ubifs_lpt_init()
1911 ubifs_lpt_free(c, 0); in ubifs_lpt_init()
1942 * @c: the UBIFS file-system description object
1950 static struct ubifs_nnode *scan_get_nnode(struct ubifs_info *c, in scan_get_nnode() argument
1956 void *buf = c->lpt_nod_buf; in scan_get_nnode()
1977 if (c->big_lpt) in scan_get_nnode()
1978 nnode->num = calc_nnode_num_from_parent(c, parent, iip); in scan_get_nnode()
1980 err = ubifs_leb_read(c, branch->lnum, buf, branch->offs, in scan_get_nnode()
1981 c->nnode_sz, 1); in scan_get_nnode()
1984 err = ubifs_unpack_nnode(c, buf, nnode); in scan_get_nnode()
1988 err = validate_nnode(c, nnode, parent, iip); in scan_get_nnode()
1991 if (!c->big_lpt) in scan_get_nnode()
1992 nnode->num = calc_nnode_num_from_parent(c, parent, iip); in scan_get_nnode()
2001 * @c: the UBIFS file-system description object
2009 static struct ubifs_pnode *scan_get_pnode(struct ubifs_info *c, in scan_get_pnode() argument
2015 void *buf = c->lpt_nod_buf; in scan_get_pnode()
2037 if (c->big_lpt) in scan_get_pnode()
2038 pnode->num = calc_pnode_num_from_parent(c, parent, iip); in scan_get_pnode()
2042 lprops->free = c->leb_size; in scan_get_pnode()
2043 lprops->flags = ubifs_categorize_lprops(c, lprops); in scan_get_pnode()
2046 ubifs_assert(c, branch->lnum >= c->lpt_first && in scan_get_pnode()
2047 branch->lnum <= c->lpt_last); in scan_get_pnode()
2048 ubifs_assert(c, branch->offs >= 0 && branch->offs < c->leb_size); in scan_get_pnode()
2049 err = ubifs_leb_read(c, branch->lnum, buf, branch->offs, in scan_get_pnode()
2050 c->pnode_sz, 1); in scan_get_pnode()
2053 err = unpack_pnode(c, buf, pnode); in scan_get_pnode()
2057 err = validate_pnode(c, pnode, parent, iip); in scan_get_pnode()
2060 if (!c->big_lpt) in scan_get_pnode()
2061 pnode->num = calc_pnode_num_from_parent(c, parent, iip); in scan_get_pnode()
2064 set_pnode_lnum(c, pnode); in scan_get_pnode()
2070 * @c: the UBIFS file-system description object
2078 int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum, in ubifs_lpt_scan_nolock() argument
2088 if (start_lnum >= c->leb_cnt) in ubifs_lpt_scan_nolock()
2089 start_lnum = c->main_first; in ubifs_lpt_scan_nolock()
2092 ubifs_assert(c, start_lnum >= c->main_first && start_lnum < c->leb_cnt); in ubifs_lpt_scan_nolock()
2093 ubifs_assert(c, end_lnum >= c->main_first && end_lnum < c->leb_cnt); in ubifs_lpt_scan_nolock()
2095 if (!c->nroot) { in ubifs_lpt_scan_nolock()
2096 err = ubifs_read_nnode(c, NULL, 0); in ubifs_lpt_scan_nolock()
2101 path = kmalloc_array(c->lpt_hght + 1, sizeof(struct lpt_scan_node), in ubifs_lpt_scan_nolock()
2106 path[0].ptr.nnode = c->nroot; in ubifs_lpt_scan_nolock()
2110 nnode = c->nroot; in ubifs_lpt_scan_nolock()
2111 i = start_lnum - c->main_first; in ubifs_lpt_scan_nolock()
2112 shft = c->lpt_hght * UBIFS_LPT_FANOUT_SHIFT; in ubifs_lpt_scan_nolock()
2113 for (h = 1; h < c->lpt_hght; h++) { in ubifs_lpt_scan_nolock()
2116 nnode = scan_get_nnode(c, path + h, nnode, iip); in ubifs_lpt_scan_nolock()
2123 pnode = scan_get_pnode(c, path + h, nnode, iip); in ubifs_lpt_scan_nolock()
2135 ret = scan_cb(c, lprops, path[h].in_tree, data); in ubifs_lpt_scan_nolock()
2142 for (h = 1; h < c->lpt_hght; h++) { in ubifs_lpt_scan_nolock()
2160 ubifs_ensure_cat(c, lprops); in ubifs_lpt_scan_nolock()
2174 update_cats(c, pnode); in ubifs_lpt_scan_nolock()
2175 c->pnodes_have += 1; in ubifs_lpt_scan_nolock()
2177 err = dbg_check_lpt_nodes(c, (struct ubifs_cnode *) in ubifs_lpt_scan_nolock()
2178 c->nroot, 0, 0); in ubifs_lpt_scan_nolock()
2181 err = dbg_check_cats(c); in ubifs_lpt_scan_nolock()
2198 if (lnum + 1 >= c->leb_cnt) { in ubifs_lpt_scan_nolock()
2200 start_lnum = c->main_first; in ubifs_lpt_scan_nolock()
2212 ubifs_assert(c, h >= 0); in ubifs_lpt_scan_nolock()
2222 for (; h < c->lpt_hght; h++) { in ubifs_lpt_scan_nolock()
2223 nnode = scan_get_nnode(c, path + h, nnode, iip); in ubifs_lpt_scan_nolock()
2230 pnode = scan_get_pnode(c, path + h, nnode, iip); in ubifs_lpt_scan_nolock()
2244 * @c: the UBIFS file-system description object
2250 static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, in dbg_chk_pnode() argument
2256 ubifs_err(c, "pnode num %d expected %d parent num %d iip %d", in dbg_chk_pnode()
2263 c->main_first; in dbg_chk_pnode()
2268 if (lnum >= c->leb_cnt) in dbg_chk_pnode()
2271 ubifs_err(c, "bad LEB number %d expected %d", in dbg_chk_pnode()
2277 ubifs_err(c, "LEB %d taken but not uncat %d", in dbg_chk_pnode()
2290 ubifs_err(c, "LEB %d index but cat %d", in dbg_chk_pnode()
2303 ubifs_err(c, "LEB %d not index but cat %d", in dbg_chk_pnode()
2310 list = &c->uncat_list; in dbg_chk_pnode()
2313 list = &c->empty_list; in dbg_chk_pnode()
2316 list = &c->freeable_list; in dbg_chk_pnode()
2319 list = &c->frdi_idx_list; in dbg_chk_pnode()
2327 heap = &c->lpt_heap[cat - 1]; in dbg_chk_pnode()
2344 ubifs_err(c, "LEB %d cat %d not found in cat heap/list", in dbg_chk_pnode()
2350 if (lprops->free != c->leb_size) { in dbg_chk_pnode()
2351 ubifs_err(c, "LEB %d cat %d free %d dirty %d", in dbg_chk_pnode()
2359 if (lprops->free + lprops->dirty != c->leb_size) { in dbg_chk_pnode()
2360 ubifs_err(c, "LEB %d cat %d free %d dirty %d", in dbg_chk_pnode()
2373 * @c: the UBIFS file-system description object
2380 int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode, in dbg_check_lpt_nodes() argument
2387 if (!dbg_is_chk_lprops(c)) in dbg_check_lpt_nodes()
2391 ubifs_assert(c, row >= 0); in dbg_check_lpt_nodes()
2397 ubifs_err(c, "nnode num %d expected %d parent num %d iip %d", in dbg_check_lpt_nodes()
2424 err = dbg_chk_pnode(c, pnode, col); in dbg_check_lpt_nodes()