Skip to contentSkip to conversation

Fix DM DAX handling

PATCH Superseded Ross Zwisler 4 participants 27 messages Jun 26, 2018 – Jun 28, 2018

Subsystems (6)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Fix DM DAX handling

This series fixes a few issues that I found with DM's handling of DAX devices. Here are some of the issues I found:

* We can create a dm-stripe or dm-linear device which is made up of an fsdax PMEM namespace and a raw PMEM namespace but which can hold a filesystem mounted with the -o dax mount option. DAX operations to the raw PMEM namespace part lack struct page and can fail in interesting/unexpected ways when doing things like fork(), examining memory with gdb, etc.

* We can create a dm-stripe or dm-linear device which is made up of an fsdax PMEM namespace and a BRD ramdisk which can hold a filesystem mounted with the -o dax mount option. All I/O to this filesystem will fail.

---

Changes since v2:
* Only set QUEUE_FLAG_DAX for fsdax mode PMEM namespaces. (Mike)
* Check for QUEUE_FLAG_DAX in __bdev_dax_supported(). (Mike)
* Get rid of DM_TYPE_DAX_BIO_BASED reworks. (Mike)
* Dropped the first 2 prep patches of v2 since they were merged for

    v4.18-rc1.  (Thanks, Darrick!)

---

Mike, can you take this series through your tree?

Personally I think this should be treated as a bug fix and merged in the v4.18-rc* series.

Ross Zwisler (3):
pmem: only set QUEUE_FLAG_DAX for fsdax mode
dax: bdev_dax_supported() check for QUEUE_FLAG_DAX
dm: prevent DAX mounts if not supported

 drivers/dax/super.c           | 8 ++++++++
 drivers/md/dm-ioctl.c         | 5 +++++
 drivers/md/dm-table.c         | 7 +++----
 drivers/md/dm.c               | 3 +--
 drivers/nvdimm/pmem.c         | 3 ++-
 include/linux/device-mapper.h | 5 +++++
 6 files changed, 24 insertions(+), 7 deletions(-)
Signature · 1 line
2.14.4
#1 lore raw

PATCH v3 1/3 pmem: only set QUEUE_FLAG_DAX for fsdax mode

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

---
 drivers/nvdimm/pmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvdimm/pmem.c +2 -1
