From patchwork Thu Oct 11 15:03:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10636817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C01216B1 for ; Thu, 11 Oct 2018 15:04:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CF872B927 for ; Thu, 11 Oct 2018 15:04:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 319EA2B934; Thu, 11 Oct 2018 15:04:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 509D52B927 for ; Thu, 11 Oct 2018 15:04:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728110AbeJKWbm (ORCPT ); Thu, 11 Oct 2018 18:31:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:50024 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727370AbeJKWbl (ORCPT ); Thu, 11 Oct 2018 18:31:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 351DDB030 for ; Thu, 11 Oct 2018 15:04:07 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 1/8] btrfstune: Remove fs_info arg from change_device_uuid Date: Thu, 11 Oct 2018 18:03:57 +0300 Message-Id: <1539270244-27076-2-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539270244-27076-1-git-send-email-nborisov@suse.com> References: <1539270244-27076-1-git-send-email-nborisov@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This function already takes an extent buffer that contains a reference to the fs_info. Use that and reduce argument count. No functional changes. Signed-off-by: Nikolay Borisov --- btrfstune.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/btrfstune.c b/btrfstune.c index 889b931c55d8..723317a00f3a 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -179,10 +179,10 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info) return ret; } -static int change_device_uuid(struct btrfs_fs_info *fs_info, struct extent_buffer *eb, - int slot) +static int change_device_uuid(struct extent_buffer *eb, int slot) { struct btrfs_dev_item *di; + struct btrfs_fs_info *fs_info = eb->fs_info; int ret = 0; di = btrfs_item_ptr(eb, slot, struct btrfs_dev_item); @@ -217,7 +217,7 @@ static int change_devices_uuid(struct btrfs_fs_info *fs_info) if (key.type != BTRFS_DEV_ITEM_KEY || key.objectid != BTRFS_DEV_ITEMS_OBJECTID) goto next; - ret = change_device_uuid(fs_info, path.nodes[0], path.slots[0]); + ret = change_device_uuid(path.nodes[0], path.slots[0]); if (ret < 0) goto out; next: From patchwork Thu Oct 11 15:03:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10636821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 836F815E2 for ; Thu, 11 Oct 2018 15:04:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7430D2B91B for ; Thu, 11 Oct 2018 15:04:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68C902B92F; Thu, 11 Oct 2018 15:04:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9232B2B91B for ; Thu, 11 Oct 2018 15:04:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728078AbeJKWbm (ORCPT ); Thu, 11 Oct 2018 18:31:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:50030 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727579AbeJKWbm (ORCPT ); Thu, 11 Oct 2018 18:31:42 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 77A0DB0C4 for ; Thu, 11 Oct 2018 15:04:07 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 2/8] btrfstune: Rename change_header_uuid to change_buffer_header_uuid Date: Thu, 11 Oct 2018 18:03:58 +0300 Message-Id: <1539270244-27076-3-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539270244-27076-1-git-send-email-nborisov@suse.com> References: <1539270244-27076-1-git-send-email-nborisov@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Rename the function so its name falls in line with the rest of btrfs nomenclature. So when we change the uuid of the header it's in fact of the buffer header. Also remove the root argument since it's used solely to take a reference to fs_info which can be done via the mandatory eb argument. No functional changes. Signed-off-by: Nikolay Borisov --- btrfstune.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/btrfstune.c b/btrfstune.c index 723317a00f3a..3745a00c46ae 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -91,9 +91,9 @@ static int set_super_incompat_flags(struct btrfs_root *root, u64 flags) return ret; } -static int change_header_uuid(struct btrfs_root *root, struct extent_buffer *eb) +static int change_buffer_header_uuid(struct extent_buffer *eb) { - struct btrfs_fs_info *fs_info = root->fs_info; + struct btrfs_fs_info *fs_info = eb->fs_info; int same_fsid = 1; int same_chunk_tree_uuid = 1; int ret; @@ -157,7 +157,7 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info) ret = PTR_ERR(eb); goto out; } - ret = change_header_uuid(root, eb); + ret = change_buffer_header_uuid(eb); free_extent_buffer(eb); if (ret < 0) { error("failed to change uuid of tree block: %llu", From patchwork Thu Oct 11 15:03:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10636823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E33775CAF for ; Thu, 11 Oct 2018 15:04:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEB262B927 for ; Thu, 11 Oct 2018 15:04:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C10342B92F; Thu, 11 Oct 2018 15:04:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B9E52B927 for ; Thu, 11 Oct 2018 15:04:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728135AbeJKWbo (ORCPT ); Thu, 11 Oct 2018 18:31:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:50038 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727796AbeJKWbo (ORCPT ); Thu, 11 Oct 2018 18:31:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CA53EB0E5 for ; Thu, 11 Oct 2018 15:04:07 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 3/8] btrfs-progs: Add support for metadata_uuid field. Date: Thu, 11 Oct 2018 18:03:59 +0300 Message-Id: <1539270244-27076-4-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539270244-27076-1-git-send-email-nborisov@suse.com> References: <1539270244-27076-1-git-send-email-nborisov@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for a new metadata_uuid field. This is just a preparatory commit which switches all users of the fsid field for metdata comparison purposes to utilize the new field. This more or less mirrors the kernel patch, additionally: * Update 'btrfs inspect-internal dump-super' to account for the new field. This involes introducing the 'metadata_uuid' line to the output and updating the logic for comparing the fs uuid to the dev_item uuid. Signed-off-by: Nikolay Borisov --- btrfstune.c | 3 +++ check/main.c | 2 +- chunk-recover.c | 16 ++++++++++--- cmds-filesystem.c | 2 ++ cmds-inspect-dump-super.c | 22 ++++++++++++++--- convert/common.c | 2 ++ ctree.c | 14 +++++------ ctree.h | 8 +++++-- disk-io.c | 60 ++++++++++++++++++++++++++++++++++++++--------- image/main.c | 25 +++++++++++++------- volumes.c | 34 +++++++++++++++++++++------ volumes.h | 1 + 12 files changed, 146 insertions(+), 43 deletions(-) diff --git a/btrfstune.c b/btrfstune.c index 3745a00c46ae..62a075b2defc 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -248,6 +248,9 @@ static int change_fsid_prepare(struct btrfs_fs_info *fs_info) if (ret < 0) return ret; + /* Also need to change the metadatauuid of the fs info */ + memcpy(fs_info->metadata_uuid, fs_info->new_fsid, BTRFS_FSID_SIZE); + /* also restore new chunk_tree_id into tree_root for restore */ write_extent_buffer(tree_root->node, fs_info->new_chunk_tree_uuid, btrfs_header_chunk_tree_uuid(tree_root->node), diff --git a/check/main.c b/check/main.c index bc2ee22f7943..0790264190f2 100644 --- a/check/main.c +++ b/check/main.c @@ -8418,7 +8418,7 @@ static int btrfs_fsck_reinit_root(struct btrfs_trans_handle *trans, btrfs_set_header_backref_rev(c, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(c, root->root_key.objectid); - write_extent_buffer(c, root->fs_info->fsid, + write_extent_buffer(c, root->fs_info->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(c, root->fs_info->chunk_tree_uuid, diff --git a/chunk-recover.c b/chunk-recover.c index 1d30db51d8ed..31325bfc54e0 100644 --- a/chunk-recover.c +++ b/chunk-recover.c @@ -759,7 +759,7 @@ static int scan_one_device(void *dev_scan_struct) rc->nodesize) break; - if (memcmp_extent_buffer(buf, rc->fs_devices->fsid, + if (memcmp_extent_buffer(buf, rc->fs_devices->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE)) { bytenr += rc->sectorsize; @@ -1155,7 +1155,7 @@ static int __rebuild_chunk_root(struct btrfs_trans_handle *trans, btrfs_set_header_level(cow, 0); btrfs_set_header_backref_rev(cow, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(cow, BTRFS_CHUNK_TREE_OBJECTID); - write_extent_buffer(cow, root->fs_info->fsid, + write_extent_buffer(cow, root->fs_info->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(cow, root->fs_info->chunk_tree_uuid, @@ -1192,7 +1192,8 @@ static int __rebuild_device_items(struct btrfs_trans_handle *trans, btrfs_set_stack_device_io_width(dev_item, dev->io_width); btrfs_set_stack_device_sector_size(dev_item, dev->sector_size); memcpy(dev_item->uuid, dev->uuid, BTRFS_UUID_SIZE); - memcpy(dev_item->fsid, dev->fs_devices->fsid, BTRFS_UUID_SIZE); + memcpy(dev_item->fsid, dev->fs_devices->metadata_uuid, + BTRFS_FSID_SIZE); ret = btrfs_insert_item(trans, root, &key, dev_item, sizeof(*dev_item)); @@ -1432,6 +1433,7 @@ open_ctree_with_broken_chunk(struct recover_control *rc) struct btrfs_fs_info *fs_info; struct btrfs_super_block *disk_super; struct extent_buffer *eb; + u64 features; int ret; fs_info = btrfs_new_fs_info(1, BTRFS_SUPER_INFO_OFFSET); @@ -1464,6 +1466,14 @@ open_ctree_with_broken_chunk(struct recover_control *rc) if (ret) goto out_devices; + features = btrfs_super_incompat_flags(disk_super); + + if (features & BTRFS_FEATURE_INCOMPAT_METADATA_UUID) + memcpy(fs_info->metadata_uuid, disk_super->metadata_uuid, + BTRFS_FSID_SIZE); + else + memcpy(fs_info->metadata_uuid, fs_info->fsid, BTRFS_FSID_SIZE); + btrfs_setup_root(fs_info->chunk_root, fs_info, BTRFS_CHUNK_TREE_OBJECTID); diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 06c8311bdfe3..10946b31976f 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -172,6 +172,7 @@ static int match_search_item_kernel(u8 *fsid, char *mnt, char *label, return 0; } +/* Search for user visible uuid 'search' in registered filesystems */ static int uuid_search(struct btrfs_fs_devices *fs_devices, const char *search) { char uuidbuf[BTRFS_UUID_UNPARSED_SIZE]; @@ -497,6 +498,7 @@ static int copy_fs_devices(struct btrfs_fs_devices *dst, int ret = 0; memcpy(dst->fsid, src->fsid, BTRFS_FSID_SIZE); + memcpy(dst->metadata_uuid, src->metadata_uuid, BTRFS_FSID_SIZE); INIT_LIST_HEAD(&dst->devices); dst->seed = NULL; diff --git a/cmds-inspect-dump-super.c b/cmds-inspect-dump-super.c index e965267c5d96..97e9624db8d7 100644 --- a/cmds-inspect-dump-super.c +++ b/cmds-inspect-dump-super.c @@ -228,7 +228,8 @@ static struct readable_flag_entry incompat_flags_array[] = { DEF_INCOMPAT_FLAG_ENTRY(EXTENDED_IREF), DEF_INCOMPAT_FLAG_ENTRY(RAID56), DEF_INCOMPAT_FLAG_ENTRY(SKINNY_METADATA), - DEF_INCOMPAT_FLAG_ENTRY(NO_HOLES) + DEF_INCOMPAT_FLAG_ENTRY(NO_HOLES), + DEF_INCOMPAT_FLAG_ENTRY(METADATA_UUID) }; static const int incompat_flags_num = sizeof(incompat_flags_array) / sizeof(struct readable_flag_entry); @@ -319,6 +320,10 @@ static void dump_superblock(struct btrfs_super_block *sb, int full) u8 *p; u32 csum_size; u16 csum_type; + bool metadata_uuid_present = (btrfs_super_incompat_flags(sb) & + BTRFS_FEATURE_INCOMPAT_METADATA_UUID); + int cmp_res = 0; + csum_type = btrfs_super_csum_type(sb); csum_size = BTRFS_CSUM_SIZE; @@ -365,6 +370,12 @@ static void dump_superblock(struct btrfs_super_block *sb, int full) uuid_unparse(sb->fsid, buf); printf("fsid\t\t\t%s\n", buf); + if (metadata_uuid_present) { + uuid_unparse(sb->metadata_uuid, buf); + printf("metadata_uuid\t\t%s\n", buf); + } else { + printf("metadata_uuid\t\t%s\n", buf); + } printf("label\t\t\t"); s = sb->label; @@ -424,9 +435,14 @@ static void dump_superblock(struct btrfs_super_block *sb, int full) printf("dev_item.uuid\t\t%s\n", buf); uuid_unparse(sb->dev_item.fsid, buf); + if (metadata_uuid_present) { + cmp_res = !memcmp(sb->dev_item.fsid, sb->metadata_uuid, + BTRFS_FSID_SIZE); + } else { + cmp_res = !memcmp(sb->dev_item.fsid, sb->fsid, BTRFS_FSID_SIZE); + } printf("dev_item.fsid\t\t%s %s\n", buf, - !memcmp(sb->dev_item.fsid, sb->fsid, BTRFS_FSID_SIZE) ? - "[match]" : "[DON'T MATCH]"); + cmp_res ? "[match]" : "[DON'T MATCH]"); printf("dev_item.type\t\t%llu\n", (unsigned long long) btrfs_stack_device_type(&sb->dev_item)); diff --git a/convert/common.c b/convert/common.c index 6ddf4a46ce3c..77cbaf14f3c7 100644 --- a/convert/common.c +++ b/convert/common.c @@ -107,9 +107,11 @@ static int setup_temp_super(int fd, struct btrfs_mkfs_config *cfg, ret = -EINVAL; goto out; } + uuid_copy(super->metadata_uuid, super->fsid); } else { uuid_generate(super->fsid); uuid_unparse(super->fsid, cfg->fs_uuid); + uuid_copy(super->metadata_uuid, super->fsid); } uuid_generate(chunk_uuid); uuid_unparse(chunk_uuid, cfg->chunk_uuid); diff --git a/ctree.c b/ctree.c index d8a6883aa85f..883c2ae1861d 100644 --- a/ctree.c +++ b/ctree.c @@ -134,7 +134,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, else btrfs_set_header_owner(cow, new_root_objectid); - write_extent_buffer(cow, root->fs_info->fsid, + write_extent_buffer(cow, root->fs_info->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); WARN_ON(btrfs_header_generation(buf) > trans->transid); @@ -308,7 +308,7 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans, else btrfs_set_header_owner(cow, root->root_key.objectid); - write_extent_buffer(cow, root->fs_info->fsid, + write_extent_buffer(cow, root->fs_info->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); WARN_ON(!(buf->flags & EXTENT_BAD_TRANSID) && @@ -1458,7 +1458,7 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans, btrfs_node_key(lower, &lower_key, 0); c = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize, - root->root_key.objectid, &lower_key, + root->root_key.objectid, &lower_key, level, root->node->start, 0); if (IS_ERR(c)) @@ -1474,7 +1474,7 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans, root_add_used(root, root->fs_info->nodesize); - write_extent_buffer(c, root->fs_info->fsid, + write_extent_buffer(c, root->fs_info->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(c, root->fs_info->chunk_tree_uuid, @@ -1595,7 +1595,7 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root btrfs_set_header_generation(split, trans->transid); btrfs_set_header_backref_rev(split, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(split, root->root_key.objectid); - write_extent_buffer(split, root->fs_info->fsid, + write_extent_buffer(split, root->fs_info->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(split, root->fs_info->chunk_tree_uuid, btrfs_header_chunk_tree_uuid(split), @@ -2157,7 +2157,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans, } } } - + if (split == 0) btrfs_cpu_key_to_disk(&disk_key, ins_key); else @@ -2177,7 +2177,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans, btrfs_set_header_backref_rev(right, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(right, root->root_key.objectid); btrfs_set_header_level(right, 0); - write_extent_buffer(right, root->fs_info->fsid, + write_extent_buffer(right, root->fs_info->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(right, root->fs_info->chunk_tree_uuid, diff --git a/ctree.h b/ctree.h index 4719962df67d..c22d36b1871b 100644 --- a/ctree.h +++ b/ctree.h @@ -454,8 +454,9 @@ struct btrfs_super_block { __le64 cache_generation; __le64 uuid_tree_generation; + u8 metadata_uuid[BTRFS_FSID_SIZE]; /* future expansion */ - __le64 reserved[30]; + __le64 reserved[28]; u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS]; } __attribute__ ((__packed__)); @@ -489,6 +490,7 @@ struct btrfs_super_block { #define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7) #define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8) #define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9) +#define BTRFS_FEATURE_INCOMPAT_METADATA_UUID (1ULL << 10) #define BTRFS_FEATURE_COMPAT_SUPP 0ULL @@ -509,7 +511,8 @@ struct btrfs_super_block { BTRFS_FEATURE_INCOMPAT_RAID56 | \ BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \ BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA | \ - BTRFS_FEATURE_INCOMPAT_NO_HOLES) + BTRFS_FEATURE_INCOMPAT_NO_HOLES | \ + BTRFS_FEATURE_INCOMPAT_METADATA_UUID) /* * A leaf is full of items. offset and size tell us where to find @@ -1077,6 +1080,7 @@ struct btrfs_device; struct btrfs_fs_devices; struct btrfs_fs_info { u8 fsid[BTRFS_FSID_SIZE]; + u8 metadata_uuid[BTRFS_FSID_SIZE]; u8 *new_fsid; u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; u8 *new_chunk_tree_uuid; diff --git a/disk-io.c b/disk-io.c index 26e4f6e93ed6..c3be4a1017b7 100644 --- a/disk-io.c +++ b/disk-io.c @@ -55,8 +55,9 @@ static int check_tree_block(struct btrfs_fs_info *fs_info, struct extent_buffer *buf) { - struct btrfs_fs_devices *fs_devices; + struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; u32 nodesize = fs_info->nodesize; + bool fsid_match = false; int ret = BTRFS_BAD_FSID; if (buf->start != btrfs_header_bytenr(buf)) @@ -72,12 +73,26 @@ static int check_tree_block(struct btrfs_fs_info *fs_info, btrfs_header_level(buf) != 0) return BTRFS_BAD_NRITEMS; - fs_devices = fs_info->fs_devices; while (fs_devices) { - if (fs_info->ignore_fsid_mismatch || - !memcmp_extent_buffer(buf, fs_devices->fsid, - btrfs_header_fsid(), - BTRFS_FSID_SIZE)) { + /* + * Checking the incompat flag is only valid for the current + * fs. For seed devices it's forbidden to have their uuid + * changed so reading ->fsid in this case is fine + */ + if (fs_devices == fs_info->fs_devices && + btrfs_fs_incompat(fs_info, METADATA_UUID)) + fsid_match = !memcmp_extent_buffer(buf, + fs_devices->metadata_uuid, + btrfs_header_fsid(), + BTRFS_FSID_SIZE); + else + fsid_match = !memcmp_extent_buffer(buf, + fs_devices->fsid, + btrfs_header_fsid(), + BTRFS_FSID_SIZE); + + + if (fs_info->ignore_fsid_mismatch || fsid_match) { ret = 0; break; } @@ -103,7 +118,7 @@ static void print_tree_block_error(struct btrfs_fs_info *fs_info, read_extent_buffer(eb, buf, btrfs_header_fsid(), BTRFS_UUID_SIZE); uuid_unparse(buf, found_uuid); - uuid_unparse(fs_info->fsid, fs_uuid); + uuid_unparse(fs_info->metadata_uuid, fs_uuid); fprintf(stderr, "fsid mismatch, want=%s, have=%s\n", fs_uuid, found_uuid); break; @@ -1169,6 +1184,12 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path, } memcpy(fs_info->fsid, &disk_super->fsid, BTRFS_FSID_SIZE); + if (btrfs_fs_incompat(fs_info, METADATA_UUID)) { + memcpy(fs_info->metadata_uuid, disk_super->metadata_uuid, + BTRFS_FSID_SIZE); + } else { + memcpy(fs_info->metadata_uuid, fs_info->fsid, BTRFS_FSID_SIZE); + } fs_info->sectorsize = btrfs_super_sectorsize(disk_super); fs_info->nodesize = btrfs_super_nodesize(disk_super); fs_info->stripesize = btrfs_super_stripesize(disk_super); @@ -1289,6 +1310,7 @@ static int check_super(struct btrfs_super_block *sb, unsigned sbflags) u32 crc; u16 csum_type; int csum_size; + u8 *metadata_uuid; if (btrfs_super_magic(sb) != BTRFS_MAGIC) { if (btrfs_super_magic(sb) == BTRFS_MAGIC_TEMPORARY) { @@ -1377,11 +1399,16 @@ static int check_super(struct btrfs_super_block *sb, unsigned sbflags) goto error_out; } - if (memcmp(sb->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) { + if (btrfs_super_incompat_flags(sb) & BTRFS_FEATURE_INCOMPAT_METADATA_UUID) + metadata_uuid = sb->metadata_uuid; + else + metadata_uuid = sb->fsid; + + if (memcmp(metadata_uuid, sb->dev_item.fsid, BTRFS_FSID_SIZE) != 0) { char fsid[BTRFS_UUID_UNPARSED_SIZE]; char dev_fsid[BTRFS_UUID_UNPARSED_SIZE]; - uuid_unparse(sb->fsid, fsid); + uuid_unparse(sb->metadata_uuid, fsid); uuid_unparse(sb->dev_item.fsid, dev_fsid); error("dev_item UUID does not match fsid: %s != %s", dev_fsid, fsid); @@ -1448,6 +1475,7 @@ int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr, unsigned sbflags) { u8 fsid[BTRFS_FSID_SIZE]; + u8 metadata_uuid[BTRFS_FSID_SIZE]; int fsid_is_initialized = 0; char tmp[BTRFS_SUPER_INFO_SIZE]; struct btrfs_super_block *buf = (struct btrfs_super_block *)tmp; @@ -1455,6 +1483,7 @@ int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr, int ret; int max_super = sbflags & SBREAD_RECOVER ? BTRFS_SUPER_MIRROR_MAX : 1; u64 transid = 0; + bool metadata_uuid_set = false; u64 bytenr; if (sb_bytenr != BTRFS_SUPER_INFO_OFFSET) { @@ -1499,9 +1528,18 @@ int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr, continue; if (!fsid_is_initialized) { + if (btrfs_super_incompat_flags(buf) & + BTRFS_FEATURE_INCOMPAT_METADATA_UUID) { + metadata_uuid_set = true; + memcpy(metadata_uuid, buf->metadata_uuid, + sizeof(metadata_uuid)); + } memcpy(fsid, buf->fsid, sizeof(fsid)); fsid_is_initialized = 1; - } else if (memcmp(fsid, buf->fsid, sizeof(fsid))) { + } else if (memcmp(fsid, buf->fsid, sizeof(fsid)) || + (metadata_uuid_set && memcmp(metadata_uuid, + buf->metadata_uuid, + sizeof(metadata_uuid)))) { /* * the superblocks (the original one and * its backups) contain data of different @@ -1602,7 +1640,7 @@ int write_all_supers(struct btrfs_fs_info *fs_info) btrfs_set_stack_device_io_width(dev_item, dev->io_width); btrfs_set_stack_device_sector_size(dev_item, dev->sector_size); memcpy(dev_item->uuid, dev->uuid, BTRFS_UUID_SIZE); - memcpy(dev_item->fsid, dev->fs_devices->fsid, BTRFS_UUID_SIZE); + memcpy(dev_item->fsid, fs_info->metadata_uuid, BTRFS_FSID_SIZE); flags = btrfs_super_flags(sb); btrfs_set_super_flags(sb, flags | BTRFS_HEADER_FLAG_WRITTEN); diff --git a/image/main.c b/image/main.c index 351c5a256938..efab3c44fb23 100644 --- a/image/main.c +++ b/image/main.c @@ -1401,7 +1401,7 @@ static void *restore_worker(void *data) list_del_init(&async->list); if (mdres->compress_method == COMPRESS_ZLIB) { - size = compress_size; + size = compress_size; pthread_mutex_unlock(&mdres->mutex); ret = uncompress(buffer, (unsigned long *)&size, async->buffer, async->bufsize); @@ -1593,9 +1593,12 @@ static int fill_mdres_info(struct mdrestore_struct *mdres, super = (struct btrfs_super_block *)outbuf; mdres->nodesize = btrfs_super_nodesize(super); - memcpy(mdres->fsid, super->fsid, BTRFS_FSID_SIZE); - memcpy(mdres->uuid, super->dev_item.uuid, - BTRFS_UUID_SIZE); + if (btrfs_super_incompat_flags(super) & + BTRFS_FEATURE_INCOMPAT_METADATA_UUID) + memcpy(mdres->fsid, super->metadata_uuid, BTRFS_FSID_SIZE); + else + memcpy(mdres->fsid, super->fsid, BTRFS_FSID_SIZE); + memcpy(mdres->uuid, super->dev_item.uuid, BTRFS_UUID_SIZE); mdres->devid = le64_to_cpu(super->dev_item.devid); free(buffer); return 0; @@ -1722,7 +1725,7 @@ static int read_chunk_block(struct mdrestore_struct *mdres, u8 *buffer, if (memcmp(mdres->fsid, eb->data + offsetof(struct btrfs_header, fsid), BTRFS_FSID_SIZE)) { - error("filesystem UUID of eb %llu does not match", + error("filesystem metadata UUID of eb %llu does not match", (unsigned long long)bytenr); ret = -EIO; goto out; @@ -2036,9 +2039,13 @@ static int build_chunk_tree(struct mdrestore_struct *mdres, super = (struct btrfs_super_block *)buffer; chunk_root_bytenr = btrfs_super_chunk_root(super); mdres->nodesize = btrfs_super_nodesize(super); - memcpy(mdres->fsid, super->fsid, BTRFS_FSID_SIZE); - memcpy(mdres->uuid, super->dev_item.uuid, - BTRFS_UUID_SIZE); + if (btrfs_super_incompat_flags(super) & + BTRFS_FEATURE_INCOMPAT_METADATA_UUID) + memcpy(mdres->fsid, super->metadata_uuid, BTRFS_FSID_SIZE); + else + memcpy(mdres->fsid, super->fsid, BTRFS_FSID_SIZE); + + memcpy(mdres->uuid, super->dev_item.uuid, BTRFS_UUID_SIZE); mdres->devid = le64_to_cpu(super->dev_item.devid); free(buffer); pthread_mutex_unlock(&mdres->mutex); @@ -2314,7 +2321,7 @@ static int update_disk_super_on_device(struct btrfs_fs_info *info, key.offset = cur_devid; btrfs_init_path(&path); - ret = btrfs_search_slot(NULL, info->chunk_root, &key, &path, 0, 0); + ret = btrfs_search_slot(NULL, info->chunk_root, &key, &path, 0, 0); if (ret) { error("search key failed: %d", ret); ret = -EIO; diff --git a/volumes.c b/volumes.c index d81b348eb14d..b8388194c38f 100644 --- a/volumes.c +++ b/volumes.c @@ -142,13 +142,19 @@ static struct btrfs_device *find_device(struct btrfs_fs_devices *fs_devices, return NULL; } -static struct btrfs_fs_devices *find_fsid(u8 *fsid) +static struct btrfs_fs_devices *find_fsid(u8 *fsid, u8 *metadata_uuid) { struct btrfs_fs_devices *fs_devices; list_for_each_entry(fs_devices, &fs_uuids, list) { - if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0) + if (metadata_uuid && (memcmp(fsid, fs_devices->fsid, + BTRFS_FSID_SIZE) == 0) && + (memcmp(metadata_uuid, fs_devices->metadata_uuid, + BTRFS_FSID_SIZE) == 0)) { return fs_devices; + } else if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0){ + return fs_devices; + } } return NULL; } @@ -160,8 +166,15 @@ static int device_list_add(const char *path, struct btrfs_device *device; struct btrfs_fs_devices *fs_devices; u64 found_transid = btrfs_super_generation(disk_super); + bool metadata_uuid = (btrfs_super_incompat_flags(disk_super) & + BTRFS_FEATURE_INCOMPAT_METADATA_UUID); + + if (metadata_uuid) + fs_devices = find_fsid(disk_super->fsid, + disk_super->metadata_uuid); + else + fs_devices = find_fsid(disk_super->fsid, NULL); - fs_devices = find_fsid(disk_super->fsid); if (!fs_devices) { fs_devices = kzalloc(sizeof(*fs_devices), GFP_NOFS); if (!fs_devices) @@ -169,6 +182,13 @@ static int device_list_add(const char *path, INIT_LIST_HEAD(&fs_devices->devices); list_add(&fs_devices->list, &fs_uuids); memcpy(fs_devices->fsid, disk_super->fsid, BTRFS_FSID_SIZE); + if (metadata_uuid) + memcpy(fs_devices->metadata_uuid, + disk_super->metadata_uuid, BTRFS_FSID_SIZE); + else + memcpy(fs_devices->metadata_uuid, fs_devices->fsid, + BTRFS_FSID_SIZE); + fs_devices->latest_devid = devid; fs_devices->latest_trans = found_transid; fs_devices->lowest_devid = (u64)-1; @@ -712,7 +732,7 @@ int btrfs_add_device(struct btrfs_trans_handle *trans, ptr = (unsigned long)btrfs_device_uuid(dev_item); write_extent_buffer(leaf, device->uuid, ptr, BTRFS_UUID_SIZE); ptr = (unsigned long)btrfs_device_fsid(dev_item); - write_extent_buffer(leaf, fs_info->fsid, ptr, BTRFS_UUID_SIZE); + write_extent_buffer(leaf, fs_info->metadata_uuid, ptr, BTRFS_UUID_SIZE); btrfs_mark_buffer_dirty(leaf); ret = 0; @@ -1685,7 +1705,7 @@ struct btrfs_device *btrfs_find_device(struct btrfs_fs_info *fs_info, u64 devid, cur_devices = fs_info->fs_devices; while (cur_devices) { if (!fsid || - (!memcmp(cur_devices->fsid, fsid, BTRFS_UUID_SIZE) || + (!memcmp(cur_devices->metadata_uuid, fsid, BTRFS_FSID_SIZE) || fs_info->ignore_fsid_mismatch)) { device = find_device(cur_devices, devid, uuid); if (device) @@ -1966,7 +1986,7 @@ static int open_seed_devices(struct btrfs_fs_info *fs_info, u8 *fsid) fs_devices = fs_devices->seed; } - fs_devices = find_fsid(fsid); + fs_devices = find_fsid(fsid, NULL); if (!fs_devices) { /* missing all seed devices */ fs_devices = kzalloc(sizeof(*fs_devices), GFP_NOFS); @@ -2005,7 +2025,7 @@ static int read_one_dev(struct btrfs_fs_info *fs_info, BTRFS_UUID_SIZE); read_extent_buffer(leaf, fs_uuid, (unsigned long)btrfs_device_fsid(dev_item), - BTRFS_UUID_SIZE); + BTRFS_FSID_SIZE); if (memcmp(fs_uuid, fs_info->fsid, BTRFS_UUID_SIZE)) { ret = open_seed_devices(fs_info, fs_uuid); diff --git a/volumes.h b/volumes.h index b4ea93f0bec3..f5732f6a4c0f 100644 --- a/volumes.h +++ b/volumes.h @@ -71,6 +71,7 @@ struct btrfs_device { struct btrfs_fs_devices { u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */ + u8 metadata_uuid[BTRFS_FSID_SIZE]; /* FS specific uuid */ /* the device with this id has the most recent copy of the super */ u64 latest_devid; From patchwork Thu Oct 11 15:04:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10636829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0098015E2 for ; Thu, 11 Oct 2018 15:04:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E34802B927 for ; Thu, 11 Oct 2018 15:04:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7AAA2B937; Thu, 11 Oct 2018 15:04:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 025B92B927 for ; Thu, 11 Oct 2018 15:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728002AbeJKWbs (ORCPT ); Thu, 11 Oct 2018 18:31:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:50048 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727864AbeJKWbo (ORCPT ); Thu, 11 Oct 2018 18:31:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1A9F1B616 for ; Thu, 11 Oct 2018 15:04:08 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 4/8] btrfstune: Add support for changing the user uuid Date: Thu, 11 Oct 2018 18:04:00 +0300 Message-Id: <1539270244-27076-5-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539270244-27076-1-git-send-email-nborisov@suse.com> References: <1539270244-27076-1-git-send-email-nborisov@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows us to change the use-visible UUID on filesytems from userspace if desired, by copying the existing UUID to the new location for metadata comparisons. If this is done, an incompat flag must be set to prevent older filesystems from mounting the filesystem, but the original UUID can be restored, and the incompat flag removed. This introduces the new -m|-M UUID options similar to current -u|-U UUID ones with the difference that we don't rewrite the fsid but just copy the old uuid and set a new one. Additionally running with [-M old-uuid] clears the incompat flag and retains only fsid on-disk. Additionally it's not allowed to intermix -m/-u/-U/-M options in a single invocation of btrfstune, nor is it allowed to change the uuid while there is a uuid rewrite in-progress. Also changing the uuid of a seed device is not currently allowed (can change in the future). Example: btrfstune -m /dev/loop1 btrfs inspect-internal dump-super /dev/loop1 superblock: bytenr=65536, device=/dev/loop1 --------------------------------------------------------- csum_type 0 (crc32c) csum_size 4 csum 0x4b7ea749 [match] fsid 0efc41d3-4451-49f3-8108-7b8bdbcf5ae8 metadata_uuid 352715e7-62cf-4ae0-92ee-85a574adc318 incompat_flags 0x541 ( MIXED_BACKREF | EXTENDED_IREF | SKINNY_METADATA | METADATA_UUID ) dev_item.uuid 0610deee-dfc3-498b-9449-a06533cdec98 dev_item.fsid 352715e7-62cf-4ae0-92ee-85a574adc318 [match] mount /dev/loop1 btrfs-mnt/ btrfs fi show btrfs-mnt/ Label: none uuid: 0efc41d3-4451-49f3-8108-7b8bdbcf5ae8 Total devices 1 FS bytes used 128.00KiB devid 1 size 5.00GiB used 536.00MiB path /dev/loop1 In this case a new btrfs filesystem was created and the original uuid was 352715e7-62cf-4ae0-92ee-85a574adc318, then btrfstune was run which copied that value over to metadata_uuid field and set the current fsid to 0efc41d3-4451-49f3-8108-7b8bdbcf5ae8. And as far as userspace is concerned this is the fsid of the fs. Signed-off-by: Nikolay Borisov --- btrfstune.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- ctree.h | 1 + 2 files changed, 160 insertions(+), 25 deletions(-) diff --git a/btrfstune.c b/btrfstune.c index 62a075b2defc..29610476cd99 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -73,6 +73,117 @@ static int update_seeding_flag(struct btrfs_root *root, int set_flag) return ret; } +/* + * Return 0 for no unfinished fsid change. + * Return >0 for unfinished fsid change, and restore unfinished fsid/ + * chunk_tree_id into fsid_ret/chunk_id_ret. + */ +static int check_unfinished_fsid_change(struct btrfs_fs_info *fs_info, + uuid_t fsid_ret, uuid_t chunk_id_ret) +{ + struct btrfs_root *tree_root = fs_info->tree_root; + u64 flags = btrfs_super_flags(fs_info->super_copy); + + if (flags & (BTRFS_SUPER_FLAG_CHANGING_FSID | + BTRFS_SUPER_FLAG_CHANGING_FSID_V2)) { + memcpy(fsid_ret, fs_info->super_copy->fsid, BTRFS_FSID_SIZE); + read_extent_buffer(tree_root->node, chunk_id_ret, + btrfs_header_chunk_tree_uuid(tree_root->node), + BTRFS_UUID_SIZE); + return 1; + } + return 0; +} + +static int set_metadata_uuid(struct btrfs_root *root, const char *uuid_string) +{ + struct btrfs_super_block *disk_super; + uuid_t new_fsid, unused1, unused2; + struct btrfs_trans_handle *trans; + bool new_uuid = true; + u64 incompat_flags; + bool uuid_changed; + u64 super_flags; + int ret; + + disk_super = root->fs_info->super_copy; + super_flags = btrfs_super_flags(disk_super); + incompat_flags = btrfs_super_incompat_flags(disk_super); + uuid_changed = incompat_flags & BTRFS_FEATURE_INCOMPAT_METADATA_UUID; + + if (super_flags & BTRFS_SUPER_FLAG_SEEDING) { + fprintf(stderr, "Cannot set metadata UUID on a seed device\n"); + return 1; + } + + if (check_unfinished_fsid_change(root->fs_info, unused1, unused2)) { + fprintf(stderr, "UUID rewrite in progress, cannot change " + "fsid\n"); + return 1; + } + + if (uuid_string) + uuid_parse(uuid_string, new_fsid); + else + uuid_generate(new_fsid); + + new_uuid = (memcmp(new_fsid, disk_super->fsid, BTRFS_FSID_SIZE) != 0); + + /* Step 1 sest the in progress flag */ + trans = btrfs_start_transaction(root, 1); + super_flags |= BTRFS_SUPER_FLAG_CHANGING_FSID_V2; + btrfs_set_super_flags(disk_super, super_flags); + ret = btrfs_commit_transaction(trans, root); + if (ret < 0) + return ret; + + if (new_uuid && uuid_changed && memcmp(disk_super->metadata_uuid, + new_fsid, BTRFS_FSID_SIZE) == 0) { + /* + * Changing fsid to be the same as metadata uuid, so just + * disable the flag + */ + memcpy(disk_super->fsid, &new_fsid, BTRFS_FSID_SIZE); + incompat_flags &= ~BTRFS_FEATURE_INCOMPAT_METADATA_UUID; + btrfs_set_super_incompat_flags(disk_super, incompat_flags); + memset(disk_super->metadata_uuid, 0, BTRFS_FSID_SIZE); + } else if (new_uuid && uuid_changed && memcmp(disk_super->metadata_uuid, + new_fsid, BTRFS_FSID_SIZE)) { + /* + * Changing fsid on an already changed FS, in this case we + * only change the fsid and don't touch metadata uuid as it + * has already the correct value + */ + memcpy(disk_super->fsid, &new_fsid, BTRFS_FSID_SIZE); + } else if (new_uuid && !uuid_changed) { + /* + * First time changing the fsid, copy the fsid to + * metadata_uuid + */ + incompat_flags |= BTRFS_FEATURE_INCOMPAT_METADATA_UUID; + btrfs_set_super_incompat_flags(disk_super, incompat_flags); + memcpy(disk_super->metadata_uuid, disk_super->fsid, + BTRFS_FSID_SIZE); + memcpy(disk_super->fsid, &new_fsid, BTRFS_FSID_SIZE); + } else { + /* Setting the same fsid as current NOOP */ + return 0; + } + + trans = btrfs_start_transaction(root, 1); + + /* + * Step 2 is to write the metadata_uuid, set the incompat flag and + * clear the in progress flag + */ + super_flags &= ~BTRFS_SUPER_FLAG_CHANGING_FSID_V2; + btrfs_set_super_flags(disk_super, super_flags); + + /* Then actually copy the metadata uuid and set the incompat bit */ + + return btrfs_commit_transaction(trans, root); +} + static int set_super_incompat_flags(struct btrfs_root *root, u64 flags) { struct btrfs_trans_handle *trans; @@ -268,26 +379,6 @@ static int change_fsid_done(struct btrfs_fs_info *fs_info) return write_all_supers(fs_info); } -/* - * Return 0 for no unfinished fsid change. - * Return >0 for unfinished fsid change, and restore unfinished fsid/ - * chunk_tree_id into fsid_ret/chunk_id_ret. - */ -static int check_unfinished_fsid_change(struct btrfs_fs_info *fs_info, - uuid_t fsid_ret, uuid_t chunk_id_ret) -{ - struct btrfs_root *tree_root = fs_info->tree_root; - u64 flags = btrfs_super_flags(fs_info->super_copy); - - if (flags & BTRFS_SUPER_FLAG_CHANGING_FSID) { - memcpy(fsid_ret, fs_info->super_copy->fsid, BTRFS_FSID_SIZE); - read_extent_buffer(tree_root->node, chunk_id_ret, - btrfs_header_chunk_tree_uuid(tree_root->node), - BTRFS_UUID_SIZE); - return 1; - } - return 0; -} /* * Change fsid of a given fs. @@ -381,8 +472,10 @@ static void print_usage(void) printf("\t-x \t\tenable skinny metadata extent refs\n"); printf("\t-n \t\tenable no-holes feature (more efficient sparse file representation)\n"); printf("\t-f \t\tforce to do dangerous operation, make sure that you are aware of the dangers\n"); - printf("\t-u \t\tchange fsid, use a random one\n"); - printf("\t-U UUID\t\tchange fsid to UUID\n"); + printf("\t-u \t\trewrite fsid, use a random one\n"); + printf("\t-U UUID\t\trewrite fsid to UUID\n"); + printf("\t-m \t\tChange only user-facing uuid (lighterweight than -u|-U\n"); + printf("\t-M UUID\t\tchange fsid to UUID\n"); } int main(int argc, char *argv[]) @@ -394,6 +487,7 @@ int main(int argc, char *argv[]) int seeding_flag = 0; u64 seeding_value = 0; int random_fsid = 0; + int change_metadata_uuid = 0; char *new_fsid_str = NULL; int ret; u64 super_flags = 0; @@ -404,7 +498,7 @@ int main(int argc, char *argv[]) { "help", no_argument, NULL, GETOPT_VAL_HELP}, { NULL, 0, NULL, 0 } }; - int c = getopt_long(argc, argv, "S:rxfuU:n", long_options, NULL); + int c = getopt_long(argc, argv, "S:rxfuU:nmM:", long_options, NULL); if (c < 0) break; @@ -433,6 +527,15 @@ int main(int argc, char *argv[]) ctree_flags |= OPEN_CTREE_IGNORE_FSID_MISMATCH; random_fsid = 1; break; + case 'M': + ctree_flags |= OPEN_CTREE_IGNORE_FSID_MISMATCH; + change_metadata_uuid = 1; + new_fsid_str = optarg; + break; + case 'm': + ctree_flags |= OPEN_CTREE_IGNORE_FSID_MISMATCH; + change_metadata_uuid = 1; + break; case GETOPT_VAL_HELP: default: print_usage(); @@ -451,7 +554,8 @@ int main(int argc, char *argv[]) error("random fsid can't be used with specified fsid"); return 1; } - if (!super_flags && !seeding_flag && !(random_fsid || new_fsid_str)) { + if (!super_flags && !seeding_flag && !(random_fsid || new_fsid_str) && + !change_metadata_uuid) { error("at least one option should be specified"); print_usage(); return 1; @@ -497,6 +601,12 @@ int main(int argc, char *argv[]) } if (seeding_flag) { + if (btrfs_fs_incompat(root->fs_info, METADATA_UUID)) { + fprintf(stderr, "SEED flag cannot be changed on a metadata-uuid changed fs\n"); + ret = 1; + goto out; + } + if (!seeding_value && !force) { warning( "this is dangerous, clearing the seeding flag may cause the derived device not to be mountable!"); @@ -521,7 +631,31 @@ int main(int argc, char *argv[]) total++; } - if (random_fsid || new_fsid_str) { + if (change_metadata_uuid) { + if (seeding_flag) { + fprintf(stderr, "Not allowed to set both seeding flag and uuid metadata\n"); + ret = 1; + goto out; + } + + if (new_fsid_str) + ret = set_metadata_uuid(root, new_fsid_str); + else + ret = set_metadata_uuid(root, NULL); + + if (!ret) + success++; + total++; + } + + if (random_fsid || (new_fsid_str && !change_metadata_uuid)) { + if (btrfs_fs_incompat(root->fs_info, METADATA_UUID)) { + fprintf(stderr, "Cannot rewrite fsid while METADATA_UUID flag is active." + "Ensure fsid and metadata_uuid match before retrying.\n"); + ret = 1; + goto out; + } + if (!force) { warning( "it's highly recommended to run 'btrfs check' before this operation"); diff --git a/ctree.h b/ctree.h index c22d36b1871b..ff2ae9fecc11 100644 --- a/ctree.h +++ b/ctree.h @@ -330,6 +330,7 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes) #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) #define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) +#define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36) #define BTRFS_BACKREF_REV_MAX 256 #define BTRFS_BACKREF_REV_SHIFT 56 From patchwork Thu Oct 11 15:04:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10636831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C977A16B1 for ; Thu, 11 Oct 2018 15:04:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2DAC2B927 for ; Thu, 11 Oct 2018 15:04:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6E082B92D; Thu, 11 Oct 2018 15:04:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E46C2B92A for ; Thu, 11 Oct 2018 15:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbeJKWbt (ORCPT ); Thu, 11 Oct 2018 18:31:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:50072 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728122AbeJKWbs (ORCPT ); Thu, 11 Oct 2018 18:31:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6FE26B0C4 for ; Thu, 11 Oct 2018 15:04:09 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 5/8] btrfs-progs: tests: Add tests for changing fsid feature Date: Thu, 11 Oct 2018 18:04:01 +0300 Message-Id: <1539270244-27076-6-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539270244-27076-1-git-send-email-nborisov@suse.com> References: <1539270244-27076-1-git-send-email-nborisov@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a bunch of tests exercising the new btrfstune functionality. In particular check that various restrictions are implemented correctly, test that btrfs-image works as expected and also test the output of btrfs inspect-internal dump-super is correct. Signed-off-by: Nikolay Borisov --- tests/misc-tests/033-metadata-uuid/disk1.raw.xz | Bin 0 -> 78336 bytes tests/misc-tests/033-metadata-uuid/disk2.raw.xz | Bin 0 -> 77664 bytes tests/misc-tests/033-metadata-uuid/disk3.raw.xz | Bin 0 -> 78328 bytes tests/misc-tests/033-metadata-uuid/disk4.raw.xz | Bin 0 -> 77592 bytes tests/misc-tests/033-metadata-uuid/disk5.raw.xz | Bin 0 -> 78348 bytes tests/misc-tests/033-metadata-uuid/disk6.raw.xz | Bin 0 -> 77552 bytes tests/misc-tests/033-metadata-uuid/test.sh | 225 ++++++++++++++++++++++++ 7 files changed, 225 insertions(+) create mode 100644 tests/misc-tests/033-metadata-uuid/disk1.raw.xz create mode 100644 tests/misc-tests/033-metadata-uuid/disk2.raw.xz create mode 100644 tests/misc-tests/033-metadata-uuid/disk3.raw.xz create mode 100644 tests/misc-tests/033-metadata-uuid/disk4.raw.xz create mode 100644 tests/misc-tests/033-metadata-uuid/disk5.raw.xz create mode 100644 tests/misc-tests/033-metadata-uuid/disk6.raw.xz create mode 100755 tests/misc-tests/033-metadata-uuid/test.sh diff --git a/tests/misc-tests/033-metadata-uuid/disk1.raw.xz b/tests/misc-tests/033-metadata-uuid/disk1.raw.xz new file mode 100644 index 0000000000000000000000000000000000000000..24f47d2b07553b394f273df8794f503935ab658e GIT binary patch literal 78336 zcmeI5i8s{y|Ho&t8pWSE$2S({;!7V6%}2-%k*5y~F9w#gFNDq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AOTv<{BsOwC^*zL}BrFL_!jiBgED1}(lCUH!2}{C~up}%AOHx21&Lfjuh;M8bfldHQVmO@F=|`DL7hfBlpS mZ5-Agt1Kok6tpn~1_n+s5D2xa$ok6#G?f^C`2{8m%YOoASkx{6 literal 0 HcmV?d00001 diff --git a/tests/misc-tests/033-metadata-uuid/disk3.raw.xz b/tests/misc-tests/033-metadata-uuid/disk3.raw.xz new file mode 100644 index 0000000000000000000000000000000000000000..25e9be696fef1d3ae590185a85de9ed9a2a7d012 GIT binary patch literal 78328 zcmeI5XH?YblE%BqC`e9%AUOyEl0iU8!T<)^L2?pNl++RgMB>08L4qKlk|ZOk2@)i! zC|Lo?NRAREh#;YN_spHMvv=>E3p1d8C_j5nAL`Uw_57Zy_x*24xa#O35O@=vg(^4* zRwNSwfgpdU(}cxx;GHl;AZ)j=*ra0Y897y&n^LA1O2T<2lKcqQ=f{}6-wVE$K8aMv zxYq{+XbL8g_IRX@2C-A1hIHv)I|hv0T6-4ZL2|u%z(LL2AVH{pP+Fn9W^-a84LcRK z6?dpaBC&>#4>^nNcQMubxzLuny6nJbY$gGK@VzCZ~?EnJV$kWc52b=H^qu zfnt^c4mlR7zQ-9?rppXNTlht3cx32YJ5|bNX8B@Y-JYuFwsk@4exRM#XHhp^n7iEI zZPrDNcDbQC#y{yEwz*>3QR@_2R7-)Am}&knhQBm*oGtsh23nGLyPi(Ex5dlL>>X1+ zkz^#MD(X2;(RknojDgGuf9Y&a+nnfpm#S0ZDr=&r<|FN#Nc+tY{Ty@mCrh1VY4mN4j1F+;3tQrL{K8O8 z5Um-#)t%cBN>;;(TKgO(E{va&H*fpGPV)>&YZyglw#kvQw-|1E16{w57Fs%$ADyyv z$Hw*XiPmd-vo|-i=(Z*N`mPrp;26hWtDs$+!!l8z`NGjLp$k0R>Ca2C3=j+0PlqW1a_( z*=o_59JIe7Yc^Z+S{zY%&4X7gv)s&RfzX-Nv-O2M=TBM59QpO_nDn&SGN+ueNSV6j z+@}63Qbd@4sC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1J( zVNe(phSO{~&4$x#IL!ud9i}lBSOKg6Rsbu26~GE$1+W5GF*4h6a2PlY90m>phk?Vu zVc;-u7&r`<6&W$xa9I&GhEtbO6DD|L-UvpSNAS@YjW8NvG{R_v(FmgvMk9zI* zVKn-G9gRF&#R&o8jRP%(!@TS&lCBrRCW!o#Z2ym}yaa;O(ZJ*B>G_F75W$Pvs;16Z OrZ|@P_dgzElYasEi@X&8 literal 0 HcmV?d00001 diff --git a/tests/misc-tests/033-metadata-uuid/disk5.raw.xz b/tests/misc-tests/033-metadata-uuid/disk5.raw.xz new file mode 100644 index 0000000000000000000000000000000000000000..e9095b78877555a7e2364ebb7bf4237c4796c071 GIT binary patch literal 78348 zcmeI5c{~;98pn^d?6S*FcE^@A9EP$Cvdc0>#?oX>q!dnyP)JeQs4N*#$drbbTiGBGq@x|V+QbMx zB2EMXLEmImkHhUEl{<()c&_4bNd-6^lrFQk@?n$0DMVr3G6U?W6f6S8!_m&oF5xReYEVgkDlXqiCuIUH{5ror%j$OB`F>; z=}25PoQ%z7RhgD9q#PMYM|E$Ty04w!f`%4`*2qZ6g))fY$Y5 zPIO8YDpthVw=sK6NFZ&Q{9@Pppbi=i^#H$z=a~3BT3-4upqR`YPGndQkJyrJ$5eM` zVpmMXeHyrJc{MS8W@^i#jua~BIx)BYJeB#15=pysI+VV%=4D1&9R1bhV<)YbsTy!` zBHDC6V$Zx@xhXAaSr*h&Ihi~We6w6_oNlS}2(CW1&OT6pyJpCv=9wmK$Q&wo60Nte zS5bRNL(TW`aplyA)!?MLdise|K5ftW8IYrB`UtF`rJCPDKtpJT2A5d-QIsm_H{7@z zw$!oodm18ruXyAYU)2a{I!7{}`QF*9PQ|l-NuUzflCyul_9Ar$+ z%{s}U|L%v{Tpco<{nH}H3}hb(qj@;It4v%x9jxWr&?<%IqjO>yk#ddEf%L!;sX)2n z*|cvZ5`$#eWJhQtjWEiYPnd%*`Y#=jJ zZbNC(*Z~xROFMYS4TGoI9)9#nH$Rxaj9D1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/misc-tests/033-metadata-uuid/disk6.raw.xz b/tests/misc-tests/033-metadata-uuid/disk6.raw.xz new file mode 100644 index 0000000000000000000000000000000000000000..9926ae494f53cbacd94b8bc61a3440b38f1c0ac0 GIT binary patch literal 77552 zcmeI5`#0448pmgnTNjrkLOwJGQ`3GjLXWrlE{d%6y`}>(uonRX~0%3CN zt6StrgtZVXZY>C+?%`WO+AMwe`{w{=u#m*@HFe zPxO`(&2EI2MMj#dUz+|ljQ-~dMN!Hhwvtc$Bbx)6d2wOW+>77&nK(OK43-gAy6PqM zX#G$zbvG^?Tg~aChN;* zdEe<>@$h9VOIjKh+E8xn!!M=W!%v>FG2>6Z-v>FX~qVhy!2UX@1ij zFS=4b_sdr9l?%A7? zuISjIT5-5KJ|QwxE#|X||5vGEz6A4x(Kpv?PYXXLQJDQP+M2v+IbB{4_L{GqRvjan zkwu+zuj+=1q=W5|cGpcdh3x^Ewk^%A7nW(A3BRUC-jQV@q8Ox|Ueyt0`e>Kaq~29g z#>Rqq1t%`X7E#K_uAb)K!%P_7Y^h`HBc_u3m~IvrbJt8N*ELdDV5g|yZx?Qo$o*^H zq}c}NGhWF*V_dE|zhtyo?^pe$gJ(u&DlwLH@Ah@0?>nwZoRdW9(LFIkC4+S)c}~lS zfAh3aN^k)y?n_34v+$an5%P=J((<7P!%B?Xkt$dHrRsjGv)mO@v~*+XIno=xG~;TL zsz6D%RldI>NiF@exzV)_Q>~ltkED%d-!o{cqF;D+tM!z0wP*9ip+oc~zl+?o>h*oN1_gB)$Ih>Tr5+Tkfbof%zN4fHIzqjWV7%X9AjSO#^?^h{n zFK;y1Krvv>a~9O6RjBQ5ysh8!xL}cEhOnWTtI=sOA(qG)rgxAnb800kUX?6-btL57 zaFWI%tK#UxUn0VbUD!|>=fB!gcttJ>#>Q`jg0U&?Zw0%{^Zx(xku>Ak*Cm_%=A^$c zUGrh?#_sny??_|HsTUuO^j5gjO{1ol47Ir&|2SL{WcW*zL{n&cw>TrUGnTnW&8O6N z&eP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*A1Ib!GI{rwzV5-tgsgiFFD;gWDkxFm=E)fQL* ztN>O3D}WWi3Sb4W0$8ERo0ik%^|QMHI1C&H4g-gQ!+v(>MWBw&&WnPfVBEDTC=3dN z!jN%A#uXXYpYf;m7{1x`8x#x$M!`@p z?hYAH7!(GD;pHs6oQ0RO0ImR64vn$E3Sb4W0$2g809F7ifEB=siP?^W!@yzSFmM<+ z3>*dy1BZdbz+t$1$EL77Ak((xy*;nMU$RtaACo39$~=Kz zjnN3B5%)(UTAK`EI-$dtl0I6P9U^vZ;XEdxI_$8}kh{!M0> "$RESULTS" + #Test with random uuid + run_check $SUDO_HELPER "$TOP/btrfstune" -m "$TEST_DEV" + + #check that specific uuid can set + run_check $SUDO_HELPER "$TOP/btrfstune" -M d88c8333-a652-4476-b225-2e9284eb59f1 "$TEST_DEV" + + #test that having seed on already changed device doesn't work + run_mustfail "Managed to set seed on metadata uuid fs" \ + $SUDO_HELPER "$TOP/btrfstune" -S 1 "$TEST_DEV" + + #test that setting both seed and -m|M is forbidden + run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV" + run_mustfail "Succeeded setting seed and changing fs uuid" \ + $SUDO_HELPER "$TOP/btrfstune" -S 1 -m "$TEST_DEV" + + #test that having -m|-M on seed device is forbidden + run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV" + run_check $SUDO_HELPER "$TOP/btrfstune" -S 1 "$TEST_DEV" + run_mustfail "Succeded changing fsid on a seed device" $SUDO_HELPER "$TOP/btrfstune" -m "$TEST_DEV" + + #test that using -U|-u on an fs with METADATA_UUID flag is forbidden + run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV" + run_check $SUDO_HELPER "$TOP/btrfstune" -m "$TEST_DEV" + run_mustfail "Succeeded triggering FSID rewrite while METADATA_UUID is active" \ + $SUDO_HELPER "$TOP/btrfstune" -u "$TEST_DEV" + +} + +function check_dump_super_output { + local fsid + local metadata_uuid + local dev_item_match + local old_metadata_uuid + + echo "Checking dump-super output" >> "$RESULTS" + #Assert that metadata/fsid match on non-changed fs + fsid=$(read_fsid "$TEST_DEV") + metadata_uuid=$(read_metadata_uuid "$TEST_DEV") + [ "$fsid" = "$metadata_uuid" ] || _fail "fsid ("$fsid") doesn't match metadata_uuid ("$metadata_uuid")" + + dev_item_match=$(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super \ + "$TEST_DEV" | awk '/dev_item.fsid/ {print $3}') + + [ $dev_item_match = "[match]" ] || _fail "dev_item.fsid doesn't match on non-metadata uuid fs" + + + echo "Checking output after fsid change" >> "$RESULTS" + #change metadatauuid and ensure everything in the output is still correct + old_metadata_uuid=$metadata_uuid + run_check $SUDO_HELPER "$TOP/btrfstune" -M d88c8333-a652-4476-b225-2e9284eb59f1 "$TEST_DEV" + fsid=$(read_fsid "$TEST_DEV") + metadata_uuid=$(read_metadata_uuid "$TEST_DEV") + dev_item_match=$(run_check_stdout $SUDO_HELPER "$TOP/btrfs" \ + inspect-internal dump-super "$TEST_DEV" | awk '/dev_item.fsid/ {print $3}') + + [ "$dev_item_match" = "[match]" ] || _fail "dev_item.fsid doesn't match on metadata uuid fs" + [ "$fsid" = "d88c8333-a652-4476-b225-2e9284eb59f1" ] || _fail "btrfstune metadata UUID change failed" + [ "$old_metadata_uuid" = "$metadata_uuid" ] || _fail "Metadata uuid change unexpectedly" + + echo "Checking for incompat textual representation" >> "$RESULTS" + #check for textual output of the new incompat feature + run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super \ + "$TEST_DEV" | grep -q METADATA_UUID + [ $? -eq 0 ] || _fail "Didn't find textual representation of METADATA_UUID feature" + + echo "Checking setting fsid back to original" >> "$RESULTS" + #ensure that setting the fsid back to the original works + run_check $SUDO_HELPER "$TOP/btrfstune" -M "$old_metadata_uuid" "$TEST_DEV" + + fsid=$(read_fsid "$TEST_DEV") + metadata_uuid=$(read_metadata_uuid "$TEST_DEV") + + [ "$fsid" = "$metadata_uuid" ] || _fail "FSID and METADATA_UUID don't match" + run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super \ + "$TEST_DEV" | grep -q METADATA_UUID + [ $? -eq 1 ] || _fail "METADATA_UUID feature still shown as enabled" +} + +function check_image_restore { + local metadata_uuid + local fsid + local fsid_restored + local metadata_uuid_restored + + echo "TESTING btrfs-image restore" >> "$RESULTS" + run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV" + run_check $SUDO_HELPER "$TOP/btrfstune" -m "$TEST_DEV" + fsid=$(read_fsid "$TEST_DEV") + metadata_uuid=$(read_metadata_uuid "$TEST_DEV") + run_mayfail $SUDO_HELPER "$TOP/btrfs-image" "$TEST_DEV" /tmp/test-img.dump + # erase the fs by creating a new one, wipefs is not sufficient as it just + # deletes the fs magic string + run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV" + run_check $SUDO_HELPER "$TOP/btrfs-image" -r /tmp/test-img.dump "$TEST_DEV" + fsid_restored=$(read_fsid "$TEST_DEV") + metadata_uuid_restored=$(read_metadata_uuid "$TEST_DEV") + + [ "$fsid" = "$fsid_restored" ] || _fail "FSID don't match after restore" + [ "$metadata_uuid" = "$metadata_uuid_restored" ] || _fail "metadata uuids don't match after restore" +} + +function check_inprogress_flag { + + # check the flag is indeed cleared + run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super \ + $1 | grep -q 0x1000000001 + [ $? -eq 1 ] || _fail "Found BTRFS_SUPER_FLAG_CHANGING_FSID_V2 set for $1" + + run_check_stdout $SUDO_HELPER $TOP/btrfs inspect-internal dump-super \ + $2 | grep -q 0x1000000001 + [ $? -eq 1 ] || _fail "Found BTRFS_SUPER_FLAG_CHANGING_FSID_V2 set for $2" +} + +function check_completed { + + # check that metadata uuid is indeed completed + run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super \ + $1 | grep -q METADATA_UUID + [ $? -eq 0 ] || _fail "METADATA_UUID not set on $1" + + run_check_stdout $SUDO_HELPER $TOP/btrfs inspect-internal dump-super \ + $2 | grep -q METADATA_UUID + [ $? -eq 0 ] || _fail "METADATA_UUID not set on $2" +} + +function check_multi_fsid_change { + check_inprogress_flag $1 $2 + check_completed $1 $2 +} + +function failure_recovery { + local image1 + local image2 + local loop1 + local loop2 + local devcount + + image1=$(extract_image "$1") + image2=$(extract_image "$2") + loop1=$(run_check_stdout $SUDO_HELPER losetup --find --show "$image1") + loop2=$(run_check_stdout $SUDO_HELPER losetup --find --show "$image2") + + # Mount and unmount, on trans commit all disks should be consistent + run_check $SUDO_HELPER mount "$loop1" "$TEST_MNT" + run_check $SUDO_HELPER umount "$TEST_MNT" + + # perform any specific check + $3 "$loop1" "$loop2" + + # cleanup + run_check $SUDO_HELPER losetup -d "$loop1" + run_check $SUDO_HELPER losetup -d "$loop2" + rm -f "$image1" "$image2" +} + +function reload_btrfs { + rmmod btrfs + modprobe btrfs +} + +#for full coverage we need btrfs to actually be a module +modinfo btrfs > /dev/null 2>&1 || _not_run "btrfs must be a module." +modprobe -r btrfs || _not_run "Require btrfs to be unloadable" +modprobe btrfs || _not_run "btrfs load failed" + +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV" +check_btrfstune + +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV" +check_dump_super_output + +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV" +check_image_restore + +# disk1 is an image which has no metadata uuid flags set and disk2 is part of +# the same fs but has the in-progress flag set. Test that whicever is scanned +# first will result in consistent filesystem. +failure_recovery "./disk1.raw.xz" "./disk2.raw.xz" check_inprogress_flag +reload_btrfs +failure_recovery "./disk2.raw.xz" "./disk1.raw.xz" check_inprogress_flag + +reload_btrfs + +# disk4 contains an image in with the in-progress flag set and disk 3 is part +# of the same filesystem but has both METADATA_UUID incompat and a new +# metadata uuid set. So disk 3 must always take precedence. +failure_recovery "./disk3.raw.xz" "./disk4.raw.xz" check_completed +reload_btrfs +failure_recovery "./disk4.raw.xz" "./disk3.raw.xz" check_completed + +# disk5 contains an image which has undergone a successful fsid change more +# than once, disk6 on the other hand is member of the same filesystem but +# hasn't completed its last change. Thus it has both the FSID_CHANGING flag set +# and METADATA_UUID flag set. +failure_recovery "./disk5.raw.xz" "./disk6.raw.xz" check_multi_fsid_change +reload_btrfs +failure_recovery "./disk6.raw.xz" "./disk5.raw.xz" check_multi_fsid_change From patchwork Thu Oct 11 15:04:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10636827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92AEE69B1 for ; Thu, 11 Oct 2018 15:04:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E4052B927 for ; Thu, 11 Oct 2018 15:04:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72D2F2B92A; Thu, 11 Oct 2018 15:04:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C35272B91B for ; Thu, 11 Oct 2018 15:04:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728141AbeJKWbp (ORCPT ); Thu, 11 Oct 2018 18:31:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:50054 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726843AbeJKWbo (ORCPT ); Thu, 11 Oct 2018 18:31:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B293EB615 for ; Thu, 11 Oct 2018 15:04:08 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 6/8] btrfs-progs: Remove fsid/metdata_uuid fields from fs_info Date: Thu, 11 Oct 2018 18:04:02 +0300 Message-Id: <1539270244-27076-7-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539270244-27076-1-git-send-email-nborisov@suse.com> References: <1539270244-27076-1-git-send-email-nborisov@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nikolay Borisov --- btrfstune.c | 5 +++-- check/main.c | 2 +- chunk-recover.c | 11 +++++------ ctree.c | 11 ++++++----- ctree.h | 2 -- disk-io.c | 18 +++++++++--------- volumes.c | 5 +++-- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/btrfstune.c b/btrfstune.c index 29610476cd99..c1e4fa8067e8 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -360,7 +360,8 @@ static int change_fsid_prepare(struct btrfs_fs_info *fs_info) return ret; /* Also need to change the metadatauuid of the fs info */ - memcpy(fs_info->metadata_uuid, fs_info->new_fsid, BTRFS_FSID_SIZE); + memcpy(fs_info->fs_devices->metadata_uuid, fs_info->new_fsid, + BTRFS_FSID_SIZE); /* also restore new chunk_tree_id into tree_root for restore */ write_extent_buffer(tree_root->node, fs_info->new_chunk_tree_uuid, @@ -417,7 +418,7 @@ static int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str) fs_info->new_fsid = new_fsid; fs_info->new_chunk_tree_uuid = new_chunk_id; - memcpy(old_fsid, (const char*)fs_info->fsid, BTRFS_UUID_SIZE); + memcpy(old_fsid, (const char*)fs_info->fs_devices->fsid, BTRFS_UUID_SIZE); uuid_unparse(old_fsid, uuid_buf); printf("Current fsid: %s\n", uuid_buf); diff --git a/check/main.c b/check/main.c index 0790264190f2..0aede2742dcf 100644 --- a/check/main.c +++ b/check/main.c @@ -8418,7 +8418,7 @@ static int btrfs_fsck_reinit_root(struct btrfs_trans_handle *trans, btrfs_set_header_backref_rev(c, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(c, root->root_key.objectid); - write_extent_buffer(c, root->fs_info->metadata_uuid, + write_extent_buffer(c, root->fs_info->fs_devices->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(c, root->fs_info->chunk_tree_uuid, diff --git a/chunk-recover.c b/chunk-recover.c index 31325bfc54e0..959c169f79a4 100644 --- a/chunk-recover.c +++ b/chunk-recover.c @@ -1155,7 +1155,7 @@ static int __rebuild_chunk_root(struct btrfs_trans_handle *trans, btrfs_set_header_level(cow, 0); btrfs_set_header_backref_rev(cow, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(cow, BTRFS_CHUNK_TREE_OBJECTID); - write_extent_buffer(cow, root->fs_info->metadata_uuid, + write_extent_buffer(cow, root->fs_info->fs_devices->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(cow, root->fs_info->chunk_tree_uuid, @@ -1457,7 +1457,7 @@ open_ctree_with_broken_chunk(struct recover_control *rc) goto out_devices; } - memcpy(fs_info->fsid, &disk_super->fsid, BTRFS_FSID_SIZE); + ASSERT(!memcmp(disk_super->fsid, rc->fs_devices->fsid, BTRFS_FSID_SIZE)); fs_info->sectorsize = btrfs_super_sectorsize(disk_super); fs_info->nodesize = btrfs_super_nodesize(disk_super); fs_info->stripesize = btrfs_super_stripesize(disk_super); @@ -1469,10 +1469,9 @@ open_ctree_with_broken_chunk(struct recover_control *rc) features = btrfs_super_incompat_flags(disk_super); if (features & BTRFS_FEATURE_INCOMPAT_METADATA_UUID) - memcpy(fs_info->metadata_uuid, disk_super->metadata_uuid, - BTRFS_FSID_SIZE); - else - memcpy(fs_info->metadata_uuid, fs_info->fsid, BTRFS_FSID_SIZE); + ASSERT(!memcmp(disk_super->metadata_uuid, + fs_info->fs_devices->metadata_uuid, + BTRFS_FSID_SIZE)); btrfs_setup_root(fs_info->chunk_root, fs_info, BTRFS_CHUNK_TREE_OBJECTID); diff --git a/ctree.c b/ctree.c index 883c2ae1861d..c79837e0206f 100644 --- a/ctree.c +++ b/ctree.c @@ -23,6 +23,7 @@ #include "internal.h" #include "sizes.h" #include "messages.h" +#include "volumes.h" static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, int level); @@ -134,7 +135,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, else btrfs_set_header_owner(cow, new_root_objectid); - write_extent_buffer(cow, root->fs_info->metadata_uuid, + write_extent_buffer(cow, root->fs_info->fs_devices->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); WARN_ON(btrfs_header_generation(buf) > trans->transid); @@ -308,7 +309,7 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans, else btrfs_set_header_owner(cow, root->root_key.objectid); - write_extent_buffer(cow, root->fs_info->metadata_uuid, + write_extent_buffer(cow, root->fs_info->fs_devices->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); WARN_ON(!(buf->flags & EXTENT_BAD_TRANSID) && @@ -1474,7 +1475,7 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans, root_add_used(root, root->fs_info->nodesize); - write_extent_buffer(c, root->fs_info->metadata_uuid, + write_extent_buffer(c, root->fs_info->fs_devices->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(c, root->fs_info->chunk_tree_uuid, @@ -1595,7 +1596,7 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root btrfs_set_header_generation(split, trans->transid); btrfs_set_header_backref_rev(split, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(split, root->root_key.objectid); - write_extent_buffer(split, root->fs_info->metadata_uuid, + write_extent_buffer(split, root->fs_info->fs_devices->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(split, root->fs_info->chunk_tree_uuid, btrfs_header_chunk_tree_uuid(split), @@ -2177,7 +2178,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans, btrfs_set_header_backref_rev(right, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(right, root->root_key.objectid); btrfs_set_header_level(right, 0); - write_extent_buffer(right, root->fs_info->metadata_uuid, + write_extent_buffer(right, root->fs_info->fs_devices->metadata_uuid, btrfs_header_fsid(), BTRFS_FSID_SIZE); write_extent_buffer(right, root->fs_info->chunk_tree_uuid, diff --git a/ctree.h b/ctree.h index ff2ae9fecc11..bf0c0ca86219 100644 --- a/ctree.h +++ b/ctree.h @@ -1080,8 +1080,6 @@ struct btrfs_block_group_cache { struct btrfs_device; struct btrfs_fs_devices; struct btrfs_fs_info { - u8 fsid[BTRFS_FSID_SIZE]; - u8 metadata_uuid[BTRFS_FSID_SIZE]; u8 *new_fsid; u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; u8 *new_chunk_tree_uuid; diff --git a/disk-io.c b/disk-io.c index c3be4a1017b7..e17fed13302b 100644 --- a/disk-io.c +++ b/disk-io.c @@ -118,7 +118,7 @@ static void print_tree_block_error(struct btrfs_fs_info *fs_info, read_extent_buffer(eb, buf, btrfs_header_fsid(), BTRFS_UUID_SIZE); uuid_unparse(buf, found_uuid); - uuid_unparse(fs_info->metadata_uuid, fs_uuid); + uuid_unparse(fs_info->fs_devices->metadata_uuid, fs_uuid); fprintf(stderr, "fsid mismatch, want=%s, have=%s\n", fs_uuid, found_uuid); break; @@ -1183,13 +1183,12 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path, goto out_devices; } - memcpy(fs_info->fsid, &disk_super->fsid, BTRFS_FSID_SIZE); - if (btrfs_fs_incompat(fs_info, METADATA_UUID)) { - memcpy(fs_info->metadata_uuid, disk_super->metadata_uuid, - BTRFS_FSID_SIZE); - } else { - memcpy(fs_info->metadata_uuid, fs_info->fsid, BTRFS_FSID_SIZE); - } + ASSERT(!memcmp(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE)); + ASSERT(!memcmp(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE)); + if (btrfs_fs_incompat(fs_info, METADATA_UUID)) + ASSERT(!memcmp(disk_super->metadata_uuid, + fs_devices->metadata_uuid, BTRFS_FSID_SIZE)); + fs_info->sectorsize = btrfs_super_sectorsize(disk_super); fs_info->nodesize = btrfs_super_nodesize(disk_super); fs_info->stripesize = btrfs_super_stripesize(disk_super); @@ -1640,7 +1639,8 @@ int write_all_supers(struct btrfs_fs_info *fs_info) btrfs_set_stack_device_io_width(dev_item, dev->io_width); btrfs_set_stack_device_sector_size(dev_item, dev->sector_size); memcpy(dev_item->uuid, dev->uuid, BTRFS_UUID_SIZE); - memcpy(dev_item->fsid, fs_info->metadata_uuid, BTRFS_FSID_SIZE); + memcpy(dev_item->fsid, fs_info->fs_devices->metadata_uuid, + BTRFS_FSID_SIZE); flags = btrfs_super_flags(sb); btrfs_set_super_flags(sb, flags | BTRFS_HEADER_FLAG_WRITTEN); diff --git a/volumes.c b/volumes.c index b8388194c38f..e13f120e2296 100644 --- a/volumes.c +++ b/volumes.c @@ -732,7 +732,8 @@ int btrfs_add_device(struct btrfs_trans_handle *trans, ptr = (unsigned long)btrfs_device_uuid(dev_item); write_extent_buffer(leaf, device->uuid, ptr, BTRFS_UUID_SIZE); ptr = (unsigned long)btrfs_device_fsid(dev_item); - write_extent_buffer(leaf, fs_info->metadata_uuid, ptr, BTRFS_UUID_SIZE); + write_extent_buffer(leaf, fs_info->fs_devices->metadata_uuid, ptr, + BTRFS_UUID_SIZE); btrfs_mark_buffer_dirty(leaf); ret = 0; @@ -2027,7 +2028,7 @@ static int read_one_dev(struct btrfs_fs_info *fs_info, (unsigned long)btrfs_device_fsid(dev_item), BTRFS_FSID_SIZE); - if (memcmp(fs_uuid, fs_info->fsid, BTRFS_UUID_SIZE)) { + if (memcmp(fs_uuid, fs_info->fs_devices->fsid, BTRFS_UUID_SIZE)) { ret = open_seed_devices(fs_info, fs_uuid); if (ret) return ret; From patchwork Thu Oct 11 15:04:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10636825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FD3F16B1 for ; Thu, 11 Oct 2018 15:04:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EE872B927 for ; Thu, 11 Oct 2018 15:04:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 037F12B92F; Thu, 11 Oct 2018 15:04:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6554A2B92A for ; Thu, 11 Oct 2018 15:04:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728145AbeJKWbp (ORCPT ); Thu, 11 Oct 2018 18:31:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:50060 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727370AbeJKWbo (ORCPT ); Thu, 11 Oct 2018 18:31:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 020DBACB5 for ; Thu, 11 Oct 2018 15:04:09 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 7/8] btrfs-progs: Remove btrfs_fs_info::new_fsid Date: Thu, 11 Oct 2018 18:04:03 +0300 Message-Id: <1539270244-27076-8-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539270244-27076-1-git-send-email-nborisov@suse.com> References: <1539270244-27076-1-git-send-email-nborisov@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This member was used only by btrfstune when using the old method to change fsid. It's only an in-memory value with a very specific purpose so it makes no sense to pollute a generic structure such as btrfs_fs_info with it. Just remove it and pass it as a function argument where pertinent. No functional changes. Signed-off-by: Nikolay Borisov --- btrfstune.c | 46 +++++++++++++++++++++------------------------- ctree.h | 1 - 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/btrfstune.c b/btrfstune.c index c1e4fa8067e8..d093d26f288c 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -202,15 +202,15 @@ static int set_super_incompat_flags(struct btrfs_root *root, u64 flags) return ret; } -static int change_buffer_header_uuid(struct extent_buffer *eb) +static int change_buffer_header_uuid(struct extent_buffer *eb, uuid_t new_fsid) { struct btrfs_fs_info *fs_info = eb->fs_info; int same_fsid = 1; int same_chunk_tree_uuid = 1; int ret; - same_fsid = !memcmp_extent_buffer(eb, fs_info->new_fsid, - btrfs_header_fsid(), BTRFS_FSID_SIZE); + same_fsid = !memcmp_extent_buffer(eb, new_fsid, btrfs_header_fsid(), + BTRFS_FSID_SIZE); same_chunk_tree_uuid = !memcmp_extent_buffer(eb, fs_info->new_chunk_tree_uuid, btrfs_header_chunk_tree_uuid(eb), @@ -218,7 +218,7 @@ static int change_buffer_header_uuid(struct extent_buffer *eb) if (same_fsid && same_chunk_tree_uuid) return 0; if (!same_fsid) - write_extent_buffer(eb, fs_info->new_fsid, btrfs_header_fsid(), + write_extent_buffer(eb, new_fsid, btrfs_header_fsid(), BTRFS_FSID_SIZE); if (!same_chunk_tree_uuid) write_extent_buffer(eb, fs_info->new_chunk_tree_uuid, @@ -229,7 +229,7 @@ static int change_buffer_header_uuid(struct extent_buffer *eb) return ret; } -static int change_extents_uuid(struct btrfs_fs_info *fs_info) +static int change_extents_uuid(struct btrfs_fs_info *fs_info, uuid_t new_fsid) { struct btrfs_root *root = fs_info->extent_root; struct btrfs_path path; @@ -268,7 +268,7 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info) ret = PTR_ERR(eb); goto out; } - ret = change_buffer_header_uuid(eb); + ret = change_buffer_header_uuid(eb, new_fsid); free_extent_buffer(eb); if (ret < 0) { error("failed to change uuid of tree block: %llu", @@ -290,27 +290,27 @@ static int change_extents_uuid(struct btrfs_fs_info *fs_info) return ret; } -static int change_device_uuid(struct extent_buffer *eb, int slot) +static int change_device_uuid(struct extent_buffer *eb, int slot, + uuid_t new_fsid) { struct btrfs_dev_item *di; struct btrfs_fs_info *fs_info = eb->fs_info; int ret = 0; di = btrfs_item_ptr(eb, slot, struct btrfs_dev_item); - if (!memcmp_extent_buffer(eb, fs_info->new_fsid, + if (!memcmp_extent_buffer(eb, new_fsid, (unsigned long)btrfs_device_fsid(di), BTRFS_FSID_SIZE)) return ret; - write_extent_buffer(eb, fs_info->new_fsid, - (unsigned long)btrfs_device_fsid(di), + write_extent_buffer(eb, new_fsid, (unsigned long)btrfs_device_fsid(di), BTRFS_FSID_SIZE); ret = write_tree_block(NULL, fs_info, eb); return ret; } -static int change_devices_uuid(struct btrfs_fs_info *fs_info) +static int change_devices_uuid(struct btrfs_fs_info *fs_info, uuid_t new_fsid) { struct btrfs_root *root = fs_info->chunk_root; struct btrfs_path path; @@ -328,7 +328,8 @@ static int change_devices_uuid(struct btrfs_fs_info *fs_info) if (key.type != BTRFS_DEV_ITEM_KEY || key.objectid != BTRFS_DEV_ITEMS_OBJECTID) goto next; - ret = change_device_uuid(path.nodes[0], path.slots[0]); + ret = change_device_uuid(path.nodes[0], path.slots[0], + new_fsid); if (ret < 0) goto out; next: @@ -345,7 +346,7 @@ static int change_devices_uuid(struct btrfs_fs_info *fs_info) return ret; } -static int change_fsid_prepare(struct btrfs_fs_info *fs_info) +static int change_fsid_prepare(struct btrfs_fs_info *fs_info, uuid_t new_fsid) { struct btrfs_root *tree_root = fs_info->tree_root; u64 flags = btrfs_super_flags(fs_info->super_copy); @@ -354,14 +355,13 @@ static int change_fsid_prepare(struct btrfs_fs_info *fs_info) flags |= BTRFS_SUPER_FLAG_CHANGING_FSID; btrfs_set_super_flags(fs_info->super_copy, flags); - memcpy(fs_info->super_copy->fsid, fs_info->new_fsid, BTRFS_FSID_SIZE); + memcpy(fs_info->super_copy->fsid, new_fsid, BTRFS_FSID_SIZE); ret = write_all_supers(fs_info); if (ret < 0) return ret; /* Also need to change the metadatauuid of the fs info */ - memcpy(fs_info->fs_devices->metadata_uuid, fs_info->new_fsid, - BTRFS_FSID_SIZE); + memcpy(fs_info->fs_devices->metadata_uuid, new_fsid, BTRFS_FSID_SIZE); /* also restore new chunk_tree_id into tree_root for restore */ write_extent_buffer(tree_root->node, fs_info->new_chunk_tree_uuid, @@ -415,7 +415,6 @@ static int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str) uuid_generate(new_chunk_id); } - fs_info->new_fsid = new_fsid; fs_info->new_chunk_tree_uuid = new_chunk_id; memcpy(old_fsid, (const char*)fs_info->fs_devices->fsid, BTRFS_UUID_SIZE); @@ -426,13 +425,13 @@ static int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str) printf("New fsid: %s\n", uuid_buf); /* Now we can begin fsid change */ printf("Set superblock flag CHANGING_FSID\n"); - ret = change_fsid_prepare(fs_info); + ret = change_fsid_prepare(fs_info, new_fsid); if (ret < 0) goto out; /* Change extents first */ printf("Change fsid in extents\n"); - ret = change_extents_uuid(fs_info); + ret = change_extents_uuid(fs_info, new_fsid); if (ret < 0) { error("failed to change UUID of metadata: %d", ret); goto out; @@ -440,17 +439,15 @@ static int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str) /* Then devices */ printf("Change fsid on devices\n"); - ret = change_devices_uuid(fs_info); + ret = change_devices_uuid(fs_info, new_fsid); if (ret < 0) { error("failed to change UUID of devices: %d", ret); goto out; } /* Last, change fsid in super */ - memcpy(fs_info->fs_devices->fsid, fs_info->new_fsid, - BTRFS_FSID_SIZE); - memcpy(fs_info->super_copy->fsid, fs_info->new_fsid, - BTRFS_FSID_SIZE); + memcpy(fs_info->fs_devices->fsid, new_fsid, BTRFS_FSID_SIZE); + memcpy(fs_info->super_copy->fsid, new_fsid, BTRFS_FSID_SIZE); ret = write_all_supers(fs_info); if (ret < 0) goto out; @@ -458,7 +455,6 @@ static int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str) /* Now fsid change is done */ printf("Clear superblock flag CHANGING_FSID\n"); ret = change_fsid_done(fs_info); - fs_info->new_fsid = NULL; fs_info->new_chunk_tree_uuid = NULL; printf("Fsid change finished\n"); out: diff --git a/ctree.h b/ctree.h index bf0c0ca86219..3938e8e8b0e5 100644 --- a/ctree.h +++ b/ctree.h @@ -1080,7 +1080,6 @@ struct btrfs_block_group_cache { struct btrfs_device; struct btrfs_fs_devices; struct btrfs_fs_info { - u8 *new_fsid; u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; u8 *new_chunk_tree_uuid; struct btrfs_root *fs_root; From patchwork Thu Oct 11 15:04:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Borisov X-Patchwork-Id: 10636819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81C9D15E2 for ; Thu, 11 Oct 2018 15:04:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7094B2B92A for ; Thu, 11 Oct 2018 15:04:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6527D2B92D; Thu, 11 Oct 2018 15:04:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC3732B92A for ; Thu, 11 Oct 2018 15:04:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728132AbeJKWbo (ORCPT ); Thu, 11 Oct 2018 18:31:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:50066 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728120AbeJKWbn (ORCPT ); Thu, 11 Oct 2018 18:31:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 43FF9B030 for ; Thu, 11 Oct 2018 15:04:09 +0000 (UTC) From: Nikolay Borisov To: linux-btrfs@vger.kernel.org Cc: Nikolay Borisov Subject: [PATCH 8/8] btrfs-progs: Directly pass root to change_devices_uuid Date: Thu, 11 Oct 2018 18:04:04 +0300 Message-Id: <1539270244-27076-9-git-send-email-nborisov@suse.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539270244-27076-1-git-send-email-nborisov@suse.com> References: <1539270244-27076-1-git-send-email-nborisov@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This function currently takes an fs_info only to reference the chunk root. Just pass the root directly. No functional changes. Signed-off-by: Nikolay Borisov --- btrfstune.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/btrfstune.c b/btrfstune.c index d093d26f288c..81af11e9be60 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -310,9 +310,8 @@ static int change_device_uuid(struct extent_buffer *eb, int slot, return ret; } -static int change_devices_uuid(struct btrfs_fs_info *fs_info, uuid_t new_fsid) +static int change_devices_uuid(struct btrfs_root *root, uuid_t new_fsid) { - struct btrfs_root *root = fs_info->chunk_root; struct btrfs_path path; struct btrfs_key key = {0, 0, 0}; int ret = 0; @@ -439,7 +438,7 @@ static int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str) /* Then devices */ printf("Change fsid on devices\n"); - ret = change_devices_uuid(fs_info, new_fsid); + ret = change_devices_uuid(fs_info->chunk_root, new_fsid); if (ret < 0) { error("failed to change UUID of devices: %d", ret); goto out;