Qu Wenruo | cac06d8 | 2021-01-26 16:33:47 +0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | |
| 3 | #ifndef BTRFS_SUBPAGE_H |
| 4 | #define BTRFS_SUBPAGE_H |
| 5 | |
| 6 | #include <linux/spinlock.h> |
| 7 | |
| 8 | /* |
| 9 | * Maximum page size we support is 64K, minimum sector size is 4K, u16 bitmap |
| 10 | * is sufficient. Regular bitmap_* is not used due to size reasons. |
| 11 | */ |
| 12 | #define BTRFS_SUBPAGE_BITMAP_SIZE 16 |
| 13 | |
| 14 | /* |
| 15 | * Structure to trace status of each sector inside a page, attached to |
| 16 | * page::private for both data and metadata inodes. |
| 17 | */ |
| 18 | struct btrfs_subpage { |
| 19 | /* Common members for both data and metadata pages */ |
| 20 | spinlock_t lock; |
| 21 | }; |
| 22 | |
| 23 | enum btrfs_subpage_type { |
| 24 | BTRFS_SUBPAGE_METADATA, |
| 25 | BTRFS_SUBPAGE_DATA, |
| 26 | }; |
| 27 | |
| 28 | int btrfs_attach_subpage(const struct btrfs_fs_info *fs_info, |
| 29 | struct page *page, enum btrfs_subpage_type type); |
| 30 | void btrfs_detach_subpage(const struct btrfs_fs_info *fs_info, |
| 31 | struct page *page); |
| 32 | |
| 33 | #endif |