Skip to content

Commit 8849377

Browse files
Li Zetaokdave
authored andcommitted
btrfs: convert read_key_bytes() to take a folio
The old page API is being gradually replaced and converted to use folio to improve code readability and avoid repeated conversion between page and folio. Moreover, use kmap_local_folio() instead of kmap_local_page(), which is more consistent with folio usage. Signed-off-by: Li Zetao <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b8ae2bf commit 8849377

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fs/btrfs/verity.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static int write_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset,
284284
* page and ignore dest, but it must still be non-NULL to avoid the
285285
* counting-only behavior.
286286
* @len: length in bytes to read
287-
* @dest_page: copy into this page instead of the dest buffer
287+
* @dest_folio: copy into this folio instead of the dest buffer
288288
*
289289
* Helper function to read items from the btree. This returns the number of
290290
* bytes read or < 0 for errors. We can return short reads if the items don't
@@ -294,7 +294,7 @@ static int write_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset,
294294
* Returns number of bytes read or a negative error code on failure.
295295
*/
296296
static int read_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset,
297-
char *dest, u64 len, struct page *dest_page)
297+
char *dest, u64 len, struct folio *dest_folio)
298298
{
299299
struct btrfs_path *path;
300300
struct btrfs_root *root = inode->root;
@@ -314,7 +314,7 @@ static int read_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset,
314314
if (!path)
315315
return -ENOMEM;
316316

317-
if (dest_page)
317+
if (dest_folio)
318318
path->reada = READA_FORWARD;
319319

320320
key.objectid = btrfs_ino(inode);
@@ -371,15 +371,15 @@ static int read_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset,
371371
copy_offset = offset - key.offset;
372372

373373
if (dest) {
374-
if (dest_page)
375-
kaddr = kmap_local_page(dest_page);
374+
if (dest_folio)
375+
kaddr = kmap_local_folio(dest_folio, 0);
376376

377377
data = btrfs_item_ptr(leaf, path->slots[0], void);
378378
read_extent_buffer(leaf, kaddr + dest_offset,
379379
(unsigned long)data + copy_offset,
380380
copy_bytes);
381381

382-
if (dest_page)
382+
if (dest_folio)
383383
kunmap_local(kaddr);
384384
}
385385

@@ -762,7 +762,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode,
762762
* [ inode objectid, BTRFS_MERKLE_ITEM_KEY, offset in bytes ]
763763
*/
764764
ret = read_key_bytes(BTRFS_I(inode), BTRFS_VERITY_MERKLE_ITEM_KEY, off,
765-
folio_address(folio), PAGE_SIZE, &folio->page);
765+
folio_address(folio), PAGE_SIZE, folio);
766766
if (ret < 0) {
767767
folio_put(folio);
768768
return ERR_PTR(ret);

0 commit comments

Comments
 (0)