Skip to contentSkip to conversation

fix and cleanup discard_alignment handling

PATCH In review Christoph Hellwig 9 participants 28 messages Apr 18, 2022 – May 6, 2022

Subsystems (12)
Block layer s390 MD RAID virtio core +8 more subsystems
lore
Share & tools
lore

Christoph Hellwig

author maintainer
#0 lore raw

Hi all,

the somewhat confusing name of the discard_alignment queue limit, that really is an offset for the discard granularity mislead a lot of driver authors to set it to an incorrect value. This series tries to fix up all these cases.

Diffstat:

 arch/um/drivers/ubd_kern.c         |    1 -
 drivers/block/loop.c               |    1 -
 drivers/block/nbd.c                |    3 ---
 drivers/block/null_blk/main.c      |    1 -
 drivers/block/rnbd/rnbd-srv-dev.h  |    2 +-
 drivers/block/virtio_blk.c         |    7 ++++---
 drivers/block/xen-blkback/xenbus.c |    4 ++--
 drivers/md/dm-zoned-target.c       |    2 +-
 drivers/md/raid5.c                 |    1 -
 drivers/nvme/host/core.c           |    1 -
 drivers/s390/block/dasd_fba.c      |    1 -
 11 files changed, 8 insertions(+), 16 deletions(-)

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

author maintainer
#1 lore raw

PATCH 1/11 ubd: don't set the discard_alignment queue limit

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to the discard granularity as done by ubd is mostly harmless but also useless.

---
 arch/um/drivers/ubd_kern.c | 1 -
 1 file changed, 1 deletion(-)
arch/um/drivers/ubd_kern.c +0 -1
index 085ffdf98e57e..c4344b67628dd 100644
@@ -799,7 +799,6 @@ static int ubd_open_dev(struct ubd *ubd_dev)
 	}
 	if (ubd_dev->no_trim == 0) {
 		ubd_dev->queue->limits.discard_granularity = SECTOR_SIZE;
-		ubd_dev->queue->limits.discard_alignment = SECTOR_SIZE;
 		blk_queue_max_discard_sectors(ubd_dev->queue, UBD_MAX_REQUEST);
 		blk_queue_max_write_zeroes_sectors(ubd_dev->queue, UBD_MAX_REQUEST);
 	}
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
author maintainer
#2 lore raw

PATCH 2/11 nbd: don't set the discard_alignment queue limit

In reply to Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to the discard granularity as done by nbd is mostly harmless but also useless.

---
 drivers/block/nbd.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/block/nbd.c +0 -3
index 4729aef8c6462..102597a4277b9 100644
@@ -333,7 +333,6 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
 
 	if (nbd->config->flags & NBD_FLAG_SEND_TRIM) {
 		nbd->disk->queue->limits.discard_granularity = blksize;
-		nbd->disk->queue->limits.discard_alignment = blksize;
 		blk_queue_max_discard_sectors(nbd->disk->queue, UINT_MAX);
 	}
 	blk_queue_logical_block_size(nbd->disk->queue, blksize);
@@ -1316,7 +1315,6 @@ static void nbd_config_put(struct nbd_device *nbd)
 
 		nbd->tag_set.timeout = 0;
 		nbd->disk->queue->limits.discard_granularity = 0;
-		nbd->disk->queue->limits.discard_alignment = 0;
 		blk_queue_max_discard_sectors(nbd->disk->queue, 0);
 
 		mutex_unlock(&nbd->config_lock);
@@ -1781,7 +1779,6 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
 	blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue);
 	blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue);
 	disk->queue->limits.discard_granularity = 0;
-	disk->queue->limits.discard_alignment = 0;
 	blk_queue_max_discard_sectors(disk->queue, 0);
 	blk_queue_max_segment_size(disk->queue, UINT_MAX);
 	blk_queue_max_segments(disk->queue, USHRT_MAX);
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
author maintainer
#3 lore raw

PATCH 3/11 null_blk: don't set the discard_alignment queue limit

In reply to Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to the discard granularity as done by null_blk is mostly harmless but also useless.

---
 drivers/block/null_blk/main.c | 1 -
 1 file changed, 1 deletion(-)
drivers/block/null_blk/main.c +0 -1
index 5cb4c92cdffea..a521e914a9843 100644
@@ -1765,7 +1765,6 @@ static void null_config_discard(struct nullb *nullb)
 	}
 
 	nullb->q->limits.discard_granularity = nullb->dev->blocksize;
