syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
Don't use hardcoded threshold(default 4%) to check free space because it can be changed by writing "/proc/sys/kernel/acct" or using sysctl.
--- testcases/kernel/syscalls/acct/acct02.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/acct/acct02.c +6 -3
@@ -150,18 +150,21 @@ static void run(void)static void setup (void ) {struct statfs buf; +float limit; clock_ticks =SAFE_SYSCONF (_SC_CLK_TCK);SAFE_STATFS ("." , &buf);float avail = (100.00 * buf.f_bavail) / buf.f_blocks; +SAFE_FILE_SCANF ("/proc/sys/kernel/acct" ,"%f %*i %*i" , &limit); + limit +=0.1 ;/* The accounting data are silently discarded on nearly FS */ -if (avail <4.1 ) { +if (avail < limit) {tst_brk (TCONF , -"Less than 4.1%% (%.2f) of free space on filesystem" , - avail); +"Less than (%.2f)%% (%.2f) of free space on filesystem" , + limit, avail); }TEST (acct (NULL ));
Signature · 1 line
1.8.3.1
PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
Hi!
Quoted 3 lines
Don't use hardcoded threshold(default 4%) to check free space because it can be changed by writing "
/proc/sys/kernel/acct" or using sysctl.
Good catch, I missed the sysctl API since I haven't realized that the proc handlers are all stuffed in a different file in kernel/sysctl.c.
What about we as well temporarily lower the value if needed while the test is running?
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
Quoted 9 lines · Cyril Hrubis
Hi!
Quoted 3 lines
Don't use hardcoded threshold(default 4%) to check free space because it can be changed by writing "
/proc/sys/kernel/acct" or using sysctl.Good catch, I missed the sysctl API since I haven't realized that the proc handlers are all stuffed in a different file in
kernel/sysctl.c.What about we as well temporarily lower the value if needed while the test is running?
Hi Cyril,
When free space is not enough, test can change the threshold by itself or remind user to modify the threshold by sysctl API manually.
Which one do you prefer?
Best Regards,
Xiao Yang
Quoted 1 line
PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
Hi!
Quoted 11 lines
Quoted 5 lines
Good catch, I missed the sysctl API since I haven't realized that the proc handlers are all stuffed in a different file in
kernel/sysctl.c.What about we as well temporarily lower the value if needed while the test is running?
Hi Cyril,
When free space is not enough, test can change the threshold by itself or remind user to modify the threshold by sysctl API manually.
Which one do you prefer?
Ideally the test should modify the threshold.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
Quoted 6 lines · Cyril Hrubis
Hi!
Quoted 5 lines
Quoted 5 lines
Good catch, I missed the sysctl API since I haven't realized that the proc handlers are all stuffed in a different file in
kernel/sysctl.c.What about we as well temporarily lower the value if needed while the test is running?
Quoted 7 lines
Quoted 6 lines
Hi Cyril,
When free space is not enough, test can change the threshold by itself or remind user to modify the threshold by sysctl API manually.
Which one do you prefer?
Ideally the test should modify the threshold.
Hi Cyril,
OK, I will improve the patch as you suggested. :-)
Best Regards,
Xiao Yang