All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: [RFC][PATCH] Btrfs-progs: Update for new inode number allocator
Date: Wed, 26 Jan 2011 09:53:04 +0800	[thread overview]
Message-ID: <4D3F7E80.5080300@cn.fujitsu.com> (raw)

- Create an initial ino extent in the fs tree.
- Add debug code to btrfs-debug-tree command.

Singed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 ctree.h      |    2 ++
 mkfs.c       |   16 ++++++++++++++++
 print-tree.c |   23 ++++++++++++++++++++++-
 3 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/ctree.h b/ctree.h
index b79e238..997cff0 100644
--- a/ctree.h
+++ b/ctree.h
@@ -849,6 +849,8 @@ struct btrfs_root {
 #define BTRFS_DEV_ITEM_KEY	216
 #define BTRFS_CHUNK_ITEM_KEY	228
 
+#define BTRFS_INO_EXTENT_KEY	230
+
 /*
  * string items are for debugging.  They just store a short string of
  * data in the FS
diff --git a/mkfs.c b/mkfs.c
index 2e99b95..8bebb05 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -69,6 +69,18 @@ static u64 parse_size(char *s)
 	return atol(s) * mult;
 }
 
+static int insert_ino_extent(struct btrfs_trans_handle *trans,
+			    struct btrfs_root *root)
+{
+	struct btrfs_key key;
+
+	key.objectid = (BTRFS_FIRST_FREE_OBJECTID + 1) + ((u64)1 << 63);
+	key.type = BTRFS_INO_EXTENT_KEY;
+	key.offset = BTRFS_LAST_FREE_OBJECTID;
+
+	return btrfs_insert_item(trans, root, &key, NULL, 0);
+}
+
 static int make_root_dir(struct btrfs_root *root)
 {
 	struct btrfs_trans_handle *trans;
@@ -135,6 +147,10 @@ static int make_root_dir(struct btrfs_root *root)
 	if (ret)
 		goto err;
 
+	ret = insert_ino_extent(trans, root);
+	if (ret)
+		goto err;
+
 	btrfs_commit_transaction(trans, root);
 err:
 	return ret;
diff --git a/print-tree.c b/print-tree.c
index ac575d5..b6d5dc9 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -351,6 +351,9 @@ static void print_key_type(u8 type)
 	case BTRFS_DEV_EXTENT_KEY:
 		printf("DEV_EXTENT");
 		break;
+	case BTRFS_INO_EXTENT_KEY:
+		printf("INO_EXTENT");
+		break;
 	case BTRFS_STRING_ITEM_KEY:
 		printf("STRING_ITEM");
 		break;
@@ -364,6 +367,9 @@ static void print_objectid(unsigned long long objectid, u8 type)
 	if (type == BTRFS_DEV_EXTENT_KEY) {
 		printf("%llu", objectid); /* device id */
 		return;
+	} else if (type == BTRFS_INO_EXTENT_KEY) {
+		printf("%llu", objectid - ((u64)1 << 63));
+		return;
 	}
 
 	switch (objectid) {
@@ -423,16 +429,28 @@ static void print_objectid(unsigned long long objectid, u8 type)
 	}
 }
 
+static void print_key_offset(unsigned long long offset, u8 type)
+{
+	if (type == BTRFS_INO_EXTENT_KEY)
+		printf("%llu", offset - ((u64)1 << 63));
+	else
+		printf("%llu", offset);
+}
+
 void btrfs_print_key(struct btrfs_disk_key *disk_key)
 {
 	u8 type;
+
 	printf("key (");
 	type = btrfs_disk_key_type(disk_key);
 	print_objectid((unsigned long long)btrfs_disk_key_objectid(disk_key),
 		type);
 	printf(" ");
 	print_key_type(type);
-	printf(" %llu)", (unsigned long long)btrfs_disk_key_offset(disk_key));
+	printf(" ");
+	print_key_offset((unsigned long long)btrfs_disk_key_offset(disk_key),
+		type);
+	printf(")");
 }
 
 void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
@@ -600,6 +618,9 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
 			       (unsigned long long)
 			       btrfs_dev_extent_length(l, dev_extent));
 			break;
+		case BTRFS_INO_EXTENT_KEY:
+			/* The item of this type has no data */
+			break;
 		case BTRFS_STRING_ITEM_KEY:
 			/* dirty, but it's simple */
 			str = l->data + btrfs_item_ptr_offset(l, i);
-- 1.6.3 

                 reply	other threads:[~2011-01-26  1:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4D3F7E80.5080300@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.