All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v5 1/3] btrfs: add function to device list delete
Date: Thu,  7 Dec 2017 22:36:21 +0800	[thread overview]
Message-ID: <20171207143623.26710-2-anand.jain@oracle.com> (raw)
In-Reply-To: <20171207143623.26710-1-anand.jain@oracle.com>

We need device delete from the dev_list so create a new function.
New instead of refactor of btrfs_free_stale_device() because,
btrfs_free_stale_device() doesn't hold device_list_mutex which
is actually needed here.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v1: title of this patch
  btrfs: refactor btrfs_free_stale_device() to get device list delete
v2:
 delete_device_from_list() is not pealed from btrfs_free_stale_device()
 as this needs device_list_mutex. And its static now.
v3: Send to correct ML
v4: no change
v5: use helper free_device()

 fs/btrfs/volumes.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index d0dd0eb3d2e5..f53d62e92fa9 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -607,6 +607,26 @@ static void pending_bios_fn(struct btrfs_work *work)
 	run_scheduled_bios(device);
 }
 
+static void delete_device_from_list(struct btrfs_device *device)
+{
+	struct btrfs_fs_devices *fs_devices;
+
+	fs_devices = device->fs_devices;
+
+	lockdep_assert_held(&uuid_mutex);
+
+	mutex_lock(&fs_devices->device_list_mutex);
+	fs_devices->num_devices--;
+	list_del(&device->dev_list);
+	mutex_unlock(&fs_devices->device_list_mutex);
+
+	free_device(device);
+	if (fs_devices->num_devices == 0) {
+		btrfs_sysfs_remove_fsid(fs_devices);
+		list_del(&fs_devices->list);
+		free_fs_devices(fs_devices);
+	}
+}
 
 static void btrfs_free_stale_device(struct btrfs_device *cur_dev)
 {
-- 
2.7.0


  reply	other threads:[~2017-12-07 14:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 14:36 [PATCH v5 0/3] Add cli and ioctl to deregister devices Anand Jain
2017-12-07 14:36 ` Anand Jain [this message]
2017-12-07 14:36 ` [PATCH v5 2/3] btrfs: introduce feature to deregister a btrfs device Anand Jain
2017-12-07 14:36 ` [PATCH v5 3/3] btrfs: add feature to deregister all unmounted devices Anand Jain
2017-12-07 14:52 ` [PATCH v5 0/3] Add cli and ioctl to deregister devices Austin S. Hemmelgarn
2017-12-08  0:51   ` Anand Jain
2017-12-08  2:17     ` Duncan
2017-12-08 13:09       ` Austin S. Hemmelgarn
2017-12-12  7:37         ` Anand Jain
2017-12-07 14:52 ` [PATCH v5 1/2] btrfs-progs: add cli to deregister a device Anand Jain
2017-12-07 14:52   ` [PATCH v5 2/2] btrfs-progs: add feature to deregister all devices Anand Jain

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=20171207143623.26710-2-anand.jain@oracle.com \
    --to=anand.jain@oracle.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.