All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Cc: Anand Jain <anand.jain@oracle.com>
Subject: [PATCH v3 1/6] btrfs: use num_device to check for the last surviving seed device
Date: Mon,  4 Oct 2021 13:19:17 -0400	[thread overview]
Message-ID: <57941caac7f14f631da079aaa150f305877c4e2f.1633367810.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1633367810.git.josef@toxicpanda.com>

From: Anand Jain <anand.jain@oracle.com>

For both sprout and seed fsids,
 btrfs_fs_devices::num_devices provides device count including missing
 btrfs_fs_devices::open_devices provides device count excluding missing

We create a dummy struct btrfs_device for the missing device, so
num_devices != open_devices when there is a missing device.

In btrfs_rm_devices() we wrongly check for %cur_devices->open_devices
before freeing the seed fs_devices. Instead we should check for
%cur_devices->num_devices.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 6031e2f4c6bc..0941f61d8071 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2211,7 +2211,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
 	synchronize_rcu();
 	btrfs_free_device(device);
 
-	if (cur_devices->open_devices == 0) {
+	if (cur_devices->num_devices == 0) {
 		list_del_init(&cur_devices->seed_list);
 		close_fs_devices(cur_devices);
 		free_fs_devices(cur_devices);
-- 
2.26.3


  reply	other threads:[~2021-10-04 17:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 17:19 [PATCH v3 0/6] Fix lockdep issues around device removal Josef Bacik
2021-10-04 17:19 ` Josef Bacik [this message]
2021-10-04 17:19 ` [PATCH v3 2/6] btrfs: add comments for device counts in struct btrfs_fs_devices Josef Bacik
2021-10-04 17:19 ` [PATCH v3 3/6] btrfs: do not call close_fs_devices in btrfs_rm_device Josef Bacik
2021-10-05  3:18   ` Anand Jain
2021-10-04 17:19 ` [PATCH v3 4/6] btrfs: handle device lookup with btrfs_dev_lookup_args Josef Bacik
2021-10-05  4:48   ` Anand Jain
2021-10-05  5:25     ` Anand Jain
2021-10-04 17:19 ` [PATCH v3 5/6] btrfs: add a btrfs_get_dev_args_from_path helper Josef Bacik
2021-10-05  5:27   ` Anand Jain
2021-10-04 17:19 ` [PATCH v3 6/6] btrfs: use btrfs_get_dev_args_from_path in dev removal ioctls Josef Bacik

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=57941caac7f14f631da079aaa150f305877c4e2f.1633367810.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=anand.jain@oracle.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.