All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/3] common/rc: add scratch shutdown support for overlayfs
@ 2017-12-12  3:09 Chengguang Xu
  2017-12-12  3:09 ` [PATCH v3 2/3] common/rc: add a check case in _require_xfs_io_command() to support syncfs Chengguang Xu
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Chengguang Xu @ 2017-12-12  3:09 UTC (permalink / raw)
  To: eguan, amir73il; +Cc: fstests, linux-unionfs, Chengguang Xu

OverlayFS overrides SCRATCH_MNT variable to it's own,
so adjust target to underlying filesystem(OVL_BASE_SCRATCH_MNT)
when running shutdown on overlayfs.

Signed-off-by: Chengguang Xu <cgxu519@icloud.com>
---

Changes since v2:
1. Make option for _scratch_shutdown(), so caller can 
specify option when calling.
2. Add comment for why overlay requires special handling.
3. Add commit log.

Changes since v1:
_scratch_shutdown() does not call notrun.

 common/rc | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/common/rc b/common/rc
index 4c053a5..a5c4ace 100644
--- a/common/rc
+++ b/common/rc
@@ -382,6 +382,24 @@ _scratch_cycle_mount()
     _scratch_mount "$opts"
 }
 
+_scratch_shutdown()
+{
+	if [ $FSTYP = "overlay" ]; then
+		# In lagacy overlay usage, it may specify directory as 
+		# SCRATCH_DEV, in this case OVL_BASE_SCRATCH_DEV
+		# will be null, so check OVL_BASE_SCRATCH_DEV before
+		# running shutdown to avoid shutting down base fs accidently.
+		if [ -z $OVL_BASE_SCRATCH_DEV ]; then
+			echo -n "Ignore shutdown because "
+			echo "$SCRATCH_DEV is not a block device"
+		else
+			src/godown $* $OVL_BASE_SCRATCH_MNT
+		fi
+	else
+		src/godown $* $SCRATCH_MNT
+	fi
+}
+
 _test_mount()
 {
     if [ "$FSTYP" == "overlay" ]; then
@@ -2908,8 +2926,23 @@ _require_scratch_shutdown()
 
 	_scratch_mkfs > /dev/null 2>&1
 	_scratch_mount
-	src/godown -f $SCRATCH_MNT 2>&1 \
-		|| _notrun "$FSTYP does not support shutdown"
+
+	if [ $FSTYP = "overlay" ]; then
+		if [ -z $OVL_BASE_SCRATCH_DEV ]; then
+			# In lagacy overlay usage, it may specify directory as 
+			# SCRATCH_DEV, in this case OVL_BASE_SCRATCH_DEV
+			# will be null, so check OVL_BASE_SCRATCH_DEV before
+			# running shutdown to avoid shutting down base fs accidently.
+			_notrun "$SCRATCH_DEV is not a block device"
+		else
+			src/godown -f $OVL_BASE_SCRATCH_MNT 2>&1 \
+			|| _notrun "Underlying filesystem does not support shutdown"
+		fi
+	else
+		src/godown -f $SCRATCH_MNT 2>&1 \
+			|| _notrun "$FSTYP does not support shutdown"
+	fi
+
 	_scratch_unmount
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-01-10  2:35 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12  3:09 [PATCH v3 1/3] common/rc: add scratch shutdown support for overlayfs Chengguang Xu
2017-12-12  3:09 ` [PATCH v3 2/3] common/rc: add a check case in _require_xfs_io_command() to support syncfs Chengguang Xu
2017-12-12  3:09 ` [PATCH v3 3/3] generic/470: add syncfs test Chengguang Xu
2017-12-12  6:00   ` Amir Goldstein
2017-12-12  6:07     ` Chengguang Xu
2017-12-12  9:24   ` [PATCH v3 3/3] generic/471: " Eryu Guan
2017-12-12  9:56     ` Amir Goldstein
2017-12-12 10:05       ` Chengguang Xu
2017-12-12 11:00         ` Amir Goldstein
2017-12-12 13:30         ` Eryu Guan
2017-12-12  5:58 ` [PATCH v3 1/3] common/rc: add scratch shutdown support for overlayfs Amir Goldstein
2017-12-12  9:16 ` Eryu Guan
2017-12-12 10:20   ` Chengguang Xu
2017-12-12 13:39     ` Eryu Guan
2018-01-03 12:44       ` Chengguang Xu
2018-01-03 12:58         ` Amir Goldstein
2018-01-03 14:25           ` Chengguang Xu
2018-01-03 14:54             ` Amir Goldstein
2018-01-10  2:35               ` Chengguang Xu
2017-12-14  3:35   ` Chengguang Xu
2017-12-14  4:32     ` Eryu Guan
2017-12-14  5:31       ` Chengguang Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.