Re: [PATCH v5 7/7] pmem: fix pmem_do_write() avoid writing to 'np' page

Christoph Hellwig
2022-02-02T13:28:53Z

On Fri, Jan 28, 2022 at 02:31:50PM -0700, Jane Chu wrote:
> + if (!bad_pmem) {
> write_pmem(pmem_addr, page, page_off, len);
> + } else {
> + rc = pmem_clear_poison(pmem, pmem_off, len);
> + if (rc == BLK_STS_OK)
> + write_pmem(pmem_addr, page, page_off, len);
> + else
> + pr_warn("%s: failed to clear poison\n",
> + __func__);

This warning probably needs ratelimiting.

Also this flow looks a little odd. I'd redo the whole function with a
clear bad_mem case:

if (unlikely(is_bad_pmem(&pmem->bb, sector, len))) {
blk_status_t rc = pmem_clear_poison(pmem, pmem_off, len);

if (rc != BLK_STS_OK) {
pr_warn("%s: failed to clear poison\n", __func__);
return rc;
}
}
flush_dcache_page(page);
write_pmem(pmem_addr, page, page_off, len);
return BLK_STS_OK;