]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
filemap: Add folio_next_pos()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 24 Oct 2025 17:08:09 +0000 (18:08 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 31 Oct 2025 12:11:37 +0000 (13:11 +0100)
Replace the open-coded implementation in ocfs2 (which loses the top
32 bits on 32-bit architectures) with a helper in pagemap.h.

Fixes: 35edec1d52c0 (ocfs2: update truncate handling of partial clusters)
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://patch.msgid.link/20251024170822.1427218-2-willy@infradead.org
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: ocfs2-devel@lists.linux.dev
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/ocfs2/alloc.c
include/linux/pagemap.h

index 162711cc5b201f2a361dd08933464915c37ecbb8..b267ec580da995e23b1d3876d8a4a45b18a5d7f5 100644 (file)
@@ -6892,7 +6892,7 @@ static void ocfs2_zero_cluster_folios(struct inode *inode, loff_t start,
                ocfs2_map_and_dirty_folio(inode, handle, from, to, folio, 1,
                                &phys);
 
-               start = folio_next_index(folio) << PAGE_SHIFT;
+               start = folio_next_pos(folio);
        }
 out:
        if (folios)
index 09b581c1d878d3b59aa7018ca0c3e82b3c774f7c..e16576e3763a18e147d21211a6c77f28f6c5fbd4 100644 (file)
@@ -941,6 +941,17 @@ static inline pgoff_t folio_next_index(const struct folio *folio)
        return folio->index + folio_nr_pages(folio);
 }
 
+/**
+ * folio_next_pos - Get the file position of the next folio.
+ * @folio: The current folio.
+ *
+ * Return: The position of the folio which follows this folio in the file.
+ */
+static inline loff_t folio_next_pos(const struct folio *folio)
+{
+       return (loff_t)folio_next_index(folio) << PAGE_SHIFT;
+}
+
 /**
  * folio_file_page - The page for a particular index.
  * @folio: The folio which contains this index.