summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/subpage.h
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2021-01-26 16:33:48 +0800
committerDavid Sterba <dsterba@suse.com>2021-02-08 22:59:01 +0100
commit760f991f1428f25fd18b8638004c95f0a2a43b2f (patch)
tree1a5346dc72ecf14145d9fbadadd06e34bfd36e38 /fs/btrfs/subpage.h
parentcac06d843f259ebc4d03e4bc8af7304c17f76ee5 (diff)
downloadlinux-760f991f1428f25fd18b8638004c95f0a2a43b2f.tar.gz
linux-760f991f1428f25fd18b8638004c95f0a2a43b2f.tar.bz2
linux-760f991f1428f25fd18b8638004c95f0a2a43b2f.zip
btrfs: make attach_extent_buffer_page() handle subpage case
For subpage case, we need to allocate additional memory for each metadata page. So we need to: - Allow attach_extent_buffer_page() to return int to indicate allocation failure - Allow manually pre-allocate subpage memory for alloc_extent_buffer() As we don't want to use GFP_ATOMIC under spinlock, we introduce btrfs_alloc_subpage() and btrfs_free_subpage() functions for this purpose. (The simple wrap for btrfs_free_subpage() is for later convert to kmem_cache. Already internally tested without problem) - Preallocate btrfs_subpage structure for alloc_extent_buffer() We don't want to call memory allocation with spinlock held, so do preallocation before we acquire mapping->private_lock. - Handle subpage and regular case differently in attach_extent_buffer_page() For regular case, no change, just do the usual thing. For subpage case, allocate new memory or use the preallocated memory. For future subpage metadata, we will make use of radix tree to grab extent buffer. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/subpage.h')
-rw-r--r--fs/btrfs/subpage.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/subpage.h b/fs/btrfs/subpage.h
index 676280bc7562..7ba544bcc9c6 100644
--- a/fs/btrfs/subpage.h
+++ b/fs/btrfs/subpage.h
@@ -18,6 +18,10 @@
struct btrfs_subpage {
/* Common members for both data and metadata pages */
spinlock_t lock;
+ union {
+ /* Structures only used by metadata */
+ /* Structures only used by data */
+ };
};
enum btrfs_subpage_type {
@@ -30,4 +34,10 @@ int btrfs_attach_subpage(const struct btrfs_fs_info *fs_info,
void btrfs_detach_subpage(const struct btrfs_fs_info *fs_info,
struct page *page);
+/* Allocate additional data where page represents more than one sector */
+int btrfs_alloc_subpage(const struct btrfs_fs_info *fs_info,
+ struct btrfs_subpage **ret,
+ enum btrfs_subpage_type type);
+void btrfs_free_subpage(struct btrfs_subpage *subpage);
+
#endif