index 68940356cad3..8b1fd7f1a224 100644
@@ -414,7 +414,8 @@ static int pmem_attach_disk(struct device *dev,
 	blk_queue_logical_block_size(q, pmem_sector_size(ndns));
 	blk_queue_max_hw_sectors(q, UINT_MAX);
 	blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
-	blk_queue_flag_set(QUEUE_FLAG_DAX, q);
+	if (pmem->pfn_flags & PFN_MAP)
+		blk_queue_flag_set(QUEUE_FLAG_DAX, q);
 	q->queuedata = pmem;
 
 	disk = alloc_disk_node(0, nid);
Signature · 1 line
2.14.4
#2 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 8 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

#3 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 7 lines · Dan Williams
Quoted 5 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Quoted 8 lines
Quoted 3 lines

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

This isn't cosmetic when you consider that stacking up a DM device is looking at this flag to determine whether a table does or does _not_ support DAX.

So this patch, in conjunction with the other changes in the series, is certainly something I'd consider appropriate for stable.

Mike

#4 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 19 lines · Mike Snitzer
Quoted 7 lines · Dan Williams
Quoted 5 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Quoted 8 lines
Quoted 3 lines

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

Quoted 6 lines

This isn't cosmetic when you consider that stacking up a DM device is looking at this flag to determine whether a table does or does _not_ support DAX.

So this patch, in conjunction with the other changes in the series, is certainly something I'd consider appropriate for stable.

I think this classifies as something that never worked correctly and is not a regression. It does not identify which commit it is repairing or the user visible failure mode.

#5 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 24 lines · Dan Williams
Quoted 23 lines · Mike Snitzer
Quoted 7 lines · Dan Williams
Quoted 5 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Quoted 8 lines
Quoted 3 lines

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

This isn't cosmetic when you consider that stacking up a DM device is looking at this flag to determine whether a table does or does _not_ support DAX.

Quoted 6 lines
Quoted 2 lines

So this patch, in conjunction with the other changes in the series, is certainly something I'd consider appropriate for stable.

I think this classifies as something that never worked correctly and is not a regression. It does not identify which commit it is repairing or the user visible failure mode.

Ah, do I need a Fixes: tag for patch 2, then? That one *does* need to go to stable, I think.

#6 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

In reply to Dan Williams
Quoted 24 lines · Dan Williams
Quoted 23 lines · Mike Snitzer
Quoted 7 lines · Dan Williams
Quoted 5 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Quoted 8 lines
Quoted 3 lines

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

This isn't cosmetic when you consider that stacking up a DM device is looking at this flag to determine whether a table does or does _not_ support DAX.

Quoted 6 lines
Quoted 2 lines

So this patch, in conjunction with the other changes in the series, is certainly something I'd consider appropriate for stable.

I think this classifies as something that never worked correctly and is not a regression. It does not identify which commit it is repairing or the user visible failure mode.

So you're taking issue with making stacked dax configs work in older kernels? That's fine. We can drop the stable cc if you like.

But I mean we intended for this to work.. so the Fixes commit references can easily be added, e.g.: 545ed20e6df68a4d2584a29a2a28ee8b2f7e9547 ("dm: add infrastructure for DAX support")

#7 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 34 lines · Mike Snitzer
Quoted 24 lines · Dan Williams
Quoted 23 lines · Mike Snitzer
Quoted 7 lines · Dan Williams
Quoted 5 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Quoted 8 lines
Quoted 3 lines

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

This isn't cosmetic when you consider that stacking up a DM device is looking at this flag to determine whether a table does or does _not_ support DAX.

Quoted 6 lines
Quoted 2 lines

So this patch, in conjunction with the other changes in the series, is certainly something I'd consider appropriate for stable.

I think this classifies as something that never worked correctly and is not a regression. It does not identify which commit it is repairing or the user visible failure mode.

Quoted 6 lines

So you're taking issue with making stacked dax configs work in older kernels? That's fine. We can drop the stable cc if you like.

But I mean we intended for this to work.. so the Fixes commit references can easily be added, e.g.: 545ed20e6df68a4d2584a29a2a28ee8b2f7e9547 ("dm: add infrastructure for DAX support")

...but to be clear stacked DAX configs are not broken, right? They just happen not to work in this corner case of pmem devices without pages. Given we dropped DAX support for page less devices what configurations are repaired by this change? Am I missing something? Is it a data corruption scenario if this DM gets the wrong idea about DAX support. I could be convinced to recommend this for -stable, but the changelog as written does not make a strong case.

#8 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

In reply to Mike Snitzer
Quoted 34 lines · Mike Snitzer
Quoted 24 lines · Dan Williams
Quoted 23 lines · Mike Snitzer
Quoted 7 lines · Dan Williams
Quoted 5 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Quoted 8 lines
Quoted 3 lines

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

This isn't cosmetic when you consider that stacking up a DM device is looking at this flag to determine whether a table does or does _not_ support DAX.

Quoted 6 lines
Quoted 2 lines

So this patch, in conjunction with the other changes in the series, is certainly something I'd consider appropriate for stable.

I think this classifies as something that never worked correctly and is not a regression. It does not identify which commit it is repairing or the user visible failure mode.

Quoted 6 lines

So you're taking issue with making stacked dax configs work in older kernels? That's fine. We can drop the stable cc if you like.

But I mean we intended for this to work.. so the Fixes commit references can easily be added, e.g.: 545ed20e6df68a4d2584a29a2a28ee8b2f7e9547 ("dm: add infrastructure for DAX support")

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Thanks,
-Toshi

#9 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 38 lines · Toshi
Quoted 37 lines · Mike Snitzer
Quoted 24 lines · Dan Williams
Quoted 23 lines · Mike Snitzer
Quoted 7 lines · Dan Williams
Quoted 5 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Quoted 8 lines
Quoted 3 lines

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

This isn't cosmetic when you consider that stacking up a DM device is looking at this flag to determine whether a table does or does _not_ support DAX.

Quoted 6 lines
Quoted 2 lines

So this patch, in conjunction with the other changes in the series, is certainly something I'd consider appropriate for stable.

I think this classifies as something that never worked correctly and is not a regression. It does not identify which commit it is repairing or the user visible failure mode.

So you're taking issue with making stacked dax configs work in older kernels? That's fine. We can drop the stable cc if you like.

Quoted 8 lines
Quoted 3 lines

But I mean we intended for this to work.. so the Fixes commit references can easily be added, e.g.: 545ed20e6df68a4d2584a29a2a28ee8b2f7e9547 ("dm: add infrastructure for DAX support")

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

#10 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 48 lines · Dan Williams
Quoted 38 lines · Toshi
Quoted 37 lines · Mike Snitzer
Quoted 24 lines · Dan Williams
Quoted 23 lines · Mike Snitzer
Quoted 7 lines · Dan Williams
Quoted 5 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Quoted 8 lines
Quoted 3 lines

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

This isn't cosmetic when you consider that stacking up a DM device is looking at this flag to determine whether a table does or does _not_ support DAX.

Quoted 6 lines
Quoted 2 lines

So this patch, in conjunction with the other changes in the series, is certainly something I'd consider appropriate for stable.

I think this classifies as something that never worked correctly and is not a regression. It does not identify which commit it is repairing or the user visible failure mode.

So you're taking issue with making stacked dax configs work in older kernels? That's fine. We can drop the stable cc if you like.

Quoted 8 lines
Quoted 3 lines

But I mean we intended for this to work.. so the Fixes commit references can easily be added, e.g.: 545ed20e6df68a4d2584a29a2a28ee8b2f7e9547 ("dm: add infrastructure for DAX support")

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Quoted 5 lines

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

Thanks,
-Toshi

#11 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 2 lines · Toshi
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 1:54 PM, Kani, Toshi <[email protected]> wrote:

[..]

Quoted 11 lines
Quoted 10 lines
Quoted 4 lines

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

Quoted 7 lines

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

That commit, 569d0365f571 "dax: require 'struct page' by default for filesystem dax", has not been tagged for -stable.

#12 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 20 lines · Dan Williams
Quoted 2 lines · Toshi
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 1:54 PM, Kani, Toshi <[email protected]> wrote:

[..]

Quoted 15 lines
Quoted 10 lines
Quoted 4 lines

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Quoted 6 lines
Quoted 3 lines

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

That commit, 569d0365f571 "dax: require 'struct page' by default for filesystem dax", has not been tagged for -stable.

Then, Fixes tag should be set to 569d0365f571 to keep the behavior consistent.

-Toshi

#13 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 25 lines · Toshi
Quoted 24 lines · Dan Williams
Quoted 2 lines · Toshi
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 1:54 PM, Kani, Toshi <[email protected]> wrote:

[..]

Quoted 18 lines
Quoted 10 lines
Quoted 4 lines

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

Quoted 5 lines
Quoted 2 lines

That commit, 569d0365f571 "dax: require 'struct page' by default for filesystem dax", has not been tagged for -stable.

Then, Fixes tag should be set to 569d0365f571 to keep the behavior consistent.

Sure, and the failure mode is...? I'm thinking the commit log should say:

"Starting with commit 569d0365f571 "dax: require 'struct page' by default for filesystem dax", dax is no longer supported for page-less configurations. However, device-mapper sees the QUEUE_FLAG_DAX still being set and falsely assumes that DAX is enabled, this leads to <insert user visible failure mode details here>"

#14 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 32 lines · Dan Williams
Quoted 25 lines · Toshi
Quoted 24 lines · Dan Williams
Quoted 2 lines · Toshi
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 1:54 PM, Kani, Toshi <[email protected]> wrote:

[..]

Quoted 18 lines
Quoted 10 lines
Quoted 4 lines

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

Quoted 5 lines
Quoted 2 lines

That commit, 569d0365f571 "dax: require 'struct page' by default for filesystem dax", has not been tagged for -stable.

Then, Fixes tag should be set to 569d0365f571 to keep the behavior consistent.

Quoted 7 lines

Sure, and the failure mode is...? I'm thinking the commit log should say:

"Starting with commit 569d0365f571 "dax: require 'struct page' by default for filesystem dax", dax is no longer supported for page-less configurations. However, device-mapper sees the QUEUE_FLAG_DAX still being set and falsely assumes that DAX is enabled, this leads to <insert user visible failure mode details here>"

Dan is correct that there is no user visible change for this. It is the right thing to do for consistency and sanity, but it doesn't actually have user visible behavior that needs to be backported to stable.

Toshi is correct that this change is only for raw mode namespaces, not btt namespaces.

I'll adjust the changelog and remove the stable flag for v5, and I'll add a
Fixes: tag for patch 2.

#15 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 45 lines · Ross Zwisler
Quoted 32 lines · Dan Williams
Quoted 25 lines · Toshi
Quoted 24 lines · Dan Williams
Quoted 2 lines · Toshi
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 1:54 PM, Kani, Toshi <[email protected]> wrote:

[..]

Quoted 18 lines
Quoted 10 lines
Quoted 4 lines

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

Quoted 5 lines
Quoted 2 lines

That commit, 569d0365f571 "dax: require 'struct page' by default for filesystem dax", has not been tagged for -stable.

Then, Fixes tag should be set to 569d0365f571 to keep the behavior consistent.

Quoted 7 lines

Sure, and the failure mode is...? I'm thinking the commit log should say:

"Starting with commit 569d0365f571 "dax: require 'struct page' by default for filesystem dax", dax is no longer supported for page-less configurations. However, device-mapper sees the QUEUE_FLAG_DAX still being set and falsely assumes that DAX is enabled, this leads to <insert user visible failure mode details here>"

Dan is correct that there is no user visible change for this. It is the right thing to do for consistency and sanity, but it doesn't actually have user visible behavior that needs to be backported to stable.

Quoted 5 lines

Toshi is correct that this change is only for raw mode namespaces, not btt namespaces.

I'll adjust the changelog and remove the stable flag for v5, and I'll add a
Fixes: tag for patch 2.

Hi Ross,

Your patches look good. But I am still not clear about the Fixes & stable handling. Talking about user visible behavior, I do not think we had any issue until dax support was dropped from raw mode. Until then, the pmem driver supported dax for all modes, and the check for direct_access worked.

Thanks,
-Toshi

#16 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 52 lines · Toshi
Quoted 45 lines · Ross Zwisler
Quoted 32 lines · Dan Williams
Quoted 25 lines · Toshi
Quoted 24 lines · Dan Williams
Quoted 2 lines · Toshi
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 1:54 PM, Kani, Toshi <[email protected]> wrote:

[..]

Quoted 18 lines
Quoted 10 lines
Quoted 4 lines

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

Quoted 5 lines
Quoted 2 lines

That commit, 569d0365f571 "dax: require 'struct page' by default for filesystem dax", has not been tagged for -stable.

Then, Fixes tag should be set to 569d0365f571 to keep the behavior consistent.

Quoted 7 lines

Sure, and the failure mode is...? I'm thinking the commit log should say:

"Starting with commit 569d0365f571 "dax: require 'struct page' by default for filesystem dax", dax is no longer supported for page-less configurations. However, device-mapper sees the QUEUE_FLAG_DAX still being set and falsely assumes that DAX is enabled, this leads to <insert user visible failure mode details here>"

Dan is correct that there is no user visible change for this. It is the right thing to do for consistency and sanity, but it doesn't actually have user visible behavior that needs to be backported to stable.

Quoted 5 lines

Toshi is correct that this change is only for raw mode namespaces, not btt namespaces.

I'll adjust the changelog and remove the stable flag for v5, and I'll add a
Fixes: tag for patch 2.

Quoted 7 lines

Hi Ross,

Your patches look good. But I am still not clear about the Fixes & stable handling. Talking about user visible behavior, I do not think we had any issue until dax support was dropped from raw mode. Until then, the pmem driver supported dax for all modes, and the check for direct_access worked.

I've staged the changes to send to Linus shortly.

The first patch has:

Fixes 569d0365f571 ("dax: require 'struct page' by default for filesystem dax")

As that is the right thing to do given the other 2 patches are marked for stable. We don't want to have a stable kernel with the last 2 patches but not the first.

Mike

#17 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 65 lines · Mike Snitzer
Quoted 52 lines · Toshi
Quoted 45 lines · Ross Zwisler
Quoted 32 lines · Dan Williams
Quoted 25 lines · Toshi
Quoted 24 lines · Dan Williams
Quoted 2 lines · Toshi
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 1:54 PM, Kani, Toshi <[email protected]> wrote:

[..]

Quoted 18 lines
Quoted 10 lines
Quoted 4 lines

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

Quoted 5 lines
Quoted 2 lines

That commit, 569d0365f571 "dax: require 'struct page' by default for filesystem dax", has not been tagged for -stable.

Then, Fixes tag should be set to 569d0365f571 to keep the behavior consistent.

Quoted 7 lines

Sure, and the failure mode is...? I'm thinking the commit log should say:

"Starting with commit 569d0365f571 "dax: require 'struct page' by default for filesystem dax", dax is no longer supported for page-less configurations. However, device-mapper sees the QUEUE_FLAG_DAX still being set and falsely assumes that DAX is enabled, this leads to <insert user visible failure mode details here>"

Dan is correct that there is no user visible change for this. It is the right thing to do for consistency and sanity, but it doesn't actually have user visible behavior that needs to be backported to stable.

Quoted 5 lines

Toshi is correct that this change is only for raw mode namespaces, not btt namespaces.

I'll adjust the changelog and remove the stable flag for v5, and I'll add a
Fixes: tag for patch 2.

Quoted 7 lines

Hi Ross,

Your patches look good. But I am still not clear about the Fixes & stable handling. Talking about user visible behavior, I do not think we had any issue until dax support was dropped from raw mode. Until then, the pmem driver supported dax for all modes, and the check for direct_access worked.

I've staged the changes to send to Linus shortly.

Quoted 8 lines

The first patch has:

Fixes 569d0365f571 ("dax: require 'struct page' by default for filesystem dax")

As that is the right thing to do given the other 2 patches are marked for stable. We don't want to have a stable kernel with the last 2 patches but not the first.

Ok, I'm still grumbling about the changelog being more clear about what the problem was, but let's just go with what you got.

Reviewed-by
#18 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

In reply to Mike Snitzer
Quoted 65 lines · Mike Snitzer
Quoted 52 lines · Toshi
Quoted 45 lines · Ross Zwisler
Quoted 32 lines · Dan Williams
Quoted 25 lines · Toshi
Quoted 24 lines · Dan Williams
Quoted 2 lines · Toshi
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 1:54 PM, Kani, Toshi <[email protected]> wrote:

[..]

Quoted 18 lines
Quoted 10 lines
Quoted 4 lines

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

Quoted 5 lines
Quoted 2 lines

That commit, 569d0365f571 "dax: require 'struct page' by default for filesystem dax", has not been tagged for -stable.

Then, Fixes tag should be set to 569d0365f571 to keep the behavior consistent.

Quoted 7 lines

Sure, and the failure mode is...? I'm thinking the commit log should say:

"Starting with commit 569d0365f571 "dax: require 'struct page' by default for filesystem dax", dax is no longer supported for page-less configurations. However, device-mapper sees the QUEUE_FLAG_DAX still being set and falsely assumes that DAX is enabled, this leads to <insert user visible failure mode details here>"

Dan is correct that there is no user visible change for this. It is the right thing to do for consistency and sanity, but it doesn't actually have user visible behavior that needs to be backported to stable.

Quoted 5 lines

Toshi is correct that this change is only for raw mode namespaces, not btt namespaces.

I'll adjust the changelog and remove the stable flag for v5, and I'll add a
Fixes: tag for patch 2.

Quoted 7 lines

Hi Ross,

Your patches look good. But I am still not clear about the Fixes & stable handling. Talking about user visible behavior, I do not think we had any issue until dax support was dropped from raw mode. Until then, the pmem driver supported dax for all modes, and the check for direct_access worked.

I've staged the changes to send to Linus shortly.

Quoted 8 lines

The first patch has:

Fixes 569d0365f571 ("dax: require 'struct page' by default for filesystem dax")

As that is the right thing to do given the other 2 patches are marked for stable. We don't want to have a stable kernel with the last 2 patches but not the first.

Agreed.

Technically, all 3 patches may have "Fixes: 569d0365f571 dax..", but I think having "Fixes 545ed20e6df6 dm.." for patch 2 & 3 provide a protection in case 569d0365f571 gets backported in future.

For the series:

Thanks,
-Toshi

#19 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

In reply to Kani, Toshi
Quoted 52 lines · Toshi
Quoted 45 lines · Ross Zwisler
Quoted 32 lines · Dan Williams
Quoted 25 lines · Toshi
Quoted 24 lines · Dan Williams
Quoted 2 lines · Toshi
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 1:54 PM, Kani, Toshi <[email protected]> wrote:

[..]

Quoted 18 lines
Quoted 10 lines
Quoted 4 lines

When this dm change was made, the pmem driver supported DAX for both raw and memory modes (note: sector mode does not use the pmem driver). I think the issue was introduced when we dropped DAX support from raw mode.

Still DAX with raw mode never really worked any way. It was also something that was broken from day one. So what happens to someone who happened to avoid all the problems with page-less DAX and enabled device-mapper on top? That failure mode detail needs to be added to this changelog if we want to propose this for -stable.

My point is that the behavior should be consistent between pmem and device-mapper. When -o dax succeeds on a pmem, then it should succeed on a device-mapper on top of that pmem.

Has the drop of dax support from raw mode made to -stable back to the baseline accepted 545ed20e6df6? It will introduce inconsistency, otherwise.

Quoted 5 lines
Quoted 2 lines

That commit, 569d0365f571 "dax: require 'struct page' by default for filesystem dax", has not been tagged for -stable.

Then, Fixes tag should be set to 569d0365f571 to keep the behavior consistent.

Quoted 7 lines

Sure, and the failure mode is...? I'm thinking the commit log should say:

"Starting with commit 569d0365f571 "dax: require 'struct page' by default for filesystem dax", dax is no longer supported for page-less configurations. However, device-mapper sees the QUEUE_FLAG_DAX still being set and falsely assumes that DAX is enabled, this leads to <insert user visible failure mode details here>"

Dan is correct that there is no user visible change for this. It is the right thing to do for consistency and sanity, but it doesn't actually have user visible behavior that needs to be backported to stable.

Quoted 5 lines

Toshi is correct that this change is only for raw mode namespaces, not btt namespaces.

I'll adjust the changelog and remove the stable flag for v5, and I'll add a
Fixes: tag for patch 2.

Quoted 7 lines

Hi Ross,

Your patches look good. But I am still not clear about the Fixes & stable handling. Talking about user visible behavior, I do not think we had any issue until dax support was dropped from raw mode. Until then, the pmem driver supported dax for all modes, and the check for direct_access worked.

I agree that the fsdax + raw mode failure mode I mentioned in my cover letter only started when we restricted filesystem DAX to having struct page, but I think that the other failure mode, fsdax + some random block driver (I used brd) was present in DM from the beginning.

In any case, I think both are fixed with the patches, and I think it's fine that all 3 get thrown at stable. Thanks, Mike, for the help.

#20 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

Quoted 4 lines · Ross Zwisler
Quoted 3 lines · Toshi
Quoted 2 lines · Ross Zwisler
Quoted 1 line · Dan Williams

On Tue, Jun 26, 2018 at 2:31 PM, Kani, Toshi <[email protected]> wrote:

:

Quoted 10 lines
Quoted 5 lines

Your patches look good. But I am still not clear about the Fixes & stable handling. Talking about user visible behavior, I do not think we had any issue until dax support was dropped from raw mode. Until then, the pmem driver supported dax for all modes, and the check for direct_access worked.

I agree that the fsdax + raw mode failure mode I mentioned in my cover letter only started when we restricted filesystem DAX to having struct page, but I think that the other failure mode, fsdax + some random block driver (I used brd) was present in DM from the beginning.

Ah, I see.

Quoted 2 lines

In any case, I think both are fixed with the patches, and I think it's fine that all 3 get thrown at stable. Thanks, Mike, for the help.

Yup, agreed.

Thanks!
-Toshi

#21 lore raw

Re: [PATCH v3 1/3] pmem: only set QUEUE_FLAG_DAX for fsdax mode

In reply to Mike Snitzer
Quoted 19 lines · Mike Snitzer
Quoted 7 lines · Dan Williams
Quoted 5 lines · Ross Zwisler

QUEUE_FLAG_DAX is an indication that a given block device supports filesystem DAX and should not be set for PMEM namespaces which are in "raw" or "sector" modes. These namespaces lack struct page and are prevented from participating in filesystem DAX.

Quoted 8 lines
Quoted 3 lines

Why is this cc: stable? What is the user visible impact of this change especially given the requirement to validate QUEUE_FLAG_DAX with bdev_dax_supported()? Patch looks good, but it's just a cosmetic fixup afaics.

Quoted 8 lines

This isn't cosmetic when you consider that stacking up a DM device is looking at this flag to determine whether a table does or does _not_ support DAX.

So this patch, in conjunction with the other changes in the series, is certainly something I'd consider appropriate for stable.

Mike

Because in patch 3 of this series we now use the full bdev_dax_supported() instead of just checking the queue flag in device_supports_dax(), I agree that this isn't strictly necessary for stable. device_supports_dax() will still notice that the raw/sector namespaces don't support DAX because bdev_dax_supported() will fail, and we'll end up doing the right thing and not setting QUEUE_FLAG_DAX on the DM device.

I think maybe it's good to have in stable for completeness (and it's a very small change), but if we drop it from stable the code will still do the right thing AFAICT.

