2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 SUSE Linux Products GmbH. All Rights Reserved.
7 # Tests a bug fix found in cephfs quotas handling. Here's a simplified testcase
11 # truncate files/file -s 10G
12 # setfattr limit -n ceph.quota.max_bytes -v 1000000
15 # Because we're creating a new file and truncating it, we have Fx caps and thus
16 # the truncate operation will be cached. This prevents the MDSs from updating
17 # the quota realms and thus the client will allow the above rename(2) to happen.
19 # The bug resulted in dropping support for cross quota-realms renames, reverting
20 # kernel commit dffdcd71458e ("ceph: allow rename operation under different
23 # So, the above test will now fail with a -EXDEV or, in the future (when we have
24 # a proper fix), with -EDQUOT.
26 # This bug was tracker here:
28 # https://tracker.ceph.com/issues/48203
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
45 # get standard environment, filters and checks
50 # remove previous $seqres.full before test
53 # real QA test starts here
58 _require_test_program "rename"
59 _require_ceph_vxattr_caps # we need to get file capabilities
61 workdir=$TEST_DIR/test-$seq
71 mkdir $orig1 $orig2 $dest
73 # get only the hexadecimal value of the ceph.caps vxattr, which has the
75 # ceph.caps="pAsLsXsFscr/0xd55"
78 $GETFATTR_PROG --only-values -n "ceph.caps" $1 2>/dev/null \
82 # check that a file has cephfs capabilities 'Fs'
85 caps=`get_ceph_caps $1`
86 # Fs cap is bit (1 << 8)
89 if [ $res -ne $Fs ]; then
90 _fail "File $1 doesn't have Fs caps ($caps)"
95 $SETFATTR_PROG -n ceph.quota.max_bytes -v 1000000 $dest
97 $SETFATTR_PROG -n ceph.quota.max_bytes -v 20000000000 $orig2
100 # The following 2 testcases shall fail with either -EXDEV or -EDQUOT
103 # from 'root' realm to $dest realm
104 $XFS_IO_PROG -f -c "truncate 10G" $file1
106 $here/src/rename $orig1 $dest/new1 >> $seqres.full 2>&1
107 [ $? -ne 1 ] && _fail "cross quota realms rename succeeded"
109 # from $orig2 realm to $dest realm
110 $XFS_IO_PROG -f -c "truncate 10G" $file2
112 $here/src/rename $orig2 $dest/new2 >> $seqres.full 2>&1
113 [ $? -ne 1 ] && _fail "cross quota realms rename succeeded"
115 echo "Silence is golden"