Skip to content

Commit 3115bb0

Browse files
toshikanidjbw
authored andcommitted
pmem: report error on clear poison failure
ACPI Clear Uncorrectable Error DSM function may fail or may be unsupported on a platform. pmem_clear_poison() returns without clearing badblocks in such cases. This failure is detected at the next read (-EIO). This behavior can lead to an issue when user keeps writing but does not read immediately. For instance, flight recorder file may be only read when it is necessary for troubleshooting. Change pmem_do_bvec() and pmem_clear_poison() to return -EIO so that filesystem can log an error message on a write error. Cc: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Toshi Kani <toshi.kani@hpe.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 75d2971 commit 3115bb0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/nvdimm/pmem.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static struct nd_region *to_region(struct pmem_device *pmem)
4747
return to_nd_region(to_dev(pmem)->parent);
4848
}
4949

50-
static void pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset,
50+
static int pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset,
5151
unsigned int len)
5252
{
5353
struct device *dev = to_dev(pmem);
@@ -62,8 +62,12 @@ static void pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset,
6262
__func__, (unsigned long long) sector,
6363
cleared / 512, cleared / 512 > 1 ? "s" : "");
6464
badblocks_clear(&pmem->bb, sector, cleared / 512);
65+
} else {
66+
return -EIO;
6567
}
68+
6669
invalidate_pmem(pmem->virt_addr + offset, len);
70+
return 0;
6771
}
6872

6973
static void write_pmem(void *pmem_addr, struct page *page,
@@ -123,7 +127,7 @@ static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
123127
flush_dcache_page(page);
124128
write_pmem(pmem_addr, page, off, len);
125129
if (unlikely(bad_pmem)) {
126-
pmem_clear_poison(pmem, pmem_off, len);
130+
rc = pmem_clear_poison(pmem, pmem_off, len);
127131
write_pmem(pmem_addr, page, off, len);
128132
}
129133
}

0 commit comments

Comments
 (0)