>From 0edbc6d9f7abae299d6b1bd4b8ad76728afab313 Mon Sep 17 00:00:00 2001 Message-Id: <0edbc6d9f7abae299d6b1bd4b8ad76728afab313.1508043579.git.shli@fb.com> From: Shaohua Li Date: Sat, 14 Oct 2017 18:57:06 -0700 Subject: [PATCH] Add cgroup2 writeback test --- common/cgroup2 | 18 +++++++++++++++++ tests/generic/463 | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/463.out | 2 ++ tests/generic/group | 1 + 4 files changed, 77 insertions(+) create mode 100644 common/cgroup2 create mode 100755 tests/generic/463 create mode 100644 tests/generic/463.out diff --git a/common/cgroup2 b/common/cgroup2 new file mode 100644 index 00000000..130c2f79 --- /dev/null +++ b/common/cgroup2 @@ -0,0 +1,18 @@ +#!/bin/bash +# cgroup2 specific common functions + +export CGROUP2_PATH="/sys/fs/cgroup" + +_require_cgroup2() +{ + if [ ! -f ${CGROUP2_PATH}/cgroup.subtree_control ]; then + _notrun "Test requires cgroup2 enabled" + fi +} + +_get_scratch_dev_devt() +{ + ls -l $SCRATCH_DEV | awk '{printf("%s:%s", substr($5, 1, length($5)-1), 0)}' +} + +/bin/true diff --git a/tests/generic/463 b/tests/generic/463 new file mode 100755 index 00000000..8dafadb0 --- /dev/null +++ b/tests/generic/463 @@ -0,0 +1,56 @@ +#! /bin/bash + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/cgroup2 + +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 +cgname=`mktemp -du ${CGROUP2_PATH}/test.XXXXXX` +_cleanup() +{ + _scratch_unmount + cd / + rmdir $cgname +} + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_scratch +_require_cgroup2 + +# Setup Filesystem +_scratch_mkfs >/dev/null 2>&1 \ + || _fail "mkfs failed" + +_scratch_mount \ + || _fail "mount failed" + +echo +io > /sys/fs/cgroup/cgroup.subtree_control +mkdir $cgname + +wbytes=$( +echo $BASHPID > $cgname/cgroup.procs; +dd if=/dev/zero of=$SCRATCH_MNT/image bs=1M count=100 >/dev/null 2>&1; +# Makre sure writeback starts +sleep 120; +cat $cgname/io.stat | sed -n "s/$(_get_scratch_dev_devt).*wbytes=\([0-9]*\).*/\1/p" +) + +[ -z "$wbytes" -o "$wbytes" = "0" ] && _fail "Cgroup writeback doesn't work" +echo "Cgroup writeback test success" + +# success, all done +status=0 +exit diff --git a/tests/generic/463.out b/tests/generic/463.out new file mode 100644 index 00000000..211da95e --- /dev/null +++ b/tests/generic/463.out @@ -0,0 +1,2 @@ +QA output created by 463 +Cgroup writeback test success diff --git a/tests/generic/group b/tests/generic/group index f2a6cdad..ea7b6956 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -465,3 +465,4 @@ 460 auto quick rw 461 auto shutdown stress 462 auto quick dax +463 cgroup writeback test -- 2.11.0