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 10head -c 1024 /dev/zero > file_kb 11head -c $((64*1024*1024)) /dev/zero > file_chunk 12 13one_kb_file_size=$(mfs_dir_info size file_kb) 14one_chunk_file_size=$(mfs_dir_info size file_chunk) 15soft=$((2*one_kb_file_size)) 16hard=$((3*one_kb_file_size)) 17 18mkdir dir 19directory=$(readlink -m dir) 20 21lizardfs setquota -d $soft $hard 0 0 dir 22lizardfs setquota -d $soft $hard 0 0 dir 23 24verify_dir_quota "Directory $directory -- 0 $soft $hard 0 0 0" $directory 25 26head -c 1024 /dev/zero > dir/file_1 27verify_dir_quota "Directory $directory -- $one_kb_file_size $soft $hard 1 0 0" $directory 28head -c 1024 /dev/zero > dir/file_2 29verify_dir_quota "Directory $directory -- $soft $soft $hard 2 0 0" $directory 30head -c 1024 /dev/zero > dir/file_3 31verify_dir_quota "Directory $directory +- $hard $soft $hard 3 0 0" $directory 32 33# check if quota can't be exceeded further.. 34# .. by creating new files: 35expect_failure head -c 1024 /dev/zero > dir/file_4 36assert_equals "$(stat --format=%s dir/file_4)" 0 # file was created, but no data was written 37# .. by creating new chunks for existing files: 38expect_failure head -c $((64*1024*1024)) /dev/zero >> dir/file_1 39 40# rewriting existing chunks is always possible, even after exceeding the limits: 41dd if=/dev/zero of=dir/file_2 bs=1024c count=1 conv=notrunc 42 43# truncate should always work (on files which don't have snapshots), but.. 44truncate -s 1P dir/file_2 45dd if=/dev/zero of=dir/file_2 bs=1M seek=63 count=1 conv=notrunc 46# .. one can't create new chunks: 47expect_failure dd if=/dev/zero of=dir/file_2 bs=1M seek=64 count=1 conv=notrunc 48truncate -s 1024 dir/file_2 49 50# Check 51verify_dir_quota "Directory $directory +- $((2 * one_kb_file_size + one_chunk_file_size)) $soft $hard 4 0 0" $directory 52rm -f dir/* 53verify_dir_quota "Directory $directory -- 0 $soft $hard 0 0 0" $directory 54 55# check if snapshots are properly handled: 56head -c 1024 /dev/zero > dir/file_1 57lizardfs makesnapshot dir/file_1 dir/snapshot_1 58verify_dir_quota "Directory $directory -- $((2 * one_kb_file_size)) $soft $hard 2 0 0" $directory 59 60# BTW, check if '+' for soft limit is properly printed.. 61lizardfs setquota -d $((soft-1)) $hard 0 0 dir 62verify_dir_quota "Directory $directory +- $soft $((soft-1)) $hard 2 0 0" $directory 63lizardfs setquota -d $soft $hard 0 0 dir # .. OK, come back to the previous limit 64 65# snapshots continued.. 66lizardfs makesnapshot dir/file_1 dir/snapshot_2 67verify_dir_quota "Directory $directory +- $hard $soft $hard 3 0 0" $directory 68expect_failure lizardfs makesnapshot dir/file_1 dir/snapshot_3 69 70# verify that we can't create new chunks by 'splitting' a chunk shared by multiple files 71expect_failure dd if=/dev/zero of=dir/snapshot_2 bs=1k count=1 conv=notrunc 72