diff options
author | David Sterba <dsterba@suse.com> | 2023-09-13 16:11:29 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-03-04 16:24:49 +0100 |
commit | c8293894afa718653688b2fa98ab68317c875a00 (patch) | |
tree | 470bf3dfdc68cdaea79bd4ef0c9c8d7fa2811d96 /fs/btrfs/fs.h | |
parent | b2136cc288fce2f24a92f3d656531b2d50ebec5a (diff) |
btrfs: add helpers to get inode from page/folio pointers
Add convenience helpers to get a struct btrfs_inode from a page or folio
pointer instead of open coding the chain or intermediate BTRFS_I. This
is implemented as a macro (still with type checking) so we don't need
full definitions of struct page or address_space.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/fs.h')
-rw-r--r-- | fs/btrfs/fs.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h index 97d10ed4b2c1..d9a829015274 100644 --- a/fs/btrfs/fs.h +++ b/fs/btrfs/fs.h @@ -831,6 +831,11 @@ struct btrfs_fs_info { #endif }; +#define page_to_inode(_page) (BTRFS_I(_Generic((_page), \ + struct page *: (_page))->mapping->host)) +#define folio_to_inode(_folio) (BTRFS_I(_Generic((_folio), \ + struct folio *: (_folio))->mapping->host)) + static inline u64 btrfs_get_fs_generation(const struct btrfs_fs_info *fs_info) { return READ_ONCE(fs_info->generation); |