Commit 2576143
btrfs: handle errors properly in update_inline_extent_backref()
[PROBLEM]
Inside function update_inline_extent_backref(), we have several
BUG_ON()s along with some ASSERT()s which can be triggered by corrupted
filesystem.
[ANAYLYSE]
Most of those BUG_ON()s and ASSERT()s are just a way of handling
unexpected on-disk data.
Although we have tree-checker to rule out obviously incorrect extent
tree blocks, it's not enough for these ones. Thus we need proper error
handling for them.
[FIX]
Thankfully all the callers of update_inline_extent_backref() would
eventually handle the errror by aborting the current transaction.
So this patch would do the proper error handling by:
- Make update_inline_extent_backref() to return int
The return value would be either 0 or -EUCLEAN.
- Replace BUG_ON()s and ASSERT()s with proper error handling
This includes:
* Dump the bad extent tree leaf
* Output an error message for the cause
This would include the extent bytenr, num_bytes (if needed), the bad
values and expected good values.
* Return -EUCLEAN
Note here we remove all the WARN_ON()s, as eventually the transaction
would be aborted, thus a backtrace would be triggered anyway.
- Better comments on why we expect refs == 1 and refs_to_mode == -1 for
tree blocks
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>1 parent 5b135b3 commit 2576143
1 file changed
Lines changed: 61 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| 384 | + | |
384 | 385 | | |
385 | 386 | | |
386 | 387 | | |
387 | 388 | | |
388 | | - | |
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| |||
1058 | 1058 | | |
1059 | 1059 | | |
1060 | 1060 | | |
1061 | | - | |
1062 | | - | |
| 1061 | + | |
1063 | 1062 | | |
1064 | 1063 | | |
1065 | 1064 | | |
1066 | 1065 | | |
1067 | 1066 | | |
| 1067 | + | |
1068 | 1068 | | |
1069 | 1069 | | |
1070 | 1070 | | |
| |||
1077 | 1077 | | |
1078 | 1078 | | |
1079 | 1079 | | |
1080 | | - | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
1081 | 1095 | | |
1082 | 1096 | | |
1083 | 1097 | | |
1084 | 1098 | | |
1085 | 1099 | | |
| 1100 | + | |
1086 | 1101 | | |
1087 | | - | |
1088 | | - | |
| 1102 | + | |
| 1103 | + | |
1089 | 1104 | | |
1090 | | - | |
1091 | | - | |
| 1105 | + | |
| 1106 | + | |
1092 | 1107 | | |
1093 | 1108 | | |
1094 | 1109 | | |
| |||
1098 | 1113 | | |
1099 | 1114 | | |
1100 | 1115 | | |
1101 | | - | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
1102 | 1135 | | |
1103 | 1136 | | |
1104 | | - | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
1105 | 1153 | | |
1106 | 1154 | | |
1107 | 1155 | | |
| |||
1121 | 1169 | | |
1122 | 1170 | | |
1123 | 1171 | | |
| 1172 | + | |
1124 | 1173 | | |
1125 | 1174 | | |
1126 | 1175 | | |
| |||
1149 | 1198 | | |
1150 | 1199 | | |
1151 | 1200 | | |
1152 | | - | |
| 1201 | + | |
1153 | 1202 | | |
1154 | 1203 | | |
1155 | 1204 | | |
| |||
1169 | 1218 | | |
1170 | 1219 | | |
1171 | 1220 | | |
1172 | | - | |
| 1221 | + | |
1173 | 1222 | | |
1174 | 1223 | | |
1175 | 1224 | | |
| |||
0 commit comments