blob: 676280bc75621f3809851c17f007f7fe3f42a9d9 [file] [log] [blame]
Qu Wenruocac06d82021-01-26 16:33:47 +08001/* 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 */
18struct btrfs_subpage {
19 /* Common members for both data and metadata pages */
20 spinlock_t lock;
21};
22
23enum btrfs_subpage_type {
24 BTRFS_SUBPAGE_METADATA,
25 BTRFS_SUBPAGE_DATA,
26};
27
28int btrfs_attach_subpage(const struct btrfs_fs_info *fs_info,
29 struct page *page, enum btrfs_subpage_type type);
30void btrfs_detach_subpage(const struct btrfs_fs_info *fs_info,
31 struct page *page);
32
33#endif