From: Lukas Czerner <lczerner@redhat.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>,
darrick.wong@oracle.com
Subject: Re: [PATCH 8/9] e2scrub_all: refactor device probe loop
Date: Thu, 21 Mar 2019 16:57:03 +0100 [thread overview]
Message-ID: <20190321155703.ili5ghofgm3hneq5@work> (raw)
In-Reply-To: <20190321143141.GB9434@mit.edu>
On Thu, Mar 21, 2019 at 10:31:41AM -0400, Theodore Ts'o wrote:
> On Thu, Mar 21, 2019 at 11:27:42AM +0100, Lukas Czerner wrote:
> >
> > lv_role=public does not exclude snapshots and so it will fail later in
> > e2scrub when you try to create a snapshot of a thicksnapshot which is
> > not supported.
>
> Ah, good point. Thanks for pointing that out.
>
> > Also I am not sure what's the rush, but it seems you've ignored my other
> > suggestions.
>
> I did consider them all, but there were reasons why I didn't use them.
> One of them wasn't practical because I needed LVM2_VG_NAME; when you
> made that suggestion, I hadn't published the patch needed to fix
> Debian Bug #924301. Of course, if we use your suggestion of using "-S
> vg_free > ${snap_size}" it will obviate that need; so thanks for that
> suggestion.
>
> The reason why I didn't take one of your other suggestions is that we
> need to check whether or not the file system is mounted, and so we
> needed the mountpoint in lsblk, and once you ask for the mountpoint,
> we can no longer use awk to select a field, since an unmounted file
> system shows up as a an empty column.
>
> % sudo lsblk -o MOUNTPOINT,FSTYPE,NAME -l
> LVM2_member nvme0n1p3_crypt
> ext4 lambda-uroot
> [SWAP] swap lambda-swap_1
> / ext4 lambda-root
> ext4 lambda-old--files
> ext4 lambda-library
> ext4 lambda-test--4k
> ext4 lambda-scratch
> ext4 lambda-test--1k
> lambda-scratch2
> lambda-scratch3
> ext4 lambda-results
> lambda-thinpool_tmeta
> lambda-thinpool_tdata
So the good news is that it's not really a problem. What you really want
is the mountpoint if it exists and the device otherwise right ?
Then my suggestion will do just that becuase awk will separate the fieds
with FS (field separator) which by default is a single space. But space
is special in awk becuase the fields will be separated by a runs of
space, so if you pick the fileds just right you'll get what you want.
So if I run this on my system
# lsblk -o MOUNTPOINT,NAME,FSTYPE -p -n -l `lvs -o lv_path -S lv_active=active,lv_role=public,lv_role!=snapshot,vg_free\>256 --noheadings`
I'll get
/dev/mapper/vg_perpetuum-ext4--suck
/dev/mapper/vg_perpetuum-fedora29
/dev/mapper/vg_perpetuum-fedora29--2
/dev/mapper/vg_perpetuum-freebsd
/mnt/kernel /dev/mapper/vg_perpetuum-kernel ext4
/home /dev/mapper/vg_perpetuum-lv_home xfs
/ /dev/mapper/vg_perpetuum-lv_root xfs
[SWAP] /dev/mapper/vg_perpetuum-lv_swap swap
/var /dev/mapper/vg_perpetuum-lv_var xfs
/dev/mapper/vg_perpetuum-lvol001 ext4
/dev/mapper/vg_perpetuum-overlay ext4
/dev/mapper/vg_perpetuum-rhel7
/dev/mapper/vg_perpetuum-rhel8
/dev/mapper/vg_perpetuum-test0 ext3
/dev/mapper/vg_perpetuum-test1 xfs
/dev/mapper/vg_perpetuum-test10 ext4
/dev/mapper/vg_perpetuum-test11 ext4
/dev/mapper/vg_perpetuum-test12
/dev/mapper/vg_perpetuum-test2
/dev/mapper/vg_perpetuum-test3 ext4
/dev/mapper/vg_perpetuum-test4 ext4
/dev/mapper/vg_perpetuum-test5
/dev/mapper/vg_perpetuum-test6 LVM2_member
/dev/mapper/vg_perpetuum-test7
/dev/mapper/vg_perpetuum-test8
/dev/mapper/vg_perpetuum-test9 ext4
/dev/mapper/vg_perpetuum-testing ext4
/dev/mapper/vg_perpetuum-testing1 xfs
/dev/mapper/vg_perpetuum-thinvolume
now if I add
| awk '{print $1}'
I'll get
/dev/mapper/vg_perpetuum-ext4--suck
/dev/mapper/vg_perpetuum-fedora29
/dev/mapper/vg_perpetuum-fedora29--2
/dev/mapper/vg_perpetuum-freebsd
/mnt/kernel
/home
/
[SWAP]
/var
/dev/mapper/vg_perpetuum-lvol001
/dev/mapper/vg_perpetuum-overlay
/dev/mapper/vg_perpetuum-rhel7
/dev/mapper/vg_perpetuum-rhel8
/dev/mapper/vg_perpetuum-test0
/dev/mapper/vg_perpetuum-test1
/dev/mapper/vg_perpetuum-test10
/dev/mapper/vg_perpetuum-test11
/dev/mapper/vg_perpetuum-test12
/dev/mapper/vg_perpetuum-test2
/dev/mapper/vg_perpetuum-test3
/dev/mapper/vg_perpetuum-test4
/dev/mapper/vg_perpetuum-test5
/dev/mapper/vg_perpetuum-test6
/dev/mapper/vg_perpetuum-test7
/dev/mapper/vg_perpetuum-test8
/dev/mapper/vg_perpetuum-test9
/dev/mapper/vg_perpetuum-testing
/dev/mapper/vg_perpetuum-testing1
/dev/mapper/vg_perpetuum-thinvolume
hence I get mountpoin where the volume is mounted and the device where
it is not. That's what we need right ?
What I did not consider was [SWAP] but we can get rid of that easily.
grep -v '[SWAP]'
>
> I also really didn't like using grep to select the file system type
> ext[234], since if it would falsely select a LV name that contained
> "ext4", e.g.:
>
> /home/dave xfs rhel-ext4--sucks
That can be dealt with as well as well just by grepping for ' ext[234]$'
So in the end we'll have something like
# lsblk -o MOUNTPOINT,NAME,FSTYPE -p -n -l `lvs -o lv_path -S lv_active=active,lv_role=public,lv_role!=snapshot,vg_free\>256 --noheadings` | grep -v '[SWAP]' | grep ' ext[234]$' | awk '{print $1}'
and so on my system this gives me
/mnt/kernel
/dev/mapper/vg_perpetuum-lvol001
/dev/mapper/vg_perpetuum-overlay
/dev/mapper/vg_perpetuum-test0
/dev/mapper/vg_perpetuum-test10
/dev/mapper/vg_perpetuum-test11
/dev/mapper/vg_perpetuum-test3
/dev/mapper/vg_perpetuum-test4
/dev/mapper/vg_perpetuum-test9
/dev/mapper/vg_perpetuum-testing
And leaving out mounted file systems is again as simple as
grep -v '^/dev/'
Have I missed something ?
Now for the performance. I drop caches, then run each twice
the ls_scan_targets function runs
real 0m0.575s
user 0m0.086s
sys 0m0.179s
real 0m0.241s
user 0m0.088s
sys 0m0.169s
My one-line suggestion runs
real 0m0.275s
user 0m0.027s
sys 0m0.047s
real 0m0.069s
user 0m0.015s
sys 0m0.052s
So the difference is significant, although I would not consider it
meaningful since it's really low anyway, but some people complained so I
guess someone cares and people do have different systems so...
>
> :-)
>
> We could have used awk to select the field, but that still doesn't
> deal with the mountpoint column being empty when it is unmounted. I
> did briefly consider using lsblk -J, but I didn't want to add a
> dependency on the jq[1] package (and I didn't even know if RHEL/Fedora
> packages jq).
>
> [1] https://packages.debian.org/stretch/jq
Yes Fedora does have it, but I agree that adding this dependency is not
ideal.
Thanks!
-Lukas
>
> Cheers,
>
> - Ted
next prev parent reply other threads:[~2019-03-21 15:57 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 2:02 [PATCH 1/9] e2scrub: check to make sure lvm2 is installed Theodore Ts'o
2019-03-21 2:02 ` [PATCH 2/9] debian: drop lvm2 from the recommends line Theodore Ts'o
2019-03-21 3:57 ` Darrick J. Wong
2019-03-21 2:02 ` [PATCH 3/9] Fix "make install-strip" Theodore Ts'o
2019-03-21 2:02 ` [PATCH 4/9] e2scrub: fix up "make install-strip" support Theodore Ts'o
2019-03-21 2:02 ` [PATCH 5/9] e2fscrub: add the -n option which shows what commands e2scrub would execute Theodore Ts'o
2019-03-21 3:59 ` Darrick J. Wong
2019-03-21 10:57 ` Lukas Czerner
2019-03-21 14:32 ` Theodore Ts'o
2019-03-21 2:02 ` [PATCH 6/9] e2scrub_all: add the -n option which shows what e2scrub_all would do Theodore Ts'o
2019-03-21 4:01 ` Darrick J. Wong
2019-03-21 2:02 ` [PATCH 7/9] e2scrub_all: make sure there's enough free space for a snapshot Theodore Ts'o
2019-03-21 4:02 ` Darrick J. Wong
2019-03-21 11:18 ` Lukas Czerner
2019-03-21 14:26 ` Theodore Ts'o
2019-03-21 2:02 ` [PATCH 8/9] e2scrub_all: refactor device probe loop Theodore Ts'o
2019-03-21 4:05 ` Darrick J. Wong
2019-03-21 10:27 ` Lukas Czerner
2019-03-21 14:31 ` Theodore Ts'o
2019-03-21 15:57 ` Lukas Czerner [this message]
2019-03-21 18:24 ` Theodore Ts'o
2019-03-21 20:17 ` Lukas Czerner
2019-03-21 20:48 ` Theodore Ts'o
2019-03-21 21:14 ` Lukas Czerner
2019-03-21 22:04 ` Theodore Ts'o
2019-03-21 22:08 ` Theodore Ts'o
2019-03-22 9:38 ` Lukas Czerner
2019-03-21 20:09 ` Andreas Dilger
2019-03-21 17:48 ` Theodore Ts'o
2019-03-21 19:49 ` Lukas Czerner
2019-03-21 20:23 ` Theodore Ts'o
2019-03-21 16:10 ` Lukas Czerner
2019-03-21 2:02 ` [PATCH 9/9] e2scrub,e2scrub_all: print a (more understandable) error if not run as root Theodore Ts'o
2019-03-21 4:04 ` Darrick J. Wong
2019-03-21 11:36 ` Lukas Czerner
2019-03-21 14:40 ` Theodore Ts'o
2019-03-21 3:55 ` [PATCH 1/9] e2scrub: check to make sure lvm2 is installed Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2019-03-21 20:25 [PATCH -v2 0/9] e2fsprogs: e2scrub cleanups Theodore Ts'o
2019-03-21 20:25 ` [PATCH 8/9] e2scrub_all: refactor device probe loop Theodore Ts'o
2019-03-21 20:55 ` Lukas Czerner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190321155703.ili5ghofgm3hneq5@work \
--to=lczerner@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).