Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Jun 2011 14:34:00 -0700
From:      Xin LI <delphij@delphij.net>
To:        Alexander Motin <mav@FreeBSD.org>
Cc:        "Andrey V. Elsukov" <ae@FreeBSD.org>, d@delphij.net, freebsd-geom@freebsd.org
Subject:   Re: gpart sizes way off
Message-ID:  <4DFFBCC8.5090005@delphij.net>
In-Reply-To: <4DFFB0DD.5070701@FreeBSD.org>
References:  <4DFF8611.4090705@pcbsd.org> <4DFF8DC6.1010701@FreeBSD.org>	<4DFFA14F.4030402@delphij.net> <4DFFB0DD.5070701@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 06/20/11 13:43, Alexander Motin wrote:
> On 20.06.2011 22:36, Xin LI wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>> On 06/20/11 11:13, Andrey V. Elsukov wrote:
>>> On 20.06.2011 21:40, Kris Moore wrote:
>>>>
>>>> Not sure if this has been reported, apologies if I'm late to
>>>> noticing this.
>>>>
>>>> I'm not sure if something has changed in the past few weeks on CURRENT
>>>> to cause this, or if we are just noticing it for the first time, but
>>>> when doing installs and using "gpart add" for creating partitions on a
>>>> 2nd MBR slice, the sizes we are giving it are WAY off what actually is
>>>> allocated. For example:
>>>>
>>>> # gpart add -s 2048M -t freebsd-ufs -i 1 /dev/ada0s2
>>>> ada0s2a added
>>>> # gpart add -s 1534M -t freebsd-swap -i 2 /dev/ada0s2
>>>> ada0s2b added
>>>> # gpart add -s 2048M -t freebsd-ufs -i 4 /dev/ada0s2
>>>> ada0s2d added
>>>> # gpart add -s 97165M -t freebsd-ufs -i 5 /dev/ada0s2
>>>> gpart: autofill: No space left on device
>>>
>>> Which revision do you use?
>>> Also, please, show the output of `gpart list` and `geom disk list`.
>>
>> I can reproduce the problem on -CURRENT however the cause seems to be a
>> weird one.
>>
>> Attached is a (workaround?) for this issue.
>>
>> The revision 201645 seems to have exposed this problem -- when there is
>> no stripesize, the part class exposes the absolute offset when
>> stripesize == 0, while what gpart really want to do is to align against
>> a stripe, where the stripesize is not really meaningful here.
>>
>> Alexander, would you please help to review my patch?
> 
> I think it is also not good. It will ignore useful absolute offset in
> case if user specified wanted alignment on command line. Proper fix I
> think would be in adding there:
>     offset %= alignment;

Like:

===================================================================
- --- sbin/geom/class/part/geom_part.c	(revision 223344)
+++ sbin/geom/class/part/geom_part.c	(working copy)
@@ -362,7 +362,7 @@
 			goto done;
 	}

- -	offset = pp->lg_stripeoffset / pp->lg_sectorsize;
+	offset = (pp->lg_stripeoffset / pp->lg_sectorsize) % alignment;
 	last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0);
 	LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
 		s = find_provcfg(pp, "index");
@@ -497,7 +497,7 @@
 		alignment = len;

 	/* Adjust parameters to stripeoffset */
- -	offset = pp->lg_stripeoffset / pp->lg_sectorsize;
+	offset = (pp->lg_stripeoffset / pp->lg_sectorsize) % alignment;
 	start = ALIGNUP(start + offset, alignment);
 	if (size + offset > alignment)
 		size = ALIGNDOWN(size + offset, alignment);

?

Cheers,
- -- 
Xin LI <delphij@delphij.net>	https://www.delphij.net/
FreeBSD - The Power to Serve!		Live free or die
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (FreeBSD)

iQEcBAEBCAAGBQJN/7zIAAoJEATO+BI/yjfBoCoH/iUIno+qBi0RougSPj0aa1cd
HbkdsbYy3FCjgPm2QD6JYLriZaJOAwfrtliG7mNzTkX8J4uCRwxCs6bTOcDYhUs8
y8ym1MInAdRcOKrsW+0sP9J3B7bnNePHYYtqDfmryEIxKc3Lh0xCiKPHiD3E8dUm
oyJMG+kutbxJJUkbYWGmLvrSdv7hF/cFa7DWgD9PBfbO1H2pRnq+KsV959XoBYBV
mYSDiI9zqLeHe9ClELc9UPV1wkMl0RbwkvSzpA1GHj/bTjA2KchiYUC0U1E18LHh
nTEvQdw5s6paAB5lVcf+/K9AdnVWTjqucglFV2w6LLRx4nl3b+Otu89oyEa9oc8=
=FtAq
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DFFBCC8.5090005>