btrfs: move space_info to space-info.h
authorJosef Bacik <josef@toxicpanda.com>
Tue, 18 Jun 2019 20:09:16 +0000 (16:09 -0400)
committerDavid Sterba <dsterba@suse.com>
Tue, 2 Jul 2019 10:30:51 +0000 (12:30 +0200)
Migrate the struct definition and the one helper that's in ctree.h into
space-info.h

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/free-space-cache.c
fs/btrfs/ioctl.c
fs/btrfs/space-info.h [new file with mode: 0644]
fs/btrfs/super.c
fs/btrfs/sysfs.c
fs/btrfs/volumes.c

index 5e89e4d5b06534f4be70d580f4581876bf8cba4a..1d6a60f437a62d78e0cf57306aae1bb9b16295d5 100644 (file)
@@ -37,6 +37,7 @@ struct btrfs_trans_handle;
 struct btrfs_transaction;
 struct btrfs_pending_snapshot;
 struct btrfs_delayed_ref_root;
+struct btrfs_space_info;
 extern struct kmem_cache *btrfs_trans_handle_cachep;
 extern struct kmem_cache *btrfs_bit_radix_cachep;
 extern struct kmem_cache *btrfs_path_cachep;
@@ -402,72 +403,6 @@ struct raid_kobject {
        struct list_head list;
 };
 
-struct btrfs_space_info {
-       spinlock_t lock;
-
-       u64 total_bytes;        /* total bytes in the space,
-                                  this doesn't take mirrors into account */
-       u64 bytes_used;         /* total bytes used,
-                                  this doesn't take mirrors into account */
-       u64 bytes_pinned;       /* total bytes pinned, will be freed when the
-                                  transaction finishes */
-       u64 bytes_reserved;     /* total bytes the allocator has reserved for
-                                  current allocations */
-       u64 bytes_may_use;      /* number of bytes that may be used for
-                                  delalloc/allocations */
-       u64 bytes_readonly;     /* total bytes that are read only */
-
-       u64 max_extent_size;    /* This will hold the maximum extent size of
-                                  the space info if we had an ENOSPC in the
-                                  allocator. */
-
-       unsigned int full:1;    /* indicates that we cannot allocate any more
-                                  chunks for this space */
-       unsigned int chunk_alloc:1;     /* set if we are allocating a chunk */
-
-       unsigned int flush:1;           /* set if we are trying to make space */
-
-       unsigned int force_alloc;       /* set if we need to force a chunk
-                                          alloc for this space */
-
-       u64 disk_used;          /* total bytes used on disk */
-       u64 disk_total;         /* total bytes on disk, takes mirrors into
-                                  account */
-
-       u64 flags;
-
-       /*
-        * bytes_pinned is kept in line with what is actually pinned, as in
-        * we've called update_block_group and dropped the bytes_used counter
-        * and increased the bytes_pinned counter.  However this means that
-        * bytes_pinned does not reflect the bytes that will be pinned once the
-        * delayed refs are flushed, so this counter is inc'ed every time we
-        * call btrfs_free_extent so it is a realtime count of what will be
-        * freed once the transaction is committed.  It will be zeroed every
-        * time the transaction commits.
-        */
-       struct percpu_counter total_bytes_pinned;
-
-       struct list_head list;
-       /* Protected by the spinlock 'lock'. */
-       struct list_head ro_bgs;
-       struct list_head priority_tickets;
-       struct list_head tickets;
-       /*
-        * tickets_id just indicates the next ticket will be handled, so note
-        * it's not stored per ticket.
-        */
-       u64 tickets_id;
-
-       struct rw_semaphore groups_sem;
-       /* for block groups in our same type */
-       struct list_head block_groups[BTRFS_NR_RAID_TYPES];
-       wait_queue_head_t wait;
-
-       struct kobject kobj;
-       struct kobject *block_group_kobjs[BTRFS_NR_RAID_TYPES];
-};
-
 /*
  * Types of block reserves
  */
@@ -2693,12 +2628,6 @@ static inline u64 btrfs_extref_hash(u64 parent_objectid, const char *name,
        return (u64) crc32c(parent_objectid, name, len);
 }
 
