> 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.
Stefan Hajnoczi
2022-Aug-24 18:37 UTC
[PATCH] virtio_blk: add SECURE ERASE command support
On Wed, Aug 24, 2022 at 09:45:57AM +0300, Alvaro Karsz wrote:> > 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.How about calculating the minimum of the limits? Stefan -------------- 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/20220824/597b0bf4/attachment.sig>