From: Stefan Hajnoczi <stefanha@redhat.com>
To: Alvaro Karsz <alvaro.karsz@solid-run.com>
Cc: Jens Axboe <axboe@kernel.dk>, Paolo Bonzini <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v2] virtio_blk: add SECURE ERASE command support
Date: Mon, 19 Sep 2022 13:33:39 -0400 [thread overview]
Message-ID: <Yyin8zSKJb3GPFno@fedora> (raw)
In-Reply-To: <20220829082313.419220-1-alvaro.karsz@solid-run.com>
[-- Attachment #1.1: Type: text/plain, Size: 1753 bytes --]
On Mon, Aug 29, 2022 at 11:23:13AM +0300, Alvaro Karsz wrote:
> @@ -1075,6 +1068,57 @@ 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)) {
> + /* The discard alignment value should be the minimum between
> + * secure_erase_sector_alignment and discard_sector_alignment
> + * (if VIRTIO_BLK_F_DISCARD is negotiated).
> + */
> + virtio_cread(vdev, struct virtio_blk_config,
> + secure_erase_sector_alignment, &v);
> + if (v) {
> + if (discard_granularity)
> + discard_granularity = min(discard_granularity, v);
> + else
> + discard_granularity = v;
This can be simplified with min_not_zero().
> + }
> +
> + virtio_cread(vdev, struct virtio_blk_config,
> + max_secure_erase_sectors, &v);
> + blk_queue_max_secure_erase_sectors(q, v ? v : UINT_MAX);
> +
> + /* The max discard segments value should be the minimum between
> + * max_secure_erase_seg and max_discard_seg (if VIRTIO_BLK_F_DISCARD
> + * is negotiated).
> + */
> + virtio_cread(vdev, struct virtio_blk_config,
> + max_secure_erase_seg, &v);
> + if (v) {
> + if (max_discard_segs)
> + max_discard_segs = min(max_discard_segs, v);
> + else
> + max_discard_segs = v;
Same here.
> + }
> + }
> +
> + if (virtio_has_feature(vdev, VIRTIO_BLK_F_DISCARD) ||
> + virtio_has_feature(vdev, VIRTIO_BLK_F_SECURE_ERASE)) {
It's worth including a comment here that the discard and secure erase
limits are combined because the Linux block layer only has one limit
value. If the block layer supported independent limit values we wouldn't
need to do this.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2022-09-19 17:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 8:23 [PATCH v2] virtio_blk: add SECURE ERASE command support Alvaro Karsz
2022-09-01 7:44 ` Alvaro Karsz
2022-09-09 8:33 ` Alvaro Karsz
2022-09-18 13:30 ` Michael S. Tsirkin
2022-09-18 14:01 ` Alvaro Karsz
2022-09-18 15:13 ` Michael S. Tsirkin
2022-09-18 16:07 ` Alvaro Karsz
2022-09-20 18:10 ` Stefan Hajnoczi
2022-09-22 17:00 ` Michael S. Tsirkin
2022-09-19 17:33 ` Stefan Hajnoczi [this message]
2022-09-19 18:09 ` Alvaro Karsz
2022-09-20 18:11 ` Stefan Hajnoczi
2022-09-21 6:51 ` Alvaro Karsz
2022-09-22 16:58 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yyin8zSKJb3GPFno@fedora \
--to=stefanha@redhat.com \
--cc=alvaro.karsz@solid-run.com \
--cc=axboe@kernel.dk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).