]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
btrfs: use write_extent_buffer() to implement write_extent_buffer_*id()
authorQu Wenruo <wqu@suse.com>
Sat, 15 Jul 2023 11:08:30 +0000 (19:08 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Aug 2023 12:52:17 +0000 (14:52 +0200)
Helpers write_extent_buffer_chunk_tree_uuid() and
write_extent_buffer_fsid(), they can be implemented by
write_extent_buffer().

These two helpers are not that frequently used, they only get called
during initialization of a new tree block.  There is not much need for
those slightly optimized versions.  And since they can be easily
converted to one write_extent_buffer() call, define them as inline
helpers.

This would make later page/folio switch much easier, as all change only
need to happen in write_extent_buffer().

Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h

index 3e9f39bda9f2a631ff71ce2657f87ecbfd7bad5a..dc15eaa75c6588ec095653776fe1ffbded76e064 100644 (file)
@@ -4129,28 +4129,6 @@ static void assert_eb_page_uptodate(const struct extent_buffer *eb,
        }
 }
 
-void write_extent_buffer_chunk_tree_uuid(const struct extent_buffer *eb,
-               const void *srcv)
-{
-       char *kaddr;
-
-       assert_eb_page_uptodate(eb, eb->pages[0]);
-       kaddr = page_address(eb->pages[0]) +
-               get_eb_offset_in_page(eb, offsetof(struct btrfs_header,
-                                                  chunk_tree_uuid));
-       memcpy(kaddr, srcv, BTRFS_FSID_SIZE);
-}
-
-void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *srcv)
-{
-       char *kaddr;
-
-       assert_eb_page_uptodate(eb, eb->pages[0]);
-       kaddr = page_address(eb->pages[0]) +
-               get_eb_offset_in_page(eb, offsetof(struct btrfs_header, fsid));
-       memcpy(kaddr, srcv, BTRFS_FSID_SIZE);
-}
-
 void write_extent_buffer(const struct extent_buffer *eb, const void *srcv,
                         unsigned long start, unsigned long len)
 {
index c01f9c5ddc13c06fdee955395804b58d72bb3604..adda14c1b763e342126587cad1f952049572719a 100644 (file)
@@ -236,11 +236,24 @@ void read_extent_buffer(const struct extent_buffer *eb, void *dst,
 int read_extent_buffer_to_user_nofault(const struct extent_buffer *eb,
                                       void __user *dst, unsigned long start,
                                       unsigned long len);
-void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *src);
-void write_extent_buffer_chunk_tree_uuid(const struct extent_buffer *eb,
-               const void *src);
 void write_extent_buffer(const struct extent_buffer *eb, const void *src,
                         unsigned long start, unsigned long len);
+
+static inline void write_extent_buffer_chunk_tree_uuid(
+               const struct extent_buffer *eb, const void *chunk_tree_uuid)
+{
+       write_extent_buffer(eb, chunk_tree_uuid,
+                           offsetof(struct btrfs_header, chunk_tree_uuid),
+                           BTRFS_FSID_SIZE);
+}
+
+static inline void write_extent_buffer_fsid(const struct extent_buffer *eb,
+                                           const void *fsid)
+{
+       write_extent_buffer(eb, fsid, offsetof(struct btrfs_header, fsid),
+                           BTRFS_FSID_SIZE);
+}
+
 void copy_extent_buffer_full(const struct extent_buffer *dst,
                             const struct extent_buffer *src);
 void copy_extent_buffer(const struct extent_buffer *dst,