#22 lore raw

PATCH v3 2/3 dax: bdev_dax_supported() check for QUEUE_FLAG_DAX

In reply to Ross Zwisler

Add an explicit check for QUEUE_FLAG_DAX to __bdev_dax_supported(). This is needed for DM configurations where the first element in the dm-linear or dm-stripe target supports DAX, but other elements do not. Without this check __bdev_dax_supported() will pass for such devices, letting a filesystem on that device mount with the DAX option.

---
 drivers/dax/super.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/dax/super.c +8 -0
index 903d9c473749..45276abf03aa 100644
@@ -86,6 +86,7 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
 {
 	struct dax_device *dax_dev;
 	bool dax_enabled = false;
+	struct request_queue *q;
 	pgoff_t pgoff;
 	int err, id;
 	void *kaddr;
@@ -99,6 +100,13 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
 		return false;
 	}
 
+	q = bdev_get_queue(bdev);
+	if (!q || !blk_queue_dax(q)) {
+		pr_debug("%s: error: request queue doesn't support dax\n",
+				bdevname(bdev, buf));
+		return false;
+	}
+
 	err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff);
 	if (err) {
 		pr_debug("%s: error: unaligned partition for dax\n",
Signature · 1 line
2.14.4
#23 lore raw

PATCH v3 3/3 dm: prevent DAX mounts if not supported

In reply to Ross Zwisler

Currently device_supports_dax() just checks to see if the QUEUE_FLAG_DAX flag is set on the device's request queue to decide whether or not the device supports filesystem DAX. Really we should be using bdev_dax_supported() like filesystems do at mount time. This performs other tests like checking to make sure the dax_direct_access() path works.

Conditionally set QUEUE_FLAG_DAX on the DM device's request queue based on whether all underlying devices support DAX. Now that bdev_dax_supported() explicitly checks for this flag, this will ensure that filesystems built upon DM devices will only be able to mount with DAX if all underlying devices also support DAX.

Fixes commit 545ed20e6df6 ("dm: add infrastructure for DAX support")
---
 drivers/md/dm-ioctl.c         | 5 +++++
 drivers/md/dm-table.c         | 7 +++----
 drivers/md/dm.c               | 3 +--
 include/linux/device-mapper.h | 5 +++++
 4 files changed, 14 insertions(+), 6 deletions(-)
drivers/md/dm-ioctl.c +5 -0
index b810ea77e6b1..0055bdbee5b1 100644
@@ -1350,6 +1350,11 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si
 		goto err_unlock_md_type;
 	}
 
+	if (dm_table_supports_dax(t))
+		blk_queue_flag_set(QUEUE_FLAG_DAX, md->queue);
+	else
+		blk_queue_flag_clear(QUEUE_FLAG_DAX, md->queue);
+
 	dm_unlock_md_type(md);
 
 	/* stage inactive table */
drivers/md/dm-table.c +3 -4
index 938766794c2e..c673b4a51fb2 100644
@@ -885,12 +885,10 @@ EXPORT_SYMBOL_GPL(dm_table_set_type);
 static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
 			       sector_t start, sector_t len, void *data)
 {
-	struct request_queue *q = bdev_get_queue(dev->bdev);
-
-	return q && blk_queue_dax(q);
+	return bdev_dax_supported(dev->bdev, PAGE_SIZE);
 }
 
