From owner-freebsd-geom@FreeBSD.ORG Mon Jun 20 21:34:01 2011 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6DB11065674; Mon, 20 Jun 2011 21:34:01 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from anubis.delphij.net (anubis.delphij.net [IPv6:2001:470:1:117::25]) by mx1.freebsd.org (Postfix) with ESMTP id BBB458FC18; Mon, 20 Jun 2011 21:34:01 +0000 (UTC) Received: from delta.delphij.net (drawbridge.ixsystems.com [206.40.55.65]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by anubis.delphij.net (Postfix) with ESMTPSA id 7E94DEDB2; Mon, 20 Jun 2011 14:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=delphij.net; s=anubis; t=1308605641; bh=QG30Hc6q6SD8AVZAEBL6e76i5wWsKuLsYA9yfqChJws=; h=Message-ID:Date:From:Reply-To:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=KdimiT8RcC5oHINp7Ps9VvECLCy4Ptyvewp43FbU+HYZdvBvNwDTJl5pPu2o34UEk lq2wpcZTsbbq+zYYjpbJGbDcHF8iR7MO3ObtFdR1t8FNM7E1Waoya37FaH+d2ROW+J padSKvycXzKZD7/86vwlbMvhrC5Dh1pk9jlBgpSk= Message-ID: <4DFFBCC8.5090005@delphij.net> Date: Mon, 20 Jun 2011 14:34:00 -0700 From: Xin LI Organization: The FreeBSD Project MIME-Version: 1.0 To: Alexander Motin References: <4DFF8611.4090705@pcbsd.org> <4DFF8DC6.1010701@FreeBSD.org> <4DFFA14F.4030402@delphij.net> <4DFFB0DD.5070701@FreeBSD.org> In-Reply-To: <4DFFB0DD.5070701@FreeBSD.org> OpenPGP: id=3FCA37C1; url=http://www.delphij.net/delphij.asc Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Cc: "Andrey V. Elsukov" , d@delphij.net, freebsd-geom@freebsd.org Subject: Re: gpart sizes way off X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2011 21:34:02 -0000 -----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 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-----