Message ID | 1563203796-22102-1-git-send-email-ice_yangxiao@163.com |
---|---|
State | Changes Requested |
Headers | show |
Series | syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct | expand |
Hi! > 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?
On 07/16/2019 12:00 AM, Cyril Hrubis wrote: > Hi! >> 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 >
Hi! > > 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.
On 07/16/2019 10:17 PM, Cyril Hrubis wrote: > Hi! >>> 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. Hi Cyril, OK, I will improve the patch as you suggested. :-) Best Regards, Xiao Yang >
diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c index c2c2066..9e2f934 100644 --- a/testcases/kernel/syscalls/acct/acct02.c +++ b/testcases/kernel/syscalls/acct/acct02.c @@ -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));
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. Signed-off-by: Xiao Yang <ice_yangxiao@163.com> --- testcases/kernel/syscalls/acct/acct02.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)