-static inline bool btrfs_mixed_space_info(struct btrfs_space_info *space_info)
-{
-       return ((space_info->flags & BTRFS_BLOCK_GROUP_METADATA) &&
-               (space_info->flags & BTRFS_BLOCK_GROUP_DATA));
-}
-
 static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping)
 {
        return mapping_gfp_constraint(mapping, ~__GFP_FS);
index 8ec9d6fbad42a9b02544984b44181c147a390502..11ee633b02dc89f17e6484dca42ddbbe2bb8bf1e 100644 (file)
@@ -28,6 +28,7 @@
 #include "sysfs.h"
 #include "qgroup.h"
 #include "ref-verify.h"
+#include "space-info.h"
 
 #undef SCRAMBLE_DELAYED_REFS
 
index 6814fa42eba3ccf8a2f47cb1e6bc73591b75075a..390cd3d7d5eaffe7ea5ba652276759c142c99c48 100644 (file)
@@ -18,6 +18,7 @@
 #include "extent_io.h"
 #include "inode-map.h"
 #include "volumes.h"
+#include "space-info.h"
 
 #define BITS_PER_BITMAP                (PAGE_SIZE * 8UL)
 #define MAX_CACHE_BYTES_PER_GIG        SZ_32K
index 5b4beebf138ce98a7ce37e71067456a900dfd974..ca32b97b6b4bfe8ce8b802dcec5d4d6c6269eaa1 100644 (file)
@@ -43,6 +43,7 @@
 #include "qgroup.h"
 #include "tree-log.h"
 #include "compression.h"
+#include "space-info.h"
 
 #ifdef CONFIG_64BIT
 /* If we have a 32-bit userspace and 64-bit kernel, then the UAPI
diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h
new file mode 100644 (file)
index 0000000..5f96333
--- /dev/null
@@ -0,0 +1,78 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef BTRFS_SPACE_INFO_H
+#define BTRFS_SPACE_INFO_H
+
+struct btrfs_space_info {
+       spinlock_t lock;
+
+       u64 total_bytes;        /* total bytes in the space,
+                                  this doesn't take mirrors into account */
+       u64 bytes_used;         /* total bytes used,
+                                  this doesn't take mirrors into account */
+       u64 bytes_pinned;       /* total bytes pinned, will be freed when the
+                                  transaction finishes */
+       u64 bytes_reserved;     /* total bytes the allocator has reserved for
+                                  current allocations */
+       u64 bytes_may_use;      /* number of bytes that may be used for
+                                  delalloc/allocations */
+       u64 bytes_readonly;     /* total bytes that are read only */
+
+       u64 max_extent_size;    /* This will hold the maximum extent size of
+                                  the space info if we had an ENOSPC in the
+                                  allocator. */
+
+       unsigned int full:1;    /* indicates that we cannot allocate any more
+                                  chunks for this space */
+       unsigned int chunk_alloc:1;     /* set if we are allocating a chunk */
+
+       unsigned int flush:1;           /* set if we are trying to make space */
+
+       unsigned int force_alloc;       /* set if we need to force a chunk
+                                          alloc for this space */
+
+       u64 disk_used;          /* total bytes used on disk */
+       u64 disk_total;         /* total bytes on disk, takes mirrors into
+                                  account */
+
+       u64 flags;
+
+       /*
+        * bytes_pinned is kept in line with what is actually pinned, as in
+        * we've called update_block_group and dropped the bytes_used counter
+        * and increased the bytes_pinned counter.  However this means that
+        * bytes_pinned does not reflect the bytes that will be pinned once the
+        * delayed refs are flushed, so this counter is inc'ed every time we
+        * call btrfs_free_extent so it is a realtime count of what will be
+        * freed once the transaction is committed.  It will be zeroed every
+        * time the transaction commits.
+        */
+       struct percpu_counter total_bytes_pinned;
+
+       struct list_head list;
+       /* Protected by the spinlock 'lock'. */
+       struct list_head ro_bgs;
+       struct list_head priority_tickets;
+       struct list_head tickets;
+       /*
+        * tickets_id just indicates the next ticket will be handled, so note
+        * it's not stored per ticket.
+        */
+       u64 tickets_id;
+
+       struct rw_semaphore groups_sem;
+       /* for block groups in our same type */
+       struct list_head block_groups[BTRFS_NR_RAID_TYPES];
+       wait_queue_head_t wait;
+
+       struct kobject kobj;
+       struct kobject *block_group_kobjs[BTRFS_NR_RAID_TYPES];
+};
+
+static inline bool btrfs_mixed_space_info(struct btrfs_space_info *space_info)
+{
+       return ((space_info->flags & BTRFS_BLOCK_GROUP_METADATA) &&
+               (space_info->flags & BTRFS_BLOCK_GROUP_DATA));
+}
+
+#endif /* BTRFS_SPACE_INFO_H */
index 7d20856ae0c42b669596f3b1f0a6c4d64160a3bd..78de9d5d80c6f0b63f19094c40b01f8569f5d447 100644 (file)
@@ -42,6 +42,7 @@
 #include "dev-replace.h"
 #include "free-space-cache.h"
 #include "backref.h"
+#include "space-info.h"
 #include "tests/btrfs-tests.h"
 
 #include "qgroup.h"
index 2f078b77fe145937fada488e43eb7a12cc79161e..e6493b0682940afbb5521d6e2a1886dbc338f3fa 100644 (file)
@@ -16,6 +16,7 @@
 #include "transaction.h"
 #include "sysfs.h"
 #include "volumes.h"
+#include "space-info.h"
 
 static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj);
 static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj);
index b9606501d33bae8f0d45bd9aa9ecb156cab3a2e6..a13ddba1ebc3b75f9fc0f301036d0d7979a74c1d 100644 (file)
@@ -28,6 +28,7 @@
 #include "dev-replace.h"
 #include "sysfs.h"
 #include "tree-checker.h"
+#include "space-info.h"
 
 const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
        [BTRFS_RAID_RAID10] = {