Skip to contentSkip to conversation

dm writecache: reject asynchronous pmem.

PATCH Superseded Michal Suchanek 3 participants 10 messages Jun 30, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm writecache: reject asynchronous pmem.

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +6 -0
index 30505d70f423..57b0a972f6fd 100644
@@ -2277,6 +2277,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 
 		wc->memory_map_size -= (uint64_t)wc->start_sector << SECTOR_SHIFT;
 
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
+
 		bio_list_init(&wc->flush_list);
 		wc->flush_thread = kthread_create(writecache_flush_thread, wc, "dm_writecache_flush");
 		if (IS_ERR(wc->flush_thread)) {
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 19 lines · Michal Suchanek

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +0 -0
index 30505d70f423..57b0a972f6fd 100644
@@ -2277,6 +2277,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 
 		wc->memory_map_size -= (uint64_t)wc->start_sector << SECTOR_SHIFT;

drivers/md/dm-writecache.c static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) · line 2288

Quoted 10 lines
drivers/md/dm-writecache.c +6 -0
 
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
+
 		bio_list_init(&wc->flush_list);
 		wc->flush_thread = kthread_create(writecache_flush_thread, wc, "dm_writecache_flush");
 		if (IS_ERR(wc->flush_thread)) {

Hi

Shouldn't this be in the "if (WC_MODE_PMEM(wc))" block?

WC_MODE_PMEM(wc) retrurns true if we are using persistent memory as a cache device, otherwise we are using generic block device as a cache device.

Mikulas

#2 lore raw
Quoted 36 lines · Mikulas Patocka
Quoted 19 lines · Michal Suchanek

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +0 -0
index 30505d70f423..57b0a972f6fd 100644
@@ -2277,6 +2277,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 
 		wc->memory_map_size -= (uint64_t)wc->start_sector << SECTOR_SHIFT;

drivers/md/dm-writecache.c static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) · line 2288

Quoted 10 lines
drivers/md/dm-writecache.c +6 -0
 
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
+
 		bio_list_init(&wc->flush_list);
 		wc->flush_thread = kthread_create(writecache_flush_thread, wc, "dm_writecache_flush");
 		if (IS_ERR(wc->flush_thread)) {

Hi

Quoted 1 line

Shouldn't this be in the "if (WC_MODE_PMEM(wc))" block?

That should be always the case at this point.

Quoted 4 lines

WC_MODE_PMEM(wc) retrurns true if we are using persistent memory as a cache device, otherwise we are using generic block device as a cache device.

This is to prevent the situation where we have WC_MODE_PMEM(wc) but cannot guarantee consistency because the async flush is not handled.

Thanks

Michal

#3 lore raw
Quoted 38 lines · Michal Suchánek
Quoted 36 lines · Mikulas Patocka
Quoted 19 lines · Michal Suchanek

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +0 -0
index 30505d70f423..57b0a972f6fd 100644
@@ -2277,6 +2277,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 
 		wc->memory_map_size -= (uint64_t)wc->start_sector << SECTOR_SHIFT;

drivers/md/dm-writecache.c static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) · line 2288

Quoted 10 lines
drivers/md/dm-writecache.c +6 -0
 
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
+
 		bio_list_init(&wc->flush_list);
 		wc->flush_thread = kthread_create(writecache_flush_thread, wc, "dm_writecache_flush");
 		if (IS_ERR(wc->flush_thread)) {

Hi

Quoted 1 line

Shouldn't this be in the "if (WC_MODE_PMEM(wc))" block?

Quoted 8 lines

That should be always the case at this point.

Quoted 4 lines

WC_MODE_PMEM(wc) retrurns true if we are using persistent memory as a cache device, otherwise we are using generic block device as a cache device.

This is to prevent the situation where we have WC_MODE_PMEM(wc) but cannot guarantee consistency because the async flush is not handled.

The writecache operates in 2 modes. SSD or PMEM. Mikulas is saying your dax_synchronous() check should go within a WC_MODE_PMEM(wc) block because it doesn't make sense to do the check when in SSD mode.

Mike

#4 lore raw
Quoted 47 lines · Mike Snitzer
Quoted 44 lines · Michal Suchánek
Quoted 36 lines · Mikulas Patocka
Quoted 19 lines · Michal Suchanek

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +0 -0
index 30505d70f423..57b0a972f6fd 100644
@@ -2277,6 +2277,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 
 		wc->memory_map_size -= (uint64_t)wc->start_sector << SECTOR_SHIFT;

drivers/md/dm-writecache.c static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) · line 2288

