I noticed that dm-snap reloads DM table of target mapped-device, which
fails for dax-capable device after dax support is added. Ideally,
adding dax support to dm-snap solves the issue, but it cannot be done
easily. This patch-set allows dm-snap to work with dax-capable target
devices when bio-based operation is used.
dax operation is unsupported with dm-snap, such that:
a) After snapshot is taken, mount with dax option to a target device
or a snapshot device fails. They can be mounted without dax.
b) After snapshot is taken to a dax-mounted target device, any writes
to the target device fails (EIO).
b) can be protected by changing lvcreate to fail when snapshot is
requested to a dax-mounted target device.
- Patch 1 solves an error when lvremove is made to a snapshot device.
- Patch 2 solves an error when lvcreate --snapshot is made to a dax-
capable device.
---
Toshi Kani (2):
1/2 dm: update table type check for dax
2/2 dm snap: add fake origin_direct_access
---
drivers/md/dm-ioctl.c | 11 ++++++++++-
drivers/md/dm-snap.c | 8 ++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
@@ -1267,6 +1267,15 @@ static int populate_table(struct dm_table *table,returndm_table_complete(table);}+staticboolis_valid_type(unsignedcur,unsignednew)+{+if(cur==new||+(cur==DM_TYPE_BIO_BASED&&new==DM_TYPE_DAX_BIO_BASED))+returntrue;++returnfalse;+}+staticinttable_load(structdm_ioctl*param,size_tparam_size){intr;
@@ -1309,7 +1318,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size)DMWARN("unable to set up device queue for new table.");gotoerr_unlock_md_type;}-}elseif(dm_get_md_type(md)!=dm_table_get_type(t)){+}elseif(!is_valid_type(dm_get_md_type(md),dm_table_get_type(t))){DMWARN("can't change device type after initial table load.");r=-EINVAL;gotoerr_unlock_md_type;
dax-capable mapped-device is marked as DM_TYPE_DAX_BIO_BASED,
which supports both dax and bio-based operations. dm-snap
needs to work with dax-capable device when bio-based operation
is used.
Add fake origin_direct_access() to origin device so that its
origin device is also marked as DM_TYPE_DAX_BIO_BASED for
dax-capable device. This allows to extend target's DM table.
dm-snap works normally when bio-based operation is used.
dm-snap does not support dax operation, and mount with dax
option to a target device or snapshot device fails.
Signed-off-by: Toshi Kani <redacted>
Cc: Mike Snitzer <redacted>
Cc: Alasdair Kergon <redacted>
Cc: Dan Williams <redacted>
---
drivers/md/dm-snap.c | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -2301,6 +2301,13 @@ static int origin_map(struct dm_target *ti, struct bio *bio)returndo_origin(o->dev,bio);}+staticlongorigin_direct_access(structdm_target*ti,sector_tsector,+void__pmem**kaddr,pfn_t*pfn,longsize)+{+DMWARN("device does not support dax.");+return-EIO;+}+/**Setthetarget"max_io_len"fieldtotheminimumofallthesnapshots'*chunksizes.
Sorry, subject line should be "[PATCH 0/2] fix dm-snap for dax"
-Toshi
On Tue, 2016-06-28 at 13:37 -0600, Toshi Kani wrote:
I noticed that dm-snap reloads DM table of target mapped-device, which
fails for dax-capable device after dax support is added. Ideally,
adding dax support to dm-snap solves the issue, but it cannot be done
easily. This patch-set allows dm-snap to work with dax-capable target
devices when bio-based operation is used.
dax operation is unsupported with dm-snap, such that:
a) After snapshot is taken, mount with dax option to a target device
or a snapshot device fails. They can be mounted without dax.
b) After snapshot is taken to a dax-mounted target device, any writes
to the target device fails (EIO).
b) can be protected by changing lvcreate to fail when snapshot is
requested to a dax-mounted target device.
- Patch 1 solves an error when lvremove is made to a snapshot device.
- Patch 2 solves an error when lvcreate --snapshot is made to a dax-
capable device.
---
Toshi Kani (2):
1/2 dm: update table type check for dax
2/2 dm snap: add fake origin_direct_access
---
drivers/md/dm-ioctl.c | 11 ++++++++++-
drivers/md/dm-snap.c | 8 ++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
@@ -1267,6 +1267,15 @@ static int populate_table(struct dm_table *table,returndm_table_complete(table);}+staticboolis_valid_type(unsignedcur,unsignednew)+{+if(cur==new||+(cur==DM_TYPE_BIO_BASED&&new==DM_TYPE_DAX_BIO_BASED))+returntrue;++returnfalse;+}+staticinttable_load(structdm_ioctl*param,size_tparam_size){intr;
@@ -1309,7 +1318,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size)DMWARN("unable to set up device queue for new table.");gotoerr_unlock_md_type;}-}elseif(dm_get_md_type(md)!=dm_table_get_type(t)){+}elseif(!is_valid_type(dm_get_md_type(md),dm_table_get_type(t))){DMWARN("can't change device type after initial table load.");r=-EINVAL;gotoerr_unlock_md_type;
You said in the 0th header: "Patch 1 solves an error when lvremove is
made to a snapshot device."
I'm not seeing why this patch 1 fixes anything specific to snapshot
device removal (but I can see why patch 2 makes snapshot creation
"work"). I'll apply your 2nd patch and see if I can see what you mean.
I actually see this error, without either of your 2 proposed patches
applied, when I try to create a snapshot of a DAX capable LV:
# lvcreate -s -n snap -L 100M pmem/lv
device-mapper: reload ioctl on (253:7) failed: Invalid argument
Failed to lock logical volume pmem/lv.
Aborting. Manual intervention required.
Jun 28 15:57:28 rhel-storage-02 kernel: device-mapper: ioctl: can't change device type after initial table load.
On Tue, 2016-06-28 at 16:07 -0400, Mike Snitzer wrote:
On Tue, Jun 28 2016 at 3:37pm -0400,
Toshi Kani [off-list ref] wrote:
:
You said in the 0th header: "Patch 1 solves an error when lvremove is
made to a snapshot device."
I'm not seeing why this patch 1 fixes anything specific to snapshot
device removal (but I can see why patch 2 makes snapshot creation
"work"). I'll apply your 2nd patch and see if I can see what you mean.
I actually see this error, without either of your 2 proposed patches
applied, when I try to create a snapshot of a DAX capable LV:
# lvcreate -s -n snap -L 100M pmem/lv
device-mapper: reload ioctl on (253:7) failed: Invalid argument
Failed to lock logical volume pmem/lv.
Aborting. Manual intervention required.
Jun 28 15:57:28 rhel-storage-02 kernel: device-mapper: ioctl: can't change
device type after initial table load.
Yes, patch 2 fixes this error.
I have not looked into why lvremove does this, but lvremove to a snapshot
device fails to reload DM table of "<dev>-lvsnap" device (which is marked as
DM_TYPE_BIO_BASED) with DM_TYPE_DAX_BIO_BASED. Patch 1 fixes this error. I
think it also generally makes sense to allow this case.
Thanks,
-Toshi
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
drivers/md/dm-ioctl.c:1273:42: error: 'DM_TYPE_DAX_BIO_BASED' undeclared (first use in this function)
(cur == DM_TYPE_BIO_BASED && new == DM_TYPE_DAX_BIO_BASED))
^~~~~~~~~~~~~~~~~~~~~
drivers/md/dm-ioctl.c:1273:42: note: each undeclared identifier is reported only once for each function it appears in
vim +/DM_TYPE_DAX_BIO_BASED +1273 drivers/md/dm-ioctl.c
1267 return dm_table_complete(table);
1268 }
1269
1270 static bool is_valid_type(unsigned cur, unsigned new)
1271 {
1272 if (cur == new ||
1273 (cur == DM_TYPE_BIO_BASED && new == DM_TYPE_DAX_BIO_BASED))
1274 return true;
1275
1276 return false;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
From: Mike Snitzer <hidden> Date: 2016-06-29 00:41:31
On Tue, Jun 28 2016 at 4:23pm -0400,
Kani, Toshimitsu [off-list ref] wrote:
On Tue, 2016-06-28 at 16:07 -0400, Mike Snitzer wrote:
quoted
On Tue, Jun 28 2016 at 3:37pm -0400,
Toshi Kani [off-list ref] wrote:
:
quoted
You said in the 0th header: "Patch 1 solves an error when lvremove is
made to a snapshot device."
I'm not seeing why this patch 1 fixes anything specific to snapshot
device removal (but I can see why patch 2 makes snapshot creation
"work"). I'll apply your 2nd patch and see if I can see what you mean.
I actually see this error, without either of your 2 proposed patches
applied, when I try to create a snapshot of a DAX capable LV:
# lvcreate -s -n snap -L 100M pmem/lv
device-mapper: reload ioctl on (253:7) failed: Invalid argument
Failed to lock logical volume pmem/lv.
Aborting. Manual intervention required.
Jun 28 15:57:28 rhel-storage-02 kernel: device-mapper: ioctl: can't change
device type after initial table load.
Yes, patch 2 fixes this error.
I have not looked into why lvremove does this, but lvremove to a snapshot
device fails to reload DM table of "<dev>-lvsnap" device (which is marked as
DM_TYPE_BIO_BASED) with DM_TYPE_DAX_BIO_BASED. Patch 1 fixes this error.
It looks like a strange intermediate state that lvm2 uses during
snapshot removal.
Full listing of snapshot related DM tables (before lvremove):
pmem-lv-real: 0 6086656 linear 259:0 2048
pmem-lv: 0 6086656 snapshot-origin 253:5
pmem-snap-cow: 0 204800 linear 259:0 6088704
pmem-snap: 0 6086656 snapshot 253:5 253:6 P 8
When removing this snapshot we're wanting to be left with:
pmem-lv: 0 6086656 linear 259:0 2048
I augmented the DM core error to be more expressive, resulting in:
device-mapper: ioctl: 253:7: can't change device type (from 1 to 4) after initial table load.
1 is DM_TYPE_BIO_BASED and 4 is DM_TYPE_DAX_BIO_BASED -- which makes
sense given the linear target is DM_TYPE_DAX_BIO_BASED.
The previous DM table for 253:7 was:
pmem-snap: 0 6086656 snapshot 253:5 253:6 P 8
The intermediate table that lvm2 is trying to load for 253:7 is:
0 204800 linear 259:0 6088704
(this linear target was previously pmem-snap-cow)
I think it also generally makes sense to allow this case.
You're probably right but I need to think about it a little bit more.
On Tue, 2016-06-28 at 20:40 -0400, Mike Snitzer wrote:
On Tue, Jun 28 2016 at 4:23pm -0400,
Kani, Toshimitsu [off-list ref] wrote:
quoted
On Tue, 2016-06-28 at 16:07 -0400, Mike Snitzer wrote:
quoted
On Tue, Jun 28 2016 at 3:37pm -0400,
Toshi Kani [off-list ref] wrote:
:
quoted
You said in the 0th header: "Patch 1 solves an error when lvremove is
made to a snapshot device."
I'm not seeing why this patch 1 fixes anything specific to snapshot
device removal (but I can see why patch 2 makes snapshot creation
"work"). I'll apply your 2nd patch and see if I can see what you mean.
I actually see this error, without either of your 2 proposed patches
applied, when I try to create a snapshot of a DAX capable LV:
# lvcreate -s -n snap -L 100M pmem/lv
device-mapper: reload ioctl on (253:7) failed: Invalid argument
Failed to lock logical volume pmem/lv.
Aborting. Manual intervention required.
Jun 28 15:57:28 rhel-storage-02 kernel: device-mapper: ioctl: can't
change device type after initial table load.
Yes, patch 2 fixes this error.
I have not looked into why lvremove does this, but lvremove to a snapshot
device fails to reload DM table of "<dev>-lvsnap" device (which is marked
as DM_TYPE_BIO_BASED) with DM_TYPE_DAX_BIO_BASED. Patch 1 fixes this
error.
It looks like a strange intermediate state that lvm2 uses during
snapshot removal.
Full listing of snapshot related DM tables (before lvremove):
pmem-lv-real: 0 6086656 linear 259:0 2048
pmem-lv: 0 6086656 snapshot-origin 253:5
pmem-snap-cow: 0 204800 linear 259:0 6088704
pmem-snap: 0 6086656 snapshot 253:5 253:6 P 8
When removing this snapshot we're wanting to be left with:
pmem-lv: 0 6086656 linear 259:0 2048
I augmented the DM core error to be more expressive, resulting in:
device-mapper: ioctl: 253:7: can't change device type (from 1 to 4) after
initial table load.
1 is DM_TYPE_BIO_BASED and 4 is DM_TYPE_DAX_BIO_BASED -- which makes
sense given the linear target is DM_TYPE_DAX_BIO_BASED.
The previous DM table for 253:7 was:
pmem-snap: 0 6086656 snapshot 253:5 253:6 P 8
The intermediate table that lvm2 is trying to load for 253:7 is:
0 204800 linear 259:0 6088704
(this linear target was previously pmem-snap-cow)
Yes, that is consistent with what I saw.
quoted
I think it also generally makes sense to allow this case.
You're probably right but I need to think about it a little bit more.