public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio-blk: Assign discard_granularity
@ 2022-02-24  9:38 Akihiko Odaki
  2022-02-28 10:51 ` Stefan Hajnoczi
  0 siblings, 1 reply; 5+ messages in thread
From: Akihiko Odaki @ 2022-02-24  9:38 UTC (permalink / raw)
  Cc: linux-kernel, linux-block, virtualization, Jens Axboe,
	Stefan Hajnoczi, Paolo Bonzini, Akihiko Odaki

Virtual I/O Device (VIRTIO) Version 1.1
https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html
> discard_sector_alignment can be used by OS when splitting a request
> based on alignment.

According to Documentation/ABI/stable/sysfs-block, the corresponding
field in the kernel is, confusingly, discard_granularity, not
discard_alignment.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
 drivers/block/virtio_blk.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index c443cd64fc9b..1fb3c89900e3 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -913,11 +913,9 @@ 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;
+		q->limits.discard_granularity = v ? v << SECTOR_SHIFT : 0;
 
 		virtio_cread(vdev, struct virtio_blk_config,
 			     max_discard_sectors, &v);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-01 16:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-24  9:38 [PATCH] virtio-blk: Assign discard_granularity Akihiko Odaki
2022-02-28 10:51 ` Stefan Hajnoczi
2022-03-01  5:43   ` Akihiko Odaki
2022-03-01  9:06     ` Stefan Hajnoczi
2022-03-01 16:30     ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox