diff mbox series

[3/6] pmem: pmem_dax_direct_access() to honor the DAXDEV_F_RECOVERY flag

Message ID 20211021001059.438843-4-jane.chu@oracle.com (mailing list archive)
State New, archived
Headers show
Series dax poison recovery with RWF_RECOVERY_DATA flag | expand

Commit Message

Jane Chu Oct. 21, 2021, 12:10 a.m. UTC
Let pmem_dax_direct_access() skip badblock checking if the caller
intends to do data recovery by providing the DAXDEV_F_RECOVERY flag.

Signed-off-by: Jane Chu <jane.chu@oracle.com>
---
 drivers/nvdimm/pmem.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Oct. 21, 2021, 11:23 a.m. UTC | #1
On Wed, Oct 20, 2021 at 06:10:56PM -0600, Jane Chu wrote:
> -	if (unlikely(is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512,
> -					PFN_PHYS(nr_pages))))
> +	if (unlikely(!(flags & DAXDEV_F_RECOVERY) &&
> +		is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512,
> +				PFN_PHYS(nr_pages))))

The indentation here is pretty messed up. Something like this would
be move normal:

	if (unlikely(!(flags & DAXDEV_F_RECOVERY) &&
			is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512,
				    PFN_PHYS(nr_pages)))) {

but if we don't really need the unlikely we could do an actually
readable variant:

	if (!(flags & DAXDEV_F_RECOVERY) &&
	    is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, PFN_PHYS(nr_pages)))
Jane Chu Oct. 21, 2021, 6:24 p.m. UTC | #2
On 10/21/2021 4:23 AM, Christoph Hellwig wrote:
> On Wed, Oct 20, 2021 at 06:10:56PM -0600, Jane Chu wrote:
>> -	if (unlikely(is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512,
>> -					PFN_PHYS(nr_pages))))
>> +	if (unlikely(!(flags & DAXDEV_F_RECOVERY) &&
>> +		is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512,
>> +				PFN_PHYS(nr_pages))))
> 
> The indentation here is pretty messed up. Something like this would
> be move normal:
> 
> 	if (unlikely(!(flags & DAXDEV_F_RECOVERY) &&
> 			is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512,
> 				    PFN_PHYS(nr_pages)))) {
> 

Will do.

> but if we don't really need the unlikely we could do an actually
> readable variant:
> 
> 	if (!(flags & DAXDEV_F_RECOVERY) &&
> 	    is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, PFN_PHYS(nr_pages)))
> 

'unlikely' is needed because 'RWF_RECOVERY_DATA' flag is not
recommended for normal preadv2/pwritev2 usage, it's recommended
only if user is aware of or suspect poison in the range.

thanks,
-jane
diff mbox series

Patch

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index b0b7fd40560e..ed699416655b 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -260,8 +260,9 @@  __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
 {
 	resource_size_t offset = PFN_PHYS(pgoff) + pmem->data_offset;
 
-	if (unlikely(is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512,
-					PFN_PHYS(nr_pages))))
+	if (unlikely(!(flags & DAXDEV_F_RECOVERY) &&
+		is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512,
+				PFN_PHYS(nr_pages))))
 		return -EIO;
 
 	if (kaddr)