diff mbox series

[01/13] mm/filemap: change filemap_create_folio() to take a struct kiocb

Message ID 20241108174505.1214230-2-axboe@kernel.dk (mailing list archive)
State New
Headers show
Series [01/13] mm/filemap: change filemap_create_folio() to take a struct kiocb | expand

Commit Message

Jens Axboe Nov. 8, 2024, 5:43 p.m. UTC
Rather than pass in both the file and position directly from the kiocb,
just take a struct kiocb instead. In preparation for actually needing
the kiocb in the function.

No functional changes in this patch.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 mm/filemap.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Matthew Wilcox Nov. 8, 2024, 6:18 p.m. UTC | #1
On Fri, Nov 08, 2024 at 10:43:24AM -0700, Jens Axboe wrote:
> Rather than pass in both the file and position directly from the kiocb,
> just take a struct kiocb instead. In preparation for actually needing
> the kiocb in the function.

If you're undoing this part of f253e1854ce8, it's probably worth moving
the IOCB flag checks back to where they were too.
Jens Axboe Nov. 8, 2024, 7:22 p.m. UTC | #2
On 11/8/24 11:18 AM, Matthew Wilcox wrote:
> On Fri, Nov 08, 2024 at 10:43:24AM -0700, Jens Axboe wrote:
>> Rather than pass in both the file and position directly from the kiocb,
>> just take a struct kiocb instead. In preparation for actually needing
>> the kiocb in the function.
> 
> If you're undoing this part of f253e1854ce8, it's probably worth moving
> the IOCB flag checks back to where they were too.

Ah wasn't aware of that one, didn't do any git history digging. Sure,
I can move the flags checking too.
diff mbox series

Patch

diff --git a/mm/filemap.c b/mm/filemap.c
index 36d22968be9a..2ae26a0f961b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2460,9 +2460,8 @@  static int filemap_update_page(struct kiocb *iocb,
 	return error;
 }
 
-static int filemap_create_folio(struct file *file,
-		struct address_space *mapping, loff_t pos,
-		struct folio_batch *fbatch)
+static int filemap_create_folio(struct kiocb *iocb,
+		struct address_space *mapping, struct folio_batch *fbatch)
 {
 	struct folio *folio;
 	int error;
@@ -2487,7 +2486,7 @@  static int filemap_create_folio(struct file *file,
 	 * well to keep locking rules simple.
 	 */
 	filemap_invalidate_lock_shared(mapping);
-	index = (pos >> (PAGE_SHIFT + min_order)) << min_order;
+	index = (iocb->ki_pos >> (PAGE_SHIFT + min_order)) << min_order;
 	error = filemap_add_folio(mapping, folio, index,
 			mapping_gfp_constraint(mapping, GFP_KERNEL));
 	if (error == -EEXIST)
@@ -2495,7 +2494,8 @@  static int filemap_create_folio(struct file *file,
 	if (error)
 		goto error;
 
-	error = filemap_read_folio(file, mapping->a_ops->read_folio, folio);
+	error = filemap_read_folio(iocb->ki_filp, mapping->a_ops->read_folio,
+					folio);
 	if (error)
 		goto error;
 
@@ -2553,7 +2553,7 @@  static int filemap_get_pages(struct kiocb *iocb, size_t count,
 	if (!folio_batch_count(fbatch)) {
 		if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ))
 			return -EAGAIN;
-		err = filemap_create_folio(filp, mapping, iocb->ki_pos, fbatch);
+		err = filemap_create_folio(iocb, mapping, fbatch);
 		if (err == AOP_TRUNCATED_PAGE)
 			goto retry;
 		return err;