-	nullb->q->limits.discard_alignment = nullb->dev->blocksize;
 	blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);
 }
 
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v1 3/11
#4 lore raw

Re: [dm-devel] [PATCH 03/11] null_blk: don't set the discard_alignment queue limit

Quoted 15 lines · Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to the discard granularity as done by null_blk is mostly harmless but also useless.

---
 drivers/block/null_blk/main.c | 1 -
 1 file changed, 1 deletion(-)
drivers/block/null_blk/main.c +0 -0
index 5cb4c92cdffea..a521e914a9843 100644

drivers/block/null_blk/main.c static void null_config_discard(struct nullb *nullb) · line 1770

Quoted 7 lines
drivers/block/null_blk/main.c +0 -1
@@ -1765,7 +1765,6 @@ static void null_config_discard(struct nullb *nullb)
 	}
 
 	nullb->q->limits.discard_granularity = nullb->dev->blocksize;
-	nullb->q->limits.discard_alignment = nullb->dev->blocksize;
 	blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);
 }
 
Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v1 3/11
#5 lore raw

Re: [PATCH 03/11] null_blk: don't set the discard_alignment queue limit

In reply to Christoph Hellwig
Quoted 7 lines · Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to the discard granularity as done by null_blk is mostly harmless but also useless.

---

-ck

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

author maintainer
#6 lore raw

PATCH 4/11 virtio_blk: fix the discard_granularity and discard_alignment queue limits

In reply to Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts.

On the other hand the discard_sector_alignment from the virtio 1.1 looks similar to what Linux uses as discard granularity (even if not very well described):

"discard_sector_alignment can be used by OS when splitting a request
based on alignment. "

And at least qemu does set it to the discard granularity.

So stop setting the discard_alignment and use the virtio discard_sector_alignment to set the discard granularity.

Fixes 1f23816b8eb8 ("virtio_blk: add discard and write zeroes support")
---
 drivers/block/virtio_blk.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/block/virtio_blk.c +4 -3