-static bool dm_table_supports_dax(struct dm_table *t)
+bool dm_table_supports_dax(struct dm_table *t)
 {
 	struct dm_target *ti;
 	unsigned i;
@@ -909,6 +907,7 @@ static bool dm_table_supports_dax(struct dm_table *t)
 
 	return true;
 }
+EXPORT_SYMBOL_GPL(dm_table_supports_dax);
 
 static bool dm_table_does_not_support_partial_completion(struct dm_table *t);
 
drivers/md/dm.c +1 -2
index e65429a29c06..bef5a3f243ed 100644
@@ -1056,8 +1056,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,
 	if (len < 1)
 		goto out;
 	nr_pages = min(len, nr_pages);
-	if (ti->type->direct_access)
-		ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
+	ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
 
  out:
 	dm_put_live_table(md, srcu_idx);
include/linux/device-mapper.h +5 -0
index 6fb0808e87c8..45ea9e1f9af9 100644
@@ -461,6 +461,11 @@ void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callback
  */
 void dm_table_set_type(struct dm_table *t, enum dm_queue_mode type);
 
+/*
+ * Check to see if this target type and all table devices support DAX.
+ */
+bool dm_table_supports_dax(struct dm_table *t);
+
 /*
  * Finally call this to make the table ready for use.
  */
