From owner-freebsd-bugs@freebsd.org Sun Oct 25 20:14:03 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 06968457662 for ; Sun, 25 Oct 2020 20:14:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4CK8Lf6TLNz4TL1 for ; Sun, 25 Oct 2020 20:14:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id DE325457790; Sun, 25 Oct 2020 20:14:02 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DDF46457564 for ; Sun, 25 Oct 2020 20:14:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CK8Lf5XBPz4TfP for ; Sun, 25 Oct 2020 20:14:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A14B0F31A for ; Sun, 25 Oct 2020 20:14:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 09PKE2hs088913 for ; Sun, 25 Oct 2020 20:14:02 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 09PKE2Is088912 for bugs@FreeBSD.org; Sun, 25 Oct 2020 20:14:02 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 250609] gpart resize: bug in combined -a -s usage Date: Sun, 25 Oct 2020 20:14:02 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 12.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: gwbr0601@yahoo.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2020 20:14:03 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D250609 Bug ID: 250609 Summary: gpart resize: bug in combined -a -s usage Product: Base System Version: 12.1-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: gwbr0601@yahoo.de 12.1-RELEASE-p10 :~ # uname -a FreeBSD 12.1-RELEASE-p10 FreeBSD 12.1-RELEASE-p10 GENERIC amd64 At first it seemed to be a bug in the -s switch. Later i found it's the use of -a together with -s. man gpart: resize Resize a partition from geom geom and further identified by the -i index option. If the new size is not specified it is automatically calculated to be the maximum available from geom. The resize command accepts these options: -a alignment If specified, then gpart utility tries to align partition size to be a multiple of t= he alignment value. [-f ...] -i index Specifies the index of the partition to be resized. -s size Specifies the new size of the partition, in logical blocks. A SI unit suffix is allow= ed. :~ # gpart show -l ada5 =3D> 40 7814037088 ada5 GPT (3.6T) 40 2621440000 1 DLEFT2 (1.2T) 2621440040 2516582400 - free - (1.2T) 5138022440 1258291200 3 (null) (600G) 6396313640 629145600 4 (null) (300G) 7025459240 788577888 - free - (376G) Inital condition: p1 is part of zpool raidz1. The pool should grow to ~2T. = p3 and p4 are ufs placeholders to demonstrate the bug. :~ # gpart resize -a 4k -i 1 -s 2691000000 ada5 ada5p1 resized :~ # gpart show -l ada5 =3D> 40 7814037088 ada5 GPT (3.6T) 40 5138022400 1 DLEFT2 (2.4T) 5138022440 1258291200 3 (null) (600G) 6396313640 629145600 4 (null) (300G) 7025459240 788577888 - free - (376G) It started when i noticed that the -s SIZE was ignored and all following fr= ee space was used. :~ # gpart resize -a 4k -i 1 -s 2691000000 ada5 gpart: Device busy This may be normal, the partition 1 is part of the active but unmounted poo= l. :~ # gpart delete -i 3 ada5 ada5p3 deleted :~ # gpart show -l ada5 =3D> 40 7814037088 ada5 GPT (3.6T) 40 5138022400 1 DLEFT2 (2.4T) 5138022440 1258291200 - free - (600G) 6396313640 629145600 4 (null) (300G) 7025459240 788577888 - free - (376G) :~ # gpart resize -a 4k -i 1 -s 2.5T ada5 gpart: Invalid size param: Invalid argument (Side topic: gpart doesn't understand it's own size format.) (Personally i try to talk back to software like it talks to me. ;-) ) :~ # gpart resize -a 4k -i 1 -s 2600G ada5 ada5p1 resized :~ # gpart show -l ada5 =3D> 40 7814037088 ada5 GPT (3.6T) 40 6396313600 1 DLEFT2 (3.0T) 6396313640 629145600 4 (null) (300G) 7025459240 788577888 - free - (376G) :~ # gpart show ada5 =3D> 40 7814037088 ada5 GPT (3.6T) 40 6396313600 1 freebsd-zfs (3.0T) 6396313640 629145600 4 freebsd-ufs (300G) 7025459240 788577888 - free - (376G) Again -s SIZE was ignored and all next free space was used. I was able to repeat the test on another machine because i had a spare disk available. Fresh FreeBSD installation. Same version level. Same size of the partition layout but p1 was set to UFS. :~ # gpart resize -a 4k -i 1 -s 2691000000 ada1 ada1p1 resized The first time i got the same result as above. The -s was ignored and a res= ize to maximum was performed. The second time (cursor up, return) the size was = set (reduced) correctly. That was reproducable. It needed two times of the same resize command to set the new size. Suspected bug: gpart resize size switch calculation fails on partially partitioned disks. Workaround as seen above: Add a new dummy partition of the expansion size. = Add a fill partition on the rest of the disk. Delete the dummy partition. Resize the first partition with or without the -s switch. Delete the fill partitio= n. [i found more] Back to the first system, same zpool, same disk model, same p1 layout, dummy partitions created: :~ # gpart show -l ada4 =3D> 40 7814037088 ada4 GPT (3.6T) 40 2516582400 1 DLEFT1 (1.2T) 2516582440 545259520 - free - (260G) 3061841960 1048576000 3 (null) (500G) 4110417960 1048576000 4 (null) (500G) 5158993960 1048576000 5 (null) (500G) 6207569960 1048576000 6 (null) (500G) 7256145960 545259520 7 (null) (260G) 7801405480 12631648 - free - (6.0G) # # 2516582400 old size :~ # gpart resize -i 1 -s 2716582400 ada4 ada4p1 resized :~ # gpart show -l ada4 =3D> 40 7814037088 ada4 GPT (3.6T) 40 2716582400 1 DLEFT1 (1.3T) 2716582440 345259520 - free - (165G) [...] ?? Now it worked. SIZE is set as -s told. :~ # gpart resize -i 1 -s 2730000000 ada4 ada4p1 resized :~ # gpart show -l ada4 =3D> 40 7814037088 ada4 GPT (3.6T) 40 2730000000 1 DLEFT1 (1.3T) 2730000040 331841920 - free - (158G) [...] Worked again. Now 274... with alignment: :~ # gpart resize -a 4k -i 1 -s 2740000000 ada4 ada4p1 resized :~ # gpart show -l ada4 =3D> 40 7814037088 ada4 GPT (3.6T) 40 3061841920 1 DLEFT1 (1.4T) 3061841960 1048576000 3 (null) (500G) [...] Failed. -s SIZE seems to be ignored when the -a ALIGNMENT is used. --=20 You are receiving this mail because: You are the assignee for the bug.=