From: NeilBrown <neilb@suse.de>
To: Brassow Jonathan <jbrassow@redhat.com>
Cc: dm-devel@redhat.com, linux-raid@vger.kernel.org, agk@redhat.com
Subject: Re: [PATCH v2] DM RAID: Add support for MD RAID10
Date: Wed, 18 Jul 2012 11:11:46 +1000 [thread overview]
Message-ID: <20120718111146.336c3228@notabene.brown> (raw)
In-Reply-To: <3A8FC300-59E8-48CA-81DF-CCCF780BFE0C@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4399 bytes --]
On Tue, 17 Jul 2012 11:15:56 -0500 Brassow Jonathan <jbrassow@redhat.com>
wrote:
>
> On Jul 16, 2012, at 9:34 PM, NeilBrown wrote:
>
> >>>>
> >>>> @@ -536,9 +605,25 @@ static int parse_raid_params(struct raid
> >>>> if (dm_set_target_max_io_len(rs->ti, max_io_len))
> >>>> return -EINVAL;
> >>>>
> >>>> - if ((rs->raid_type->level > 1) &&
> >>>> - sector_div(sectors_per_dev, (rs->md.raid_disks - rs->raid_type->parity_devs))) {
> >>>> + if (rs->raid_type->level == 10) {
> >>>> + /* (Len * Stripes) / Mirrors */
> >>>> + sectors_per_dev *= rs->md.raid_disks;
> >>>> + if (sector_div(sectors_per_dev, raid10_copies)) {
> >>>> + rs->ti->error = "Target length not divisible by number of data devices";
> >>>> + return -EINVAL;
> >>>> + }
> >>>
> >>> I'm not entirely sure what you are trying to do here, but I don't think it
> >>> works.
> >>>
> >>> At the very least you would need to convert the "sectors_per_dev" number to a
> >>> 'chunks_per_dev' before multiplying by raid_disks and dividing by copies.
> >>>
> >>> But even that isn't necessary. If you have a 3-device near=2 array with an
> >>> odd number of chunks per device, that will still work. The last chunk won't
> >>> be mirrored, so won't be used.
> >>> Until a couple of weeks ago a recovery of the last device would trigger an
> >>> error when we try to recover that last chunk, but that is fixed now.
> >>>
> >>> So if you want to impose this limitation (and there is some merit in making
> >>> sure people don't confuse themselves), I suggest it get imposed in the
> >>> user-space tools which create the RAID10.
> >>
> >> I have seen what you do in calc_sectors(), I suppose I could bring that in. However, I'm simply trying to find the value that will be preliminarily assigned to mddev->dev_sectors. It is an enforced (perhaps unnecessary) constraint that the array length be divisible by the number of data devices. I'm not accounting for chunk boundaries - I leave that to userspace to configure and MD to catch.
> >
> > In that case I suggest you keep it out of dmraid.
> >
> > It might make sense to check that the resulting array size matches what
> > user-space said to expect - or is at-least-as-big-as. However I don't see
> > much point in other size changes there.
>
> I'm not changing any sizes. I'm finding a value for mddev->dev_sectors (what should I set it to if not the above?), which is the size of each device as computed from the total array size. If the value can't be computed evenly, then an error is given. I'm not sure what you are suggesting my alternative is when you say, "keep it out of dm-raid"... I think this is the least I can do in dm-raid.
Sorry, I mean 'checks', not 'changes'.
I was confused a bit by the code. It might be clearer to have
sectors_per_dev = ti->len * rs->md.raid_disks;
remainder = sector_div(sectors_per_dev, raid10_copies);
In almost all cases raid10_copies will be 2 and ti->len will be a multiple of
8 (as we don't support chunk sizes less than 4K), so remainder will be 0.
However this doesn't really prove anything. It is still entirely possible
that the resulting 'sectors_per_dev' will not result in a RAID10 which has
the full ti->len sectors required.
So your test is not sufficient.
Also your calculation is incorrect as it doesn't allow for the possibility of
unused space in the array.
A 3-drive 2-copy RAID10 with an odd number of chunks will not use the last
chunk on the last device. In that case the above calculation will result in
a sectors_per_dev that it too small.
I think your sectors_per_dev calculation should round up to a whole number of
chunks.
sectors_per_dev = DIV_ROUND_UP_SECTOR_T(ti->len * rs->md.raid_disks,
raid10_copies);
sectors_per_dev = round_up(sectors_per_dev, rs->md.chunk_sectors);
And then after calling md_run(), you should check that
pers->size(mddev, 0, 0) == ti->len
and abort if not.
Note that getting the sectors_per_dev right is really really important for
RAID10-far. For other layouts and levels a smaller sectors_per_dev will just
result in less data being available.
For raid10-far, sectors_per_dev is included in the layout calculations so
changing it will change the location of data and could result in corruption.
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2012-07-18 1:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-12 1:36 [PATCH v2] DM RAID: Add support for MD RAID10 Jonathan Brassow
2012-07-12 6:32 ` NeilBrown
2012-07-12 9:56 ` Alasdair G Kergon
2012-07-12 11:43 ` NeilBrown
2012-07-16 22:06 ` Brassow Jonathan
2012-07-17 2:34 ` NeilBrown
2012-07-17 16:15 ` Brassow Jonathan
2012-07-18 1:11 ` NeilBrown [this message]
2012-07-18 14:45 ` Brassow Jonathan
2012-07-12 16:22 ` keld
2012-07-12 19:00 ` Brassow Jonathan
2012-07-13 1:15 ` keld
2012-07-13 1:27 ` NeilBrown
2012-07-13 8:29 ` keld
2012-07-16 6:14 ` NeilBrown
2012-07-16 8:28 ` keld
2012-07-16 22:53 ` Brassow Jonathan
2012-07-17 2:29 ` NeilBrown
2012-07-17 20:30 ` Brassow Jonathan
2012-07-17 2:40 ` NeilBrown
2012-07-18 7:20 ` keld
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=20120718111146.336c3228@notabene.brown \
--to=neilb@suse.de \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=jbrassow@redhat.com \
--cc=linux-raid@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).