Signature · 1 line
2.14.4
#24 lore raw

Re: [PATCH v3 3/3] dm: prevent DAX mounts if not supported

Quoted 28 lines · Ross Zwisler

Currently device_supports_dax() just checks to see if the QUEUE_FLAG_DAX flag is set on the device's request queue to decide whether or not the device supports filesystem DAX. Really we should be using bdev_dax_supported() like filesystems do at mount time. This performs other tests like checking to make sure the dax_direct_access() path works.

Conditionally set QUEUE_FLAG_DAX on the DM device's request queue based on whether all underlying devices support DAX. Now that bdev_dax_supported() explicitly checks for this flag, this will ensure that filesystems built upon DM devices will only be able to mount with DAX if all underlying devices also support DAX.

Fixes commit 545ed20e6df6 ("dm: add infrastructure for DAX support")
---
 drivers/md/dm-ioctl.c         | 5 +++++
 drivers/md/dm-table.c         | 7 +++----
 drivers/md/dm.c               | 3 +--
 include/linux/device-mapper.h | 5 +++++
 4 files changed, 14 insertions(+), 6 deletions(-)
drivers/md/dm-ioctl.c +0 -0
index b810ea77e6b1..0055bdbee5b1 100644
@@ -1350,6 +1350,11 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si
 		goto err_unlock_md_type;