index 6ccf15253dee1..d624cc8eddc3c 100644
@@ -867,11 +867,12 @@ static int virtblk_probe(struct virtio_device *vdev)
 		blk_queue_io_opt(q, blk_size * opt_io_size);
 
 	if (virtio_has_feature(vdev, VIRTIO_BLK_F_DISCARD)) {
-		q->limits.discard_granularity = blk_size;
-
 		virtio_cread(vdev, struct virtio_blk_config,
 			     discard_sector_alignment, &v);
-		q->limits.discard_alignment = v ? v << SECTOR_SHIFT : 0;
+		if (v)
+			q->limits.discard_granularity = v << SECTOR_SHIFT;
+		else
+			q->limits.discard_granularity = blk_size;
 
 		virtio_cread(vdev, struct virtio_blk_config,
 			     max_discard_sectors, &v);
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
author maintainer
#7 lore raw

PATCH 5/11 dm-zoned: don't set the discard_alignment queue limit

In reply to Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to the discard granularity as done by dm-zoned is mostly harmless but also useless.

---
 drivers/md/dm-zoned-target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-zoned-target.c +1 -1
index cac295cc8840e..0ec5d8b9b1a4e 100644
@@ -1001,7 +1001,7 @@ static void dmz_io_hints(struct dm_target *ti, struct queue_limits *limits)
 	blk_limits_io_min(limits, DMZ_BLOCK_SIZE);
 	blk_limits_io_opt(limits, DMZ_BLOCK_SIZE);
 
-	limits->discard_alignment = DMZ_BLOCK_SIZE;
+	limits->discard_alignment = 0;
 	limits->discard_granularity = DMZ_BLOCK_SIZE;
 	limits->max_discard_sectors = chunk_sectors;
 	limits->max_hw_discard_sectors = chunk_sectors;
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v1 5/11
#8 lore raw

Re: [dm-devel] [PATCH 05/11] dm-zoned: don't set the discard_alignment queue limit

Quoted 15 lines · Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to the discard granularity as done by dm-zoned is mostly harmless but also useless.

---
 drivers/md/dm-zoned-target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-zoned-target.c +0 -0
index cac295cc8840e..0ec5d8b9b1a4e 100644

drivers/md/dm-zoned-target.c static void dmz_io_hints(struct dm_target *ti, struct queue_limits *limits) · line 1007

Quoted 8 lines
drivers/md/dm-zoned-target.c +1 -1
@@ -1001,7 +1001,7 @@ static void dmz_io_hints(struct dm_target *ti, struct queue_limits *limits)
 	blk_limits_io_min(limits, DMZ_BLOCK_SIZE);
 	blk_limits_io_opt(limits, DMZ_BLOCK_SIZE);
 
-	limits->discard_alignment = DMZ_BLOCK_SIZE;
+	limits->discard_alignment = 0;
 	limits->discard_granularity = DMZ_BLOCK_SIZE;
 	limits->max_discard_sectors = chunk_sectors;
 	limits->max_hw_discard_sectors = chunk_sectors
Signature · 2 lines
Damien Le Moal
Western Digital Research
author maintainer
#9 lore raw

PATCH 6/11 raid5: don't set the discard_alignment queue limit

In reply to Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to the discard granularity as done by raid5 is mostly harmless but also useless.

---
 drivers/md/raid5.c | 1 -
 1 file changed, 1 deletion(-)
drivers/md/raid5.c +0 -1
index 59f91e392a2ae..39b0afdf40d0a 100644
@@ -7749,7 +7749,6 @@ static int raid5_run(struct mddev *mddev)
 		 */
 		stripe = stripe * PAGE_SIZE;
 		stripe = roundup_pow_of_two(stripe);
-		mddev->queue->limits.discard_alignment = stripe;
 		mddev->queue->limits.discard_granularity = stripe;
 
 		blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
maintainer Acked-by on v1 6/11
#10 lore raw

Re: [PATCH 06/11] raid5: don't set the discard_alignment queue limit

Quoted 7 lines · Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to the discard granularity as done by raid5 is mostly harmless but also useless.

Quoted 17 lines
---
 drivers/md/raid5.c | 1 -
 1 file changed, 1 deletion(-)
drivers/md/raid5.c +0 -2
index 59f91e392a2ae..39b0afdf40d0a 100644
@@ -7749,7 +7749,6 @@ static int raid5_run(struct mddev *mddev)
                 */
                stripe = stripe * PAGE_SIZE;
                stripe = roundup_pow_of_two(stripe);
-               mddev->queue->limits.discard_alignment = stripe;
                mddev->queue->limits.discard_granularity = stripe;
 
                blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
--
Quoted 2 lines

2.30.2

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

author maintainer
#11 lore raw

PATCH 7/11 dasd: don't set the discard_alignment queue limit

In reply to Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to PAGE_SIZE while the discard granularity is the block size that is smaller or the same as PAGE_SIZE as done by dasd is mostly harmless but also useless.

---
 drivers/s390/block/dasd_fba.c | 1 -
 1 file changed, 1 deletion(-)
drivers/s390/block/dasd_fba.c +0 -1
index 8bd5665db9198..60be7f7bf2d16 100644
@@ -782,7 +782,6 @@ static void dasd_fba_setup_blk_queue(struct dasd_block *block)
 	blk_queue_segment_boundary(q, PAGE_SIZE - 1);
 
 	q->limits.discard_granularity = logical_block_size;
-	q->limits.discard_alignment = PAGE_SIZE;
 
 	/* Calculate max_discard_sectors and make it PAGE aligned */
 	max_bytes = USHRT_MAX * logical_block_size;
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
maintainer Acked-by on v1 7/11
#12 lore raw

Re: [PATCH 07/11] dasd: don't set the discard_alignment queue limit

Quoted 7 lines · Christoph Hellwig

The discard_alignment queue limit is named a bit misleading means the offset into the block device at which the discard granularity starts. Setting it to PAGE_SIZE while the discard granularity is the block size that is smaller or the same as PAGE_SIZE as done by dasd is mostly harmless but also useless.

Sorry for a rather late answer. I saw that Jens already applied the patches so it's fine when the Ack isn't added anymore. Wanted to send it anyway so that you know we're aware of it.

Quoted 9 lines
---
 drivers/s390/block/dasd_fba.c | 1 -
 1 file changed, 1 deletion(-)
drivers/s390/block/dasd_fba.c +0 -0
index 8bd5665db9198..60be7f7bf2d16 100644

drivers/s390/block/dasd_fba.c static void dasd_fba_setup_blk_queue(struct dasd_block *block) · line 787

Quoted 7 lines
drivers/s390/block/dasd_fba.c +0 -1
@@ -782,7 +782,6 @@ static void dasd_fba_setup_blk_queue(struct dasd_block *block)
 	blk_queue_segment_boundary(q, PAGE_SIZE - 1);
 
 	q->limits.discard_granularity = logical_block_size;
-	q->limits.discard_alignment = PAGE_SIZE;
 
 	/* Calculate max_discard_sectors and make it PAGE aligned */
 	max_bytes = USHRT_MAX * logical_block_size;

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

author maintainer
#13 lore raw

PATCH 8/11 loop: remove a spurious clear of discard_alignment

In reply to Christoph Hellwig

The loop driver never sets a discard_alignment, so it also doens't need to clear it to zero.

---
 drivers/block/loop.c | 1 -
 1 file changed, 1 deletion(-)
drivers/block/loop.c +0 -1
index 976cf987b3920..61b642b966a08 100644
@@ -789,7 +789,6 @@ static void loop_config_discard(struct loop_device *lo)
 		blk_queue_max_discard_sectors(q, 0);
 		blk_queue_max_write_zeroes_sectors(q, 0);
 	}
