From patchwork Tue Apr 2 10:34:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Henriques X-Patchwork-Id: 10881371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13D5417E0 for ; Tue, 2 Apr 2019 10:34:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04E6E22F3E for ; Tue, 2 Apr 2019 10:34:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED6492878E; Tue, 2 Apr 2019 10:34:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,LOTS_OF_MONEY, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89B9322F3E for ; Tue, 2 Apr 2019 10:34:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728746AbfDBKef (ORCPT ); Tue, 2 Apr 2019 06:34:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:36172 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726168AbfDBKee (ORCPT ); Tue, 2 Apr 2019 06:34:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6E0E5AC4A; Tue, 2 Apr 2019 10:34:32 +0000 (UTC) From: Luis Henriques To: fstests@vger.kernel.org Cc: "Yan, Zheng" , ceph-devel@vger.kernel.org, Luis Henriques Subject: [RFC PATCH 1/2] ceph: test basic ceph.quota.max_files quota Date: Tue, 2 Apr 2019 11:34:27 +0100 Message-Id: <20190402103428.21435-2-lhenriques@suse.com> In-Reply-To: <20190402103428.21435-1-lhenriques@suse.com> References: <20190402103428.21435-1-lhenriques@suse.com> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Simple set of checks for CephFS max_files directory quota implementation. Signed-off-by: Luis Henriques --- tests/ceph/001 | 108 ++++++++++++++++++++++++++++++++++++++++++++ tests/ceph/001.out | 1 + tests/ceph/Makefile | 20 ++++++++ tests/ceph/group | 1 + 4 files changed, 130 insertions(+) create mode 100755 tests/ceph/001 create mode 100644 tests/ceph/001.out create mode 100644 tests/ceph/Makefile create mode 100644 tests/ceph/group diff --git a/tests/ceph/001 b/tests/ceph/001 new file mode 100755 index 000000000000..c4fe310d5135 --- /dev/null +++ b/tests/ceph/001 @@ -0,0 +1,108 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019 SUSE LLC. All Rights Reserved. +# +# FS QA Test No. 001 +# +# Test basic ceph.quota.max_files quota features. +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +testdir=$TEST_DIR/quota-test + +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -rf $tmp.* + rm -rf $testdir +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_os Linux +_supported_fs ceph + +_require_attrs + +set_quota() +{ + val=$1 + dir=$2 + $SETFATTR_PROG -n ceph.quota.max_files -v $val $dir >/dev/null 2>&1 +} +get_quota() +{ + dir=$1 + $GETFATTR_PROG --only-values -n ceph.quota.max_files $dir 2> /dev/null +} + +mkdir $testdir + +# test setting quota +set_quota 10 $testdir +ret=$(get_quota $testdir) +if [ "$ret" -ne 10 ]; then + _fail "expected max_files quota to be 10, got '$ret' instead" +fi +# set quota to largest acceptable value (0x7FFFFFFFFFFFFFFF) +set_quota 9223372036854775807 $testdir +ret=$(get_quota $testdir) +if [ "$ret" -ne 9223372036854775807 ]; then + _fail "expected max_files quota to be 9223372036854775807, got '$ret' instead" +fi +# test resetting quota +set_quota 0 $testdir +ret=$(get_quota $testdir) +if [ -n "$ret" ]; then + _fail "expected 0 max_files quota, got '$ret' instead" +fi +# set quota to invalid values (0x8000000000000000 and -1) +set_quota 9223372036854775808 $testdir +ret=$(get_quota $testdir) +if [ -n "$ret" ]; then + _fail "expected max_files quota to be 0, got '$ret' instead" +fi +set_quota -1 $testdir +ret=$(get_quota $testdir) +if [ -n "$ret" ]; then + _fail "expected max_files quota to be 0, got '$ret' instead" +fi + +set_quota 5 $testdir +mkdir $testdir/0 +touch $testdir/0/1 +touch $testdir/0/2 +touch $testdir/3 +touch $testdir/4 2> /dev/null +if [ $? -ne 1 ]; then + _fail "Should have failed to create file" +fi +mkdir $testdir/5 2> /dev/null +if [ $? -ne 1 ]; then + _fail "Should have failed to create directory" +fi + +set_quota 0 $testdir +touch $testdir/4 2> /dev/null +if [ $? -ne 0 ]; then + _fail "Should have succeeded to create file" +fi +mkdir $testdir/5 2> /dev/null +if [ $? -ne 0 ]; then + _fail "Should have succeeded to create directory" +fi + +# success, all done +status=0 +exit diff --git a/tests/ceph/001.out b/tests/ceph/001.out new file mode 100644 index 000000000000..097d046a6fd4 --- /dev/null +++ b/tests/ceph/001.out @@ -0,0 +1 @@ +QA output created by 001 diff --git a/tests/ceph/Makefile b/tests/ceph/Makefile new file mode 100644 index 000000000000..f93862af4f31 --- /dev/null +++ b/tests/ceph/Makefile @@ -0,0 +1,20 @@ +# +# Copyright (c) 2019 SUSE LLC. All Rights Reserved. +# + +TOPDIR = ../.. +include $(TOPDIR)/include/builddefs + +CEPHFS_DIR = cephfs +TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(CEPHFS_DIR) + +include $(BUILDRULES) + +install: + $(INSTALL) -m 755 -d $(TARGET_DIR) + $(INSTALL) -m 755 $(TESTS) $(TARGET_DIR) + $(INSTALL) -m 644 group $(TARGET_DIR) + $(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR) + +# Nothing. +install-dev install-lib: diff --git a/tests/ceph/group b/tests/ceph/group new file mode 100644 index 000000000000..e389bc6ec7ee --- /dev/null +++ b/tests/ceph/group @@ -0,0 +1 @@ +001 auto quick quota From patchwork Tue Apr 2 10:34:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Henriques X-Patchwork-Id: 10881375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C592A1575 for ; Tue, 2 Apr 2019 10:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4EAE22F3E for ; Tue, 2 Apr 2019 10:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A993A2878E; Tue, 2 Apr 2019 10:34:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,LOTS_OF_MONEY, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42D9B22F3E for ; Tue, 2 Apr 2019 10:34:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728916AbfDBKeh (ORCPT ); Tue, 2 Apr 2019 06:34:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:36192 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728682AbfDBKeg (ORCPT ); Tue, 2 Apr 2019 06:34:36 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 61D55ABD4; Tue, 2 Apr 2019 10:34:34 +0000 (UTC) From: Luis Henriques To: fstests@vger.kernel.org Cc: "Yan, Zheng" , ceph-devel@vger.kernel.org, Luis Henriques Subject: [RFC PATCH 2/2] ceph: test basic ceph.quota.max_bytes quota Date: Tue, 2 Apr 2019 11:34:28 +0100 Message-Id: <20190402103428.21435-3-lhenriques@suse.com> In-Reply-To: <20190402103428.21435-1-lhenriques@suse.com> References: <20190402103428.21435-1-lhenriques@suse.com> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Simple set of checks for CephFS max_bytes directory quota implementation. Signed-off-by: Luis Henriques --- tests/ceph/002 | 147 +++++++++++++++++++++++++++++++++++++++++++++ tests/ceph/002.out | 1 + tests/ceph/group | 1 + 3 files changed, 149 insertions(+) create mode 100755 tests/ceph/002 create mode 100644 tests/ceph/002.out diff --git a/tests/ceph/002 b/tests/ceph/002 new file mode 100755 index 000000000000..313865dc639e --- /dev/null +++ b/tests/ceph/002 @@ -0,0 +1,147 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019 SUSE LLC. All Rights Reserved. +# +# FS QA Test No. 002 +# +# This tests basic ceph.quota.max_bytes quota features. +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +testdir=$TEST_DIR/quota-test + +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -rf $tmp.* + rm -rf $testdir +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_os Linux +_supported_fs ceph + +_require_attrs + +set_quota() +{ + val=$1 + dir=$2 + $SETFATTR_PROG -n ceph.quota.max_bytes -v $val $dir >/dev/null 2>&1 +} + +get_quota() +{ + dir=$1 + $GETFATTR_PROG --only-values -n ceph.quota.max_bytes $dir 2> /dev/null +} + +# function to write a file. We use a loop because quotas in CephFS is a +# "best-effort" implementation, i.e. a write may actually be allowed even if the +# quota is being exceeded. Using a loop reduces the chances of this to happen. +# +# NOTE: 'size' parameter is in M +write_file() +{ + file=$1 + size=$2 # size in M + for (( i = 1; i < $size; i++ )); do + $XFS_IO_PROG -f -c "pwrite -W $((i * 1048576)) 1048576" \ + $file >/dev/null 2>&1 + done +} + +# Check a file size +# +# NOTE: 'expected' (size) parameter is in M +check_file_size() +{ + file=$1 + expected=$(($2 * 1048576)) + size=$(stat -c %s $file) + if [ "$size" -ne "$expected" ]; then + _fail "Expecting file with $expected got $size" + fi +} + +mkdir $testdir + +# test setting quota +set_quota 1000000 $testdir +ret=$(get_quota $testdir) +if [ "$ret" -ne 1000000 ]; then + _fail "expected max_bytes quota to be 1000000, got '$ret' instead" +fi +# set quota to largest acceptable value (0x7FFFFFFFFFFFFFFF) +set_quota 9223372036854775807 $testdir +ret=$(get_quota $testdir) +if [ "$ret" -ne 9223372036854775807 ]; then + _fail "expected max_bytes quota to be 9223372036854775807, got '$ret' instead" +fi +# test resetting quota +set_quota 0 $testdir +ret=$(get_quota $testdir) +if [ -n "$ret" ]; then + _fail "expected 0 max_bytes quota, got '$ret' instead" +fi +# set quota to invalid values (0x8000000000000000 and -1) +set_quota 9223372036854775808 $testdir +ret=$(get_quota $testdir) +if [ -n "$ret" ]; then + _fail "expected max_bytes quota to be 0, got '$ret' instead" +fi +set_quota -1 $testdir +ret=$(get_quota $testdir) +if [ -n "$ret" ]; then + _fail "expected max_bytes quota to be 0, got '$ret' instead" +fi + +bigfile="$testdir/bigfile" + +# set quota to 10M +set_quota $((10 * 1048576)) $testdir + +# write 9M file +write_file $bigfile 9 +check_file_size $bigfile 9 +rm $bigfile + +# try to write 11M file +write_file $bigfile 11 # 11M +check_file_size $bigfile 10 +rm $bigfile + +# write 5 x 2M files +for (( j = 1; j < 6; j++ )); do + smallfile="$testdir/smallfile_$j" + write_file $smallfile 2 # 2M + check_file_size $smallfile 2 +done + +# try write another 2M file +smallfile="$testdir/smallfile_fail" +write_file $smallfile 2 +check_file_size $smallfile 0 + +# reset quota +set_quota 0 $testdir + +# write 2M file +write_file $smallfile 2 +check_file_size $smallfile 2 + +# success, all done +status=0 +exit diff --git a/tests/ceph/002.out b/tests/ceph/002.out new file mode 100644 index 000000000000..c57ca23e5cbe --- /dev/null +++ b/tests/ceph/002.out @@ -0,0 +1 @@ +QA output created by 002 diff --git a/tests/ceph/group b/tests/ceph/group index e389bc6ec7ee..02da95169c67 100644 --- a/tests/ceph/group +++ b/tests/ceph/group @@ -1 +1,2 @@ 001 auto quick quota +002 auto quick quota