]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
block: Added folio-ized version of bio_add_hw_page()
authorKundan Kumar <kundan.kumar@samsung.com>
Wed, 11 Sep 2024 06:49:32 +0000 (12:19 +0530)
committerJens Axboe <axboe@kernel.dk>
Wed, 11 Sep 2024 13:24:00 +0000 (07:24 -0600)
Added new bio_add_hw_folio() function as a wrapper around
bio_add_hw_page(). This is a prep patch.

Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Tested-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20240911064935.5630-2-kundan.kumar@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c
block/blk.h

index c4053d49679a9a3e3fcdf7febfc03cb991f8c6a3..f9d759315f4d5834b530cbc0a72b74449a8f7fc9 100644 (file)
@@ -1016,6 +1016,29 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,
        return len;
 }
 
+/**
+ * bio_add_hw_folio - attempt to add a folio to a bio with hw constraints
+ * @q: the target queue
+ * @bio: destination bio
+ * @folio: folio to add
+ * @len: vec entry length
+ * @offset: vec entry offset in the folio
+ * @max_sectors: maximum number of sectors that can be added
+ * @same_page: return if the segment has been merged inside the same folio
+ *
+ * Add a folio to a bio while respecting the hardware max_sectors, max_segment
+ * and gap limitations.
+ */
+int bio_add_hw_folio(struct request_queue *q, struct bio *bio,
+               struct folio *folio, size_t len, size_t offset,
+               unsigned int max_sectors, bool *same_page)
+{
+       if (len > UINT_MAX || offset > UINT_MAX)
+               return 0;
+       return bio_add_hw_page(q, bio, folio_page(folio, 0), len, offset,
+                              max_sectors, same_page);
+}
+
 /**
  * bio_add_pc_page     - attempt to add page to passthrough bio
  * @q: the target queue
index 32f4e9f630a3accae53b8622d6d2d71292406c80..86affb583eb621bb499942d2e238f0b6295284ae 100644 (file)
@@ -574,6 +574,10 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,
                struct page *page, unsigned int len, unsigned int offset,
                unsigned int max_sectors, bool *same_page);
 
+int bio_add_hw_folio(struct request_queue *q, struct bio *bio,
+               struct folio *folio, size_t len, size_t offset,
+               unsigned int max_sectors, bool *same_page);
+
 /*
  * Clean up a page appropriately, where the page may be pinned, may have a
  * ref taken on it or neither.