@@ -88,6 +88,9 @@ struct btrfs_free_space_ctl;
/* hold the block group items. */
#define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL
+/* hold the garbage collection items. */
+#define BTRFS_GC_TREE_OBJECTID 12ULL
+
/* device stats in the device tree */
#define BTRFS_DEV_STATS_OBJECTID 0ULL
@@ -1362,6 +1365,9 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
#define BTRFS_XATTR_ITEM_KEY 24
#define BTRFS_ORPHAN_ITEM_KEY 48
+/* Garbage collection items. */
+#define BTRFS_GC_INODE_ITEM_KEY 49
+
#define BTRFS_DIR_LOG_ITEM_KEY 60
#define BTRFS_DIR_LOG_INDEX_KEY 72
/*
@@ -1222,6 +1222,16 @@ static int load_global_roots(struct btrfs_fs_info *fs_info, unsigned flags)
ret = load_global_roots_objectid(fs_info, path,
BTRFS_FREE_SPACE_TREE_OBJECTID, flags,
"free space");
+ if (ret)
+ goto out;
+ if (!btrfs_fs_incompat(fs_info, EXTENT_TREE_V2))
+ goto out;
+ /* We are from mkfs, we haven't setup the GC tree yet. */
+ if (flags & OPEN_CTREE_TEMPORARY_SUPER)
+ goto out;
+ ret = load_global_roots_objectid(fs_info, path,
+ BTRFS_GC_TREE_OBJECTID, flags,
+ "garbage collection");
out:
btrfs_free_path(path);
return ret;
@@ -677,6 +677,7 @@ void print_key_type(FILE *stream, u64 objectid, u8 type)
[BTRFS_PERSISTENT_ITEM_KEY] = "PERSISTENT_ITEM",
[BTRFS_UUID_KEY_SUBVOL] = "UUID_KEY_SUBVOL",
[BTRFS_UUID_KEY_RECEIVED_SUBVOL] = "UUID_KEY_RECEIVED_SUBVOL",
+ [BTRFS_GC_INODE_ITEM_KEY] = "GC_INODE_ITEM_KEY",
};
if (type == 0 && objectid == BTRFS_FREE_SPACE_OBJECTID) {
@@ -786,6 +787,9 @@ void print_objectid(FILE *stream, u64 objectid, u8 type)
case BTRFS_BLOCK_GROUP_TREE_OBJECTID:
fprintf(stream, "BLOCK_GROUP_TREE");
break;
+ case BTRFS_GC_TREE_OBJECTID:
+ fprintf(stream, "GC_TREE");
+ break;
case (u64)-1:
fprintf(stream, "-1");
break;
This add's the necessary on disk structures for the initial garbage collection tree. At first we're going to just add orphan item support, and then add other items as the support lands for those new operations. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- kernel-shared/ctree.h | 6 ++++++ kernel-shared/disk-io.c | 10 ++++++++++ kernel-shared/print-tree.c | 4 ++++ 3 files changed, 20 insertions(+)