diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2010-07-30 07:59:50 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2010-08-02 00:21:19 -0400 |
commit | 64d4b4c90a876401e503c3a3260e9d0ed066f271 (patch) | |
tree | 4da6a688f44cdec560792a29e24031a00a0696ef /drivers/mtd/ubi/eba.c | |
parent | 7cdb996ee4d04b5bb2cd544b14e8eb91cfd7fe64 (diff) |
UBI: do not warn unnecessarily
Currently, when UBI attaches an MTD device and cannot reserve all 1% (by
default) of PEBs for bad eraseblocks handling, it prints a warning. However,
Matthew L. Creech <mlcreech@gmail.com> is not very happy to see this warning,
because he did reserve enough of PEB at the beginning, but with time some
PEBs became bad. The warning is not necessary in this case.
This patch makes UBI print the warning
o if this is a new image
o of this is used image and the amount of reserved PEBs is only 10% (or less)
of the size of the reserved PEB pool.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/eba.c')
-rw-r--r-- | drivers/mtd/ubi/eba.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index b582671ca3a0..fe74749e0dae 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c | |||
@@ -1166,6 +1166,44 @@ out_unlock_leb: | |||
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | /** | 1168 | /** |
1169 | * print_rsvd_warning - warn about not having enough reserved PEBs. | ||
1170 | * @ubi: UBI device description object | ||
1171 | * | ||
1172 | * This is a helper function for 'ubi_eba_init_scan()' which is called when UBI | ||
1173 | * cannot reserve enough PEBs for bad block handling. This function makes a | ||
1174 | * decision whether we have to print a warning or not. The algorithm is as | ||
1175 | * follows: | ||
1176 | * o if this is a new UBI image, then just print the warning | ||
1177 | * o if this is an UBI image which has already been used for some time, print | ||
1178 | * a warning only if we can reserve less than 10% of the expected amount of | ||
1179 | * the reserved PEB. | ||
1180 | * | ||
1181 | * The idea is that when UBI is used, PEBs become bad, and the reserved pool | ||
1182 | * of PEBs becomes smaller, which is normal and we do not want to scare users | ||
1183 | * with a warning every time they attach the MTD device. This was an issue | ||
1184 | * reported by real users. | ||
1185 | */ | ||
1186 | static void print_rsvd_warning(struct ubi_device *ubi, | ||
1187 | struct ubi_scan_info *si) | ||
1188 | { | ||
1189 | /* | ||
1190 | * The 1 << 18 (256KiB) number is picked randomly, just a reasonably | ||
1191 | * large number to distinguish between newly flashed and used images. | ||
1192 | */ | ||
1193 | if (si->max_sqnum > (1 << 18)) { | ||
1194 | int min = ubi->beb_rsvd_level / 10; | ||
1195 | |||
1196 | if (!min) | ||
1197 | min = 1; | ||
1198 | if (ubi->beb_rsvd_pebs > min) | ||
1199 | return; | ||
1200 | } | ||
1201 | |||
1202 | ubi_warn("cannot reserve enough PEBs for bad PEB handling, reserved %d," | ||
1203 | " need %d", ubi->beb_rsvd_pebs, ubi->beb_rsvd_level); | ||
1204 | } | ||
1205 | |||
1206 | /** | ||
1169 | * ubi_eba_init_scan - initialize the EBA sub-system using scanning information. | 1207 | * ubi_eba_init_scan - initialize the EBA sub-system using scanning information. |
1170 | * @ubi: UBI device description object | 1208 | * @ubi: UBI device description object |
1171 | * @si: scanning information | 1209 | * @si: scanning information |
@@ -1237,9 +1275,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) | |||
1237 | if (ubi->avail_pebs < ubi->beb_rsvd_level) { | 1275 | if (ubi->avail_pebs < ubi->beb_rsvd_level) { |
1238 | /* No enough free physical eraseblocks */ | 1276 | /* No enough free physical eraseblocks */ |
1239 | ubi->beb_rsvd_pebs = ubi->avail_pebs; | 1277 | ubi->beb_rsvd_pebs = ubi->avail_pebs; |
1240 | ubi_warn("cannot reserve enough PEBs for bad PEB " | 1278 | print_rsvd_warning(ubi, si); |
1241 | "handling, reserved %d, need %d", | ||
1242 | ubi->beb_rsvd_pebs, ubi->beb_rsvd_level); | ||
1243 | } else | 1279 | } else |
1244 | ubi->beb_rsvd_pebs = ubi->beb_rsvd_level; | 1280 | ubi->beb_rsvd_pebs = ubi->beb_rsvd_level; |
1245 | 1281 | ||