Thread (12 messages) 12 messages, 3 authors, 2021-03-12
STALE1936d
Revisions (5)
  1. v2 current
  2. v3 [diff vs current]
  3. v4 [diff vs current]
  4. v5 [diff vs current]
  5. v6 [diff vs current]

[RFC PATCH v2 1/3] common/xfs: add a _require_xfs_shrink helper

From: Gao Xiang <hidden>
Date: 2021-03-12 13:24:43
Also in: fstests
Subsystem: the rest · Maintainer: Linus Torvalds

In order to detect whether the current kernel supports XFS shrinking.

Signed-off-by: Gao Xiang <redacted>
---
use -D1 rather than -D0 since xfs_growfs would report unchanged size
instead.

 common/xfs | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/common/xfs b/common/xfs
index 2156749d..326edacc 100644
--- a/common/xfs
+++ b/common/xfs
@@ -432,6 +432,16 @@ _supports_xfs_scrub()
 	return 0
 }
 
+_require_xfs_shrink()
+{
+	_scratch_mkfs_xfs >/dev/null 2>&1
+
+	_scratch_mount
+	$XFS_GROWFS_PROG -D1 "$SCRATCH_MNT" 2>&1 | grep -q 'Invalid argument' || { \
+		_scratch_unmount; _notrun "kernel does not support shrinking"; }
+	_scratch_unmount
+}
+
 # run xfs_check and friends on a FS.
 _check_xfs_filesystem()
 {
-- 
2.27.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help