btrfs: introduce helpers for updating eb uuids
authorDavid Sterba <dsterba@suse.com>
Wed, 9 Nov 2016 16:43:38 +0000 (17:43 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 30 Nov 2016 12:45:17 +0000 (13:45 +0100)
The fsid and chunk tree uuid are always located in the first page,
we don't need the to use write_extent_buffer.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h

index ea9ade703da2cb7da40d3de56232472ba5b38da2..2ae731a0058ad2da34fc86b47bd377f553daeb08 100644 (file)
@@ -5465,6 +5465,27 @@ int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv,
        return ret;
 }
 
+void write_extent_buffer_chunk_tree_uuid(struct extent_buffer *eb,
+               const void *srcv)
+{
+       char *kaddr;
+
+       WARN_ON(!PageUptodate(eb->pages[0]));
+       kaddr = page_address(eb->pages[0]);
+       memcpy(kaddr + offsetof(struct btrfs_header, chunk_tree_uuid), srcv,
+                       BTRFS_FSID_SIZE);
+}
+
+void write_extent_buffer_fsid(struct extent_buffer *eb, const void *srcv)
+{
+       char *kaddr;
+
+       WARN_ON(!PageUptodate(eb->pages[0]));
+       kaddr = page_address(eb->pages[0]);
+       memcpy(kaddr + offsetof(struct btrfs_header, fsid), srcv,
+                       BTRFS_FSID_SIZE);
+}
+
 void write_extent_buffer(struct extent_buffer *eb, const void *srcv,
                         unsigned long start, unsigned long len)
 {
index ab31d145227edf423e15b7fb72d2094f402f7e56..065c77d43921a3b36a41773a20ea6a5fa016d7e4 100644 (file)
@@ -405,6 +405,9 @@ void read_extent_buffer(struct extent_buffer *eb, void *dst,
 int read_extent_buffer_to_user(struct extent_buffer *eb, void __user *dst,
                               unsigned long start,
                               unsigned long len);
+void write_extent_buffer_fsid(struct extent_buffer *eb, const void *src);
+void write_extent_buffer_chunk_tree_uuid(struct extent_buffer *eb,
+               const void *src);
 void write_extent_buffer(struct extent_buffer *eb, const void *src,
                         unsigned long start, unsigned long len);
 void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,