btrfs: move eb offset helpers into extent_io.h
authorJosef Bacik <josef@toxicpanda.com>
Tue, 15 Nov 2022 16:16:13 +0000 (11:16 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:58 +0000 (18:00 +0100)
These are very specific to how the extent buffer is defined, so this
differs between btrfs-progs and the kernel.  Make things easier by
moving these helpers into extent_io.h so we don't have to worry about
this when syncing ctree.h.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent_io.h

index 428f51e..6169d3b 100644 (file)
@@ -686,39 +686,6 @@ static inline int btrfs_next_item(struct btrfs_root *root, struct btrfs_path *p)
 }
 int btrfs_leaf_free_space(struct extent_buffer *leaf);
 
-/*
- * Get the correct offset inside the page of extent buffer.
- *
- * @eb:                target extent buffer
- * @start:     offset inside the extent buffer
- *
- * Will handle both sectorsize == PAGE_SIZE and sectorsize < PAGE_SIZE cases.
- */
-static inline size_t get_eb_offset_in_page(const struct extent_buffer *eb,
-                                          unsigned long offset)
-{
-       /*
-        * For sectorsize == PAGE_SIZE case, eb->start will always be aligned
-        * to PAGE_SIZE, thus adding it won't cause any difference.
-        *
-        * For sectorsize < PAGE_SIZE, we must only read the data that belongs
-        * to the eb, thus we have to take the eb->start into consideration.
-        */
-       return offset_in_page(offset + eb->start);
-}
-
-static inline unsigned long get_eb_page_index(unsigned long offset)
-{
-       /*
-        * For sectorsize == PAGE_SIZE case, plain >> PAGE_SHIFT is enough.
-        *
-        * For sectorsize < PAGE_SIZE case, we only support 64K PAGE_SIZE,
-        * and have ensured that all tree blocks are contained in one page,
-        * thus we always get index == 0.
-        */
-       return offset >> PAGE_SHIFT;
-}
-
 static inline int is_fstree(u64 rootid)
 {
        if (rootid == BTRFS_FS_TREE_OBJECTID ||
index 9b48641..a2c8244 100644 (file)
@@ -96,6 +96,39 @@ struct extent_buffer {
 };
 
 /*
+ * Get the correct offset inside the page of extent buffer.
+ *
+ * @eb:                target extent buffer
+ * @start:     offset inside the extent buffer
+ *
+ * Will handle both sectorsize == PAGE_SIZE and sectorsize < PAGE_SIZE cases.
+ */
+static inline size_t get_eb_offset_in_page(const struct extent_buffer *eb,
+                                          unsigned long offset)
+{
+       /*
+        * For sectorsize == PAGE_SIZE case, eb->start will always be aligned
+        * to PAGE_SIZE, thus adding it won't cause any difference.
+        *
+        * For sectorsize < PAGE_SIZE, we must only read the data that belongs
+        * to the eb, thus we have to take the eb->start into consideration.
+        */
+       return offset_in_page(offset + eb->start);
+}
+
+static inline unsigned long get_eb_page_index(unsigned long offset)
+{
+       /*
+        * For sectorsize == PAGE_SIZE case, plain >> PAGE_SHIFT is enough.
+        *
+        * For sectorsize < PAGE_SIZE case, we only support 64K PAGE_SIZE,
+        * and have ensured that all tree blocks are contained in one page,
+        * thus we always get index == 0.
+        */
+       return offset >> PAGE_SHIFT;
+}
+
+/*
  * Structure to record how many bytes and which ranges are set/cleared
  */
 struct extent_changeset {