[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YjmOb0dSY9GG/Q6r@infradead.org>
Date: Tue, 22 Mar 2022 01:53:03 -0700
From: Christoph Hellwig <hch@...radead.org>
To: Jane Chu <jane.chu@...cle.com>
Cc: david@...morbit.com, djwong@...nel.org, dan.j.williams@...el.com,
hch@...radead.org, vishal.l.verma@...el.com, dave.jiang@...el.com,
agk@...hat.com, snitzer@...hat.com, dm-devel@...hat.com,
ira.weiny@...el.com, willy@...radead.org, vgoyal@...hat.com,
linux-fsdevel@...r.kernel.org, nvdimm@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-xfs@...r.kernel.org
Subject: Re: [PATCH v6 5/6] pmem: refactor pmem_clear_poison()
> -static void hwpoison_clear(struct pmem_device *pmem,
> - phys_addr_t phys, unsigned int len)
> +static phys_addr_t to_phys(struct pmem_device *pmem, phys_addr_t offset)
> {
> + return pmem->phys_addr + offset;
> +}
> +
> +static sector_t to_sect(struct pmem_device *pmem, phys_addr_t offset)
> +{
> + return (offset - pmem->data_offset) / 512;
> +}
> +
> +static phys_addr_t to_offset(struct pmem_device *pmem, sector_t sector)
> +{
> + return sector * 512 + pmem->data_offset;
> +}
The multiplicate / divison using 512 could use shifts using
SECTOR_SHIFT.
> +
> +static void clear_hwpoison(struct pmem_device *pmem, phys_addr_t offset,
> + unsigned int len)
> +static void clear_bb(struct pmem_device *pmem, sector_t sector, long blks)
All these functions lack a pmem_ prefix.
> +static blk_status_t __pmem_clear_poison(struct pmem_device *pmem,
> + phys_addr_t offset, unsigned int len,
> + unsigned int *blks)
> +{
> + phys_addr_t phys = to_phys(pmem, offset);
> long cleared;
> + blk_status_t rc;
>
> + cleared = nvdimm_clear_poison(to_dev(pmem), phys, len);
> + *blks = cleared / 512;
> + rc = (cleared < len) ? BLK_STS_IOERR : BLK_STS_OK;
> + if (cleared <= 0 || *blks == 0)
> + return rc;
This look odd. I think just returing the cleared byte value would
make much more sense:
static long __pmem_clear_poison(struct pmem_device *pmem,
phys_addr_t offset, unsigned int len)
{
long cleared = nvdimm_clear_poison(to_dev(pmem), phys, len);
if (cleared > 0) {
clear_hwpoison(pmem, offset, cleared);
arch_invalidate_pmem(pmem->virt_addr + offset, len);
}
return cleared;
}
Powered by blists - more mailing lists