Skip to contentSkip to conversation

Patch "libnvdimm: fix badblock range handling of ARS range" has been added to the 4.12-stable tree

PATCH [email protected] 1 participant 1 message Jul 25, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

libnvdimm: fix badblock range handling of ARS range

to the 4.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
libnvdimm-fix-badblock-range-handling-of-ars-range.patch
and it can be found in the queue-4.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 4e3f0701f25ab194c5362576b1146a1e6cc6c2e7 Mon Sep 17 00:00:00 2001

From: Toshi Kani <[email protected]>
Date: Fri, 7 Jul 2017 17:44:26 -0600
Subject: libnvdimm: fix badblock range handling of ARS range

From: Toshi Kani <[email protected]>

commit 4e3f0701f25ab194c5362576b1146a1e6cc6c2e7 upstream.

__add_badblock_range() does not account sector alignment when it sets 'num_sectors'. Therefore, an ARS error record range spanning across two sectors is set to a single sector length, which leaves the 2nd sector unprotected.

Change __add_badblock_range() to set 'num_sectors' properly.

Fixes 0caeef63e6d2 ("libnvdimm: Add a poison list and export badblocks")
---
 drivers/nvdimm/core.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/nvdimm/core.c +4 -3
@@ -421,14 +421,15 @@ static void set_badblock(struct badblock
 static void __add_badblock_range(struct badblocks *bb, u64 ns_offset, u64 len)
 {
 	const unsigned int sector_size = 512;
-	sector_t start_sector;
+	sector_t start_sector, end_sector;
 	u64 num_sectors;
 	u32 rem;
 
 	start_sector = div_u64(ns_offset, sector_size);
-	num_sectors = div_u64_rem(len, sector_size, &rem);
+	end_sector = div_u64_rem(ns_offset + len, sector_size, &rem);
 	if (rem)
-		num_sectors++;
+		end_sector++;
+	num_sectors = end_sector - start_sector;
 
 	if (unlikely(num_sectors > (u64)INT_MAX)) {
 		u64 remaining = num_sectors;

Patches currently in stable-queue which might be from [email protected] are

queue-4.12/libnvdimm-btt-fix-btt_rw_page-not-returning-errors.patch queue-4.12/libnvdimm-fix-badblock-range-handling-of-ars-range.patch