diff options
author | Christoph Hellwig <hch@lst.de> | 2022-05-22 13:47:52 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-07-25 17:44:34 +0200 |
commit | a89ce08ce63808308bb41a087860c245f136928a (patch) | |
tree | d793df6d61c2ac270ddf6aa34257d9e1808bd9ee /fs/btrfs/ctree.h | |
parent | btrfs: refactor end_bio_extent_readpage code flow (diff) | |
download | linux-a89ce08ce63808308bb41a087860c245f136928a.tar.xz linux-a89ce08ce63808308bb41a087860c245f136928a.zip |
btrfs: factor out a btrfs_csum_ptr helper
Add a helper to find the csum for a byte offset into the csum buffer.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 6e65778040ed..613f46bab3e2 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2733,6 +2733,14 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb, enum btrfs_inline_ref_type is_data); u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset); +static inline u8 *btrfs_csum_ptr(const struct btrfs_fs_info *fs_info, u8 *csums, + u64 offset) +{ + u64 offset_in_sectors = offset >> fs_info->sectorsize_bits; + + return csums + offset_in_sectors * fs_info->csum_size; +} + /* * Take the number of bytes to be checksummed and figure out how many leaves * it would require to store the csums for that many bytes. |