# Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
. common/config
+. common/zoned
BC="$(type -P bc)" || BC=
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()
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
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
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