-	q->limits.discard_alignment = 0;
 }
 
 struct loop_worker {
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v1 8/11
#14 lore raw

Re: [dm-devel] [PATCH 08/11] loop: remove a spurious clear of discard_alignment

Quoted 13 lines · Christoph Hellwig

The loop driver never sets a discard_alignment, so it also doens't need to clear it to zero.

---
 drivers/block/loop.c | 1 -
 1 file changed, 1 deletion(-)
drivers/block/loop.c +0 -0
index 976cf987b3920..61b642b966a08 100644

drivers/block/loop.c static void loop_config_discard(struct loop_device *lo) · line 794

Quoted 7 lines
drivers/block/loop.c +0 -1
@@ -789,7 +789,6 @@ static void loop_config_discard(struct loop_device *lo)
 		blk_queue_max_discard_sectors(q, 0);
 		blk_queue_max_write_zeroes_sectors(q, 0);
 	}
-	q->limits.discard_alignment = 0;
 }
 
 struct loop_worker {
Signature · 7 lines
Damien Le Moal
Western Digital Research

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v1 8/11
#15 lore raw

Re: [PATCH 08/11] loop: remove a spurious clear of discard_alignment

In reply to Christoph Hellwig
Quoted 1 line · Christoph Hellwig

The loop driver never sets a discard_alignment, so it also doens't need

s/doens't/doesn't/

Quoted 3 lines

to clear it to zero.

-ck

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

author maintainer
#16 lore raw

PATCH 9/11 nvme: remove a spurious clear of discard_alignment

In reply to Christoph Hellwig

The nvme driver never sets a discard_alignment, so it also doens't need to clear it to zero.

---
 drivers/nvme/host/core.c | 1 -
 1 file changed, 1 deletion(-)
drivers/nvme/host/core.c +0 -1
index b9b0fbde97c80..76a9ccd5d064a 100644
@@ -1628,7 +1628,6 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
 	BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) <
 			NVME_DSM_MAX_RANGES);
 
-	queue->limits.discard_alignment = 0;
 	queue->limits.discard_granularity = size;
 
 	/* If discard is already enabled, don't reset queue limits */
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v1 9/11
#17 lore raw

Re: [dm-devel] [PATCH 09/11] nvme: remove a spurious clear of discard_alignment

Quoted 13 lines · Christoph Hellwig

The nvme driver never sets a discard_alignment, so it also doens't need to clear it to zero.

---
 drivers/nvme/host/core.c | 1 -
 1 file changed, 1 deletion(-)
drivers/nvme/host/core.c +0 -0
index b9b0fbde97c80..76a9ccd5d064a 100644

drivers/nvme/host/core.c static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns) · line 1633

Quoted 7 lines
drivers/nvme/host/core.c +0 -1
@@ -1628,7 +1628,6 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
 	BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) <
 			NVME_DSM_MAX_RANGES);
 
-	queue->limits.discard_alignment = 0;
 	queue->limits.discard_granularity = size;
 
 	/* If discard is already enabled, don't reset queue limits */
Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v1 9/11
#18 lore raw

Re: [PATCH 09/11] nvme: remove a spurious clear of discard_alignment

In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig

The nvme driver never sets a discard_alignment, so it also doens't need to clear it to zero.

---

-ck

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

author maintainer
#20 lore raw

PATCH 10/11 rnbd-srv: use bdev_discard_alignment

In reply to Christoph Hellwig

