From patchwork Thu Dec 7 18:48:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 845771 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="IsVjCy8D"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yt4JB45C6z9s82 for ; Fri, 8 Dec 2017 05:48:42 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750967AbdLGSsm (ORCPT ); Thu, 7 Dec 2017 13:48:42 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:57482 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbdLGSsl (ORCPT ); Thu, 7 Dec 2017 13:48:41 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vB7ImSSL058123; Thu, 7 Dec 2017 18:48:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=o41eiBwMNNcya32Pfpj/RVhvoH8Q1LepbcV8x2eS0XQ=; b=IsVjCy8DlcnYCN+PgZ821GDAus0SGx/mofyRGPcUPd599gXHJObEnwim45MSXf7LjiWX xKH9Cipm1gi8eWuAg9D0jAW5k+/lHBr+NBIToxdPwn32EJ/+R5QGi1ITuRPcm+cmMVpA y/C5aHOMs2AcT+wULneGPpUuRTimWg4kk7QcvaJg6kcZZjOJfAufq/frqwvF14B2Y0kZ /j1Rf46Gt551auF7kGu7FWUR+9ezn1YxznlO2aVjaYjPHowX9vyAZ41Hz1AddMTxk8Hy gYJe+tu+9FOS0+z0Kc12UAmnHht+1d9h3xfjsUKOEh6wfIABbN0aYS0Jm8KGdjtSVBG0 KQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2eqb8er01j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Dec 2017 18:48:38 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vB7Imb34028268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Dec 2017 18:48:37 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vB7Imb8U000455; Thu, 7 Dec 2017 18:48:37 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 07 Dec 2017 10:48:37 -0800 Subject: [PATCH 2/4] e2scrub: create a script to scrub all ext* filesystems From: "Darrick J. Wong" To: tytso@mit.edu, darrick.wong@oracle.com Cc: adilger@dilger.ca, linux-ext4@vger.kernel.org Date: Thu, 07 Dec 2017 10:48:36 -0800 Message-ID: <151267251622.1350.5012077999744307213.stgit@magnolia> In-Reply-To: <151267250365.1350.7799938074608034424.stgit@magnolia> References: <151267250365.1350.7799938074608034424.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8738 signatures=668644 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=9 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712070275 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Darrick J. Wong Create an e2scrub_all command to find all ext* filesystems and run an online scrub against them all. Signed-off-by: Darrick J. Wong --- scrub/Makefile.in | 9 +++++++- scrub/e2scrub_all.8.in | 14 +++++++++++++ scrub/e2scrub_all.in | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 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 1f3253d..ce8c85f 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..b05f13c --- /dev/null +++ b/scrub/e2scrub_all.8.in @@ -0,0 +1,14 @@ +.TH E2SCRUB 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@" +.SH NAME +e2scrub_all - Check all mounted btrfs/ext4/XFS LVM file systems for errors. +.SH SYNOPSYS +.B +e2scrub_all +.SH DESCRIPTION +Searches the system for all LVM volumes containing an ext2, ext3, or +ext4 file system, and checks them all for errors. +If the file system has no errors, it will be fstrim'd. +.SH AUTHOR +Darrick J. Wong +.SH COPYRIGHT +Copyright ©2017 Darrick J. Wong. License is GPLv2+. diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in new file mode 100644 index 0000000..a9ba670 --- /dev/null +++ b/scrub/e2scrub_all.in @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (C) 2017 Oracle. All Rights Reserved. +# +# Author: Darrick J. Wong +# +# 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" + +exitcode() { + ret="$1" + + exit "${ret}" +} + +prog_path() { + path="$1" + displayname="$2" + + if ! type -P "${path}" && [ -n "${displayname}" ]; then + echo "${displayname}: Command not found." + exitcode 8 + fi +} + +LVS_PROG="$(prog_path "@root_sbindir@/lvs" "lvs")" +BLKID_PROG="$(prog_path "@root_sbindir@/blkid" "blkid")" + +# Scrub any fs on lvm by creating a snapshot and fscking that. +"${LVS_PROG}" -o vg_name,lv_name --noheadings 2> /dev/null | while read vg lv; do + dev="/dev/${vg}/${lv}" + "${BLKID_PROG}" -p -n "${types}" "${dev}" > /dev/null 2>&1 || continue + + ${DBG} "@root_sbindir@/e2scrub" "${dev}" +done + +exitcode 0