From patchwork Wed Jan 26 01:53:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zefan X-Patchwork-Id: 507661 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0Q4lFMI023501 for ; Wed, 26 Jan 2011 04:47:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752354Ab1AZBvz (ORCPT ); Tue, 25 Jan 2011 20:51:55 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:49167 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752143Ab1AZBvy (ORCPT ); Tue, 25 Jan 2011 20:51:54 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id B9A8C170132 for ; Wed, 26 Jan 2011 09:51:52 +0800 (CST) Received: from mailserver.fnst.cn.fujitus.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p0Q1kVYZ002784 for ; Wed, 26 Jan 2011 09:46:31 +0800 Received: from [10.167.225.230] ([10.167.225.230]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011012609511695-22452 ; Wed, 26 Jan 2011 09:51:16 +0800 Message-ID: <4D3F7E80.5080300@cn.fujitsu.com> Date: Wed, 26 Jan 2011 09:53:04 +0800 From: Li Zefan User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc14 Thunderbird/3.1.4 MIME-Version: 1.0 To: "linux-btrfs@vger.kernel.org" Subject: [RFC][PATCH] Btrfs-progs: Update for new inode number allocator X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-01-26 09:51:16, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-01-26 09:51:17, Serialize complete at 2011-01-26 09:51:17 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 26 Jan 2011 04:47:17 +0000 (UTC) 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);