1timeout_set 45 seconds 2 3USE_RAMDISK=YES \ 4 MFSEXPORTS_EXTRA_OPTIONS="allcanchangequota,ignoregid" \ 5 MOUNT_EXTRA_CONFIG="mfscachemode=NEVER" \ 6 setup_local_empty_lizardfs info 7 8cd "${info[mount0]}" 9 10gid1=$(id -g lizardfstest_1) 11gid=$(id -g lizardfstest) 12 13sudo -nu lizardfstest_3 bash -c 'head -c 1024 /dev/zero > file_kb' 14sudo -nu lizardfstest_3 bash -c 'head -c $((64*1024*1024)) /dev/zero > file_chunk' 15 16one_kb_file_size=$(mfs_dir_info size file_kb) 17one_chunk_file_size=$(mfs_dir_info size file_chunk) 18soft=$((2*one_kb_file_size)) 19hard=$((3*one_kb_file_size)) 20 21lizardfs setquota -g $gid1 $soft $hard 0 0 . 22lizardfs setquota -g $gid $soft $hard 0 0 . 23 24verify_quota "Group $gid1 -- 0 $soft $hard 0 0 0" lizardfstest_1 25verify_quota "Group $gid -- 0 $soft $hard 0 0 0" lizardfstest 26 27sudo -nu lizardfstest_1 bash -c 'head -c 1024 /dev/zero > file_1' 28verify_quota "Group $gid1 -- $one_kb_file_size $soft $hard 1 0 0" lizardfstest_1 29sudo -nu lizardfstest_1 bash -c 'head -c 1024 /dev/zero > file_2' 30verify_quota "Group $gid1 -- $soft $soft $hard 2 0 0" lizardfstest_1 31sudo -nu lizardfstest_1 bash -c 'head -c 1024 /dev/zero > file_3' 32verify_quota "Group $gid1 +- $hard $soft $hard 3 0 0" lizardfstest_1 33 34# check if quota can't be exceeded further.. 35# .. by creating new files: 36expect_failure sudo -nu lizardfstest_1 bash -c 'head -c 1024 /dev/zero > file_4' 37assert_equals "$(stat --format=%s file_4)" 0 # file was created, but no data was written 38# .. by creating new chunks for existing files: 39expect_failure sudo -nu lizardfstest_1 bash -c 'head -c $((64*1024*1024)) /dev/zero >> file_1' 40 41# rewriting existing chunks is always possible, even after exceeding the limits: 42sudo -nu lizardfstest_1 dd if=/dev/zero of=file_2 bs=1024c count=1 conv=notrunc 43 44# truncate should always work (on files which don't have snapshots), but.. 45sudo -nu lizardfstest_1 truncate -s 1P file_2 46sudo -nu lizardfstest_1 dd if=/dev/zero of=file_2 bs=1M seek=63 count=1 conv=notrunc 47# .. one can't create new chunks: 48expect_failure sudo -nu lizardfstest_1 dd if=/dev/zero of=file_2 bs=1M seek=64 count=1 conv=notrunc 49sudo -nu lizardfstest_1 truncate -s 1024 file_2 50 51# changing group should affect usage: 52sudo -nu lizardfstest_1 chgrp $gid file_2 53verify_quota "Group $gid1 +- $((one_kb_file_size + one_chunk_file_size)) $soft $hard 3 0 0" \ 54 lizardfstest_1 55verify_quota "Group $gid -- $one_kb_file_size $soft $hard 1 0 0" lizardfstest 56 57# check if snapshots are properly handled: 58lizardfs makesnapshot file_2 snapshot_1 59verify_quota "Group $gid -- $soft $soft $hard 2 0 0" lizardfstest 60 61# BTW, check if '+' for soft limit is properly printed.. 62lizardfs setquota -g $gid $((soft-1)) $hard 0 0 . 63verify_quota "Group $gid +- $soft $((soft-1)) $hard 2 0 0" lizardfstest 64lizardfs setquota -g $gid $soft $hard 0 0 . # .. OK, come back to the previous limit 65 66# snapshots continued.. 67lizardfs makesnapshot file_2 snapshot_2 68verify_quota "Group $gid +- $hard $soft $hard 3 0 0" lizardfstest 69expect_failure lizardfs makesnapshot file_2 snapshot_3 70 71# verify that we can't create new chunks by 'splitting' a chunk shared by multiple files 72expect_failure sudo -nu lizardfstest_1 dd if=/dev/zero of=snapshot_2 bs=1k count=1 conv=notrunc 73 74# hard links don't occupy any new space, therefore are always permitted 75sudo -nu lizardfstest_1 ln file_2 hard_link 76verify_quota "Group $gid1 +- $((one_kb_file_size + one_chunk_file_size)) $soft $hard 3 0 0" \ 77 lizardfstest_1 78 79#It would be nice to test chown as well, but I don't know how to do that without using superuser 80 81