Linux block layer
 help / color / mirror / Atom feed
From: Kundan Kumar <kundan.kumar@samsung.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: Re: [PATCH 2/2] block: share more code for bio addition helpers
Date: Thu, 7 Nov 2024 14:40:43 +0530	[thread overview]
Message-ID: <20241107091043.dblanxy65gojsooh@green245> (raw)
In-Reply-To: <20241107072053.GA4112@lst.de>

[-- Attachment #1: Type: text/plain, Size: 1343 bytes --]

On 07/11/24 08:20AM, Christoph Hellwig wrote:
>On Wed, Nov 06, 2024 at 03:33:38PM +0530, Kundan Kumar wrote:
>>> -int bio_add_page(struct bio *bio, struct page *page,
>>> -		 unsigned int len, unsigned int offset)
>>> +static int bio_do_add_page(struct bio *bio, struct page *page,
>>> +		 unsigned int len, unsigned int offset, bool *same_page)
>>
>> As we are passing length within a folio, values will reach near UINT_MAX.
>> It will be better to make len and offset as size_t, also to add a check like :
>> if (len > UINT_MAX || offset > UINT_MAX)
>> 		return 0;
>
>Not sure what the point is.  IFF we get folio sizes overflowing an
>unsigned int we'll have a massive problem as it will overflow the
>bv_offset and bv_len fields.  So we'd need to address that first before
>doing anything else.

In my opinion, there isn't a current use case where it overflows, but
its better to include a check for the future. WARN_ON is also an option
as used in bio_add_folio_nofail()

>
>>> {
>>> -	bool same_page = false;
>>
>> nit: extra line got added
>
>Yes, the previous code was missing the empty line after the variable
>declaration, so this got fixed.
>

Actually the extra line got introduced at the beginning of function
definition of bio_do_add_page().

Otherwise the code looks good. 

Reviewed-by: Kundan Kumar <kundan.kumar@samsung.com>

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



      reply	other threads:[~2024-11-08  3:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-05 15:52 bio_add_* cleanups Christoph Hellwig
2024-11-05 15:52 ` [PATCH 1/2] block: remove bio_add_hw_folio Christoph Hellwig
2024-11-06  9:54   ` Kundan Kumar
2024-11-05 15:52 ` [PATCH 2/2] block: share more code for bio addition helpers Christoph Hellwig
2024-11-06 10:03   ` Kundan Kumar
2024-11-07  7:20     ` Christoph Hellwig
2024-11-07  9:10       ` Kundan Kumar [this message]

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=20241107091043.dblanxy65gojsooh@green245 \
    --to=kundan.kumar@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.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