aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-07-30 07:59:50 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-08-02 00:21:19 -0400
commit64d4b4c90a876401e503c3a3260e9d0ed066f271 (patch)
tree4da6a688f44cdec560792a29e24031a00a0696ef
parent7cdb996ee4d04b5bb2cd544b14e8eb91cfd7fe64 (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>
-rw-r--r--drivers/mtd/ubi/build.c3
-rw-r--r--drivers/mtd/ubi/eba.c42
2 files changed, 41 insertions, 4 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 13b05cb33b08..78ae89488a4f 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -593,6 +593,7 @@ static int attach_by_scanning(struct ubi_device *ubi)
593 ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count; 593 ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count;
594 ubi->max_ec = si->max_ec; 594 ubi->max_ec = si->max_ec;
595 ubi->mean_ec = si->mean_ec; 595 ubi->mean_ec = si->mean_ec;
596 ubi_msg("max. sequence number: %llu", si->max_sqnum);
596 597
597 err = ubi_read_volume_table(ubi, si); 598 err = ubi_read_volume_table(ubi, si);
598 if (err) 599 if (err)
@@ -981,7 +982,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
981 ubi_msg("number of PEBs reserved for bad PEB handling: %d", 982 ubi_msg("number of PEBs reserved for bad PEB handling: %d",
982 ubi->beb_rsvd_pebs); 983 ubi->beb_rsvd_pebs);
983 ubi_msg("max/mean erase counter: %d/%d", ubi->max_ec, ubi->mean_ec); 984 ubi_msg("max/mean erase counter: %d/%d", ubi->max_ec, ubi->mean_ec);
984 ubi_msg("image sequence number: %d", ubi->image_seq); 985 ubi_msg("image sequence number: %d", ubi->image_seq);
985 986
986 /* 987 /*
987 * The below lock makes sure we do not race with 'ubi_thread()' which 988 * The below lock makes sure we do not race with 'ubi_thread()' which
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 */
1186static 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