linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dax: Fix last_page check in  __bdev_dax_supported()
@ 2019-05-16  5:54 Vaibhav Jain
  2019-05-16 18:22 ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Vaibhav Jain @ 2019-05-16  5:54 UTC (permalink / raw)
  To: akpm
  Cc: Vaibhav Jain, Dan Williams, Vishal Verma, Keith Busch,
	Dave Jiang, Aneesh Kumar K.V, linux-nvdimm, linux-kernel,
	Chandan Rajendra

Presently __bdev_dax_supported() checks if first sector of last
page ( last_page ) on the block device is aligned to page
boundary. However the code to compute 'last_page' assumes that there
are 8 sectors/page assuming a 4K page-size.

This assumption breaks on architectures which use a different page
size specifically PPC64 where page-size == 64K. Hence a warning is
seen while trying to mount a xfs/ext4 file-system with dax enabled:

$ sudo mount -o dax /dev/pmem0 /mnt/pmem
XFS (pmem0): DAX enabled. Warning: EXPERIMENTAL, use at your own risk
XFS (pmem0): DAX unsupported by block device. Turning off DAX.

The patch fixes this issue by updating calculation of 'last_var' to
take into account number-of-sectors/page instead of assuming it to be
'8'.

Fixes: ad428cdb525a ("dax: Check the end of the block-device capacity with dax_direct_access()")
Signed-off-by: Chandan Rajendra <chandan@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 drivers/dax/super.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index bbd57ca0634a..6b50ed3673d3 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -116,7 +116,9 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
 		return false;
 	}
 
