[dm-devel] [PATCH v3 19/19] block: mark bio_add_page as __must_check

Johannes Thumshirn jth at kernel.org
Wed Apr 19 15:49:28 UTC 2023


On 19/04/2023 16:19, Matthew Wilcox wrote:
> On Wed, Apr 19, 2023 at 04:09:29PM +0200, Johannes Thumshirn wrote:
>> Now that all users of bio_add_page check for the return value, mark
>> bio_add_page as __must_check.
> 
> Should probably add __must_check to bio_add_folio too?  If this is
> really the way you want to go ... means we also need a
> __bio_add_folio().

I admit I haven't thought of folios, mea culpa.

3 of the callers of bio_add_folio() don't check the return value:
$ git grep -E '\sbio_add_folio\b'
fs/iomap/buffered-io.c:         bio_add_folio(ctx->bio, folio, plen, poff);
fs/iomap/buffered-io.c: bio_add_folio(&bio, folio, plen, poff);
fs/iomap/buffered-io.c:         bio_add_folio(wpc->ioend->io_bio, folio, 
len, poff);

But from a quick look they look OK to me.

Does that look reasonable to you:

diff --git a/block/bio.c b/block/bio.c
index fd11614bba4d..f3a3524b53e4 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1138,6 +1138,14 @@ int bio_add_page(struct bio *bio, struct page *page,
  }
  EXPORT_SYMBOL(bio_add_page);

+void __bio_add_folio(struct bio *bio, struct folio *folio, size_t len,
+                    size_t off)
+{
+       WARN_ON_ONCE(len > UINT_MAX);
+       WARN_ON_ONCE(off > UINT_MAX);
+       __bio_add_page(bio, &folio->page, len, off);
+}
+
  /**
   * bio_add_folio - Attempt to add part of a folio to a bio.
   * @bio: BIO to add to.


Byte,
	Johannes



More information about the dm-devel mailing list