ceph/005: verify correct statfs behaviour with quotas
PATCH v3 1/1 ceph/005: verify correct statfs behaviour with quotas
When using a directory with 'max_bytes' quota as a base for a mount, statfs shall use that 'max_bytes' value as the total disk size. That value shall be used even when using subdirectory as base for the mount.
A bug was found where, when this subdirectory also had a 'max_files' quota, the real filesystem size would be returned instead of the parent 'max_bytes' quota value. This test case verifies this bug is fixed.
---
Changes since v2:
- correctly set SCRATCH_DEV, always using its original value
Changes since v1 are:
- creation of an helper for getting total mount space using 'df'
- now the test sends quota size to stdout
common/rc | 13 +++++++++++++ tests/ceph/005 | 39 +++++++++++++++++++++++++++++++++++++++ tests/ceph/005.out | 4 ++++ 3 files changed, 56 insertions(+) create mode 100755 tests/ceph/005 create mode 100644 tests/ceph/005.out
common/rc +13 -0
@@ -4254,6 +4254,19 @@ _get_available_space() echo $((avail_kb * 1024)) } +# get the total space in bytes +# +_get_total_space() +{ + if [ -z "$1" ]; then + echo "Usage: _get_total_space <mnt>" + exit 1 + fi + local total_kb; + total_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $3 }'` + echo $(($total_kb * 1024)) +} + # return device size in kb _get_device_size() {
tests/ceph/005 new file +39 -0
@@ -0,0 +1,39 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2022 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 005 +# +# Make sure statfs reports correct total size when: +# 1. using a directory with 'max_byte' quota as base for a mount +# 2. using a subdirectory of the above directory with 'max_files' quota +# +. ./common/preamble +_begin_fstest auto quick quota + +_supported_fs ceph +_require_scratch + +_scratch_mount +mkdir -p "$SCRATCH_MNT/quota-dir/subdir" + +# set quota +quota=$((2 ** 30)) # 1G +$SETFATTR_PROG -n ceph.quota.max_bytes -v "$quota" "$SCRATCH_MNT/quota-dir" +$SETFATTR_PROG -n ceph.quota.max_files -v "$quota" "$SCRATCH_MNT/quota-dir/subdir" +_scratch_unmount + +SCRATCH_DEV_ORIG="$SCRATCH_DEV" +SCRATCH_DEV="$SCRATCH_DEV/quota-dir" _scratch_mount +echo ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir" _scratch_unmount + +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_mount +echo subdir ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_unmount + +echo "Silence is golden" + +# success, all done +status=0 +exit
tests/ceph/005.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 005 +ceph quota size is 1073741824 bytes +subdir ceph quota size is 1073741824 bytes +Silence is golden
Quoted 100 lines · Luís Henriques
When using a directory with '
max_bytes' quota as a base for a mount, statfs shall use that 'max_bytes' value as the total disk size. That value shall be used even when using subdirectory as base for the mount.A bug was found where, when this subdirectory also had a '
max_files' quota, the real filesystem size would be returned instead of the parent 'max_bytes' quota value. This test case verifies this bug is fixed.Signed-off-by Luís Henriques <[email protected]>---
Changes since v2:
- correctly setSCRATCH_DEV, always using its original valueChanges since v1 are:
- creation of an helper for getting total mount space using 'df'
- now the test sends quota size to stdoutcommon/rc | 13 +++++++++++++ tests/ceph/005 | 39 +++++++++++++++++++++++++++++++++++++++ tests/ceph/005.out | 4 ++++ 3 files changed, 56 insertions(+)create mode 100755 tests/ceph/005
create mode 100644 tests/ceph/005.outcommon/rc +13
-0@@ -4254,6 +4254,19 @@ _get_available_space() echo $((avail_kb * 1024)) } +# get the total space in bytes +# +_get_total_space() +{ + if [ -z "$1" ]; then + echo "Usage: _get_total_space <mnt>" + exit 1 + fi + local total_kb; + total_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $3 }'` + echo $(($total_kb * 1024)) +} + # return device size in kb _get_device_size() {tests/ceph/005 new file +39
-0@@ -0,0 +1,39 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2022 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 005 +# +# Make sure statfs reports correct total size when: +# 1. using a directory with 'max_byte' quota as base for a mount +# 2. using a subdirectory of the above directory with 'max_files' quota +# +. ./common/preamble +_begin_fstest auto quick quota + +_supported_fs ceph +_require_scratch + +_scratch_mount +mkdir -p "$SCRATCH_MNT/quota-dir/subdir" + +# set quota +quota=$((2 ** 30)) # 1G +$SETFATTR_PROG -n ceph.quota.max_bytes -v "$quota" "$SCRATCH_MNT/quota-dir" +$SETFATTR_PROG -n ceph.quota.max_files -v "$quota" "$SCRATCH_MNT/quota-dir/subdir" +_scratch_unmount + +SCRATCH_DEV_ORIG="$SCRATCH_DEV" +SCRATCH_DEV="$SCRATCH_DEV/quota-dir" _scratch_mount +echo ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir" _scratch_unmount + +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_mount +echo subdir ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_unmount + +echo "Silence is golden" + +# success, all done +status=0 +exittests/ceph/005.out new file +0
-0
tests/ceph/005.out line 4
Quoted 4 lines
tests/ceph/005.out new file +4
-0@@ -0,0 +1,4 @@ +QA output created by 005 +ceph quota size is 1073741824 bytes +subdir ceph quota size is 1073741824 bytes +Silence is golden
LGTM.
Hi Luis,
BTW, shouldn't you update the 'tests/ceph/group.list' at the same time ?
-- Xiubo
Quoted 104 lines · Luís Henriques
When using a directory with '
max_bytes' quota as a base for a mount, statfs shall use that 'max_bytes' value as the total disk size. That value shall be used even when using subdirectory as base for the mount.A bug was found where, when this subdirectory also had a '
max_files' quota, the real filesystem size would be returned instead of the parent 'max_bytes' quota value. This test case verifies this bug is fixed.Signed-off-by Luís Henriques <[email protected]>---
Changes since v2:
- correctly setSCRATCH_DEV, always using its original valueChanges since v1 are:
- creation of an helper for getting total mount space using 'df'
- now the test sends quota size to stdoutcommon/rc | 13 +++++++++++++ tests/ceph/005 | 39 +++++++++++++++++++++++++++++++++++++++ tests/ceph/005.out | 4 ++++ 3 files changed, 56 insertions(+)create mode 100755 tests/ceph/005
create mode 100644 tests/ceph/005.outcommon/rc +13
-0@@ -4254,6 +4254,19 @@ _get_available_space() echo $((avail_kb * 1024)) } +# get the total space in bytes +# +_get_total_space() +{ + if [ -z "$1" ]; then + echo "Usage: _get_total_space <mnt>" + exit 1 + fi + local total_kb; + total_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $3 }'` + echo $(($total_kb * 1024)) +} + # return device size in kb _get_device_size() {tests/ceph/005 new file +39
-0@@ -0,0 +1,39 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2022 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 005 +# +# Make sure statfs reports correct total size when: +# 1. using a directory with 'max_byte' quota as base for a mount +# 2. using a subdirectory of the above directory with 'max_files' quota +# +. ./common/preamble +_begin_fstest auto quick quota + +_supported_fs ceph +_require_scratch + +_scratch_mount +mkdir -p "$SCRATCH_MNT/quota-dir/subdir" + +# set quota +quota=$((2 ** 30)) # 1G +$SETFATTR_PROG -n ceph.quota.max_bytes -v "$quota" "$SCRATCH_MNT/quota-dir" +$SETFATTR_PROG -n ceph.quota.max_files -v "$quota" "$SCRATCH_MNT/quota-dir/subdir" +_scratch_unmount + +SCRATCH_DEV_ORIG="$SCRATCH_DEV" +SCRATCH_DEV="$SCRATCH_DEV/quota-dir" _scratch_mount +echo ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir" _scratch_unmount + +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_mount +echo subdir ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_unmount + +echo "Silence is golden" + +# success, all done +status=0 +exittests/ceph/005.out new file +4
-0@@ -0,0 +1,4 @@ +QA output created by 005 +ceph quota size is 1073741824 bytes +subdir ceph quota size is 1073741824 bytes +Silence is golden
Quoted 3 lines · Xiubo Li
Hi Luis,
BTW, shouldn't you update the 'tests/ceph/group.list' at the same time ?
Thanks your review from cephfs side! We don't save group.list in fstests now, group.list is generated when building fstests. Group names of a case are recorded in the case itself, refer to:
+_begin_fstest auto quick quota
Thanks,
Zorro
Quoted 108 lines
-- Xiubo
Quoted 103 lines · Luís Henriques
When using a directory with '
max_bytes' quota as a base for a mount, statfs shall use that 'max_bytes' value as the total disk size. That value shall be used even when using subdirectory as base for the mount.A bug was found where, when this subdirectory also had a '
max_files' quota, the real filesystem size would be returned instead of the parent 'max_bytes' quota value. This test case verifies this bug is fixed.Signed-off-by Luís Henriques <[email protected]>---
Changes since v2:
- correctly setSCRATCH_DEV, always using its original valueChanges since v1 are:
- creation of an helper for getting total mount space using 'df'
- now the test sends quota size to stdoutcommon/rc | 13 +++++++++++++ tests/ceph/005 | 39 +++++++++++++++++++++++++++++++++++++++ tests/ceph/005.out | 4 ++++ 3 files changed, 56 insertions(+)create mode 100755 tests/ceph/005
create mode 100644 tests/ceph/005.outcommon/rc +13
-0@@ -4254,6 +4254,19 @@ _get_available_space() echo $((avail_kb * 1024)) } +# get the total space in bytes +# +_get_total_space() +{ + if [ -z "$1" ]; then + echo "Usage: _get_total_space <mnt>" + exit 1 + fi + local total_kb; + total_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $3 }'` + echo $(($total_kb * 1024)) +} + # return device size in kb _get_device_size() {tests/ceph/005 new file +39
-0@@ -0,0 +1,39 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2022 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 005 +# +# Make sure statfs reports correct total size when: +# 1. using a directory with 'max_byte' quota as base for a mount +# 2. using a subdirectory of the above directory with 'max_files' quota +# +. ./common/preamble +_begin_fstest auto quick quota + +_supported_fs ceph +_require_scratch + +_scratch_mount +mkdir -p "$SCRATCH_MNT/quota-dir/subdir" + +# set quota +quota=$((2 ** 30)) # 1G +$SETFATTR_PROG -n ceph.quota.max_bytes -v "$quota" "$SCRATCH_MNT/quota-dir" +$SETFATTR_PROG -n ceph.quota.max_files -v "$quota" "$SCRATCH_MNT/quota-dir/subdir" +_scratch_unmount + +SCRATCH_DEV_ORIG="$SCRATCH_DEV" +SCRATCH_DEV="$SCRATCH_DEV/quota-dir" _scratch_mount +echo ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir" _scratch_unmount + +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_mount +echo subdir ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_unmount + +echo "Silence is golden" + +# success, all done +status=0 +exittests/ceph/005.out new file +4
-0@@ -0,0 +1,4 @@ +QA output created by 005 +ceph quota size is 1073741824 bytes +subdir ceph quota size is 1073741824 bytes +Silence is golden
Quoted 9 lines · Zorro Lang
Quoted 3 lines · Xiubo Li
Hi Luis,
BTW, shouldn't you update the 'tests/ceph/group.list' at the same time ?
Thanks your review from cephfs side! We don't save group.list in fstests now, group.list is generated when building fstests. Group names of a case are recorded in the case itself, refer to:
+_begin_fstest auto quick quota
Okay, get it.
Thanks.
Quoted 110 lines
Thanks,
ZorroQuoted 106 lines
-- Xiubo
Quoted 103 lines · Luís Henriques
When using a directory with '
max_bytes' quota as a base for a mount, statfs shall use that 'max_bytes' value as the total disk size. That value shall be used even when using subdirectory as base for the mount.A bug was found where, when this subdirectory also had a '
max_files' quota, the real filesystem size would be returned instead of the parent 'max_bytes' quota value. This test case verifies this bug is fixed.Signed-off-by Luís Henriques <[email protected]>---
Changes since v2:
- correctly setSCRATCH_DEV, always using its original valueChanges since v1 are:
- creation of an helper for getting total mount space using 'df' - now the test sends quota size to stdout common/rc | 13 +++++++++++++ tests/ceph/005 | 39 +++++++++++++++++++++++++++++++++++++++ tests/ceph/005.out | 4 ++++ 3 files changed, 56 insertions(+) create mode 100755 tests/ceph/005 create mode 100644 tests/ceph/005.outcommon/rc +13
-0@@ -4254,6 +4254,19 @@ _get_available_space() echo $((avail_kb * 1024)) } +# get the total space in bytes +# +_get_total_space() +{ + if [ -z "$1" ]; then + echo "Usage: _get_total_space <mnt>" + exit 1 + fi + local total_kb; + total_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $3 }'` + echo $(($total_kb * 1024)) +} + # return device size in kb _get_device_size() {tests/ceph/005 new file +39
-0@@ -0,0 +1,39 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2022 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 005 +# +# Make sure statfs reports correct total size when: +# 1. using a directory with 'max_byte' quota as base for a mount +# 2. using a subdirectory of the above directory with 'max_files' quota +# +. ./common/preamble +_begin_fstest auto quick quota + +_supported_fs ceph +_require_scratch + +_scratch_mount +mkdir -p "$SCRATCH_MNT/quota-dir/subdir" + +# set quota +quota=$((2 ** 30)) # 1G +$SETFATTR_PROG -n ceph.quota.max_bytes -v "$quota" "$SCRATCH_MNT/quota-dir" +$SETFATTR_PROG -n ceph.quota.max_files -v "$quota" "$SCRATCH_MNT/quota-dir/subdir" +_scratch_unmount + +SCRATCH_DEV_ORIG="$SCRATCH_DEV" +SCRATCH_DEV="$SCRATCH_DEV/quota-dir" _scratch_mount +echo ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir" _scratch_unmount + +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_mount +echo subdir ceph quota size is $(_get_total_space "$SCRATCH_MNT") bytes +SCRATCH_DEV="$SCRATCH_DEV_ORIG/quota-dir/subdir" _scratch_unmount + +echo "Silence is golden" + +# success, all done +status=0 +exittests/ceph/005.out new file +4
-0@@ -0,0 +1,4 @@ +QA output created by 005 +ceph quota size is 1073741824 bytes +subdir ceph quota size is 1073741824 bytes +Silence is golden