]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfs: require zoned RT devices to have at least three zones xfs-zoned-old-2024-04-10
authorChristoph Hellwig <hch@lst.de>
Wed, 21 Feb 2024 16:15:48 +0000 (17:15 +0100)
committerChristoph Hellwig <hch@lst.de>
Sat, 24 Feb 2024 05:42:19 +0000 (06:42 +0100)
Anything less will deadlock on GC and will be rejected by mkfs and the
kernel anyway.

Signed-off-by: Christoph Hellwig <hch@lst.de>
common/rc
common/xfs
tests/xfs/557 [changed mode: 0644->0755]

index 57c164a2ad47d59cadf9597a9c449e9c98c0275f..f3e042cc3efea2d2e416e22476149ef92029f609 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3,6 +3,7 @@
 # Copyright (c) 2000-2006 Silicon Graphics, Inc.  All Rights Reserved.
 
 . common/config
+. common/zoned
 
 BC="$(type -P bc)" || BC=
 
@@ -990,6 +991,22 @@ _small_fs_size_mb()
        echo "$size"
 }
 
+_zone_type()
+{
+       local target=$1
+       if [ -z $target ]; then
+               echo "Usage: _zone_type <device>"
+               exit 1
+       fi
+       local sdev=`_short_dev $target`
+
+       if [ -e /sys/block/${sdev}/queue/zoned ]; then
+               cat /sys/block/${sdev}/queue/zoned
+       else
+               echo none
+       fi
+}
+
 # Create fs of certain size on scratch device
 # _scratch_mkfs_sized <size in bytes> [optional blocksize]
 _scratch_mkfs_sized()
@@ -1049,8 +1066,25 @@ _scratch_mkfs_sized()
 
        if [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
                local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
-               [ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
-               rt_ops="-r size=$fssize"
+               local zone_type=`_zone_type $SCRATCH_RTDEV`
+               local rtsize="$fssize"
+
+               if [ "${zone_type}" != "none" ]; then
+                       local zone_capacity=$(_zone_capacity 0 $SCRATCH_RTDEV)
+                       local data_zones=$(( ($rtsize + $zone_capacity) / $zone_capacity ))
+                       local gc_zones=2
+
+                       # Add reserved space for gc and open zones. The calculation is a bit
+                       # simplified, - we assume that data zones ~< open zones.
+                       # This might result in more than the minimum but should
+                       # be fine for scratch mkfs purposes, as the requested size is
+                       # generally small
+                       rtsize=$(( (2 * $data_zones + $gc_zones) * $zone_capacity ))
+               fi
+               if [ "$rtsize" -gt "$rtdevsize" ]; then
+                       _notrun "Scratch rt device too small"
+               fi
+               rt_ops="-r size=$rtsize"
        fi
 
        case $FSTYP in
@@ -2303,22 +2337,6 @@ _require_dm_target()
        esac
 }
 
-_zone_type()
-{
-       local target=$1
-       if [ -z $target ]; then
-               echo "Usage: _zone_type <device>"
-               exit 1
-       fi
-       local sdev=`_short_dev $target`
-
-       if [ -e /sys/block/${sdev}/queue/zoned ]; then
-               cat /sys/block/${sdev}/queue/zoned
-       else
-               echo none
-       fi
-}
-
 _require_zoned_device()
 {
        local target=$1
index d9bd66860a8e44e9d8a8ebe3974e8b6c508581d2..fad1851f84d734579f2b8595cdc9c911e2fe6a5c 100644 (file)
@@ -165,6 +165,11 @@ _scratch_mkfs_xfs()
 
        grep -q crc=0 $tmp.mkfsstd && _force_xfsv4_mount_options
 
+       grep -q "zoned file systems do not support" $tmp.mkfserr && \
+               _notrun "Not supported on zoned file systems"
+       grep -q "must be greater than the minimum" $tmp.mkfserr && \
+               _notrun "Zone count too small"
+
        if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
                # manually parse the mkfs output to get the fs size in bytes
                local fs_size
old mode 100644 (file)
new mode 100755 (executable)