All of lore.kernel.org
 help / color / mirror / Atom feed
From: xuw2015@gmail.com
To: linux-btrfs@vger.kernel.org
Cc: George Wang <xuw2015@gmail.com>
Subject: [PATCH 3/3] btrfs: do not allow device path updated by the stale one
Date: Thu, 30 Apr 2015 17:07:25 +0800	[thread overview]
Message-ID: <1430384845-9666-3-git-send-email-xuw2015@gmail.com> (raw)
In-Reply-To: <1430384845-9666-1-git-send-email-xuw2015@gmail.com>

From: George Wang <xuw2015@gmail.com>

Use the btrfs_device->generation to identify which device(with same devid and
dev_uuid) is newer, and never allow the path updated by the stale one.
The btrfs_device->generation is corresponded with transaction id, which is
increased from old to new. Whether the fs_devices opened or not, stale device
can never get effective.

Signed-off-by: George Wang <xuw2015@gmail.com>
---
 fs/btrfs/disk-io.c | 3 +++
 fs/btrfs/volumes.c | 5 ++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 342d4fc..25faa53 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3508,6 +3508,9 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
 		if (!dev->in_fs_metadata || !dev->writeable)
 			continue;
 
+		/* update device generation according to disk super */
+		dev->generation = sb->generation;
+
 		btrfs_set_stack_device_generation(dev_item, 0);
 		btrfs_set_stack_device_type(dev_item, dev->type);
 		btrfs_set_stack_device_id(dev_item, dev->devid);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c8ece13..de6968d 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -525,10 +525,9 @@ static noinline int device_list_add(const char *path,
 		 * tracking a problem where systems fail mount by subvolume id
 		 * when we reject replacement on a mounted FS.
 		 */
-		if (!fs_devices->opened && found_transid < device->generation) {
+		if (found_transid < device->generation) {
 			/*
-			 * That is if the FS is _not_ mounted and if you
-			 * are here, that means there is more than one
+			 * If you are here, that means there is more than one
 			 * disk with same uuid and devid.We keep the one
 			 * with larger generation number or the last-in if
 			 * generation are equal.
-- 
1.9.3


  parent reply	other threads:[~2015-04-30  9:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30  9:07 [PATCH 1/3] btrfs: introduce BTRFS_BLOCK_SIZE to replace number 4096 xuw2015
2015-04-30  9:07 ` [PATCH 2/3] btrfs: support to find missing device by path xuw2015
2015-05-05 15:38   ` David Sterba
2015-05-06  9:15     ` Anand Jain
2015-05-06  9:22       ` Anand Jain
2015-05-07  2:51         ` George Wang
2015-05-07  3:17           ` Anand Jain
2015-05-07  3:47             ` George Wang
2015-04-30  9:07 ` xuw2015 [this message]
2015-05-05 15:34 ` [PATCH 1/3] btrfs: introduce BTRFS_BLOCK_SIZE to replace number 4096 David Sterba
2015-05-11  6:01   ` George Wang

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=1430384845-9666-3-git-send-email-xuw2015@gmail.com \
    --to=xuw2015@gmail.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.