From owner-freebsd-geom@FreeBSD.ORG Mon Jun 20 19:36:49 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 5930D10656A7; Mon, 20 Jun 2011 19:36:49 +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 01CC18FC1A; Mon, 20 Jun 2011 19:36:49 +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 63093E873; Mon, 20 Jun 2011 12:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=delphij.net; s=anubis; t=1308598608; bh=tCQlZ5XLlJJ9LRwCNMvVm8MFkc7aq5X8HlTyH1ghpS8=; h=Message-ID:Date:From:Reply-To:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type; b=o9FiBeezx3iP9opjy/x8vyiJiPxGIsjQd/VDxpycXjfK6uYg1WzTRhZp5arhrJlzY FFsXSYHop+NpGfCKZpoZWNZxvWYkBQ/Lb3kGzzeYyhKUgE7pbt7vUBH4zckQvQeDXq SP8Z/3jNNqKOT4Np0AOJ108Vad8vHeGoMrUaJWZI= Message-ID: <4DFFA14F.4030402@delphij.net> Date: Mon, 20 Jun 2011 12:36:47 -0700 From: Xin LI Organization: The FreeBSD Project MIME-Version: 1.0 To: freebsd-geom@freebsd.org References: <4DFF8611.4090705@pcbsd.org> <4DFF8DC6.1010701@FreeBSD.org> In-Reply-To: <4DFF8DC6.1010701@FreeBSD.org> OpenPGP: id=3FCA37C1; url=http://www.delphij.net/delphij.asc Content-Type: multipart/mixed; boundary="------------080804050103030201080009" Cc: Alexander Motin 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 19:36:49 -0000 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 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--