generic/084: check inotify limit before tail many files
PATCH 1/1 generic/084: check inotify limit before tail many files
generic/084 try to run 'tail' command, tail will use inotify, and there're some limit about inotify. I think the most important is fs.inotify.max_user_instances, then fs.inotify.max_user_watches is importand too.
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.
Of course, open files limit will effect this too. But generally max_user_instances is the minimum number, so I don't check open file limit.
--- tests/generic/084 | 9 +++++++++ 1 file changed, 9 insertions(+)
tests/generic/084 +9 -0
@@ -63,6 +63,15 @@ link_unlink_storm() rm -f $seqres.full nr_cpu=`$here/src/feature -o` +user_watches=`sysctl -n fs.inotify.max_user_watches` +user_instances=`sysctl -n fs.inotify.max_user_instances` + +user_limit=$((user_watches > user_instances ? user_instances : user_watches)) +if [ $nr_cpu -ge $((user_limit/2)) ] +then + nr_cpu=$((user_limit/2)) +fi + echo "Silence is golden" _scratch_mkfs >>$seqres.full 2>&1
Signature · 1 line
1.9.3
Quoted 4 lines · Zorro Lang
generic/084 try to run 'tail' command, tail will use inotify, and there're some limit about inotify. I think the most important is fs.inotify.max_user_instances, then fs.inotify.max_user_watches is importand too.
max_user_watches is much larger (usually 8k?) than max_user_instances (128), I think we can skip the max_user_watches check here.
Quoted 6 lines
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
No need to wrap lines for quoted logs.
Quoted 18 lines
Because the fs.inotify.max_user_instances is 128, so if we try to tail 154 files, it will be failed.
Of course, open files limit will effect this too. But generally
max_user_instancesis the minimum number, so I don't check open file limit.Signed-off-by Zorro Lang <[email protected]>--- tests/generic/084 | 9 +++++++++ 1 file changed, 9 insertions(+)tests/generic/084 +0
-0
tests/generic/084 link_unlink_storm() · line 67
Quoted 5 lines
tests/generic/084 +2
-0@@ -63,6 +63,15 @@ link_unlink_storm() rm -f $seqres.full nr_cpu=`$here/src/feature -o` +user_watches=`sysctl -n fs.inotify.max_user_watches` +user_instances=`sysctl -n fs.inotify.max_user_instances`
I think we need some comments in the code too.
tests/generic/084 link_unlink_storm() · line 69
Quoted 2 lines
tests/generic/084 +2
-0+ +user_limit=$((user_watches > user_instances ? user_instances : user_watches))
Please use plain if:then
tests/generic/084 link_unlink_storm() · line 71
Quoted 2 lines
tests/generic/084 +2
-0+if [ $nr_cpu -ge $((user_limit/2)) ] +then
if []; then
fi
this is the preferred format in xfstests
tests/generic/084 link_unlink_storm() · line 72
Quoted 1 line
tests/generic/084 +1
-0+ nr_cpu=$((user_limit/2))
Need comments to explain why divide by 2.
Thanks,
Eryu
Quoted 8 lines
tests/generic/084 +2
-0+fi + echo "Silence is golden" _scratch_mkfs >>$seqres.full 2>&1Signature · 1 line
1.9.3
Quoted 5 lines · Zorro Lang
generic/084 try to run 'tail' command, tail will use inotify, and there're some limit about inotify. I think the most important is fs.inotify.max_user_instances, then fs.inotify.max_user_watches is importand too.
Quoted 8 lines
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.
We use 'tail' all over the place in xfstests, so why is only generic/084 affected?
And really, this seems more like a distro/environment bug and doesn't need xfstests help to work around. i.e. changing the sysctl before starting xfstests seems much more appropriate than hacking it a random test. Especially as there may be more than one test that is affected by this, and when run in a random order this would cause those other tests to pass/fail depending on whether generic/084 had already been run on that machine....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Hi Dave,
Thanks for your reply.
----- 原始邮件 -----
Quoted 15 lines
发件人: "Dave Chinner" <[email protected]>
收件人: "Zorro Lang" <[email protected]>
抄送: [email protected], [email protected]
发送时间: 星期一, 2015年 8 月 17日 上午 8:03:36
主题: Re: [PATCH] generic/084: check inotify limit before tail many filesQuoted 8 lines · Zorro Lang
generic/084 try to run 'tail' command, tail will use inotify, and there're some limit about inotify. I think the most important is fs.inotify.max_user_instances, then fs.inotify.max_user_watches is importand too.
When I test on a machine with 154 cpu cores, this case run failed, and hit many warning likes:
Quoted 8 lines
Quoted 5 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.
We use 'tail' all over the place in xfstests, so why is only generic/084 affected?
Because generic/084 use try to create $nr_cpu tail processes:
for i in seq 1 $nr_cpu; do
...
tail -f $testfile &
...done
And nr_cpu=$here/src/feature -o.
Generally fs.inotify.max_user_instances is 128, when a machine have more than(or nearly the same) this number, this test will failed.
Maybe other cases don't try to create so many tail processes, so they passed.
Quoted 8 lines
And really, this seems more like a distro/environment bug and doesn't need xfstests help to work around. i.e. changing the sysctl before starting xfstests seems much more appropriate than hacking it a random test. Especially as there may be more than one test that is affected by this, and when run in a random order this would cause those other tests to pass/fail depending on whether generic/084 had already been run on that machine....
As this situation generally won't effect other cases, so I try to make the patch don't effect more other cases. Because I don't know if someone try to test fs.inotify...
But if maintainer think it'll be better, I will change the patch:)
Thanks,
Zorro Lang
Quoted 8 lines
Cheers,
Dave.
--
Dave Chinner
[email protected]
Quoted 34 lines · Zirong Lang
Hi Dave,
Thanks for your reply.
----- 原始邮件 -----
Quoted 15 lines
发件人: "Dave Chinner" <[email protected]>
收件人: "Zorro Lang" <[email protected]>
抄送: [email protected], [email protected]
发送时间: 星期一, 2015年 8 月 17日 上午 8:03:36
主题: Re: [PATCH] generic/084: check inotify limit before tail many filesQuoted 8 lines · Zorro Lang
generic/084 try to run 'tail' command, tail will use inotify, and there're some limit about inotify. I think the most important is fs.inotify.max_user_instances, then fs.inotify.max_user_watches is importand too.
When I test on a machine with 154 cpu cores, this case run failed, and hit many warning likes:
Quoted 8 lines
Quoted 5 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.
We use 'tail' all over the place in xfstests, so why is only generic/084 affected?
Because generic/084 use try to create $nr_cpu tail processes:
for i inseq 1 $nr_cpu; do... tail -f $testfile & ...
Quoted 7 lines
done
And nr_cpu=
$here/src/feature -o.Generally fs.inotify.max_user_instances is 128, when a machine have more than(or nearly the same) this number, this test will failed.
This information should have been in the patch description - it's concurrently run tail commands that are the problem, not a single execution of tail...
Quoted 2 lines
Maybe other cases don't try to create so many tail processes, so they passed.
Exactly. The answer is obvious when you explain it fully :)
So, we have other tests that use hundreds of open unlinked files and they don't have this problem. That means the issue is how generic/084 is creating the unlinked files, not an issue with inotify config.
Go look at src/multi_open_unlink.c and tests/xfs/1[28]1, and then rewrite generic/084 to use multi_open_unlink to create and hold open unlinked files for a specified amount of time.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
----- 原始邮件 -----
Quoted 58 lines
发件人: "Dave Chinner" <[email protected]>
收件人: "Zirong Lang" <[email protected]>
抄送: [email protected], [email protected]
发送时间: 星期一, 2015年 8 月 17日 下午 1:06:12
主题: Re: [PATCH] generic/084: check inotify limit before tail many filesQuoted 34 lines · Zirong Lang
Hi Dave,
Thanks for your reply.
----- 原始邮件 -----
Quoted 15 lines
发件人: "Dave Chinner" <[email protected]>
收件人: "Zorro Lang" <[email protected]>
抄送: [email protected], [email protected]
发送时间: 星期一, 2015年 8 月 17日 上午 8:03:36
主题: Re: [PATCH] generic/084: check inotify limit before tail many filesQuoted 8 lines · Zorro Lang
generic/084 try to run 'tail' command, tail will use inotify, and there're some limit about inotify. I think the most important is fs.inotify.max_user_instances, then fs.inotify.max_user_watches is importand too.
When I test on a machine with 154 cpu cores, this case run failed, and hit many warning likes:
Quoted 8 lines
Quoted 5 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.
We use 'tail' all over the place in xfstests, so why is only generic/084 affected?
Because generic/084 use try to create $nr_cpu tail processes:
for i inseq 1 $nr_cpu; do... tail -f $testfile & ...Quoted 7 lines
done
And nr_cpu=
$here/src/feature -o.Generally fs.inotify.max_user_instances is 128, when a machine have more than(or nearly the same) this number, this test will failed.
This information should have been in the patch description - it's concurrently run tail commands that are the problem, not a single execution of tail...
Quoted 2 lines
Maybe other cases don't try to create so many tail processes, so they passed.
Exactly. The answer is obvious when you explain it fully :)
Quoted 8 lines
So, we have other tests that use hundreds of open unlinked files and they don't have this problem. That means the issue is how generic/084 is creating the unlinked files, not an issue with inotify config.
Go look at
src/multi_open_unlink.cand tests/xfs/1[28]1, and then rewrite generic/084 to usemulti_open_unlinkto create and hold open unlinked files for a specified amount of time.
You're Great! This's a good idea to fix this problem. Thanks very much. I have sent the V3 patch, and tested on an old kernel to sure the bug still can be reproduced after I changed.
Thanks,
Zorro Lang
Quoted 8 lines
Cheers,
Dave.
--
Dave Chinner
[email protected]