Quoted 10 lines
drivers/md/dm-writecache.c +6 -0
 
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
+
 		bio_list_init(&wc->flush_list);
 		wc->flush_thread = kthread_create(writecache_flush_thread, wc, "dm_writecache_flush");
 		if (IS_ERR(wc->flush_thread)) {

Hi

Quoted 1 line

Shouldn't this be in the "if (WC_MODE_PMEM(wc))" block?

That should be always the case at this point.

Quoted 4 lines

WC_MODE_PMEM(wc) retrurns true if we are using persistent memory as a cache device, otherwise we are using generic block device as a cache device.

Quoted 6 lines
Quoted 2 lines

This is to prevent the situation where we have WC_MODE_PMEM(wc) but cannot guarantee consistency because the async flush is not handled.

The writecache operates in 2 modes. SSD or PMEM. Mikulas is saying your dax_synchronous() check should go within a WC_MODE_PMEM(wc) block because it doesn't make sense to do the check when in SSD mode.

Indeed, it's in the wrong if/else branch.

Thanks

Michal

#5 lore raw

PATCH v2 1/1 dm writecache: reject asynchronous pmem.

In reply to Mike Snitzer

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +6 -0
index 30505d70f423..1e4f37249e28 100644
@@ -2271,6 +2271,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 			ti->error = "Unable to map persistent memory for cache";
 			goto bad;
 		}
+
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
 	} else {
 		size_t n_blocks, n_metadata_blocks;
 		uint64_t n_bitmap_bits;
Signature · 1 line
2.26.2
maintainer
#6 lore raw
Quoted 7 lines · Michal Suchanek

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")

OK. I suggest to move this test before persistent_memory_claim (so that you don't try to map the whole device).

Mikulas

Quoted 24 lines
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +6 -0
index 30505d70f423..1e4f37249e28 100644
@@ -2271,6 +2271,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 			ti->error = "Unable to map persistent memory for cache";
 			goto bad;
 		}
+
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
 	} else {
 		size_t n_blocks, n_metadata_blocks;
 		uint64_t n_bitmap_bits;
Signature · 1 line
2.26.2
#7 lore raw

PATCH v3 1/1 dm writecache: reject asynchronous pmem.

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +6 -0
index 30505d70f423..5358894bb9fd 100644
@@ -2266,6 +2266,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 	}
 
 	if (WC_MODE_PMEM(wc)) {
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
+
 		r = persistent_memory_claim(wc);
 		if (r) {
 			ti->error = "Unable to map persistent memory for cache";
Signature · 1 line
2.26.2
maintainer Acked-by on v3 1/1
#8 lore raw
Quoted 7 lines · Michal Suchanek

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")
Quoted 24 lines
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +6 -0
index 30505d70f423..5358894bb9fd 100644
@@ -2266,6 +2266,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 	}
 
 	if (WC_MODE_PMEM(wc)) {
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
+
 		r = persistent_memory_claim(wc);
 		if (r) {
 			ti->error = "Unable to map persistent memory for cache";
Signature · 1 line
2.26.2
maintainer
#9 lore raw
Quoted 7 lines · Mikulas Patocka
Quoted 3 lines · Michal Suchanek

The writecache driver does not handle asynchronous pmem. Reject it when supplied as cache.

Quoted 6 lines
Quoted 4 lines
Fixes 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")

BTW, we should also add

Quoted 25 lines
Quoted 24 lines
---
 drivers/md/dm-writecache.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/md/dm-writecache.c +6 -0
index 30505d70f423..5358894bb9fd 100644
@@ -2266,6 +2266,12 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
 	}
 
 	if (WC_MODE_PMEM(wc)) {
+		if (!dax_synchronous(wc->ssd_dev->dax_dev)) {
+			r = -EOPNOTSUPP;
+			ti->error = "Asynchronous persistent memory not supported as pmem cache";
+			goto bad;
+		}
+
 		r = persistent_memory_claim(wc);
 		if (r) {
 			ti->error = "Unable to map persistent memory for cache";
Signature · 1 line
2.26.2