drivers/md/dm-ioctl.c static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si · line 1360

Quoted 10 lines
drivers/md/dm-ioctl.c +5 -0
 	}
 
+	if (dm_table_supports_dax(t))
+		blk_queue_flag_set(QUEUE_FLAG_DAX, md->queue);
+	else
+		blk_queue_flag_clear(QUEUE_FLAG_DAX, md->queue);
+
 	dm_unlock_md_type(md);
 
 	/* stage inactive table */

This should occur in drivers/md/dm-table.c:dm_table_set_restrictions(). Which already has:

      if (dm_table_supports_dax(t))
                blk_queue_flag_set(QUEUE_FLAG_DAX, q);

So it just needs tweaking.

Quoted 20 lines
drivers/md/dm-table.c +2 -4
index 938766794c2e..c673b4a51fb2 100644
@@ -885,12 +885,10 @@ EXPORT_SYMBOL_GPL(dm_table_set_type);
 static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
 			       sector_t start, sector_t len, void *data)
 {
-	struct request_queue *q = bdev_get_queue(dev->bdev);
-
-	return q && blk_queue_dax(q);
+	return bdev_dax_supported(dev->bdev, PAGE_SIZE);
 }
 
-static bool dm_table_supports_dax(struct dm_table *t)
+bool dm_table_supports_dax(struct dm_table *t)
 {
 	struct dm_target *ti;
 	unsigned i;

drivers/md/dm-table.c static bool dm_table_supports_dax(struct dm_table *t) · line 913

Quoted 7 lines
drivers/md/dm-table.c +1 -0
@@ -909,6 +907,7 @@ static bool dm_table_supports_dax(struct dm_table *t)
 
 	return true;
 }
