summaryrefslogtreecommitdiffstats
path: root/qa/workunits/fs/maxentries/maxentries.sh
blob: d48fd956e2cac8294f54d4836db7fa41575e0116 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash

set -ex

function expect_false()
{
	set -x
	if "$@"; then return 1; else return 0; fi
}

function make_files()
{
  set +x
  temp_dir=`mktemp -d mkfile_test_XXXXXX`
  for i in $(seq 1 $1)
  do
    echo -n | dd of="${temp_dir}/file_$i" conv=fsync || return 1
    sync "${temp_dir}" || return 1
  done
  set -x
  return 0
}

function make_dirs()
{
  set +x
  temp_dir=`mktemp -d mkdir_test_XXXXXX`
  for i in $(seq 1 $1)
  do
    mkdir -p ${temp_dir}/dir_${i} || return 1
    sync "${temp_dir}" || return 1
  done
  set -x
  return 0
}

function make_nodes()
{
  set +x
  temp_dir=`mktemp -d mknod_test_XXXXXX`
  for i in $(seq 1 $1)
  do
    mknod ${temp_dir}/fifo_${i} p || return 1
    sync "${temp_dir}" || return 1
  done
  set -x
  return 0
}

function rename_files()
{
  set +x
  temp_dir=`mktemp -d rename_test_XXXXXX`
  mkdir -p ${temp_dir}/rename

  for i in $(seq 1 $1)
  do
    touch ${temp_dir}/file_${i} || return 1

    mv ${temp_dir}/file_${i} ${temp_dir}/rename/ || return 1
    sync "${temp_dir}" || return 1
  done
  set -x
  return 0
}

function make_symlinks()
{
  set +x
  temp_dir=`mktemp -d symlink_test_XXXXXX`
  mkdir -p ${temp_dir}/symlink 

  touch ${temp_dir}/file

  for i in $(seq 1 $1)
  do
    ln -s ../file ${temp_dir}/symlink/sym_${i} || return 1
    sync "${temp_dir}" || return 1
  done
  set -x
  return 0
}

function make_links()
{
  set +x
  temp_dir=`mktemp -d link_test_XXXXXX`
  mkdir -p ${temp_dir}/link 

  touch ${temp_dir}/file

  for i in $(seq 1 $1)
  do
    ln ${temp_dir}/file ${temp_dir}/link/link_${i} || return 1
    sync "${temp_dir}" || return 1
  done
  set -x
  return 0
}

function cleanup()
{
  rm -rf *
}

test_dir="max_entries"
mkdir -p $test_dir
pushd $test_dir

dir_max_entries=100
ceph config set mds mds_dir_max_entries $dir_max_entries

ok_dir_max_entries=$dir_max_entries
fail_dir_max_entries=$((dir_max_entries+1))

# make files test
make_files $ok_dir_max_entries
expect_false make_files $fail_dir_max_entries

# make dirs test
make_dirs $ok_dir_max_entries
expect_false make_dirs $fail_dir_max_entries

# make nodes test
make_nodes $ok_dir_max_entries
expect_false make_nodes $fail_dir_max_entries

# rename files test
rename_files $ok_dir_max_entries
expect_false rename_files $fail_dir_max_entries

# symlink files test
make_symlinks $ok_dir_max_entries
expect_false make_symlinks $fail_dir_max_entries

# link files test
make_links $ok_dir_max_entries
expect_false make_links $fail_dir_max_entries

# no limit (e.g., default value)
dir_max_entries=0
ceph config set mds mds_dir_max_entries $dir_max_entries

make_files 500
make_dirs 500
make_nodes 500
rename_files 500
make_symlinks 500
make_links 500

cleanup

popd # $test_dir

echo OK