Skip to contentSkip to conversation

generic/084: use src/multi_open_unlink to replace tail command

PATCH Superseded Zorro Lang 2 participants 3 messages Aug 17, 2015

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH v3 1/1 generic/084: use src/multi_open_unlink to replace tail command

generic/084 try to run 'tail' command, tail will use inotify. There're some limit about the number of inotify. For example fs.inotify.max_user_instances specifies an upper limit on the number of inotify instances that can be created per real user ID.

When I test on a machine with 154 cpu cores, this case run failed, and hit many warning likes:

+tail: inotify cannot be used, reverting to polling: Too many open files

Because the fs.inotify.max_user_instances is 128, so if we try to tail 154 files, it will be failed.

So use src/multi_open_unlink to instead of tail will avoid this problem.

---
 tests/generic/084 | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
tests/generic/084 +4 -11
index 3fec6c2..d5061a7 100755
@@ -69,15 +69,8 @@ _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
 
 # create, open & unlinked files so unlinked inode list is not empty
-for i in `seq 1 $nr_cpu`; do
-	testfile=$SCRATCH_MNT/$seq.unlinked.$i
-	touch $testfile
-	tail -f $testfile &
-	tail_pids="$tail_pids $!"
-done
-# give tail some time to open the file before the file is removed
-sleep 1
-rm -f $SCRATCH_MNT/$seq.unlinked.*
+src/multi_open_unlink -f $SCRATCH_MNT/$seq.unlinked -n $nr_cpu -s 1000 &
+open_pid=$!
 
 # start link/unlink storm
 src=$SCRATCH_MNT/$seq.target
@@ -96,8 +89,8 @@ done &
 sleep 5
 kill $! >/dev/null 2>&1
 
-kill $tail_pids $link_pids >/dev/null 2>&1
-wait $tail_pids $link_pids
+kill $open_pid $link_pids >/dev/null 2>&1
+wait $open_pid $link_pids
 
 # all done, no oops/hang expected, _check_filesystems checks SCRATCH_DEV after test
 status=0
Signature · 1 line
1.9.3
#1 lore raw

----- 原始邮件 -----

Quoted 20 lines

发件人: "Zorro Lang" <[email protected]>
收件人: [email protected]
抄送: [email protected], [email protected], "Zorro Lang" <[email protected]> 发送时间: 星期一, 2015年 8 月 17日 下午 9:49:53
主题: [PATCH v3] generic/084: use src/multi_open_unlink to replace tail command

generic/084 try to run 'tail' command, tail will use inotify. There're some limit about the number of inotify. For example fs.inotify.max_user_instances specifies an upper limit on the number of inotify instances that can be created per real user ID.

When I test on a machine with 154 cpu cores, this case run failed, and hit many warning likes:

+tail: inotify cannot be used, reverting to polling: Too many open files

Because the fs.inotify.max_user_instances is 128, so if we try to tail 154 files, it will be failed.

Quoted 6 lines

So use src/multi_open_unlink to instead of tail will avoid this problem.

Hi,

Eryu told me I shouldn't add "Reviewed-by" at here. Sorry for my mistake, I just thought I should add everyone who helped me. Please help to review again.

Thanks very much.

Zorro

Reviewed-by on v3 1/1
#2 lore raw
In reply to Zorro Lang
Quoted 9 lines · Zorro Lang

generic/084 try to run 'tail' command, tail will use inotify. There're some limit about the number of inotify. For example fs.inotify.max_user_instances specifies an upper limit on the number of inotify instances that can be created per real user ID.

When I test on a machine with 154 cpu cores, this case run failed, and hit many warning likes:

Quoted 7 lines

+tail: inotify cannot be used, reverting to polling: Too many open files

Because the fs.inotify.max_user_instances is 128, so if we try to tail 154 files, it will be failed.

So use src/multi_open_unlink to instead of tail will avoid this problem.

Looks good to me overall, just some nitpicks :)

Quoted 4 lines

You shouldn't add "Reviewed-by" tags until reviewer said so.

Quoted 12 lines
---
 tests/generic/084 | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
tests/generic/084 +0 -0
index 3fec6c2..d5061a7 100755
@@ -69,15 +69,8 @@ _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
 
 # create, open & unlinked files so unlinked inode list is not empty

tests/generic/084 _scratch_mkfs >>$seqres.full 2>&1 · line 72

Quoted 10 lines
tests/generic/084 +1 -9
-for i in `seq 1 $nr_cpu`; do
-	testfile=$SCRATCH_MNT/$seq.unlinked.$i
-	touch $testfile
-	tail -f $testfile &
-	tail_pids="$tail_pids $!"
-done
-# give tail some time to open the file before the file is removed
-sleep 1
-rm -f $SCRATCH_MNT/$seq.unlinked.*
+src/multi_open_unlink -f $SCRATCH_MNT/$seq.unlinked -n $nr_cpu -s 1000 &

I think the "-s 1000" is not necessary, the default sleep time is 60s and that's enough for this test (sleep 5 below).

Thanks for fixing this case, and thanks Dave for the pointer to multi_open_unlink. Now you can add

in your v4 patch :)

Eryu