From: Christoph Hellwig <hch@infradead.org>
To: Steve Siwinski <stevensiwinski@gmail.com>
Cc: James.Bottomley@hansenpartnership.com,
martin.petersen@oracle.com, linux-kernel@vger.kernel.org,
linux-scsi@vger.kernel.org, bgrove@atto.com,
Steve Siwinski <ssiwinski@atto.com>,
Damien Le Moal <dlemoal@kernel.org>
Subject: Re: [PATCH] scsi: sd_zbc: Limit the report zones buffer size to UIO_MAXIOV
Date: Sun, 13 Apr 2025 22:52:31 -0700 [thread overview]
Message-ID: <Z_yinytV0e_BbNrF@infradead.org> (raw)
In-Reply-To: <20250411203600.84477-1-ssiwinski@atto.com>
On Fri, Apr 11, 2025 at 04:36:00PM -0400, Steve Siwinski wrote:
> The report zones buffer size is currently limited by the HBA's
> maximum segment count to ensure the buffer can be mapped. However,
> the user-space SG_IO interface further limits the number of iovec
> entries to UIO_MAXIOV when allocating a bio.
Why does the userspace SG_IO interface matter here?
sd_zbc_alloc_report_buffer is only used for the in-kernel
->report_zones call.
>
> To avoid allocation of buffers too large to be mapped, further
> restrict the maximum buffer size to UIO_MAXIOV * PAGE_SIZE.
>
> This ensures that the buffer size complies with both kernel
> and user-space constraints.
>
> Signed-off-by: Steve Siwinski <ssiwinski@atto.com>
> ---
> drivers/scsi/sd_zbc.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 7a447ff600d2..a19e76ec8fb6 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -180,12 +180,15 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp,
> * Furthermore, since the report zone command cannot be split, make
> * sure that the allocated buffer can always be mapped by limiting the
> * number of pages allocated to the HBA max segments limit.
> + * Since max segments can be larger than the max sgio entries, further
> + * limit the allocated buffer to the UIO_MAXIOV.
> */
> nr_zones = min(nr_zones, sdkp->zone_info.nr_zones);
> bufsize = roundup((nr_zones + 1) * 64, SECTOR_SIZE);
> bufsize = min_t(size_t, bufsize,
> queue_max_hw_sectors(q) << SECTOR_SHIFT);
> bufsize = min_t(size_t, bufsize, queue_max_segments(q) << PAGE_SHIFT);
> + bufsize = min_t(size_t, bufsize, UIO_MAXIOV * PAGE_SIZE);
>
> while (bufsize >= SECTOR_SIZE) {
> buf = kvzalloc(bufsize, GFP_KERNEL | __GFP_NORETRY);
> --
> 2.43.5
>
>
---end quoted text---
next prev parent reply other threads:[~2025-04-14 5:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 20:36 [PATCH] scsi: sd_zbc: Limit the report zones buffer size to UIO_MAXIOV Steve Siwinski
2025-04-14 5:52 ` Christoph Hellwig [this message]
[not found] ` <OFA5AB0241.ED5C089D-ON85258C70.0068BDE0-85258C70.00721A7A@atto.com>
2025-04-18 21:29 ` Damien Le Moal
2025-04-24 15:33 ` Siwinski, Steve
2025-04-25 1:42 ` Damien Le Moal
2025-04-30 14:06 ` Christoph Hellwig
2025-05-02 19:35 ` [PATCH v2] block, scsi: sd_zbc: Respect bio vector limits for report zones buffer Steve Siwinski
2025-05-06 2:29 ` Damien Le Moal
2025-05-08 20:01 ` [PATCH v3] " Steve Siwinski
2025-05-08 23:08 ` Damien Le Moal
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=Z_yinytV0e_BbNrF@infradead.org \
--to=hch@infradead.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=bgrove@atto.com \
--cc=dlemoal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ssiwinski@atto.com \
--cc=stevensiwinski@gmail.com \
/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