diff options
Diffstat (limited to 'fs/ubifs/lpt.c')
-rw-r--r-- | fs/ubifs/lpt.c | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 66d59d0a1402..ce33b2beb151 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
@@ -701,8 +701,7 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, | |||
701 | alen = ALIGN(len, c->min_io_size); | 701 | alen = ALIGN(len, c->min_io_size); |
702 | set_ltab(c, lnum, c->leb_size - alen, alen - len); | 702 | set_ltab(c, lnum, c->leb_size - alen, alen - len); |
703 | memset(p, 0xff, alen - len); | 703 | memset(p, 0xff, alen - len); |
704 | err = ubifs_leb_change(c, lnum++, buf, alen, | 704 | err = ubifs_leb_change(c, lnum++, buf, alen); |
705 | UBI_SHORTTERM); | ||
706 | if (err) | 705 | if (err) |
707 | goto out; | 706 | goto out; |
708 | p = buf; | 707 | p = buf; |
@@ -732,8 +731,7 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, | |||
732 | set_ltab(c, lnum, c->leb_size - alen, | 731 | set_ltab(c, lnum, c->leb_size - alen, |
733 | alen - len); | 732 | alen - len); |
734 | memset(p, 0xff, alen - len); | 733 | memset(p, 0xff, alen - len); |
735 | err = ubifs_leb_change(c, lnum++, buf, alen, | 734 | err = ubifs_leb_change(c, lnum++, buf, alen); |
736 | UBI_SHORTTERM); | ||
737 | if (err) | 735 | if (err) |
738 | goto out; | 736 | goto out; |
739 | p = buf; | 737 | p = buf; |
@@ -780,8 +778,7 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, | |||
780 | alen = ALIGN(len, c->min_io_size); | 778 | alen = ALIGN(len, c->min_io_size); |
781 | set_ltab(c, lnum, c->leb_size - alen, alen - len); | 779 | set_ltab(c, lnum, c->leb_size - alen, alen - len); |
782 | memset(p, 0xff, alen - len); | 780 | memset(p, 0xff, alen - len); |
783 | err = ubifs_leb_change(c, lnum++, buf, alen, | 781 | err = ubifs_leb_change(c, lnum++, buf, alen); |
784 | UBI_SHORTTERM); | ||
785 | if (err) | 782 | if (err) |
786 | goto out; | 783 | goto out; |
787 | p = buf; | 784 | p = buf; |
@@ -806,7 +803,7 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, | |||
806 | alen = ALIGN(len, c->min_io_size); | 803 | alen = ALIGN(len, c->min_io_size); |
807 | set_ltab(c, lnum, c->leb_size - alen, alen - len); | 804 | set_ltab(c, lnum, c->leb_size - alen, alen - len); |
808 | memset(p, 0xff, alen - len); | 805 | memset(p, 0xff, alen - len); |
809 | err = ubifs_leb_change(c, lnum++, buf, alen, UBI_SHORTTERM); | 806 | err = ubifs_leb_change(c, lnum++, buf, alen); |
810 | if (err) | 807 | if (err) |
811 | goto out; | 808 | goto out; |
812 | p = buf; | 809 | p = buf; |
@@ -826,7 +823,7 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, | |||
826 | 823 | ||
827 | /* Write remaining buffer */ | 824 | /* Write remaining buffer */ |
828 | memset(p, 0xff, alen - len); | 825 | memset(p, 0xff, alen - len); |
829 | err = ubifs_leb_change(c, lnum, buf, alen, UBI_SHORTTERM); | 826 | err = ubifs_leb_change(c, lnum, buf, alen); |
830 | if (err) | 827 | if (err) |
831 | goto out; | 828 | goto out; |
832 | 829 | ||
@@ -926,7 +923,7 @@ static int check_lpt_crc(void *buf, int len) | |||
926 | if (crc != calc_crc) { | 923 | if (crc != calc_crc) { |
927 | ubifs_err("invalid crc in LPT node: crc %hx calc %hx", crc, | 924 | ubifs_err("invalid crc in LPT node: crc %hx calc %hx", crc, |
928 | calc_crc); | 925 | calc_crc); |
929 | dbg_dump_stack(); | 926 | dump_stack(); |
930 | return -EINVAL; | 927 | return -EINVAL; |
931 | } | 928 | } |
932 | return 0; | 929 | return 0; |
@@ -949,7 +946,7 @@ static int check_lpt_type(uint8_t **addr, int *pos, int type) | |||
949 | if (node_type != type) { | 946 | if (node_type != type) { |
950 | ubifs_err("invalid type (%d) in LPT node type %d", node_type, | 947 | ubifs_err("invalid type (%d) in LPT node type %d", node_type, |
951 | type); | 948 | type); |
952 | dbg_dump_stack(); | 949 | dump_stack(); |
953 | return -EINVAL; | 950 | return -EINVAL; |
954 | } | 951 | } |
955 | return 0; | 952 | return 0; |
@@ -1247,7 +1244,7 @@ int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) | |||
1247 | 1244 | ||
1248 | out: | 1245 | out: |
1249 | ubifs_err("error %d reading nnode at %d:%d", err, lnum, offs); | 1246 | ubifs_err("error %d reading nnode at %d:%d", err, lnum, offs); |
1250 | dbg_dump_stack(); | 1247 | dump_stack(); |
1251 | kfree(nnode); | 1248 | kfree(nnode); |
1252 | return err; | 1249 | return err; |
1253 | } | 1250 | } |
@@ -1312,8 +1309,8 @@ static int read_pnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip) | |||
1312 | 1309 | ||
1313 | out: | 1310 | out: |
1314 | ubifs_err("error %d reading pnode at %d:%d", err, lnum, offs); | 1311 | ubifs_err("error %d reading pnode at %d:%d", err, lnum, offs); |
1315 | dbg_dump_pnode(c, pnode, parent, iip); | 1312 | ubifs_dump_pnode(c, pnode, parent, iip); |
1316 | dbg_dump_stack(); | 1313 | dump_stack(); |
1317 | dbg_msg("calc num: %d", calc_pnode_num_from_parent(c, parent, iip)); | 1314 | dbg_msg("calc num: %d", calc_pnode_num_from_parent(c, parent, iip)); |
1318 | kfree(pnode); | 1315 | kfree(pnode); |
1319 | return err; | 1316 | return err; |
@@ -1740,16 +1737,20 @@ int ubifs_lpt_init(struct ubifs_info *c, int rd, int wr) | |||
1740 | if (rd) { | 1737 | if (rd) { |
1741 | err = lpt_init_rd(c); | 1738 | err = lpt_init_rd(c); |
1742 | if (err) | 1739 | if (err) |
1743 | return err; | 1740 | goto out_err; |
1744 | } | 1741 | } |
1745 | 1742 | ||
1746 | if (wr) { | 1743 | if (wr) { |
1747 | err = lpt_init_wr(c); | 1744 | err = lpt_init_wr(c); |
1748 | if (err) | 1745 | if (err) |
1749 | return err; | 1746 | goto out_err; |
1750 | } | 1747 | } |
1751 | 1748 | ||
1752 | return 0; | 1749 | return 0; |
1750 | |||
1751 | out_err: | ||
1752 | ubifs_lpt_free(c, 0); | ||
1753 | return err; | ||
1753 | } | 1754 | } |
1754 | 1755 | ||
1755 | /** | 1756 | /** |
@@ -2080,8 +2081,6 @@ out: | |||
2080 | return err; | 2081 | return err; |
2081 | } | 2082 | } |
2082 | 2083 | ||
2083 | #ifdef CONFIG_UBIFS_FS_DEBUG | ||
2084 | |||
2085 | /** | 2084 | /** |
2086 | * dbg_chk_pnode - check a pnode. | 2085 | * dbg_chk_pnode - check a pnode. |
2087 | * @c: the UBIFS file-system description object | 2086 | * @c: the UBIFS file-system description object |
@@ -2096,8 +2095,8 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, | |||
2096 | int i; | 2095 | int i; |
2097 | 2096 | ||
2098 | if (pnode->num != col) { | 2097 | if (pnode->num != col) { |
2099 | dbg_err("pnode num %d expected %d parent num %d iip %d", | 2098 | ubifs_err("pnode num %d expected %d parent num %d iip %d", |
2100 | pnode->num, col, pnode->parent->num, pnode->iip); | 2099 | pnode->num, col, pnode->parent->num, pnode->iip); |
2101 | return -EINVAL; | 2100 | return -EINVAL; |
2102 | } | 2101 | } |
2103 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { | 2102 | for (i = 0; i < UBIFS_LPT_FANOUT; i++) { |
@@ -2111,14 +2110,14 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, | |||
2111 | if (lnum >= c->leb_cnt) | 2110 | if (lnum >= c->leb_cnt) |
2112 | continue; | 2111 | continue; |
2113 | if (lprops->lnum != lnum) { | 2112 | if (lprops->lnum != lnum) { |
2114 | dbg_err("bad LEB number %d expected %d", | 2113 | ubifs_err("bad LEB number %d expected %d", |
2115 | lprops->lnum, lnum); | 2114 | lprops->lnum, lnum); |
2116 | return -EINVAL; | 2115 | return -EINVAL; |
2117 | } | 2116 | } |
2118 | if (lprops->flags & LPROPS_TAKEN) { | 2117 | if (lprops->flags & LPROPS_TAKEN) { |
2119 | if (cat != LPROPS_UNCAT) { | 2118 | if (cat != LPROPS_UNCAT) { |
2120 | dbg_err("LEB %d taken but not uncat %d", | 2119 | ubifs_err("LEB %d taken but not uncat %d", |
2121 | lprops->lnum, cat); | 2120 | lprops->lnum, cat); |
2122 | return -EINVAL; | 2121 | return -EINVAL; |
2123 | } | 2122 | } |
2124 | continue; | 2123 | continue; |
@@ -2130,8 +2129,8 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, | |||
2130 | case LPROPS_FRDI_IDX: | 2129 | case LPROPS_FRDI_IDX: |
2131 | break; | 2130 | break; |
2132 | default: | 2131 | default: |
2133 | dbg_err("LEB %d index but cat %d", | 2132 | ubifs_err("LEB %d index but cat %d", |
2134 | lprops->lnum, cat); | 2133 | lprops->lnum, cat); |
2135 | return -EINVAL; | 2134 | return -EINVAL; |
2136 | } | 2135 | } |
2137 | } else { | 2136 | } else { |
@@ -2143,8 +2142,8 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, | |||
2143 | case LPROPS_FREEABLE: | 2142 | case LPROPS_FREEABLE: |
2144 | break; | 2143 | break; |
2145 | default: | 2144 | default: |
2146 | dbg_err("LEB %d not index but cat %d", | 2145 | ubifs_err("LEB %d not index but cat %d", |
2147 | lprops->lnum, cat); | 2146 | lprops->lnum, cat); |
2148 | return -EINVAL; | 2147 | return -EINVAL; |
2149 | } | 2148 | } |
2150 | } | 2149 | } |
@@ -2184,24 +2183,24 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, | |||
2184 | break; | 2183 | break; |
2185 | } | 2184 | } |
2186 | if (!found) { | 2185 | if (!found) { |
2187 | dbg_err("LEB %d cat %d not found in cat heap/list", | 2186 | ubifs_err("LEB %d cat %d not found in cat heap/list", |
2188 | lprops->lnum, cat); | 2187 | lprops->lnum, cat); |
2189 | return -EINVAL; | 2188 | return -EINVAL; |
2190 | } | 2189 | } |
2191 | switch (cat) { | 2190 | switch (cat) { |
2192 | case LPROPS_EMPTY: | 2191 | case LPROPS_EMPTY: |
2193 | if (lprops->free != c->leb_size) { | 2192 | if (lprops->free != c->leb_size) { |
2194 | dbg_err("LEB %d cat %d free %d dirty %d", | 2193 | ubifs_err("LEB %d cat %d free %d dirty %d", |
2195 | lprops->lnum, cat, lprops->free, | 2194 | lprops->lnum, cat, lprops->free, |
2196 | lprops->dirty); | 2195 | lprops->dirty); |
2197 | return -EINVAL; | 2196 | return -EINVAL; |
2198 | } | 2197 | } |
2199 | case LPROPS_FREEABLE: | 2198 | case LPROPS_FREEABLE: |
2200 | case LPROPS_FRDI_IDX: | 2199 | case LPROPS_FRDI_IDX: |
2201 | if (lprops->free + lprops->dirty != c->leb_size) { | 2200 | if (lprops->free + lprops->dirty != c->leb_size) { |
2202 | dbg_err("LEB %d cat %d free %d dirty %d", | 2201 | ubifs_err("LEB %d cat %d free %d dirty %d", |
2203 | lprops->lnum, cat, lprops->free, | 2202 | lprops->lnum, cat, lprops->free, |
2204 | lprops->dirty); | 2203 | lprops->dirty); |
2205 | return -EINVAL; | 2204 | return -EINVAL; |
2206 | } | 2205 | } |
2207 | } | 2206 | } |
@@ -2235,9 +2234,10 @@ int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode, | |||
2235 | /* cnode is a nnode */ | 2234 | /* cnode is a nnode */ |
2236 | num = calc_nnode_num(row, col); | 2235 | num = calc_nnode_num(row, col); |
2237 | if (cnode->num != num) { | 2236 | if (cnode->num != num) { |
2238 | dbg_err("nnode num %d expected %d " | 2237 | ubifs_err("nnode num %d expected %d " |
2239 | "parent num %d iip %d", cnode->num, num, | 2238 | "parent num %d iip %d", |
2240 | (nnode ? nnode->num : 0), cnode->iip); | 2239 | cnode->num, num, |
2240 | (nnode ? nnode->num : 0), cnode->iip); | ||
2241 | return -EINVAL; | 2241 | return -EINVAL; |
2242 | } | 2242 | } |
2243 | nn = (struct ubifs_nnode *)cnode; | 2243 | nn = (struct ubifs_nnode *)cnode; |
@@ -2274,5 +2274,3 @@ int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode, | |||
2274 | } | 2274 | } |
2275 | return 0; | 2275 | return 0; |
2276 | } | 2276 | } |
2277 | |||
2278 | #endif /* CONFIG_UBIFS_FS_DEBUG */ | ||