aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/lprops.c
diff options
context:
space:
mode:
authorSheng Yong <shengyong1@huawei.com>2015-03-20 06:39:42 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2015-03-25 05:08:41 -0400
commit235c362bd0f6afcf767bc72aa0c647e1434cc631 (patch)
tree1cbc858f95877e51ddf48ea00dec0f6f7a481469 /fs/ubifs/lprops.c
parent8a87dc55f75f19ffdbb52066afea1b633577c79f (diff)
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI devices, it may be not that easy to tell which volume prints the messages. Add ubi number and volume id in ubifs_msg/warn/error to help debug. These two values are passed by struct ubifs_info. For those where ubifs_info is not initialized yet, ubifs_* is replaced by pr_*. For those where ubifs_info is not avaliable, ubifs_info is passed to the calling function as a const parameter. The output looks like, [ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696 [ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1" [ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes [ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs) [ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB) [ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model [ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699 [ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2" [ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes [ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs) [ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB) [ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model [ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6) [ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1 Signed-off-by: Sheng Yong <shengyong1@huawei.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'fs/ubifs/lprops.c')
-rw-r--r--fs/ubifs/lprops.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index 46190a7c42a6..a0011aa3a779 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -682,7 +682,7 @@ int ubifs_change_one_lp(struct ubifs_info *c, int lnum, int free, int dirty,
682out: 682out:
683 ubifs_release_lprops(c); 683 ubifs_release_lprops(c);
684 if (err) 684 if (err)
685 ubifs_err("cannot change properties of LEB %d, error %d", 685 ubifs_err(c, "cannot change properties of LEB %d, error %d",
686 lnum, err); 686 lnum, err);
687 return err; 687 return err;
688} 688}
@@ -721,7 +721,7 @@ int ubifs_update_one_lp(struct ubifs_info *c, int lnum, int free, int dirty,
721out: 721out:
722 ubifs_release_lprops(c); 722 ubifs_release_lprops(c);
723 if (err) 723 if (err)
724 ubifs_err("cannot update properties of LEB %d, error %d", 724 ubifs_err(c, "cannot update properties of LEB %d, error %d",
725 lnum, err); 725 lnum, err);
726 return err; 726 return err;
727} 727}
@@ -746,7 +746,7 @@ int ubifs_read_one_lp(struct ubifs_info *c, int lnum, struct ubifs_lprops *lp)
746 lpp = ubifs_lpt_lookup(c, lnum); 746 lpp = ubifs_lpt_lookup(c, lnum);
747 if (IS_ERR(lpp)) { 747 if (IS_ERR(lpp)) {
748 err = PTR_ERR(lpp); 748 err = PTR_ERR(lpp);
749 ubifs_err("cannot read properties of LEB %d, error %d", 749 ubifs_err(c, "cannot read properties of LEB %d, error %d",
750 lnum, err); 750 lnum, err);
751 goto out; 751 goto out;
752 } 752 }
@@ -873,13 +873,13 @@ int dbg_check_cats(struct ubifs_info *c)
873 873
874 list_for_each_entry(lprops, &c->empty_list, list) { 874 list_for_each_entry(lprops, &c->empty_list, list) {
875 if (lprops->free != c->leb_size) { 875 if (lprops->free != c->leb_size) {
876 ubifs_err("non-empty LEB %d on empty list (free %d dirty %d flags %d)", 876 ubifs_err(c, "non-empty LEB %d on empty list (free %d dirty %d flags %d)",
877 lprops->lnum, lprops->free, lprops->dirty, 877 lprops->lnum, lprops->free, lprops->dirty,
878 lprops->flags); 878 lprops->flags);
879 return -EINVAL; 879 return -EINVAL;
880 } 880 }
881 if (lprops->flags & LPROPS_TAKEN) { 881 if (lprops->flags & LPROPS_TAKEN) {
882 ubifs_err("taken LEB %d on empty list (free %d dirty %d flags %d)", 882 ubifs_err(c, "taken LEB %d on empty list (free %d dirty %d flags %d)",
883 lprops->lnum, lprops->free, lprops->dirty, 883 lprops->lnum, lprops->free, lprops->dirty,
884 lprops->flags); 884 lprops->flags);
885 return -EINVAL; 885 return -EINVAL;
@@ -889,13 +889,13 @@ int dbg_check_cats(struct ubifs_info *c)
889 i = 0; 889 i = 0;
890 list_for_each_entry(lprops, &c->freeable_list, list) { 890 list_for_each_entry(lprops, &c->freeable_list, list) {
891 if (lprops->free + lprops->dirty != c->leb_size) { 891 if (lprops->free + lprops->dirty != c->leb_size) {
892 ubifs_err("non-freeable LEB %d on freeable list (free %d dirty %d flags %d)", 892 ubifs_err(c, "non-freeable LEB %d on freeable list (free %d dirty %d flags %d)",
893 lprops->lnum, lprops->free, lprops->dirty, 893 lprops->lnum, lprops->free, lprops->dirty,
894 lprops->flags); 894 lprops->flags);
895 return -EINVAL; 895 return -EINVAL;
896 } 896 }
897 if (lprops->flags & LPROPS_TAKEN) { 897 if (lprops->flags & LPROPS_TAKEN) {
898 ubifs_err("taken LEB %d on freeable list (free %d dirty %d flags %d)", 898 ubifs_err(c, "taken LEB %d on freeable list (free %d dirty %d flags %d)",
899 lprops->lnum, lprops->free, lprops->dirty, 899 lprops->lnum, lprops->free, lprops->dirty,
900 lprops->flags); 900 lprops->flags);
901 return -EINVAL; 901 return -EINVAL;
@@ -903,7 +903,7 @@ int dbg_check_cats(struct ubifs_info *c)
903 i += 1; 903 i += 1;
904 } 904 }
905 if (i != c->freeable_cnt) { 905 if (i != c->freeable_cnt) {
906 ubifs_err("freeable list count %d expected %d", i, 906 ubifs_err(c, "freeable list count %d expected %d", i,
907 c->freeable_cnt); 907 c->freeable_cnt);
908 return -EINVAL; 908 return -EINVAL;
909 } 909 }
@@ -912,26 +912,26 @@ int dbg_check_cats(struct ubifs_info *c)
912 list_for_each(pos, &c->idx_gc) 912 list_for_each(pos, &c->idx_gc)
913 i += 1; 913 i += 1;
914 if (i != c->idx_gc_cnt) { 914 if (i != c->idx_gc_cnt) {
915 ubifs_err("idx_gc list count %d expected %d", i, 915 ubifs_err(c, "idx_gc list count %d expected %d", i,
916 c->idx_gc_cnt); 916 c->idx_gc_cnt);
917 return -EINVAL; 917 return -EINVAL;
918 } 918 }
919 919
920 list_for_each_entry(lprops, &c->frdi_idx_list, list) { 920 list_for_each_entry(lprops, &c->frdi_idx_list, list) {
921 if (lprops->free + lprops->dirty != c->leb_size) { 921 if (lprops->free + lprops->dirty != c->leb_size) {
922 ubifs_err("non-freeable LEB %d on frdi_idx list (free %d dirty %d flags %d)", 922 ubifs_err(c, "non-freeable LEB %d on frdi_idx list (free %d dirty %d flags %d)",
923 lprops->lnum, lprops->free, lprops->dirty, 923 lprops->lnum, lprops->free, lprops->dirty,
924 lprops->flags); 924 lprops->flags);
925 return -EINVAL; 925 return -EINVAL;
926 } 926 }
927 if (lprops->flags & LPROPS_TAKEN) { 927 if (lprops->flags & LPROPS_TAKEN) {
928 ubifs_err("taken LEB %d on frdi_idx list (free %d dirty %d flags %d)", 928 ubifs_err(c, "taken LEB %d on frdi_idx list (free %d dirty %d flags %d)",
929 lprops->lnum, lprops->free, lprops->dirty, 929 lprops->lnum, lprops->free, lprops->dirty,
930 lprops->flags); 930 lprops->flags);
931 return -EINVAL; 931 return -EINVAL;
932 } 932 }
933 if (!(lprops->flags & LPROPS_INDEX)) { 933 if (!(lprops->flags & LPROPS_INDEX)) {
934 ubifs_err("non-index LEB %d on frdi_idx list (free %d dirty %d flags %d)", 934 ubifs_err(c, "non-index LEB %d on frdi_idx list (free %d dirty %d flags %d)",
935 lprops->lnum, lprops->free, lprops->dirty, 935 lprops->lnum, lprops->free, lprops->dirty,
936 lprops->flags); 936 lprops->flags);
937 return -EINVAL; 937 return -EINVAL;
@@ -944,15 +944,15 @@ int dbg_check_cats(struct ubifs_info *c)
944 for (i = 0; i < heap->cnt; i++) { 944 for (i = 0; i < heap->cnt; i++) {
945 lprops = heap->arr[i]; 945 lprops = heap->arr[i];
946 if (!lprops) { 946 if (!lprops) {
947 ubifs_err("null ptr in LPT heap cat %d", cat); 947 ubifs_err(c, "null ptr in LPT heap cat %d", cat);
948 return -EINVAL; 948 return -EINVAL;
949 } 949 }
950 if (lprops->hpos != i) { 950 if (lprops->hpos != i) {
951 ubifs_err("bad ptr in LPT heap cat %d", cat); 951 ubifs_err(c, "bad ptr in LPT heap cat %d", cat);
952 return -EINVAL; 952 return -EINVAL;
953 } 953 }
954 if (lprops->flags & LPROPS_TAKEN) { 954 if (lprops->flags & LPROPS_TAKEN) {
955 ubifs_err("taken LEB in LPT heap cat %d", cat); 955 ubifs_err(c, "taken LEB in LPT heap cat %d", cat);
956 return -EINVAL; 956 return -EINVAL;
957 } 957 }
958 } 958 }
@@ -988,7 +988,7 @@ void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat,
988 goto out; 988 goto out;
989 } 989 }
990 if (lprops != lp) { 990 if (lprops != lp) {
991 ubifs_err("lprops %zx lp %zx lprops->lnum %d lp->lnum %d", 991 ubifs_err(c, "lprops %zx lp %zx lprops->lnum %d lp->lnum %d",
992 (size_t)lprops, (size_t)lp, lprops->lnum, 992 (size_t)lprops, (size_t)lp, lprops->lnum,
993 lp->lnum); 993 lp->lnum);
994 err = 4; 994 err = 4;
@@ -1008,7 +1008,7 @@ void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat,
1008 } 1008 }
1009out: 1009out:
1010 if (err) { 1010 if (err) {
1011 ubifs_err("failed cat %d hpos %d err %d", cat, i, err); 1011 ubifs_err(c, "failed cat %d hpos %d err %d", cat, i, err);
1012 dump_stack(); 1012 dump_stack();
1013 ubifs_dump_heap(c, heap, cat); 1013 ubifs_dump_heap(c, heap, cat);
1014 } 1014 }
@@ -1039,7 +1039,7 @@ static int scan_check_cb(struct ubifs_info *c,
1039 if (cat != LPROPS_UNCAT) { 1039 if (cat != LPROPS_UNCAT) {
1040 cat = ubifs_categorize_lprops(c, lp); 1040 cat = ubifs_categorize_lprops(c, lp);
1041 if (cat != (lp->flags & LPROPS_CAT_MASK)) { 1041 if (cat != (lp->flags & LPROPS_CAT_MASK)) {
1042 ubifs_err("bad LEB category %d expected %d", 1042 ubifs_err(c, "bad LEB category %d expected %d",
1043 (lp->flags & LPROPS_CAT_MASK), cat); 1043 (lp->flags & LPROPS_CAT_MASK), cat);
1044 return -EINVAL; 1044 return -EINVAL;
1045 } 1045 }
@@ -1074,7 +1074,7 @@ static int scan_check_cb(struct ubifs_info *c,
1074 } 1074 }
1075 } 1075 }
1076 if (!found) { 1076 if (!found) {
1077 ubifs_err("bad LPT list (category %d)", cat); 1077 ubifs_err(c, "bad LPT list (category %d)", cat);
1078 return -EINVAL; 1078 return -EINVAL;
1079 } 1079 }
1080 } 1080 }
@@ -1086,7 +1086,7 @@ static int scan_check_cb(struct ubifs_info *c,
1086 1086
1087 if ((lp->hpos != -1 && heap->arr[lp->hpos]->lnum != lnum) || 1087 if ((lp->hpos != -1 && heap->arr[lp->hpos]->lnum != lnum) ||
1088 lp != heap->arr[lp->hpos]) { 1088 lp != heap->arr[lp->hpos]) {
1089 ubifs_err("bad LPT heap (category %d)", cat); 1089 ubifs_err(c, "bad LPT heap (category %d)", cat);
1090 return -EINVAL; 1090 return -EINVAL;
1091 } 1091 }
1092 } 1092 }
@@ -1133,7 +1133,7 @@ static int scan_check_cb(struct ubifs_info *c,
1133 is_idx = (snod->type == UBIFS_IDX_NODE) ? 1 : 0; 1133 is_idx = (snod->type == UBIFS_IDX_NODE) ? 1 : 0;
1134 1134
1135 if (is_idx && snod->type != UBIFS_IDX_NODE) { 1135 if (is_idx && snod->type != UBIFS_IDX_NODE) {
1136 ubifs_err("indexing node in data LEB %d:%d", 1136 ubifs_err(c, "indexing node in data LEB %d:%d",
1137 lnum, snod->offs); 1137 lnum, snod->offs);
1138 goto out_destroy; 1138 goto out_destroy;
1139 } 1139 }
@@ -1159,7 +1159,7 @@ static int scan_check_cb(struct ubifs_info *c,
1159 1159
1160 if (free > c->leb_size || free < 0 || dirty > c->leb_size || 1160 if (free > c->leb_size || free < 0 || dirty > c->leb_size ||
1161 dirty < 0) { 1161 dirty < 0) {
1162 ubifs_err("bad calculated accounting for LEB %d: free %d, dirty %d", 1162 ubifs_err(c, "bad calculated accounting for LEB %d: free %d, dirty %d",
1163 lnum, free, dirty); 1163 lnum, free, dirty);
1164 goto out_destroy; 1164 goto out_destroy;
1165 } 1165 }
@@ -1206,13 +1206,13 @@ static int scan_check_cb(struct ubifs_info *c,
1206 /* Free but not unmapped LEB, it's fine */ 1206 /* Free but not unmapped LEB, it's fine */
1207 is_idx = 0; 1207 is_idx = 0;
1208 else { 1208 else {
1209 ubifs_err("indexing node without indexing flag"); 1209 ubifs_err(c, "indexing node without indexing flag");
1210 goto out_print; 1210 goto out_print;
1211 } 1211 }
1212 } 1212 }
1213 1213
1214 if (!is_idx && (lp->flags & LPROPS_INDEX)) { 1214 if (!is_idx && (lp->flags & LPROPS_INDEX)) {
1215 ubifs_err("data node with indexing flag"); 1215 ubifs_err(c, "data node with indexing flag");
1216 goto out_print; 1216 goto out_print;
1217 } 1217 }
1218 1218
@@ -1241,7 +1241,7 @@ static int scan_check_cb(struct ubifs_info *c,
1241 return LPT_SCAN_CONTINUE; 1241 return LPT_SCAN_CONTINUE;
1242 1242
1243out_print: 1243out_print:
1244 ubifs_err("bad accounting of LEB %d: free %d, dirty %d flags %#x, should be free %d, dirty %d", 1244 ubifs_err(c, "bad accounting of LEB %d: free %d, dirty %d flags %#x, should be free %d, dirty %d",
1245 lnum, lp->free, lp->dirty, lp->flags, free, dirty); 1245 lnum, lp->free, lp->dirty, lp->flags, free, dirty);
1246 ubifs_dump_leb(c, lnum); 1246 ubifs_dump_leb(c, lnum);
1247out_destroy: 1247out_destroy:
@@ -1293,11 +1293,11 @@ int dbg_check_lprops(struct ubifs_info *c)
1293 lst.total_free != c->lst.total_free || 1293 lst.total_free != c->lst.total_free ||
1294 lst.total_dirty != c->lst.total_dirty || 1294 lst.total_dirty != c->lst.total_dirty ||
1295 lst.total_used != c->lst.total_used) { 1295 lst.total_used != c->lst.total_used) {
1296 ubifs_err("bad overall accounting"); 1296 ubifs_err(c, "bad overall accounting");
1297 ubifs_err("calculated: empty_lebs %d, idx_lebs %d, total_free %lld, total_dirty %lld, total_used %lld", 1297 ubifs_err(c, "calculated: empty_lebs %d, idx_lebs %d, total_free %lld, total_dirty %lld, total_used %lld",
1298 lst.empty_lebs, lst.idx_lebs, lst.total_free, 1298 lst.empty_lebs, lst.idx_lebs, lst.total_free,
1299 lst.total_dirty, lst.total_used); 1299 lst.total_dirty, lst.total_used);
1300 ubifs_err("read from lprops: empty_lebs %d, idx_lebs %d, total_free %lld, total_dirty %lld, total_used %lld", 1300 ubifs_err(c, "read from lprops: empty_lebs %d, idx_lebs %d, total_free %lld, total_dirty %lld, total_used %lld",
1301 c->lst.empty_lebs, c->lst.idx_lebs, c->lst.total_free, 1301 c->lst.empty_lebs, c->lst.idx_lebs, c->lst.total_free,
1302 c->lst.total_dirty, c->lst.total_used); 1302 c->lst.total_dirty, c->lst.total_used);
1303 err = -EINVAL; 1303 err = -EINVAL;
@@ -1306,10 +1306,10 @@ int dbg_check_lprops(struct ubifs_info *c)
1306 1306
1307 if (lst.total_dead != c->lst.total_dead || 1307 if (lst.total_dead != c->lst.total_dead ||
1308 lst.total_dark != c->lst.total_dark) { 1308 lst.total_dark != c->lst.total_dark) {
1309 ubifs_err("bad dead/dark space accounting"); 1309 ubifs_err(c, "bad dead/dark space accounting");
1310 ubifs_err("calculated: total_dead %lld, total_dark %lld", 1310 ubifs_err(c, "calculated: total_dead %lld, total_dark %lld",
1311 lst.total_dead, lst.total_dark); 1311 lst.total_dead, lst.total_dark);
1312 ubifs_err("read from lprops: total_dead %lld, total_dark %lld", 1312 ubifs_err(c, "read from lprops: total_dead %lld, total_dark %lld",
1313 c->lst.total_dead, c->lst.total_dark); 1313 c->lst.total_dead, c->lst.total_dark);
1314 err = -EINVAL; 1314 err = -EINVAL;
1315 goto out; 1315 goto out;