Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1509337

[PATCH 4.4 032/112] ubi: Deal with interrupted erasures in WL

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.4 032/112] ubi: Deal with interrupted erasures in WL
Date 2016-10-26 15:10 +0200
Message-ID <sww7V-49u-69@gated-at.bofh.it> (permalink)
References <swvER-3Eq-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Richard Weinberger <richard@nod.at>

commit 2365418879e9abf12ea9def7f9f3caf0dfa7ffb0 upstream.

When Fastmap is used we can face here an -EBADMSG
since Fastmap cannot know about unmaps.
If the erasure was interrupted the PEB may show ECC
errors and UBI would go to ro-mode as it assumes
that the PEB was check during attach time, which is
not the case with Fastmap.

Fixes: dbb7d2a88d ("UBI: Add fastmap core")
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/mtd/ubi/wl.c |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -643,7 +643,7 @@ static int wear_leveling_worker(struct u
 				int shutdown)
 {
 	int err, scrubbing = 0, torture = 0, protect = 0, erroneous = 0;
-	int vol_id = -1, lnum = -1;
+	int erase = 0, keep = 0, vol_id = -1, lnum = -1;
 #ifdef CONFIG_MTD_UBI_FASTMAP
 	int anchor = wrk->anchor;
 #endif
@@ -777,6 +777,16 @@ static int wear_leveling_worker(struct u
 			       e1->pnum);
 			scrubbing = 1;
 			goto out_not_moved;
+		} else if (ubi->fast_attach && err == UBI_IO_BAD_HDR_EBADMSG) {
+			/*
+			 * While a full scan would detect interrupted erasures
+			 * at attach time we can face them here when attached from
+			 * Fastmap.
+			 */
+			dbg_wl("PEB %d has ECC errors, maybe from an interrupted erasure",
+			       e1->pnum);
+			erase = 1;
+			goto out_not_moved;
 		}
 
 		ubi_err(ubi, "error %d while reading VID header from PEB %d",
@@ -810,6 +820,7 @@ static int wear_leveling_worker(struct u
 			 * Target PEB had bit-flips or write error - torture it.
 			 */
 			torture = 1;
+			keep = 1;
 			goto out_not_moved;
 		}
 
@@ -895,7 +906,7 @@ out_not_moved:
 		ubi->erroneous_peb_count += 1;
 	} else if (scrubbing)
 		wl_tree_add(e1, &ubi->scrub);
-	else
+	else if (keep)
 		wl_tree_add(e1, &ubi->used);
 	ubi_assert(!ubi->move_to_put);
 	ubi->move_from = ubi->move_to = NULL;
@@ -907,6 +918,12 @@ out_not_moved:
 	if (err)
 		goto out_ro;
 
+	if (erase) {
+		err = do_sync_erase(ubi, e1, vol_id, lnum, 1);
+		if (err)
+			goto out_ro;
+	}
+
 	mutex_unlock(&ubi->move_mutex);
 	return 0;
 

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.4 000/112] 4.4.28-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 14:50 +0200
  [PATCH 4.4 061/112] NFSv4: Dont report revoked delegations as valid in nfs_have_delegation() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 084/112] irqchip/gicv3: Handle loop timeout proper Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 028/112] powerpc/powernv: Use CPU-endian hub diag-data type in pnv_eeh_get_and_dump_hub_diag() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 051/112] ALSA: hda - Fix a failure of micmute led when having multi adcs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 074/112] Clarify locking of cifs file and tcon structures and make more granular Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 027/112] powerpc/powernv: Pass CPU-endian PE number to opal_pci_eeh_freeze_clear() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 071/112] fs/super.c: fix race between freeze_super() and thaw_super() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 077/112] SMB3: GUIDs should be constructed as random but valid uuids Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 019/112] perf intel-pt: Fix snapshot overlap detection decoder errors Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 024/112] dm mpath: check if paths request_queue is dying in activate_path() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 072/112] cifs: Limit the overall credit acquired Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 070/112] arc: dont leak bits of kernel stack into coredump Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 057/112] Input: i8042 - skip selftest on ASUS laptops Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 054/112] lib: move strtobool() to kstrtobool() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 037/112] zfcp: restore: Dont use 0 to indicate invalid LUN in rec trace Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 058/112] Input: elantech - force needed quirks on Fujitsu H760 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 055/112] lib: update single-char callers of strtobool() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 060/112] sunrpc: fix write space race causing stalls Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 053/112] MIPS: ptrace: Fix regs_return_value for kernel context Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 056/112] lib: add "on"/"off" support to kstrtobool Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:00 +0200
  [PATCH 4.4 010/112] platform: dont return 0 from platform_get_irq[_byname]() on error Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 047/112] [media] mb86a20s: fix the locking logic Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 022/112] dm: mark request_queue dead before destroying the DM device Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 021/112] perf intel-pt: Fix MTC timestamp calculation for large MTC periods Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 043/112] scsi: zfcp: spin_lock_irqsave() is not nestable Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 017/112] pstore/ram: Use memcpy_toio instead of memcpy Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 041/112] zfcp: fix payload trace length for SAN request&response Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 050/112] [media] cx231xx: fix GPIOs for Pixelview SBTVD hybrid Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 049/112] [media] cx231xx: dont return error on success Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 044/112] fbdev/efifb: Fix 16 color palette entry calculation Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 048/112] [media] mb86a20s: fix demod settings Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 015/112] pstore/ramoops: fixup driver removal Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 032/112] ubi: Deal with interrupted erasures in WL Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 046/112] ovl: copy_up_xattr(): use strnlen Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 036/112] zfcp: retain trace level for SCSI and HBA FSF response records Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 013/112] parisc: Fix kernel memory layout regarding position of __gp Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 011/112] cpufreq: intel_pstate: Fix unsafe HWP MSR access Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 038/112] zfcp: trace on request for open and close of WKA port Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 035/112] zfcp: close window with unblocked rport during rport gone Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 034/112] zfcp: fix ELS/GS request&response length for hardware data router Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 042/112] zfcp: trace full payload of all SAN records (req,resp,iels) Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 040/112] zfcp: fix D_ID field with actual value on tracing SAN responses Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 045/112] ovl: Fix info leak in ovl_lookup_temp() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  [PATCH 4.4 033/112] zfcp: fix fc_host port_type with NPIV Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-26 15:10 +0200
  Re: [PATCH 4.4 000/112] 4.4.28-stable review Shuah Khan <shuah.kh@samsung.com> - 2016-10-26 20:50 +0200
  Re: [PATCH 4.4 000/112] 4.4.28-stable review Guenter Roeck <linux@roeck-us.net> - 2016-10-26 23:50 +0200

csiph-web