Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Jun 2011 12:36:47 -0700
From:      Xin LI <delphij@delphij.net>
To:        freebsd-geom@freebsd.org
Cc:        Alexander Motin <mav@FreeBSD.org>
Subject:   Re: gpart sizes way off
Message-ID:  <4DFFA14F.4030402@delphij.net>
In-Reply-To: <4DFF8DC6.1010701@FreeBSD.org>
References:  <4DFF8611.4090705@pcbsd.org> <4DFF8DC6.1010701@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------080804050103030201080009
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: 7bit

-----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?

====================
r201645 | mav | 2010-01-06 05:14:37 -0800 (Wed, 06 Jan 2010) | 8 lines

Change the way in which zero stripesize is handled. Instead of reporting
zero stripeoffset in such case (as if device has no stripes), report offset
from the beginning of the media (as if device has single infinite stripe).

This gives partitioning tools information, required to guess better
partition alignment, in case if hardware doesn't report it's stripe size.
For example, it should give disklabel info about odd offset made by fdisk.

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/6FOAAoJEATO+BI/yjfB20IIALN45Q9j7B2nlLrf4n4VdKVe
lgYelj6aBr8GrFFmCPrVAZ7MLlk4U9+fGziVba4g7SrFPZLZrX4QmCUo1xk3xWk4
8/0arxj0QavqcdOEgFc1iJ4fItCszaV1itRwqvQyQTHymuionyc9BqPU+Fo/ALMK
TdeZbKWVRlg/5fadVuW0cjsX48SgNY+gZlM3pvtSrHGWTxKhq3a0es6cgEg9i81I
d7sCpXSskL5jk980IzA0rgiE5uNpMqw3520cJl0PO2HcwC2UkU6I5WM6Mmdwx7An
1jSyzKm+qA5eCnIBRAWQkhsZGB9jd3AmcvyWoPxkB/H/hqAhHYh00vn8Uy4QYio=
=uwO2
-----END PGP SIGNATURE-----

--------------080804050103030201080009
Content-Type: text/plain;
 name="gpart.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="gpart.diff"

Index: sbin/geom/class/part/geom_part.c
===================================================================
--- sbin/geom/class/part/geom_part.c	(revision 223344)
+++ sbin/geom/class/part/geom_part.c	(working copy)
@@ -363,6 +363,8 @@
 	}
 
 	offset = pp->lg_stripeoffset / pp->lg_sectorsize;
+	if (pp->lg_stripesize == 0)
+		offset = 0;
 	last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0);
 	LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
 		s = find_provcfg(pp, "index");
@@ -498,6 +500,8 @@
 
 	/* Adjust parameters to stripeoffset */
 	offset = pp->lg_stripeoffset / pp->lg_sectorsize;
+	if (pp->lg_stripesize == 0)
+		offset = 0;
 	start = ALIGNUP(start + offset, alignment);
 	if (size + offset > alignment)
 		size = ALIGNDOWN(size + offset, alignment);

--------------080804050103030201080009--



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