diff options
author | David Sterba <dsterba@suse.com> | 2023-09-14 16:24:43 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-03-04 16:24:49 +0100 |
commit | b33d2e535f9b2a1c4210cfc4843ac0dbacbeebcc (patch) | |
tree | 239967d4bacf6574b0a97638c561b8d77d5c1c75 /fs/btrfs/fs.h | |
parent | btrfs: add helpers to get inode from page/folio pointers (diff) | |
download | linux-b33d2e535f9b2a1c4210cfc4843ac0dbacbeebcc.tar.xz linux-b33d2e535f9b2a1c4210cfc4843ac0dbacbeebcc.zip |
btrfs: add helpers to get fs_info from page/folio pointers
Add convenience helpers to get a fs_info from a page or folio pointer
instead of open coding the chain or using btrfs_sb() that in some cases
does one more pointer hop. This is implemented as a macro (still with
type checking) so we don't need full definitions of struct page, folio,
btrfs_root and btrfs_fs_info. The latter can't be static inlines as this
would create loop between ctree.h <-> fs.h, or the headers would have to
be restructured.
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 | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h index d9a829015274..60ec557a7e3a 100644 --- a/fs/btrfs/fs.h +++ b/fs/btrfs/fs.h @@ -836,6 +836,9 @@ struct btrfs_fs_info { #define folio_to_inode(_folio) (BTRFS_I(_Generic((_folio), \ struct folio *: (_folio))->mapping->host)) +#define page_to_fs_info(_page) (page_to_inode(_page)->root->fs_info) +#define folio_to_fs_info(_folio) (folio_to_inode(_folio)->root->fs_info) + static inline u64 btrfs_get_fs_generation(const struct btrfs_fs_info *fs_info) { return READ_ONCE(fs_info->generation); |