Use bdev_discard_alignment to calculate the correct discard alignment offset even for partitions instead of just looking at the queue limit.

---
 drivers/block/rnbd/rnbd-srv-dev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rnbd/rnbd-srv-dev.h +1 -1
index d080a0de59225..4309e52524691 100644
@@ -59,7 +59,7 @@ static inline int rnbd_dev_get_discard_granularity(const struct rnbd_dev *dev)
 
 static inline int rnbd_dev_get_discard_alignment(const struct rnbd_dev *dev)
 {
-	return bdev_get_queue(dev->bdev)->limits.discard_alignment;
+	return bdev_discard_alignment(dev->bdev);
 }
 
 #endif /* RNBD_SRV_DEV_H */
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v1 10/11
#21 lore raw

Re: [dm-devel] [PATCH 10/11] rnbd-srv: use bdev_discard_alignment

Quoted 13 lines · Christoph Hellwig

Use bdev_discard_alignment to calculate the correct discard alignment offset even for partitions instead of just looking at the queue limit.

---
 drivers/block/rnbd/rnbd-srv-dev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rnbd/rnbd-srv-dev.h +0 -0
index d080a0de59225..4309e52524691 100644

drivers/block/rnbd/rnbd-srv-dev.h static inline int rnbd_dev_get_discard_granularity(const struct rnbd_dev *dev) · line 65

Quoted 8 lines
drivers/block/rnbd/rnbd-srv-dev.h +1 -1
@@ -59,7 +59,7 @@ static inline int rnbd_dev_get_discard_granularity(const struct rnbd_dev *dev)
 
 static inline int rnbd_dev_get_discard_alignment(const struct rnbd_dev *dev)
 {
-	return bdev_get_queue(dev->bdev)->limits.discard_alignment;
+	return bdev_discard_alignment(dev->bdev);
 }
 
 #endif /* RNBD_SRV_DEV_H */
Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer Acked-by on v1 10/11
#22 lore raw

Re: [PATCH 10/11] rnbd-srv: use bdev_discard_alignment

In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig

Use bdev_discard_alignment to calculate the correct discard alignment offset even for partitions instead of just looking at the queue limit.

Thx!

Quoted 18 lines
---
 drivers/block/rnbd/rnbd-srv-dev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rnbd/rnbd-srv-dev.h +1 -2
index d080a0de59225..4309e52524691 100644
@@ -59,7 +59,7 @@ static inline int rnbd_dev_get_discard_granularity(const struct rnbd_dev *dev)
 
 static inline int rnbd_dev_get_discard_alignment(const struct rnbd_dev *dev)
 {
-       return bdev_get_queue(dev->bdev)->limits.discard_alignment;
+       return bdev_discard_alignment(dev->bdev);
 }
 
 #endif /* RNBD_SRV_DEV_H */
--
Quoted 2 lines

2.30.2

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

author maintainer
#23 lore raw

PATCH 11/11 xen-blkback: use bdev_discard_alignment

In reply to Christoph Hellwig

Use bdev_discard_alignment to calculate the correct discard alignment offset even for partitions instead of just looking at the queue limit.

Also switch to use bdev_discard_granularity to get rid of the last direct queue reference in xen_blkbk_discard.

---
 drivers/block/xen-blkback/xenbus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xen-blkback/xenbus.c +2 -2
