Stefan Hajnoczi
2022-Aug-23 19:46 UTC
[PATCH] virtio_blk: add SECURE ERASE command support
On Mon, Aug 22, 2022 at 07:20:55PM +0300, Alvaro Karsz wrote:> @@ -1075,6 +1079,12 @@ static int virtblk_probe(struct virtio_device *vdev) > blk_queue_max_write_zeroes_sectors(q, v ? v : UINT_MAX); > } > > + if (virtio_has_feature(vdev, VIRTIO_BLK_F_SECURE_ERASE)) { > + virtio_cread(vdev, struct virtio_blk_config, > + max_secure_erase_sectors, &v); > + blk_queue_max_secure_erase_sectors(q, v ? v : UINT_MAX); > + }What about max_secure_erase_seg and secure_erase_sector_alignment? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20220823/736065c1/attachment.sig>
> What about max_secure_erase_seg and secure_erase_sector_alignment?Hi Stefan, If I understand correctly, the Linux kernel uses the same "max segments" value for a discard and a secure erase command.> unsigned int blk_recalc_rq_segments(struct request *rq) > { > unsigned int nr_phys_segs = 0; > unsigned int bytes = 0; > struct req_iterator iter; > struct bio_vec bv; > > > if (!rq->bio) > return 0; > > > switch (bio_op(rq->bio)) { > case REQ_OP_DISCARD: > case REQ_OP_SECURE_ERASE: > if (queue_max_discard_segments(rq->q) > 1) { > struct bio *bio = rq->bio; > > > for_each_bio(bio) > nr_phys_segs++; > return nr_phys_segs; > } > > ....> struct bio *__bio_split_to_limits(struct bio *bio, struct queue_limits *lim, > unsigned int *nr_segs) > { > struct bio_set *bs = &bio->bi_bdev->bd_disk->bio_split; > struct bio *split; > > > switch (bio_op(bio)) { > case REQ_OP_DISCARD: > case REQ_OP_SECURE_ERASE: > split = bio_split_discard(bio, lim, nr_segs, bs); > > break; > > ...What do you suggest? BTW, the same happens for the write zeros command implementation. max_write_zeroes_seg and write_zeroes_may_unmap are ignored in the Linux kernel.