Date: Tue, 12 Mar 2019 12:38:11 +0100 (CET) From: =?ISO-8859-1?Q?Trond_Endrest=F8l?= <Trond.Endrestol@fagskolen.gjovik.no> To: FreeBSD current <freebsd-current@freebsd.org> Subject: Re: ZFS no longer mounted in alphanumerical order Message-ID: <alpine.BSF.2.21.9999.1903121237090.315@mail.fig.ol.no> In-Reply-To: <alpine.BSF.2.21.9999.1903121211370.315@mail.fig.ol.no> References: <201903120012.x2C0CeeJ012446@gndrsh.dnsmgr.net> <e45bc5ab-af40-ad75-b5b2-8b0830aa915a@FreeBSD.org> <alpine.BSF.2.21.9999.1903121034570.315@mail.fig.ol.no> <97B0EDCF-355F-4600-8316-2B12473445A4@transactionware.com> <alpine.BSF.2.21.9999.1903121211370.315@mail.fig.ol.no>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 12 Mar 2019 12:14+0100, Trond Endrestøl wrote: > On Tue, 12 Mar 2019 11:37+0100, Jan Martin Mikkelsen wrote: > > > > On 12 Mar 2019, at 10:37, Trond Endrestøl <Trond.Endrestol@fagskolen.gjovik.no> wrote: > > > I concocted a shell script, it looks promising: > > > > > > #!/bin/sh > > > #- > > > # Parallel mounting of ZFS filesystems leaves a chaotic listing of > > > # mounted filesystems when viewed by df(1). > > > # Separating the header from the remaining lines and sorting the > > > # latter before recombining is a viable solution. > > > #- > > > > > > DF=/bin/df > > > > > > ${DF} ${@} | grep ^Filesystem > > > ${DF} ${@} | grep -v ^Filesystem | sort -k 6 > > > > > > # new-df.sh > > > > An alternative sort approach, which handles df arguments which change the number of columns, and only invokes df once: > > > > ${DF} "$@" | awk '/^Filesystem/ { print; sort = "sort -k " NF } ! /^Filesystem/ { print | sort }’ > > Well, yes and no, mostly no. > > Why are we feeding each line from df(1) separately to sort(1)? > It defeats the entire purpose. No sorting takes place. > > We might be better off accumulating the majority of the lines and > sorting them in an END block. How about this? /bin/df ${@} | /usr/bin/awk '/^Filesystem/ { print; sort = "/usr/bin/sort -sk " NF-1 } ! /^Filesystem/ { if (length(acc) > 0) acc = acc "\n" $0; else acc = $0; } END { print acc | sort }' -- Trond. From owner-freebsd-current@freebsd.org Tue Mar 12 11:55:49 2019 Return-Path: <owner-freebsd-current@freebsd.org> Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67957152E77B for <freebsd-current@mailman.ysv.freebsd.org>; Tue, 12 Mar 2019 11:55:49 +0000 (UTC) (envelope-from trond@fagskolen.gjovik.no) Received: from smtp.fagskolen.gjovik.no (smtp.fagskolen.gjovik.no [IPv6:2001:700:1100:1:200:ff:fe00:b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B0ACF8B5AC for <freebsd-current@freebsd.org>; Tue, 12 Mar 2019 11:55:48 +0000 (UTC) (envelope-from trond@fagskolen.gjovik.no) Received: from mail.fig.ol.no (localhost [127.0.0.1]) by mail.fig.ol.no (8.15.2/8.15.2) with ESMTP id x2CBtjxu092091 for <freebsd-current@freebsd.org>; Tue, 12 Mar 2019 12:55:45 +0100 (CET) (envelope-from trond@fagskolen.gjovik.no) Received: from localhost (trond@localhost) by mail.fig.ol.no (8.15.2/8.15.2/Submit) with ESMTP id x2CBtj7I092088 for <freebsd-current@freebsd.org>; Tue, 12 Mar 2019 12:55:45 +0100 (CET) (envelope-from trond@fagskolen.gjovik.no) X-Authentication-Warning: mail.fig.ol.no: trond owned process doing -bs Date: Tue, 12 Mar 2019 12:55:45 +0100 (CET) From: =?ISO-8859-1?Q?Trond_Endrest=F8l?= <Trond.Endrestol@fagskolen.gjovik.no> Sender: Trond.Endrestol@fagskolen.gjovik.no To: FreeBSD current <freebsd-current@freebsd.org> Subject: Re: ZFS no longer mounted in alphanumerical order In-Reply-To: <f87ca9b7-3c3e-63f6-511d-190c5375ebf9@FreeBSD.org> Message-ID: <alpine.BSF.2.21.9999.1903121248230.315@mail.fig.ol.no> References: <201903120012.x2C0CeeJ012446@gndrsh.dnsmgr.net> <e45bc5ab-af40-ad75-b5b2-8b0830aa915a@FreeBSD.org> <alpine.BSF.2.21.9999.1903121034570.315@mail.fig.ol.no> <f87ca9b7-3c3e-63f6-511d-190c5375ebf9@FreeBSD.org> User-Agent: Alpine 2.21.9999 (BSF 287 2018-06-16) Organization: Fagskolen Innlandet OpenPGP: url=http://fig.ol.no/~trond/trond.key MIME-Version: 1.0 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.fig.ol.no Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current <freebsd-current.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-current>, <mailto:freebsd-current-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-current/> List-Post: <mailto:freebsd-current@freebsd.org> List-Help: <mailto:freebsd-current-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-current>, <mailto:freebsd-current-request@freebsd.org?subject=subscribe> X-List-Received-Date: Tue, 12 Mar 2019 11:55:49 -0000 On Tue, 12 Mar 2019 13:27+0200, Andriy Gapon wrote: > On 12/03/2019 11:37, Trond Endrestøl wrote: > > # Parallel mounting of ZFS filesystems leaves a chaotic listing of > > # mounted filesystems when viewed by df(1). > > df reports filesystems in the order they were mounted. > If you unmount and remount a filesystem or mount a new filesystem, you can see > it for yourself. Also, if you ever used fstab then you could see that too. > Just because previously the output happened to look like it was sorted does not > mean that it was or that there was such an intention. I am aware of all of this. I was caught by surprise when my ZFS filesystems appeared partially ordered. I know that / and /dev are mounted by the kernel, and sometime later the remaining UFS/ZFS filesystems, and I also have a few synthetic filesystems mounted late in the boot process, and the latter ones (still) appear at the end of df(1)'s output. Order has somewhat been restored. Maybe it's no biggie. -- Trond. From owner-freebsd-current@freebsd.org Tue Mar 12 12:52:53 2019 Return-Path: <owner-freebsd-current@freebsd.org> Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5EC8A15304EB for <freebsd-current@mailman.ysv.freebsd.org>; Tue, 12 Mar 2019 12:52:53 +0000 (UTC) (envelope-from janm@transactionware.com) Received: from mail3.transactionware.com (mail.transactionware.com [203.14.245.7]) by mx1.freebsd.org (Postfix) with SMTP id 4E9748D42F for <freebsd-current@freebsd.org>; Tue, 12 Mar 2019 12:52:50 +0000 (UTC) (envelope-from janm@transactionware.com) Received: (qmail 61644 invoked by uid 907); 12 Mar 2019 12:52:46 -0000 Received: from p54B736ED.dip0.t-ipconnect.de (HELO [192.168.7.2]) (84.183.54.237) (smtp-auth username janm, mechanism plain) by mail3.transactionware.com (qpsmtpd/0.84) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) ESMTPSA; Tue, 12 Mar 2019 23:52:46 +1100 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: ZFS no longer mounted in alphanumerical order From: Jan Martin Mikkelsen <janm@transactionware.com> In-Reply-To: <alpine.BSF.2.21.9999.1903121211370.315@mail.fig.ol.no> Date: Tue, 12 Mar 2019 13:52:37 +0100 Cc: FreeBSD current <freebsd-current@freebsd.org> Content-Transfer-Encoding: quoted-printable Message-Id: <1A1A2A75-0DEB-4511-84B1-17E19F10FA29@transactionware.com> References: <201903120012.x2C0CeeJ012446@gndrsh.dnsmgr.net> <e45bc5ab-af40-ad75-b5b2-8b0830aa915a@FreeBSD.org> <alpine.BSF.2.21.9999.1903121034570.315@mail.fig.ol.no> <97B0EDCF-355F-4600-8316-2B12473445A4@transactionware.com> <alpine.BSF.2.21.9999.1903121211370.315@mail.fig.ol.no> To: =?utf-8?Q?Trond_Endrest=C3=B8l?= <Trond.Endrestol@fagskolen.gjovik.no> X-Mailer: Apple Mail (2.3445.9.1) X-Rspamd-Queue-Id: 4E9748D42F X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.986,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current <freebsd-current.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-current>, <mailto:freebsd-current-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-current/> List-Post: <mailto:freebsd-current@freebsd.org> List-Help: <mailto:freebsd-current-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-current>, <mailto:freebsd-current-request@freebsd.org?subject=subscribe> X-List-Received-Date: Tue, 12 Mar 2019 12:52:53 -0000 > On 12 Mar 2019, at 12:14, Trond Endrest=C3=B8l = <Trond.Endrestol@fagskolen.gjovik.no> wrote: >> An alternative sort approach, which handles df arguments which change = the number of columns, and only invokes df once: >>=20 >> ${DF} "$@" | awk '/^Filesystem/ { print; sort =3D "sort -k " NF } ! = /^Filesystem/ { print | sort }=E2=80=99 >=20 > Well, yes and no, mostly no. >=20 > Why are we feeding each line from df(1) separately to sort(1)? > It defeats the entire purpose. No sorting takes place. >=20 > We might be better off accumulating the majority of the lines and=20 > sorting them in an END block. That=E2=80=99s not how awk works. It maintains a pipe and feeds each = line to the same sort process. There is another bug there, of course. The field number should be (NF - = 1) because of the space in the =E2=80=9CMounted on=E2=80=9D header on = the last column. That=E2=80=99s what I get for just typing code into an = email. Regards, Jan M.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.21.9999.1903121237090.315>