index b21bffc9c50bc..04c90cb8955f6 100644
@@ -583,14 +583,14 @@ static void xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info
 	if (bdev_max_discard_sectors(bdev)) {
 		err = xenbus_printf(xbt, dev->nodename,
 			"discard-granularity", "%u",
-			q->limits.discard_granularity);
+			bdev_discard_granularity(bdev));
 		if (err) {
 			dev_warn(&dev->dev, "writing discard-granularity (%d)", err);
 			return;
 		}
 		err = xenbus_printf(xbt, dev->nodename,
 			"discard-alignment", "%u",
-			q->limits.discard_alignment);
+			bdev_discard_alignment(bdev));
 		if (err) {
 			dev_warn(&dev->dev, "writing discard-alignment (%d)", err);
 			return;
Signature · 7 lines
2.30.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v1 11/11
#24 lore raw

Re: [dm-devel] [PATCH 11/11] xen-blkback: use bdev_discard_alignment

Quoted 22 lines · Christoph Hellwig

Use bdev_discard_alignment to calculate the correct discard alignment offset even for partitions instead of just looking at the queue limit.

Also switch to use bdev_discard_granularity to get rid of the last direct queue reference in xen_blkbk_discard.

---
 drivers/block/xen-blkback/xenbus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xen-blkback/xenbus.c +1 -1
index b21bffc9c50bc..04c90cb8955f6 100644
@@ -583,14 +583,14 @@ static void xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info
 	if (bdev_max_discard_sectors(bdev)) {
 		err = xenbus_printf(xbt, dev->nodename,
 			"discard-granularity", "%u",
-			q->limits.discard_granularity);
+			bdev_discard_granularity(bdev));
 		if (err) {

drivers/block/xen-blkback/xenbus.c static void xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info · line 596

Quoted 10 lines
drivers/block/xen-blkback/xenbus.c +1 -1
 			dev_warn(&dev->dev, "writing discard-granularity (%d)", err);
 			return;
 		}
 		err = xenbus_printf(xbt, dev->nodename,
 			"discard-alignment", "%u",
-			q->limits.discard_alignment);
+			bdev_discard_alignment(bdev));
 		if (err) {
 			dev_warn(&dev->dev, "writing discard-alignment (%d)", err);
 			return;
Signature · 7 lines
Damien Le Moal
Western Digital Research

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by
#25 lore raw
In reply to Christoph Hellwig

Christoph,

Quoted 4 lines

the somewhat confusing name of the discard_alignment queue limit, that really is an offset for the discard granularity mislead a lot of driver authors to set it to an incorrect value. This series tries to fix up all these cases.

Not sure how I ended up with "discard_alignment" when I called the corresponding I/O parameter "alignment_offset".

Anyway. All this looks good to me.

Signature · 6 lines
Martin K. Petersen	Oracle Linux Engineering

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
maintainer Applied
#27 lore raw
In reply to Christoph Hellwig
Quoted 19 lines · Christoph Hellwig

the somewhat confusing name of the discard_alignment queue limit, that really is an offset for the discard granularity mislead a lot of driver authors to set it to an incorrect value. This series tries to fix up all these cases.

Diffstat:

 arch/um/drivers/ubd_kern.c         |    1 -
 drivers/block/loop.c               |    1 -
 drivers/block/nbd.c                |    3 ---
 drivers/block/null_blk/main.c      |    1 -
 drivers/block/rnbd/rnbd-srv-dev.h  |    2 +-
 drivers/block/virtio_blk.c         |    7 ++++---
 drivers/block/xen-blkback/xenbus.c |    4 ++--
 drivers/md/dm-zoned-target.c       |    2 +-
 drivers/md/raid5.c                 |    1 -
 drivers/nvme/host/core.c           |    1 -
 drivers/s390/block/dasd_fba.c      |    1 -
 11 files changed, 8 insertions(+), 16 deletions(-)
Quoted 1 line

[...]

Applied, thanks!

[01/11] ubd: don't set the discard_alignment queue limit

        commit: 07c6e92a8478770a7302f7dde72f03a5465901bd
[02/11] nbd: don't set the discard_alignment queue limit
        commit: 4a04d517c56e0616c6f69afc226ee2691e543712
[03/11] null_blk: don't set the discard_alignment queue limit
        commit: fb749a87f4536d2fa86ea135ae4eff1072903438
[04/11] virtio_blk: fix the discard_granularity and discard_alignment queue limits
        commit: 62952cc5bccd89b76d710de1d0b43244af0f2903
[05/11] dm-zoned: don't set the discard_alignment queue limit
        commit: 44d583702f4429763c558624fac763650a1f05bf
[06/11] raid5: don't set the discard_alignment queue limit
        commit: 3d50d368c92ade2f98a3d0d28b842a57c35284e9
[07/11] dasd: don't set the discard_alignment queue limit
        commit: c3f765299632727fa5ea5a0acf118665227a4f1a
[08/11] loop: remove a spurious clear of discard_alignment
        commit: 4418bfd8fb9602d9cd8747c3ad52fdbaa02e2ffd
[09/11] nvme: remove a spurious clear of discard_alignment
        commit: 4e7f0ece41e1be8f876f320a0972a715daec0a50
[10/11] rnbd-srv: use bdev_discard_alignment
        commit: 18292faa89d2bff3bdd33ab9c065f45fb6710e47
[11/11] xen-blkback: use bdev_discard_alignment
        commit: c899b23533866910c90ef4386b501af50270d320

Best regards,

Signature · 1 line
Jens Axboe