linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH] e2scrub: remove -C from e2scrub_all
Date: Mon, 3 Jun 2019 21:27:12 -0700	[thread overview]
Message-ID: <20190604042712.GB5378@magnolia> (raw)

From: Darrick J. Wong <darrick.wong@oracle.com>

We already have the "SERVICE_MODE=1" feature that signals to e2scrub
that we're running as a background daemon and therefore we should exit
quietly if conditions aren't right.

It's therefore unnecessary to have a separate -C flag to achieve the
same outcome for cron jobs.  Merge the two together.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 scrub/e2scrub_all.cron.in     |    4 ++--
 scrub/e2scrub_all.in          |   12 +++---------
 scrub/e2scrub_all.service.in  |    2 +-
 scrub/e2scrub_all_cron.in     |    2 +-
 scrub/e2scrub_reap.service.in |    3 ++-
 5 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/scrub/e2scrub_all.cron.in b/scrub/e2scrub_all.cron.in
index 5bf83ec97..395fb2ab4 100644
--- a/scrub/e2scrub_all.cron.in
+++ b/scrub/e2scrub_all.cron.in
@@ -1,2 +1,2 @@
-30 3 * * 0 root test -e /run/systemd/system || @pkglibdir@/e2scrub_all_cron
-10 3 * * * root test -e /run/systemd/system || @root_sbindir@/e2scrub_all -C -A -r
+30 3 * * 0 root test -e /run/systemd/system || SERVICE_MODE=1 @pkglibdir@/e2scrub_all_cron
+10 3 * * * root test -e /run/systemd/system || SERVICE_MODE=1 @root_sbindir@/e2scrub_all -A -r
diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in
index d99c81978..cdc37ced4 100644
--- a/scrub/e2scrub_all.in
+++ b/scrub/e2scrub_all.in
@@ -26,7 +26,6 @@ if (( $EUID != 0 )); then
 fi
 
 scrub_all=0
-run_from_cron=0
 snap_size_mb=256
 reap=0
 conffile="@root_sysconfdir@/e2scrub.conf"
@@ -69,12 +68,11 @@ exitcode() {
 	exit "${ret}"
 }
 
-while getopts "nrACV" opt; do
+while getopts "nrAV" opt; do
 	case "${opt}" in
 	"n") DBG="echo Would execute: " ;;
 	"r") scrub_args="${scrub_args} -r"; reap=1;;
 	"A") scrub_all=1;;
-	"C") run_from_cron=1;;
 	"V") print_version; exitcode 0;;
 	*) print_help; exitcode 2;;
 	esac
@@ -86,17 +84,13 @@ shift "$((OPTIND - 1))"
 # when e2scrub_all is run out of cron or a systemd timer.
 
 if ! type lsblk >& /dev/null ; then
-    if [ "${run_from_cron}" -eq 1 ] ; then
-	exitcode 0
-    fi
+    test -n "${SERVICE_MODE}" && exitcode 0
     echo "e2scrub_all: can't find lsblk --- is util-linux installed?"
     exitcode 1
 fi
 
 if ! type lvcreate >& /dev/null ; then
-    if [ "${run_from_cron}" -eq 1 ] ; then
-	exitcode 0
-    fi
+    test -n "${SERVICE_MODE}" && exitcode 0
     echo "e2scrub_all: can't find lvcreate --- is lvm2 installed?"
     exitcode 1
 fi
diff --git a/scrub/e2scrub_all.service.in b/scrub/e2scrub_all.service.in
index 77b6ad599..20f42bfe3 100644
--- a/scrub/e2scrub_all.service.in
+++ b/scrub/e2scrub_all.service.in
@@ -8,5 +8,5 @@ Documentation=man:e2scrub_all(8)
 [Service]
 Type=oneshot
 Environment=SERVICE_MODE=1
-ExecStart=@root_sbindir@/e2scrub_all -C
+ExecStart=@root_sbindir@/e2scrub_all
 SyslogIdentifier=e2scrub_all
diff --git a/scrub/e2scrub_all_cron.in b/scrub/e2scrub_all_cron.in
index bc26fee3d..f9cff878c 100644
--- a/scrub/e2scrub_all_cron.in
+++ b/scrub/e2scrub_all_cron.in
@@ -65,4 +65,4 @@ on_ac_power() {
 test -e /run/systemd/system && exit 0
 on_ac_power || exit 0
 
-exec @root_sbindir@/e2scrub_all -C
+exec @root_sbindir@/e2scrub_all
diff --git a/scrub/e2scrub_reap.service.in b/scrub/e2scrub_reap.service.in
index 40511f735..10d25f06f 100644
--- a/scrub/e2scrub_reap.service.in
+++ b/scrub/e2scrub_reap.service.in
@@ -16,7 +16,8 @@ NoNewPrivileges=yes
 User=root
 IOSchedulingClass=idle
 CPUSchedulingPolicy=idle
-ExecStart=@root_sbindir@/e2scrub_all -C -A -r
+Environment=SERVICE_MODE=1
+ExecStart=@root_sbindir@/e2scrub_all -A -r
 SyslogIdentifier=%N
 RemainAfterExit=no
 

             reply	other threads:[~2019-06-04  4:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04  4:27 Darrick J. Wong [this message]
2019-06-04 18:02 ` [PATCH] e2scrub: remove -C from e2scrub_all Theodore Ts'o

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=20190604042712.GB5378@magnolia \
    --to=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).