Skip to contentSkip to conversation

multipath: set discard and norot queue flags on the multipath stacking device

PATCH New Sagi Grimberg 2 participants 2 messages Mar 12, 2019 NVMe

lore
Share & tools
lore

Sagi Grimberg

author maintainer
#0 lore raw

PATCH v2 1/1 multipath: set discard and norot queue flags on the multipath stacking device

If the underlying device supports discard we set it and clear it otherwise. Without this blkdiscard doesn't work on a multipath device node.

Signed-off-by Sagi Grimberg <sagi at grimberg.me>

---
Changes from v1:
- removed the nonrot queue setting from the mpath device

Christoph,
I lost reply and only saw it while searching for something else in the archives.

So to your question,
"For discard don't we also need to the limits? Also what about Write Zeroes?"

blk_queue_stack_limits takes care of the discard and write_zeros limits, we just need to set the queue flag.

 drivers/nvme/host/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +6 -2
index d29ff9b910d9..40fcd80ec09f 100644
@@ -1561,9 +1561,13 @@ static inline void nvme_config_write_zeroes(struct nvme_ns *ns)
 	blk_queue_max_write_zeroes_sectors(ns->queue, max_sectors);
 }
 
-static inline void nvme_ns_config_oncs(struct nvme_ns *ns)
+static inline void nvme_ns_config_oncs(struct gendisk *disk, struct nvme_ns *ns)
 {
 	nvme_config_discard(ns);
+	if (blk_queue_discard(ns->queue))
+		blk_queue_flag_set(QUEUE_FLAG_DISCARD, disk->queue);
+	else
+		blk_queue_flag_clear(QUEUE_FLAG_DISCARD, disk->queue);
 	nvme_config_write_zeroes(ns);
 }
 
@@ -1620,7 +1624,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
 		capacity = 0;
 
 	set_capacity(disk, capacity);
-	nvme_ns_config_oncs(ns);
+	nvme_ns_config_oncs(disk, ns);
 
 	if (id->nsattr & (1 << 0))
 		set_disk_ro(disk, true);
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 multipath: set discard and norot queue flags on the multipath stacking device

Quoted 29 lines · Sagi Grimberg

If the underlying device supports discard we set it and clear it otherwise. Without this blkdiscard doesn't work on a multipath device node.

Signed-off-by Sagi Grimberg <sagi at grimberg.me>

---
Changes from v1:
- removed the nonrot queue setting from the mpath device

Christoph,
I lost reply and only saw it while searching for something else in the archives.

So to your question,
"For discard don't we also need to the limits? Also what about Write Zeroes?"

blk_queue_stack_limits takes care of the discard and write_zeros limits, we just need to set the queue flag.

 drivers/nvme/host/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +0 -0
index d29ff9b910d9..40fcd80ec09f 100644
@@ -1561,9 +1561,13 @@ static inline void nvme_config_write_zeroes(struct nvme_ns *ns)
 	blk_queue_max_write_zeroes_sectors(ns->queue, max_sectors);
 }

drivers/nvme/host/core.c static inline void nvme_config_write_zeroes(struct nvme_ns *ns) · line 1571

Quoted 10 lines
drivers/nvme/host/core.c +5 -1
 
-static inline void nvme_ns_config_oncs(struct nvme_ns *ns)
+static inline void nvme_ns_config_oncs(struct gendisk *disk, struct nvme_ns *ns)
 {
 	nvme_config_discard(ns);
+	if (blk_queue_discard(ns->queue))
+		blk_queue_flag_set(QUEUE_FLAG_DISCARD, disk->queue);
+	else
+		blk_queue_flag_clear(QUEUE_FLAG_DISCARD, disk->queue);
 	nvme_config_write_zeroes(ns);

This looks a bit odd as I'd expect this code to be inside nvme_config_discard. But there is some other oddness in this area, let me send a small series with a refreshed version of your patch for comments.