-	last_page = PFN_DOWN(i_size_read(bdev->bd_inode) - 1) * 8;
+	/* Calculate the first sector of last page on the block device */
+	last_page = PFN_DOWN(i_size_read(bdev->bd_inode) - 1) *
+		(PAGE_SIZE >> SECTOR_SHIFT);
 	err = bdev_dax_pgoff(bdev, last_page, PAGE_SIZE, &pgoff_end);
 	if (err) {
 		pr_debug("%s: error: unaligned partition for dax\n",
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] dax: Fix last_page check in __bdev_dax_supported()
  2019-05-16  5:54 [PATCH] dax: Fix last_page check in __bdev_dax_supported() Vaibhav Jain
@ 2019-05-16 18:22 ` Dan Williams
  2019-05-17  5:36   ` Vaibhav Jain
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Williams @ 2019-05-16 18:22 UTC (permalink / raw)
  To: Vaibhav Jain
  Cc: Andrew Morton, Vishal Verma, Keith Busch, Dave Jiang,
	Aneesh Kumar K.V, linux-nvdimm, Linux Kernel Mailing List,
	Chandan Rajendra, Mike Snitzer

On Wed, May 15, 2019 at 10:55 PM Vaibhav Jain <vaibhav@linux.ibm.com> wrote:
>
> Presently __bdev_dax_supported() checks if first sector of last
> page ( last_page ) on the block device is aligned to page
> boundary. However the code to compute 'last_page' assumes that there
> are 8 sectors/page assuming a 4K page-size.
>
> This assumption breaks on architectures which use a different page
> size specifically PPC64 where page-size == 64K. Hence a warning is
> seen while trying to mount a xfs/ext4 file-system with dax enabled:
>
> $ sudo mount -o dax /dev/pmem0 /mnt/pmem
> XFS (pmem0): DAX enabled. Warning: EXPERIMENTAL, use at your own risk
> XFS (pmem0): DAX unsupported by block device. Turning off DAX.
>
> The patch fixes this issue by updating calculation of 'last_var' to
> take into account number-of-sectors/page instead of assuming it to be
> '8'.

Yes, I noticed this too and fixed it up in a wider change that also
allows device-mapper to validate each component device. Does this
patch work for you?

https://lore.kernel.org/lkml/155789172402.748145.11853718580748830476.stgit@dwillia2-desk3.amr.corp.intel.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dax: Fix last_page check in __bdev_dax_supported()
  2019-05-16 18:22 ` Dan Williams
@ 2019-05-17  5:36   ` Vaibhav Jain
  2019-05-20 17:08     ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Vaibhav Jain @ 2019-05-17  5:36 UTC (permalink / raw)
  To: Dan Williams
  Cc: Andrew Morton, Vishal Verma, Keith Busch, Dave Jiang,
	Aneesh Kumar K.V, linux-nvdimm, Linux Kernel Mailing List,
	Chandan Rajendra, Mike Snitzer

Dan Williams <dan.j.williams@intel.com> writes:

> On Wed, May 15, 2019 at 10:55 PM Vaibhav Jain <vaibhav@linux.ibm.com> wrote:
>>
>> Presently __bdev_dax_supported() checks if first sector of last
>> page ( last_page ) on the block device is aligned to page
>> boundary. However the code to compute 'last_page' assumes that there
>> are 8 sectors/page assuming a 4K page-size.
>>
>> This assumption breaks on architectures which use a different page
>> size specifically PPC64 where page-size == 64K. Hence a warning is
>> seen while trying to mount a xfs/ext4 file-system with dax enabled:
>>
>> $ sudo mount -o dax /dev/pmem0 /mnt/pmem
>> XFS (pmem0): DAX enabled. Warning: EXPERIMENTAL, use at your own risk
>> XFS (pmem0): DAX unsupported by block device. Turning off DAX.
>>
>> The patch fixes this issue by updating calculation of 'last_var' to
>> take into account number-of-sectors/page instead of assuming it to be
>> '8'.
>
> Yes, I noticed this too and fixed it up in a wider change that also
> allows device-mapper to validate each component device. Does this
> patch work for you?
>
> https://lore.kernel.org/lkml/155789172402.748145.11853718580748830476.stgit@dwillia2-desk3.amr.corp.intel.com/

Thanks Dan, I tested your patch and not seeing the issue anymore.

So, please ignore this patch.

-- 
Vaibhav Jain <vaibhav@linux.ibm.com>
Linux Technology Center, IBM India Pvt. Ltd.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dax: Fix last_page check in __bdev_dax_supported()
  2019-05-17  5:36   ` Vaibhav Jain
@ 2019-05-20 17:08     ` Dan Williams
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2019-05-20 17:08 UTC (permalink / raw)
  To: Vaibhav Jain
  Cc: Andrew Morton, Vishal Verma, Keith Busch, Dave Jiang,
	Aneesh Kumar K.V, linux-nvdimm, Linux Kernel Mailing List,
	Chandan Rajendra, Mike Snitzer

On Thu, May 16, 2019 at 10:37 PM Vaibhav Jain <vaibhav@linux.ibm.com> wrote:
>
> Dan Williams <dan.j.williams@intel.com> writes:
>
> > On Wed, May 15, 2019 at 10:55 PM Vaibhav Jain <vaibhav@linux.ibm.com> wrote:
> >>
> >> Presently __bdev_dax_supported() checks if first sector of last
> >> page ( last_page ) on the block device is aligned to page
> >> boundary. However the code to compute 'last_page' assumes that there
> >> are 8 sectors/page assuming a 4K page-size.
> >>
> >> This assumption breaks on architectures which use a different page
> >> size specifically PPC64 where page-size == 64K. Hence a warning is
> >> seen while trying to mount a xfs/ext4 file-system with dax enabled:
> >>
> >> $ sudo mount -o dax /dev/pmem0 /mnt/pmem
> >> XFS (pmem0): DAX enabled. Warning: EXPERIMENTAL, use at your own risk
> >> XFS (pmem0): DAX unsupported by block device. Turning off DAX.
> >>
> >> The patch fixes this issue by updating calculation of 'last_var' to
> >> take into account number-of-sectors/page instead of assuming it to be
> >> '8'.
> >
> > Yes, I noticed this too and fixed it up in a wider change that also
> > allows device-mapper to validate each component device. Does this
> > patch work for you?
> >
> > https://lore.kernel.org/lkml/155789172402.748145.11853718580748830476.stgit@dwillia2-desk3.amr.corp.intel.com/
>
> Thanks Dan, I tested your patch and not seeing the issue anymore.

Thanks, I recorded a "Tested-by" for you.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-20 17:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16  5:54 [PATCH] dax: Fix last_page check in __bdev_dax_supported() Vaibhav Jain
2019-05-16 18:22 ` Dan Williams
2019-05-17  5:36   ` Vaibhav Jain
2019-05-20 17:08     ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).