linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 4/8 v2] btrfs: update sprout seed pointer when seed fs is relinquished
Date: Wed, 13 Aug 2014 14:24:22 +0800	[thread overview]
Message-ID: <1407911066-5363-4-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1407911066-5363-1-git-send-email-anand.jain@oracle.com>

We are not updating sprout fs seed pointer when all seed device
is replaced. This patch will check if all seed device has been
replaced and then update the sprout pointer accordingly.

Same reproducer as in the previous patch would apply here.
And notice that btrfs_close_device will check if seed fs is
present and spits out the error with out this patch.

int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
{
::
                seed_devices = fs_devices->seed;
::
        while (seed_devices) {
                fs_devices = seed_devices;
                seed_devices = fs_devices->seed;
                __btrfs_close_devices(fs_devices);
                free_fs_devices(fs_devices);
        }

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 v2: fixes per Miao review. also keep the list pointer update to the last

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

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index f098ae7..6716658 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1993,6 +1993,27 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info,
 	}
 
 	call_rcu(&srcdev->rcu, free_device);
+
+	/*
+	 * unless fs_devices is seed fs, num_devices shouldn't go
+	 * zero
+	 */
+	BUG_ON(!fs_devices->num_devices && !fs_devices->seeding);
+
+	/* if this is no devs we rather delete the fs_devices */
+	if (!fs_devices->num_devices) {
+		struct btrfs_fs_devices *tmp_fs_devices;
+
+		tmp_fs_devices = fs_info->fs_devices;
+		while (tmp_fs_devices) {
+			if (tmp_fs_devices->seed == fs_devices) {
+				tmp_fs_devices->seed = fs_devices->seed;
+				break;
+			}
+			tmp_fs_devices = tmp_fs_devices->seed;
+		}
+		fs_devices->seed = NULL;
+	}
 }
 
 void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
-- 
2.0.0.153.g79dcccc


  parent reply	other threads:[~2014-08-13  6:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13  6:24 [PATCH 1/8] btrfs: preparatory to make btrfs_rm_dev_replace_srcdev() seed aware Anand Jain
2014-08-13  6:24 ` [PATCH 2/8] btrfs: replace seed device followed by unmount causes kernel WARNING Anand Jain
2014-08-19 15:44   ` David Sterba
2014-08-20  2:56   ` [PATCH 2/8 v2] " Anand Jain
2014-08-13  6:24 ` [PATCH 3/8] btrfs: fix rw_devices miss match after seed replace Anand Jain
2014-08-13  6:24 ` Anand Jain [this message]
2014-08-13  6:24 ` [PATCH 5/8] btrfs: fix memory leak when there is no more seed device Anand Jain
2014-08-13  6:24 ` [PATCH 6/8] btrfs: rw_devices shouldn't be incremented for seed fs in btrfs_rm_dev_replace_srcdev() Anand Jain
2014-08-13  6:24 ` [PATCH 7/8] btrfs: fix typo in the log message Anand Jain
2014-08-13  6:24 ` [PATCH 8/8] btrfs: rename total_bytes to avoid confusion Anand Jain
2014-08-19 15:37   ` David Sterba
2014-08-20  2:54   ` [PATCH 8/8 v2] " Anand Jain
2014-08-20 14:29     ` David Sterba

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=1407911066-5363-4-git-send-email-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).