@@ -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
@@ -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;
@@ -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);