Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Alexandre Oliva <oliva@lsd.ic.unicamp.br>
To: Chris Mason <chris.mason@oracle.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: Don't prevent removal of devices that break raid reqs
Date: Sat, 19 Nov 2011 08:10:24 -0200	[thread overview]
Message-ID: <oraa7s778v.fsf@livre.localdomain> (raw)
In-Reply-To: <20111111022100.GD4435@shiny> (Chris Mason's message of "Thu, 10 Nov 2011 21:21:00 -0500")

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

On Nov 11, 2011, Chris Mason <chris.mason@oracle.com> wrote:

> On Thu, Nov 10, 2011 at 05:32:48PM -0200, Alexandre Oliva wrote:
>> Instead of preventing the removal of devices that would render existing
>> raid10 or raid1 impossible, warn but go ahead with it; the rebalancing
>> code is smart enough to use different block group types.

> We'll need a --force or some kind.  There are definitely cases users
> have wanted to do this but it is rarely a good idea ;)

Even if it's just metadata that will turn from raid1 to dup, as in the
revised patch below?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Btrfs-enable-removal-of-second-disk-with-raid1-metad.patch --]
[-- Type: text/x-diff, Size: 1324 bytes --]

>From 276b1af70556bf5bdbaa1f81cb630d6c83962323 Mon Sep 17 00:00:00 2001
From: Alexandre Oliva <lxoliva@fsfla.org>
Date: Tue, 8 Nov 2011 12:33:11 -0200
Subject: [PATCH 1/8] Btrfs: enable removal of second disk with raid1 metadata

Enable removal of a second disk even if that requires conversion of
metadata from raid1 to dup, but not when data would lose replication.

Signed-off-by: Alexandre Oliva <oliva@lsd.ic.unicamp.br>
---
 fs/btrfs/volumes.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c37433d..7b348c2 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1290,12 +1290,16 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
 		goto out;
 	}
 
-	if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) &&
+	if ((root->fs_info->avail_data_alloc_bits & BTRFS_BLOCK_GROUP_RAID1) &&
 	    root->fs_info->fs_devices->num_devices <= 2) {
 		printk(KERN_ERR "btrfs: unable to go below two "
 		       "devices on raid1\n");
 		ret = -EINVAL;
 		goto out;
+	} else if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) &&
+		   root->fs_info->fs_devices->num_devices <= 2) {
+		printk(KERN_ERR "btrfs: going below two devices "
+		       "will switch metadata from raid1 to dup\n");
 	}
 
 	if (strcmp(device_path, "missing") == 0) {
-- 
1.7.4.4


[-- Attachment #3: Type: text/plain, Size: 258 bytes --]



-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

  parent reply	other threads:[~2011-11-19 10:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-10 19:32 Don't prevent removal of devices that break raid reqs Alexandre Oliva
2011-11-11  2:21 ` Chris Mason
2011-11-15  9:37   ` Ilya Dryomov
2011-11-16  1:10     ` Chris Mason
2011-11-16  3:21     ` Alexandre Oliva
2011-11-19 10:10   ` Alexandre Oliva [this message]
2011-12-05 21:20 ` Phillip Susi

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=oraa7s778v.fsf@livre.localdomain \
    --to=oliva@lsd.ic.unicamp.br \
    --cc=chris.mason@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