linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugo Mills <hugo@carfax.org.uk>
To: Btrfs mailing list <linux-btrfs@vger.kernel.org>,
	Chris Mason <chris.mason@oracle.com>,
	David Sterba <dave@jikos.cz>
Subject: Re: [PATCH v8 7/8] btrfs: Replication-type information
Date: Tue, 28 Jun 2011 20:26:43 +0100	[thread overview]
Message-ID: <20110628192643.GC24675@carfax.org.uk> (raw)
In-Reply-To: <20110628163243.GS12709@twin.jikos.cz>

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

On Tue, Jun 28, 2011 at 06:32:43PM +0200, David Sterba wrote:
> On Sun, Jun 26, 2011 at 09:36:54PM +0100, Hugo Mills wrote:
> > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> > index 828aa34..fb11550 100644
> > --- a/fs/btrfs/volumes.c
> > +++ b/fs/btrfs/volumes.c
> > @@ -117,6 +117,52 @@ static void requeue_list(struct btrfs_pending_bios *pending_bios,
> >  		pending_bios->tail = tail;
> >  }
> >  
> > +void btrfs_get_replication_info(struct btrfs_replication_info *info,
> > +								u64 type)
> > +{
> > +	info->sub_stripes = 1;
> > +	info->dev_stripes = 1;
> > +	info->devs_increment = 1;
> > +	info->num_copies = 1;
> > +	info->devs_max = 0;	/* 0 == as many as possible */
> > +	info->devs_min = 1;
> > +
> > +	if (type & BTRFS_BLOCK_GROUP_DUP) {
> > +		info->dev_stripes = 2;
> > +		info->num_copies = 2;
> > +		info->devs_max = 1;
> > +	} else if (type & BTRFS_BLOCK_GROUP_RAID0) {
> > +		info->devs_min = 2;
> > +	} else if (type & BTRFS_BLOCK_GROUP_RAID1) {
> > +		info->devs_increment = 2;
> > +		info->num_copies = 2;
> > +		info->devs_max = 2;
> > +		info->devs_min = 2;
> > +	} else if (type & BTRFS_BLOCK_GROUP_RAID10) {
> > +		info->sub_stripes = 2;
> > +		info->devs_increment = 2;
> > +		info->num_copies = 2;
> > +		info->devs_min = 4;
> > +	}
> > +
> > +	if (type & BTRFS_BLOCK_GROUP_DATA) {
> > +		info->max_stripe_size = 1024 * 1024 * 1024;
> > +		info->min_stripe_size = 64 * 1024 * 1024;
> > +		info->max_chunk_size = 10 * info->max_stripe_size;
> > +	} else if (type & BTRFS_BLOCK_GROUP_METADATA) {
> > +		info->max_stripe_size = 256 * 1024 * 1024;
> > +		info->min_stripe_size = 32 * 1024 * 1024;
> > +		info->max_chunk_size = info->max_stripe_size;
> > +	} else if (type & BTRFS_BLOCK_GROUP_SYSTEM) {
> > +		info->max_stripe_size = 8 * 1024 * 1024;
> > +		info->min_stripe_size = 1 * 1024 * 1024;
> > +		info->max_chunk_size = 2 * info->max_stripe_size;
> > +	} else {
> > +		printk(KERN_ERR "Block group is of an unknown usage type: not data, metadata or system.\n");
> > +		BUG_ON(1);

   From inspection, this looks like it's a viable solution:

+               info->max_stripe_size = 0;
+               info->min_stripe_size = -1ULL;
+               info->max_chunk_size = 0;

We only run into problems if a user of this function passes a
RAID-only block group type and then tries to use the size parameters
from it. There's only three users of the function currently, and this
case is the only one that doesn't pass a "real" block group type flag.

   I'll run a quick test of dev rm and see what happens...

> I'm hitting this BUG_ON with 'btrfs device delete', type = 24 which is
> BTRFS_BLOCK_GROUP_RAID0 + BTRFS_BLOCK_GROUP_RAID1 .
> 
> in btrfs_rm_device:
> 
> 1277         all_avail = root->fs_info->avail_data_alloc_bits |
> 1278                 root->fs_info->avail_system_alloc_bits |
> 1279                 root->fs_info->avail_metadata_alloc_bits;
> 
> the values before the call are:
> 
> [  105.107074] D: all_avail 24
> [  105.111844] D: root->fs_info->avail_data_alloc_bits 8
> [  105.118858] D: root->fs_info->avail_system_alloc_bits 16
> [  105.126110] D: root->fs_info->avail_metadata_alloc_bits 16
> 
> 
> there are 5 devices, sdb5 - sdb9, i'm removing sdb9, after clean
> mount.
> 
> 
> david

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
               --- vi vi vi:  the Editor of the Beast. ---               

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

  reply	other threads:[~2011-06-28 19:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-26 20:36 [PATCH v8 0/8] Balance management patches, v8 Hugo Mills
2011-06-26 20:36 ` [PATCH v8 1/8] btrfs: Balance progress monitoring Hugo Mills
2011-06-26 20:36 ` [PATCH v8 2/8] btrfs: Cancel filesystem balance Hugo Mills
2011-06-29  6:00   ` Li Zefan
2011-06-29 10:43     ` David Sterba
2011-06-26 20:36 ` [PATCH v8 3/8] btrfs: Factor out enumeration of chunks to a separate function Hugo Mills
2011-06-26 20:36 ` [PATCH v8 4/8] btrfs: Implement filtered balance ioctl Hugo Mills
2011-06-26 20:36 ` [PATCH v8 5/8] btrfs: Balance filter for device ID Hugo Mills
2011-06-26 20:36 ` [PATCH v8 6/8] btrfs: Balance filter for virtual address ranges Hugo Mills
2011-06-26 20:36 ` [PATCH v8 7/8] btrfs: Replication-type information Hugo Mills
2011-06-28 16:32   ` David Sterba
2011-06-28 19:26     ` Hugo Mills [this message]
2011-06-28 20:41       ` Ilya Dryomov
2011-06-26 20:36 ` [PATCH v8 8/8] btrfs: Balance filter for physical device address Hugo Mills

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=20110628192643.GC24675@carfax.org.uk \
    --to=hugo@carfax.org.uk \
    --cc=chris.mason@oracle.com \
    --cc=dave@jikos.cz \
    --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).