Message ID | 152087129361.4129.2235207563424173822.stgit@magnolia |
---|---|
State | Superseded, archived |
Headers | show |
Series | e2scrub: online fsck for ext4 | expand |
On Mon, Mar 12, 2018 at 09:14:53AM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <darrick.wong@oracle.com> > > Create an e2scrub_all command to find all ext* filesystems > and run an online scrub against them all. Sorry for not bringing that up before, by why don't we have e2scrub -a instead of this ? Wouldn't it be better to have just one tool ? -Lukas > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> > --- > scrub/Makefile.in | 9 ++++++-- > scrub/e2scrub_all.8.in | 30 ++++++++++++++++++++++++++ > scrub/e2scrub_all.in | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 92 insertions(+), 2 deletions(-) > create mode 100644 scrub/e2scrub_all.8.in > create mode 100644 scrub/e2scrub_all.in > > > diff --git a/scrub/Makefile.in b/scrub/Makefile.in > index a8bb06b..1744941 100644 > --- a/scrub/Makefile.in > +++ b/scrub/Makefile.in > @@ -11,8 +11,8 @@ INSTALL = @INSTALL@ > > @MCONFIG@ > > -PROGS= e2scrub > -MANPAGES= e2scrub.8 > +PROGS= e2scrub e2scrub_all > +MANPAGES= e2scrub.8 e2scrub_all.8 > CONFFILES= e2scrub.conf > > ifeq ($(HAVE_UDEV),yes) > @@ -29,6 +29,11 @@ e2scrub: $(DEP_SUBSTITUTE) e2scrub.in > $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e2scrub.in $@ > $(Q) chmod a+x $@ > > +e2scrub_all: e2scrub_all.in > + $(E) " SUBST $@" > + $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e2scrub_all.in $@ > + $(Q) chmod a+x $@ > + > %.8: %.8.in $(DEP_SUBSTITUTE) > $(E) " SUBST $@" > $(Q) $(SUBSTITUTE_UPTIME) $< $@ > diff --git a/scrub/e2scrub_all.8.in b/scrub/e2scrub_all.8.in > new file mode 100644 > index 0000000..034ed9e > --- /dev/null > +++ b/scrub/e2scrub_all.8.in > @@ -0,0 +1,30 @@ > +.TH E2SCRUB 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@" > +.SH NAME > +e2scrub_all - Check all mounted ext[234] LVM file systems for errors. > +.SH SYNOPSYS > +.B > +e2scrub_all [OPTION] > +.SH DESCRIPTION > +Searches the system for all LVM logical volumes containing an ext2, ext3, or > +ext4 file system, and checks them for problems. > +The checking is performed by invoking the > +.B e2scrub > +tool, which will look for corruptions. > +Corrupt filesystems will be tagged as having errors so that fsck will be > +invoked before the next mount. > +If no errors are encountered, > +.B fstrim > +will be called on the filesystem if it is mounted. > +See the > +.B e2scrub > +manual page for more information about how the checking is performed. > +.SH OPTIONS > +.TP > +\fB-V\fR > +Print version information and exit. > +.SH SEE ALSO > +.BR e2scrub "(8)" > +.SH AUTHOR > +Darrick J. Wong <darrick.wong@oracle.com> > +.SH COPYRIGHT > +Copyright ©2018 Oracle. License is GPLv2+. <http://www.gnu.org/licenses/gpl-2.0.html> > diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in > new file mode 100644 > index 0000000..453981b > --- /dev/null > +++ b/scrub/e2scrub_all.in > @@ -0,0 +1,55 @@ > +#!/bin/bash > + > +# Copyright (C) 2018 Oracle. All Rights Reserved. > +# > +# Author: Darrick J. Wong <darrick.wong@oracle.com> > +# > +# This program is free software; you can redistribute it and/or > +# modify it under the terms of the GNU General Public License > +# as published by the Free Software Foundation; either version 2 > +# of the License, or (at your option) any later version. > +# > +# This program is distributed in the hope that it would be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program; if not, write the Free Software Foundation, > +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. > + > +# Check all ext[234] filesystems mounted on LVM > +types="ext2,ext3,ext4" > + > +print_help() { > + echo "Usage: $0 [OPTIONS]" > + echo " -V: Print version information and exit." > +} > + > +print_version() { > + echo "e2scrub_all @E2FSPROGS_VERSION@ (@E2FSPROGS_DATE@)" > +} > + > +while getopts "V" opt; do > + case "${opt}" in > + "V") print_version; exit 0;; > + *) print_help; exit 2;; > + esac > +done > +shift "$((OPTIND - 1))" > + > +# Scrub any fs on lvm by creating a snapshot and fscking that. > +lvs -o vg_name,lv_name,lv_role --noheadings 2> /dev/null | while read vg lv role extra; do > + # parsing error? > + test -n "${extra}" && continue > + # Skip snapshots > + echo "${role}" | grep -q "snapshot" && continue > + > + dev="/dev/${vg}/${lv}" > + # Skip non-ext[234] > + blkid -p -n "${types}" "${dev}" > /dev/null 2>&1 || continue > + > + ${DBG} "@root_sbindir@/e2scrub" "${dev}" > +done > + > +exit 0 >
On Tue, Mar 13, 2018 at 07:23:44AM +0100, Lukas Czerner wrote: > On Mon, Mar 12, 2018 at 09:14:53AM -0700, Darrick J. Wong wrote: > > From: Darrick J. Wong <darrick.wong@oracle.com> > > > > Create an e2scrub_all command to find all ext* filesystems > > and run an online scrub against them all. > > Sorry for not bringing that up before, by why don't we have > > e2scrub -a > > instead of this ? Wouldn't it be better to have just one tool ? I'd rather have two simple tools that each do one thing ("scrub this ext4 lvm volume") ("find all ext4 lvm volumes and run scrub") than combine them into one less cohesive tool. There's precedence here with fsck.$fstype and fsck, where the first one performs an offline check of a single filesystem and the second one (if you fsck -A) finds all the individual filesystems and feeds them through fsck.$fstype. In the longer term it probably makes sense to set up a fsscrub wrapper to invoke the fs-specific scrub tools. Though now that I think about that, e2scrub probably ought to take a mount point and translate that into a lvm volume, which makes e2scrub_all mostly a dumb iterator of /proc/mounts. --D > -Lukas > > > > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> > > --- > > scrub/Makefile.in | 9 ++++++-- > > scrub/e2scrub_all.8.in | 30 ++++++++++++++++++++++++++ > > scrub/e2scrub_all.in | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 92 insertions(+), 2 deletions(-) > > create mode 100644 scrub/e2scrub_all.8.in > > create mode 100644 scrub/e2scrub_all.in > > > > > > diff --git a/scrub/Makefile.in b/scrub/Makefile.in > > index a8bb06b..1744941 100644 > > --- a/scrub/Makefile.in > > +++ b/scrub/Makefile.in > > @@ -11,8 +11,8 @@ INSTALL = @INSTALL@ > > > > @MCONFIG@ > > > > -PROGS= e2scrub > > -MANPAGES= e2scrub.8 > > +PROGS= e2scrub e2scrub_all > > +MANPAGES= e2scrub.8 e2scrub_all.8 > > CONFFILES= e2scrub.conf > > > > ifeq ($(HAVE_UDEV),yes) > > @@ -29,6 +29,11 @@ e2scrub: $(DEP_SUBSTITUTE) e2scrub.in > > $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e2scrub.in $@ > > $(Q) chmod a+x $@ > > > > +e2scrub_all: e2scrub_all.in > > + $(E) " SUBST $@" > > + $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e2scrub_all.in $@ > > + $(Q) chmod a+x $@ > > + > > %.8: %.8.in $(DEP_SUBSTITUTE) > > $(E) " SUBST $@" > > $(Q) $(SUBSTITUTE_UPTIME) $< $@ > > diff --git a/scrub/e2scrub_all.8.in b/scrub/e2scrub_all.8.in > > new file mode 100644 > > index 0000000..034ed9e > > --- /dev/null > > +++ b/scrub/e2scrub_all.8.in > > @@ -0,0 +1,30 @@ > > +.TH E2SCRUB 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@" > > +.SH NAME > > +e2scrub_all - Check all mounted ext[234] LVM file systems for errors. > > +.SH SYNOPSYS > > +.B > > +e2scrub_all [OPTION] > > +.SH DESCRIPTION > > +Searches the system for all LVM logical volumes containing an ext2, ext3, or > > +ext4 file system, and checks them for problems. > > +The checking is performed by invoking the > > +.B e2scrub > > +tool, which will look for corruptions. > > +Corrupt filesystems will be tagged as having errors so that fsck will be > > +invoked before the next mount. > > +If no errors are encountered, > > +.B fstrim > > +will be called on the filesystem if it is mounted. > > +See the > > +.B e2scrub > > +manual page for more information about how the checking is performed. > > +.SH OPTIONS > > +.TP > > +\fB-V\fR > > +Print version information and exit. > > +.SH SEE ALSO > > +.BR e2scrub "(8)" > > +.SH AUTHOR > > +Darrick J. Wong <darrick.wong@oracle.com> > > +.SH COPYRIGHT > > +Copyright ©2018 Oracle. License is GPLv2+. <http://www.gnu.org/licenses/gpl-2.0.html> > > diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in > > new file mode 100644 > > index 0000000..453981b > > --- /dev/null > > +++ b/scrub/e2scrub_all.in > > @@ -0,0 +1,55 @@ > > +#!/bin/bash > > + > > +# Copyright (C) 2018 Oracle. All Rights Reserved. > > +# > > +# Author: Darrick J. Wong <darrick.wong@oracle.com> > > +# > > +# This program is free software; you can redistribute it and/or > > +# modify it under the terms of the GNU General Public License > > +# as published by the Free Software Foundation; either version 2 > > +# of the License, or (at your option) any later version. > > +# > > +# This program is distributed in the hope that it would be useful, > > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > +# GNU General Public License for more details. > > +# > > +# You should have received a copy of the GNU General Public License > > +# along with this program; if not, write the Free Software Foundation, > > +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. > > + > > +# Check all ext[234] filesystems mounted on LVM > > +types="ext2,ext3,ext4" > > + > > +print_help() { > > + echo "Usage: $0 [OPTIONS]" > > + echo " -V: Print version information and exit." > > +} > > + > > +print_version() { > > + echo "e2scrub_all @E2FSPROGS_VERSION@ (@E2FSPROGS_DATE@)" > > +} > > + > > +while getopts "V" opt; do > > + case "${opt}" in > > + "V") print_version; exit 0;; > > + *) print_help; exit 2;; > > + esac > > +done > > +shift "$((OPTIND - 1))" > > + > > +# Scrub any fs on lvm by creating a snapshot and fscking that. > > +lvs -o vg_name,lv_name,lv_role --noheadings 2> /dev/null | while read vg lv role extra; do > > + # parsing error? > > + test -n "${extra}" && continue > > + # Skip snapshots > > + echo "${role}" | grep -q "snapshot" && continue > > + > > + dev="/dev/${vg}/${lv}" > > + # Skip non-ext[234] > > + blkid -p -n "${types}" "${dev}" > /dev/null 2>&1 || continue > > + > > + ${DBG} "@root_sbindir@/e2scrub" "${dev}" > > +done > > + > > +exit 0 > >
On Mar 13, 2018, at 10:36 AM, Darrick J. Wong <darrick.wong@oracle.com> wrote: > > On Tue, Mar 13, 2018 at 07:23:44AM +0100, Lukas Czerner wrote: >> On Mon, Mar 12, 2018 at 09:14:53AM -0700, Darrick J. Wong wrote: >>> From: Darrick J. Wong <darrick.wong@oracle.com> >>> >>> Create an e2scrub_all command to find all ext* filesystems >>> and run an online scrub against them all. >> >> Sorry for not bringing that up before, by why don't we have >> >> e2scrub -a >> >> instead of this ? Wouldn't it be better to have just one tool ? > > I'd rather have two simple tools that each do one thing ("scrub this > ext4 lvm volume") ("find all ext4 lvm volumes and run scrub") than > combine them into one less cohesive tool. There's precedence here with > fsck.$fstype and fsck, where the first one performs an offline check of a > single filesystem and the second one (if you fsck -A) finds all the > individual filesystems and feeds them through fsck.$fstype. In the > longer term it probably makes sense to set up a fsscrub wrapper to > invoke the fs-specific scrub tools. > > Though now that I think about that, e2scrub probably ought to take a > mount point and translate that into a lvm volume, which makes > e2scrub_all mostly a dumb iterator of /proc/mounts. Except that won't scrub offline volumes, nor will all mounted ext4 filesystems be LVs that can be scrubbed, so I don't think that is an improvement. Cheers, Andreas
Am 13.03.2018 um 18:08 schrieb Andreas Dilger: > On Mar 13, 2018, at 10:36 AM, Darrick J. Wong <darrick.wong@oracle.com> wrote: >> >> On Tue, Mar 13, 2018 at 07:23:44AM +0100, Lukas Czerner wrote: >>> On Mon, Mar 12, 2018 at 09:14:53AM -0700, Darrick J. Wong wrote: >>>> From: Darrick J. Wong <darrick.wong@oracle.com> >>>> >>>> Create an e2scrub_all command to find all ext* filesystems >>>> and run an online scrub against them all. >>> >>> Sorry for not bringing that up before, by why don't we have >>> >>> e2scrub -a >>> >>> instead of this ? Wouldn't it be better to have just one tool ? >> >> I'd rather have two simple tools that each do one thing ("scrub this >> ext4 lvm volume") ("find all ext4 lvm volumes and run scrub") than >> combine them into one less cohesive tool. There's precedence here with >> fsck.$fstype and fsck, where the first one performs an offline check of a >> single filesystem and the second one (if you fsck -A) finds all the >> individual filesystems and feeds them through fsck.$fstype. In the >> longer term it probably makes sense to set up a fsscrub wrapper to >> invoke the fs-specific scrub tools. >> >> Though now that I think about that, e2scrub probably ought to take a >> mount point and translate that into a lvm volume, which makes >> e2scrub_all mostly a dumb iterator of /proc/mounts. > > Except that won't scrub offline volumes, nor will all mounted ext4 > filesystems be LVs that can be scrubbed, so I don't think that is > an improvement why is that at all limited to ext4 on top of LVM? both layers should not need to know from each other - feels not that good for the long term having different paths of code depending on the underlying block layer (raw-disk, mdraid, lvm, lvm-on-mdraid...)
On Mar 13, 2018, at 11:11 AM, Reindl Harald <h.reindl@thelounge.net> wrote: > > > Am 13.03.2018 um 18:08 schrieb Andreas Dilger: >> On Mar 13, 2018, at 10:36 AM, Darrick J. Wong <darrick.wong@oracle.com> wrote: >>> >>> I'd rather have two simple tools that each do one thing ("scrub this >>> ext4 lvm volume") ("find all ext4 lvm volumes and run scrub") than >>> combine them into one less cohesive tool. There's precedence here with >>> fsck.$fstype and fsck, where the first one performs an offline check of a >>> single filesystem and the second one (if you fsck -A) finds all the >>> individual filesystems and feeds them through fsck.$fstype. In the >>> longer term it probably makes sense to set up a fsscrub wrapper to >>> invoke the fs-specific scrub tools. >>> >>> Though now that I think about that, e2scrub probably ought to take a >>> mount point and translate that into a lvm volume, which makes >>> e2scrub_all mostly a dumb iterator of /proc/mounts. >> Except that won't scrub offline volumes, nor will all mounted ext4 >> filesystems be LVs that can be scrubbed, so I don't think that is >> an improvement > > why is that at all limited to ext4 on top of LVM? > > both layers should not need to know from each other - feels not that good for the long term having different paths of code depending on the underlying block layer (raw-disk, mdraid, lvm, lvm-on-mdraid...) Because LVM can create snapshots of the block device, which is required for running e2fsck while the filesystem is "mounted" (though the check is done on the unmounted snapshot device and not the actual in-use block device). Cheers, Andreas
On Tue, Mar 13, 2018 at 11:08:11AM -0600, Andreas Dilger wrote: > On Mar 13, 2018, at 10:36 AM, Darrick J. Wong <darrick.wong@oracle.com> wrote: > > > > On Tue, Mar 13, 2018 at 07:23:44AM +0100, Lukas Czerner wrote: > >> On Mon, Mar 12, 2018 at 09:14:53AM -0700, Darrick J. Wong wrote: > >>> From: Darrick J. Wong <darrick.wong@oracle.com> > >>> > >>> Create an e2scrub_all command to find all ext* filesystems > >>> and run an online scrub against them all. > >> > >> Sorry for not bringing that up before, by why don't we have > >> > >> e2scrub -a > >> > >> instead of this ? Wouldn't it be better to have just one tool ? > > > > I'd rather have two simple tools that each do one thing ("scrub this > > ext4 lvm volume") ("find all ext4 lvm volumes and run scrub") than > > combine them into one less cohesive tool. There's precedence here with > > fsck.$fstype and fsck, where the first one performs an offline check of a > > single filesystem and the second one (if you fsck -A) finds all the > > individual filesystems and feeds them through fsck.$fstype. In the > > longer term it probably makes sense to set up a fsscrub wrapper to > > invoke the fs-specific scrub tools. > > > > Though now that I think about that, e2scrub probably ought to take a > > mount point and translate that into a lvm volume, which makes > > e2scrub_all mostly a dumb iterator of /proc/mounts. > > Except that won't scrub offline volumes, nor will all mounted ext4 > filesystems be LVs that can be scrubbed, so I don't think that is > an improvement. Ok, I'll modify e2scrub so that you can pass it either (a) a lvm block device or (b) a mountpoint for a filesystem on a lvm block device. e2scrub_all will retain its ability to schedule a check even if the fs isn't mounted. --D > Cheers, Andreas > > > > >
On Tue, Mar 13, 2018 at 10:49:23AM -0700, Darrick J. Wong wrote: > On Tue, Mar 13, 2018 at 11:08:11AM -0600, Andreas Dilger wrote: > > On Mar 13, 2018, at 10:36 AM, Darrick J. Wong <darrick.wong@oracle.com> wrote: > > > > > > On Tue, Mar 13, 2018 at 07:23:44AM +0100, Lukas Czerner wrote: > > >> On Mon, Mar 12, 2018 at 09:14:53AM -0700, Darrick J. Wong wrote: > > >>> From: Darrick J. Wong <darrick.wong@oracle.com> > > >>> > > >>> Create an e2scrub_all command to find all ext* filesystems > > >>> and run an online scrub against them all. > > >> > > >> Sorry for not bringing that up before, by why don't we have > > >> > > >> e2scrub -a > > >> > > >> instead of this ? Wouldn't it be better to have just one tool ? > > > > > > I'd rather have two simple tools that each do one thing ("scrub this > > > ext4 lvm volume") ("find all ext4 lvm volumes and run scrub") than > > > combine them into one less cohesive tool. There's precedence here with > > > fsck.$fstype and fsck, where the first one performs an offline check of a > > > single filesystem and the second one (if you fsck -A) finds all the > > > individual filesystems and feeds them through fsck.$fstype. In the > > > longer term it probably makes sense to set up a fsscrub wrapper to > > > invoke the fs-specific scrub tools. > > > > > > Though now that I think about that, e2scrub probably ought to take a > > > mount point and translate that into a lvm volume, which makes > > > e2scrub_all mostly a dumb iterator of /proc/mounts. > > > > Except that won't scrub offline volumes, nor will all mounted ext4 > > filesystems be LVs that can be scrubbed, so I don't think that is > > an improvement. > > Ok, I'll modify e2scrub so that you can pass it either (a) a lvm block > device or (b) a mountpoint for a filesystem on a lvm block device. > e2scrub_all will retain its ability to schedule a check even if the fs > isn't mounted. It occurred to me while making these changes that it's not necessarily safe to assume that we can check all the offline LVs -- suppose you have clustered storage being managed by LVM. If each node only e2scrubs the LVs that it has mounted, we avoid a thundering stampede at 3:30am when all the nodes all start trying to e2scrub any LV they have access to. However, I'll grant you that we could (more) easily have offline local LVs, so I think a reasonable compromise is to establish "e2scrub_all -A" to mean "check all the LVs regardless of mount state". --D > --D > > > Cheers, Andreas > > > > > > > > > > > >
diff --git a/scrub/Makefile.in b/scrub/Makefile.in index a8bb06b..1744941 100644 --- a/scrub/Makefile.in +++ b/scrub/Makefile.in @@ -11,8 +11,8 @@ INSTALL = @INSTALL@ @MCONFIG@ -PROGS= e2scrub -MANPAGES= e2scrub.8 +PROGS= e2scrub e2scrub_all +MANPAGES= e2scrub.8 e2scrub_all.8 CONFFILES= e2scrub.conf ifeq ($(HAVE_UDEV),yes) @@ -29,6 +29,11 @@ e2scrub: $(DEP_SUBSTITUTE) e2scrub.in $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e2scrub.in $@ $(Q) chmod a+x $@ +e2scrub_all: e2scrub_all.in + $(E) " SUBST $@" + $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e2scrub_all.in $@ + $(Q) chmod a+x $@ + %.8: %.8.in $(DEP_SUBSTITUTE) $(E) " SUBST $@" $(Q) $(SUBSTITUTE_UPTIME) $< $@ diff --git a/scrub/e2scrub_all.8.in b/scrub/e2scrub_all.8.in new file mode 100644 index 0000000..034ed9e --- /dev/null +++ b/scrub/e2scrub_all.8.in @@ -0,0 +1,30 @@ +.TH E2SCRUB 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@" +.SH NAME +e2scrub_all - Check all mounted ext[234] LVM file systems for errors. +.SH SYNOPSYS +.B +e2scrub_all [OPTION] +.SH DESCRIPTION +Searches the system for all LVM logical volumes containing an ext2, ext3, or +ext4 file system, and checks them for problems. +The checking is performed by invoking the +.B e2scrub +tool, which will look for corruptions. +Corrupt filesystems will be tagged as having errors so that fsck will be +invoked before the next mount. +If no errors are encountered, +.B fstrim +will be called on the filesystem if it is mounted. +See the +.B e2scrub +manual page for more information about how the checking is performed. +.SH OPTIONS +.TP +\fB-V\fR +Print version information and exit. +.SH SEE ALSO +.BR e2scrub "(8)" +.SH AUTHOR +Darrick J. Wong <darrick.wong@oracle.com> +.SH COPYRIGHT +Copyright ©2018 Oracle. License is GPLv2+. <http://www.gnu.org/licenses/gpl-2.0.html> diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in new file mode 100644 index 0000000..453981b --- /dev/null +++ b/scrub/e2scrub_all.in @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright (C) 2018 Oracle. All Rights Reserved. +# +# Author: Darrick J. Wong <darrick.wong@oracle.com> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +# Check all ext[234] filesystems mounted on LVM +types="ext2,ext3,ext4" + +print_help() { + echo "Usage: $0 [OPTIONS]" + echo " -V: Print version information and exit." +} + +print_version() { + echo "e2scrub_all @E2FSPROGS_VERSION@ (@E2FSPROGS_DATE@)" +} + +while getopts "V" opt; do + case "${opt}" in + "V") print_version; exit 0;; + *) print_help; exit 2;; + esac +done +shift "$((OPTIND - 1))" + +# Scrub any fs on lvm by creating a snapshot and fscking that. +lvs -o vg_name,lv_name,lv_role --noheadings 2> /dev/null | while read vg lv role extra; do + # parsing error? + test -n "${extra}" && continue + # Skip snapshots + echo "${role}" | grep -q "snapshot" && continue + + dev="/dev/${vg}/${lv}" + # Skip non-ext[234] + blkid -p -n "${types}" "${dev}" > /dev/null 2>&1 || continue + + ${DBG} "@root_sbindir@/e2scrub" "${dev}" +done + +exit 0