From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH v2 13/15] btrfs-progs: add on-disk items and read support for the gc tree
Date: Mon, 7 Mar 2022 17:13:18 -0500 [thread overview]
Message-ID: <e8ceb59cd4f2a30a2634359bba47132ea84a26db.1646691128.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1646691128.git.josef@toxicpanda.com>
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(+)
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index d79f49c9..72c87485 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -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
/*
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 4964cd38..35422d8c 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -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;
diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 978d92bc..554cc641 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -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;
--
2.26.3
next prev parent reply other threads:[~2022-03-07 22:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 22:13 [PATCH v2 00/15] btrfs-progs: extent tree v2 gc tree and metadata ref changes Josef Bacik
2022-03-07 22:13 ` [PATCH v2 01/15] btrfs-progs: extract out free extent accounting handling Josef Bacik
2022-03-07 22:13 ` [PATCH v2 02/15] btrfs-progs: check: skip owner ref check for extent tree v2 Josef Bacik
2022-03-07 22:13 ` [PATCH v2 03/15] btrfs-progs: check: skip extent backref for metadata in " Josef Bacik
2022-03-07 22:13 ` [PATCH v2 04/15] btrfs-progs: check: calculate normal flags for extent tree v2 metadata Josef Bacik
2022-03-07 22:13 ` [PATCH v2 05/15] btrfs-progs: check: make metadata ref counting extent tree v2 aware Josef Bacik
2022-03-07 22:13 ` [PATCH v2 06/15] btrfs-progs: check: update block group used properly for extent tree v2 Josef Bacik
2022-03-07 22:13 ` [PATCH v2 07/15] btrfs-progs: do not insert extent items for metadata " Josef Bacik
2022-03-07 22:13 ` [PATCH v2 08/15] btrfs-progs: do not remove metadata backrefs " Josef Bacik
2022-03-07 22:13 ` [PATCH v2 09/15] btrfs-progs: repair: traverse tree blocks " Josef Bacik
2022-03-07 22:13 ` [PATCH v2 10/15] btrfs-progs: cache the block group with the free space tree if possible Josef Bacik
2022-03-07 22:13 ` [PATCH v2 11/15] btrfs-progs: make btrfs_lookup_extent_info extent tree v2 aware Josef Bacik
2022-03-07 22:13 ` [PATCH v2 12/15] btrfs-progs: mkfs: don't populate extent tree with extent tree v2 Josef Bacik
2022-03-07 22:13 ` Josef Bacik [this message]
2022-03-07 22:13 ` [PATCH v2 14/15] btrfs-progs: mkfs: create the gc tree at mkfs time Josef Bacik
2022-03-07 22:13 ` [PATCH v2 15/15] btrfs-progs: deal with GC items in check Josef Bacik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e8ceb59cd4f2a30a2634359bba47132ea84a26db.1646691128.git.josef@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox