All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: "Christian Völker" <cvoelker@knebb.de>, linux-btrfs@vger.kernel.org
Subject: Re: Adding Device Fails - Why?
Date: Mon, 1 Mar 2021 20:06:01 +0800	[thread overview]
Message-ID: <0a746faf-6c3c-542b-ac71-8d5012e998bc@gmx.com> (raw)
In-Reply-To: <36a13b99-7003-d114-568d-6c03b66190b2@knebb.de>

[-- Attachment #1: Type: text/plain, Size: 4259 bytes --]



On 2021/3/1 下午7:19, Christian Völker wrote:
> Hi all,
>
> I am using BTRS on a Debian10 system. I am trying to extend my existing
> filesystem with another device but adding it fails for no reason.
>
> This is my setup of existing btrfs:
>
>   2x DRBD Devices (Network RAID1)
>   top of each a luks encrypted device (crypt_drbd1 and crypt_drbd3):
>
> vdb                         254:16   0  1,1T  0 disk
> └─drbd1                     147:1    0  1,1T  0 disk
>    └─crypt_drbd1             253:3    0  1,1T  0 crypt
> vdc                         254:32   0  900G  0 disk
> └─drbd2                     147:2    0  900G  0 disk
>    └─crypt2                  253:4    0  900G  0 crypt
> vdd                         254:48   0  800G  0 disk
> └─drbd3                     147:3    0  800G  0 disk
>    └─crypt_drbd3             253:5    0  800G  0 crypt /var/lib/backuppc
>
>
>
> I have now a third drbd device (drbd2) which I encrypted, too (crypt2).
> And tried to add to existing fi.
> Here further system information:
>
> Linux backuppc41 5.10.0-3-amd64 #1 SMP Debian 5.10.13-1 (2021-02-06)
> x86_64 GNU/Linux
> btrfs-progs v5.10.1
>
> root@backuppc41:~# btrfs fi sh
> Label: 'backcuppc'  uuid: 73b98c7b-832a-437a-a15b-6cb00734e5db
>          Total devices 2 FS bytes used 1.83TiB
>          devid    3 size 799.96GiB used 789.96GiB path dm-5
>          devid    4 size 1.07TiB used 1.06TiB path dm-3
>
>
> I can create an additional btrfs filesystem with mkfs.btrfs on the new
> device without any issues:
>
> root@backuppc41:~# btrfs fi sh
> Label: 'backcuppc'  uuid: 73b98c7b-832a-437a-a15b-6cb00734e5db
>          Total devices 2 FS bytes used 1.83TiB
>          devid    3 size 799.96GiB used 789.96GiB path dm-5
>          devid    4 size 1.07TiB used 1.06TiB path dm-3
>
> Label: none  uuid: b111a08e-2969-457a-b9f1-551ff65451d1
>          Total devices 1 FS bytes used 128.00KiB
>          devid    1 size 899.96GiB used 2.02GiB path /dev/mapper/crypt2
>
>
> But I can not add this device to the existing btrfs fi:
> root@backuppc41:~# wipefs /dev/mapper/crypt2 -a
> /dev/mapper/crypt2: 8 bytes were erased at offset 0x00010040 (btrfs): 5f
> 42 48 52 66 53 5f 4d
>
> root@backuppc41:~# btrfs device add /dev/mapper/crypt2 /var/lib/backuppc/
> ERROR: error adding device 'dm-4': No such file or directory
>
> This is what I see in dmesg:
> [43827.535383] BTRFS info (device dm-5): disk added /dev/drbd2
> [43868.910994] BTRFS info (device dm-5): device deleted: /dev/drbd2
> [48125.323995] BTRFS: device fsid 2b4b631c-b500-4f8d-909c-e88b012eba1e
> devid 1 transid 5 /dev/mapper/crypt2 scanned by mkfs.btrfs (4937)
> [57799.499249] BTRFS: device fsid b111a08e-2969-457a-b9f1-551ff65451d1
> devid 1 transid 5 /dev/mapper/crypt2 scanned by mkfs.btrfs (5178)

If you can recompile btrfs module, would you mind to test the following
diff to help us debugging the problem?

Of course, after applying the diff and recompiling the module, you still
need to use the new btrfs module to try add the device again to trigger
the error.

Thanks,
Qu
>
>
>
> And these are the mapping in dm:
>
> root@backuppc41:~# ll /dev/mapper/
> insgesamt 0
> lrwxrwxrwx 1 root root       7 28. Feb 21:08 backuppc41--vg-root -> ../dm-1
> lrwxrwxrwx 1 root root       7 28. Feb 21:08 backuppc41--vg-swap_1 ->
> ../dm-2
> crw------- 1 root root 10, 236 28. Feb 21:08 control
> lrwxrwxrwx 1 root root       7  1. Mär 12:12 crypt2 -> ../dm-4
> lrwxrwxrwx 1 root root       7 28. Feb 20:21 crypt_drbd1 -> ../dm-3
> lrwxrwxrwx 1 root root       7 28. Feb 20:21 crypt_drbd3 -> ../dm-5
> lrwxrwxrwx 1 root root       7 28. Feb 21:08 vda5_crypt -> ../dm-0
>
>
> Anyone having an idea why I can not add the device to the existing
> filesystem? The error message is not really helpful...
>
> Thanks a lot!
>
> /KNEBB
>
>
>

[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 2078 bytes --]

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index b8fab44394f5..9e759a0f9c10 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2586,8 +2586,11 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 
 	bdev = blkdev_get_by_path(device_path, FMODE_WRITE | FMODE_EXCL,
 				  fs_info->bdev_holder);
-	if (IS_ERR(bdev))
+	if (IS_ERR(bdev)) {
+		pr_info("%s: failed to get blkdev: %ld\n", __func__,
+			PTR_ERR(bdev));
 		return PTR_ERR(bdev);
+	}
 
 	if (!btrfs_check_device_zone_type(fs_info, bdev)) {
 		ret = -EINVAL;
@@ -2617,6 +2620,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 	if (IS_ERR(device)) {
 		/* we can safely leave the fs_devices entry around */
 		ret = PTR_ERR(device);
+		pr_info("%s: failed to alloc dev: %d\n", __func__, ret);
 		goto error;
 	}
 
@@ -2637,6 +2641,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 	trans = btrfs_start_transaction(root, 0);
 	if (IS_ERR(trans)) {
 		ret = PTR_ERR(trans);
+		pr_info("%s: failed to start transaction: %d\n", __func__, ret);
 		goto error_free_zone;
 	}
 
@@ -2741,8 +2746,10 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 		up_write(&sb->s_umount);
 		locked = false;
 
-		if (ret) /* transaction commit */
+		if (ret) /* transaction commit */ {
+			pr_info("%s: failed to commit trans: %d\n", __func__, ret);
 			return ret;
+		}
 
 		ret = btrfs_relocate_sys_chunks(fs_info);
 		if (ret < 0)
@@ -2753,6 +2760,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 			if (PTR_ERR(trans) == -ENOENT)
 				return 0;
 			ret = PTR_ERR(trans);
+			pr_info("%s: failed to attach trans: %d\n", __func__, ret);
 			trans = NULL;
 			goto error_sysfs;
 		}
@@ -2771,6 +2779,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 	/* Update ctime/mtime for blkid or udev */
 	update_dev_time(device_path);
 
+	pr_info("%s: final ret: %d\n", __func__, ret);
 	return ret;
 
 error_sysfs:

  parent reply	other threads:[~2021-03-01 12:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 11:19 Adding Device Fails - Why? Christian Völker
2021-03-01 11:44 ` Hugo Mills
2021-03-01 12:06 ` Qu Wenruo [this message]
2021-03-01 12:10   ` Christian Völker
2021-03-01 17:24 ` Christian Völker
2021-03-02  1:18   ` Qu Wenruo
2021-03-02  7:10     ` Christian Völker
2021-03-02  7:26     ` Christian Völker
     [not found]     ` <4890dd37-3ef1-e589-9fd1-543a993436c4@knebb.de>
2021-03-02  7:31       ` Qu Wenruo
2021-03-02 21:24         ` Christian Völker

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=0a746faf-6c3c-542b-ac71-8d5012e998bc@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=cvoelker@knebb.de \
    --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.