+EXPORT_SYMBOL_GPL(dm_table_supports_dax);
 
 static bool dm_table_does_not_support_partial_completion(struct dm_table *t);
 

Which would mean you don't need to export dm_table_supports_dax().

Quoted 20 lines
drivers/md/dm.c +1 -2
index e65429a29c06..bef5a3f243ed 100644
@@ -1056,8 +1056,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,
 	if (len < 1)
 		goto out;
 	nr_pages = min(len, nr_pages);
-	if (ti->type->direct_access)
-		ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
+	ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
 
  out:
 	dm_put_live_table(md, srcu_idx);
include/linux/device-mapper.h +0 -0
index 6fb0808e87c8..45ea9e1f9af9 100644
@@ -461,6 +461,11 @@ void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callback
  */

include/linux/device-mapper.h void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callback · line 471

Quoted 10 lines
include/linux/device-mapper.h +5 -0
 void dm_table_set_type(struct dm_table *t, enum dm_queue_mode type);
 
+/*
+ * Check to see if this target type and all table devices support DAX.
+ */
+bool dm_table_supports_dax(struct dm_table *t);
+
 /*
  * Finally call this to make the table ready for use.
  */

Nor do you need to publish the dm_table_supports_dax() interface via include/linux/device-mapper.h

#25 lore raw

