]> git.hungrycats.org Git - linux/commitdiff
btrfs: use u64 for the page indices in heuristic_collect_sample()
authorTal Zussman <tz2294@columbia.edu>
Wed, 9 Sep 2026 17:10:48 +0000 (13:10 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Sep 2026 11:23:38 +0000 (13:23 +0200)
index and index_end are derived from the u64 start and end offsets, and
index is shifted back into a byte offset for offset_in_folio(), which
needs a cast to u64 to be safe on 32-bit. Make them u64 instead so the
cast goes away. They still fit pgoff_t where they are passed to
filemap_get_folio(), as they came from a valid file offset.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c

index 20169d0289619191a5e1013a2181c1fbc318a4bf..228d1cdd7c2950231b6cfe479ca098ce5b12b248 100644 (file)
@@ -1489,7 +1489,7 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
                                     struct heuristic_ws *ws)
 {
        struct folio *folio;
-       pgoff_t index, index_end;
+       u64 index, index_end;
        u32 i, curr_sample_pos;
        u8 *in_data;
 
@@ -1517,7 +1517,7 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
                folio = filemap_get_folio(inode->i_mapping, index);
                ASSERT(!IS_ERR(folio));
                in_data = kmap_local_folio(folio,
-                               offset_in_folio(folio, (u64)index << PAGE_SHIFT));
+                               offset_in_folio(folio, index << PAGE_SHIFT));
                /* Handle case where the start is not aligned to PAGE_SIZE */
                i = start % PAGE_SIZE;
                while (i < PAGE_SIZE - SAMPLING_READ_SIZE) {