PATCH v4 3/3 dm: prevent DAX mounts if not supported

In reply to Ross Zwisler

Currently device_supports_dax() just checks to see if the QUEUE_FLAG_DAX flag is set on the device's request queue to decide whether or not the device supports filesystem DAX. Really we should be using bdev_dax_supported() like filesystems do at mount time. This performs other tests like checking to make sure the dax_direct_access() path works.

Conditionally set QUEUE_FLAG_DAX on the DM device's request queue based on whether all underlying devices support DAX. Now that bdev_dax_supported() explicitly checks for this flag, this will ensure that filesystems built upon DM devices will only be able to mount with DAX if all underlying devices also support DAX.

Fixes commit 545ed20e6df6 ("dm: add infrastructure for DAX support")

---

Changes in v4:
* Set/clear QUEUE_FLAG_DAX in dm_table_set_restrictions(). (Mike)

---
 drivers/md/dm-table.c | 7 ++++---
 drivers/md/dm.c       | 3 +--
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/md/dm-table.c +4 -3
index 938766794c2e..3d0e2c198f06 100644
@@ -885,9 +885,7 @@ EXPORT_SYMBOL_GPL(dm_table_set_type);
 static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
 			       sector_t start, sector_t len, void *data)
 {
-	struct request_queue *q = bdev_get_queue(dev->bdev);
-
-	return q && blk_queue_dax(q);
+	return bdev_dax_supported(dev->bdev, PAGE_SIZE);
 }
 
 static bool dm_table_supports_dax(struct dm_table *t)
@@ -1907,6 +1905,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 
 	if (dm_table_supports_dax(t))
 		blk_queue_flag_set(QUEUE_FLAG_DAX, q);
+	else
+		blk_queue_flag_clear(QUEUE_FLAG_DAX, q);
+
 	if (dm_table_supports_dax_write_cache(t))
 		dax_write_cache(t->md->dax_dev, true);
 
drivers/md/dm.c +1 -2
index e65429a29c06..bef5a3f243ed 100644
@@ -1056,8 +1056,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,
 	if (len < 1)
 		goto out;
 	nr_pages = min(len, nr_pages);
-	if (ti->type->direct_access)
-		ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
+	ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
 
  out:
 	dm_put_live_table(md, srcu_idx);
Signature · 1 line
2.14.4
#26 lore raw
In reply to Ross Zwisler
Quoted 22 lines · Ross Zwisler

This series fixes a few issues that I found with DM's handling of DAX devices. Here are some of the issues I found:

* We can create a dm-stripe or dm-linear device which is made up of an fsdax PMEM namespace and a raw PMEM namespace but which can hold a filesystem mounted with the -o dax mount option. DAX operations to the raw PMEM namespace part lack struct page and can fail in interesting/unexpected ways when doing things like fork(), examining memory with gdb, etc.

* We can create a dm-stripe or dm-linear device which is made up of an fsdax PMEM namespace and a BRD ramdisk which can hold a filesystem mounted with the -o dax mount option. All I/O to this filesystem will fail.

---

Changes since v2:
* Only set QUEUE_FLAG_DAX for fsdax mode PMEM namespaces. (Mike)
* Check for QUEUE_FLAG_DAX in __bdev_dax_supported(). (Mike)
* Get rid of DM_TYPE_DAX_BIO_BASED reworks. (Mike)
* Dropped the first 2 prep patches of v2 since they were merged for

Quoted 8 lines
    v4.18-rc1.  (Thanks, Darrick!)

---

Mike, can you take this series through your tree?

Personally I think this should be treated as a bug fix and merged in the v4.18-rc* series.

I'd be fine with staging it for 4.18. Only question is whether others are fine with the dax patch (and me being the one to get it to Linus)?

I already replied to the 3rd patch with some feedback for v4 (but I can also take care of those changes if I'm the one to stage these changes).

Maybe if Dan and/or others could provide their review for both the dax and pmem patches? If I can get review on those I'll get the series staged for Linus to pull this week.

Thanks,
Mike