All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/2] Fix acct failures on nearly full FS.
@ 2019-07-12 14:15 Cyril Hrubis
  2019-07-12 14:15 ` [LTP] [PATCH 1/2] safe_macros: Add SAFE_STATFS() Cyril Hrubis
  2019-07-12 14:15 ` [LTP] [PATCH 2/2] syscalls/acct02: Fix failures with nearly full FS Cyril Hrubis
  0 siblings, 2 replies; 6+ messages in thread
From: Cyril Hrubis @ 2019-07-12 14:15 UTC (permalink / raw)
  To: ltp

Unfortunately it looks like BSD process accounting on Linux is bit of a
minefield, even when you enable the accounting and everything looks OK
kernel may still drop the data silently for a couple of reasons. You can
have a look at kernel/acct.c. This patch disables the test if there is
no enough disk space because in that case data are silently dropped.

If there is less than 4% of free space the accounting is silently
disabled from the start hence the test produces TCONF unless there is at
least 4.1% of free space now.

Cyril Hrubis (2):
  safe_macros: Add SAFE_STATFS()
  syscalls/acct02: Fix failures with nearly full FS

 include/tst_safe_macros.h               | 18 ++++++++++++++++++
 testcases/kernel/syscalls/acct/acct02.c | 12 ++++++++++++
 2 files changed, 30 insertions(+)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 1/2] safe_macros: Add SAFE_STATFS()
  2019-07-12 14:15 [LTP] [PATCH 0/2] Fix acct failures on nearly full FS Cyril Hrubis
@ 2019-07-12 14:15 ` Cyril Hrubis
  2019-07-12 14:15 ` [LTP] [PATCH 2/2] syscalls/acct02: Fix failures with nearly full FS Cyril Hrubis
  1 sibling, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2019-07-12 14:15 UTC (permalink / raw)
  To: ltp

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/tst_safe_macros.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 53a888c80..80c4d9cb9 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -24,6 +24,7 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/stat.h>
+#include <sys/vfs.h>
 #include <fcntl.h>
 #include <libgen.h>
 #include <signal.h>
@@ -340,6 +341,23 @@ static inline int safe_lstat(const char *file, const int lineno,
 #define SAFE_LSTAT(path, buf) \
 	safe_lstat(__FILE__, __LINE__, (path), (buf))
 
+static inline int safe_statfs(const char *file, const int lineno,
+                              const char *path, struct statfs *buf)
+{
+	int rval;
+
+	rval = statfs(path, buf);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+		         "statfs(%s,%p) failed", path, buf);
+	}
+
+	return rval;
+}
+#define SAFE_STATFS(path, buf) \
+        safe_statfs(__FILE__, __LINE__, (path), (buf))
+
 static inline off_t safe_lseek(const char *file, const int lineno,
                                int fd, off_t offset, int whence)
 {
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] syscalls/acct02: Fix failures with nearly full FS
  2019-07-12 14:15 [LTP] [PATCH 0/2] Fix acct failures on nearly full FS Cyril Hrubis
  2019-07-12 14:15 ` [LTP] [PATCH 1/2] safe_macros: Add SAFE_STATFS() Cyril Hrubis
@ 2019-07-12 14:15 ` Cyril Hrubis
  2019-07-15  8:13   ` Yang Xu
  1 sibling, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2019-07-12 14:15 UTC (permalink / raw)
  To: ltp

While process accounting is running the kernel checks the percentage of
available space on disk. If the accounting is enabled and the free space
drops below 2% the accounting is disabled until we reach at least 4% of
free space. Which especially means that we have to have more than 4% of
free space when we start the accounting because we are starting in
disabled state. And when accounting is disabled the data are dropped
silently instead of being written to the file, which makes this test
fail because we end up with an empty file.

So this patch checks if there is at least 4.1% of free space before we
start the test and exit with TCONF otherwise.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
CC: Christian Amann <camann@suse.com>
---
 testcases/kernel/syscalls/acct/acct02.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
index f61faf206..6c375d5cb 100644
--- a/testcases/kernel/syscalls/acct/acct02.c
+++ b/testcases/kernel/syscalls/acct/acct02.c
@@ -146,8 +146,20 @@ static void run(void)
 
 static void setup(void)
 {
+	struct statfs buf;
+
 	clock_ticks = SAFE_SYSCONF(_SC_CLK_TCK);
 
+	SAFE_STATFS(".", &buf);
+
+	float avail = (100.00 * buf.f_bavail) / buf.f_blocks;
+
+	if (avail < 4.1) {
+		tst_brk(TCONF,
+			"Less than 4.1%% (%.2f) of free space on filesystem",
+			avail);
+	}
+
 	TEST(acct(NULL));
 	if (TST_RET == -1)
 		tst_brk(TBROK | TTERRNO,
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] syscalls/acct02: Fix failures with nearly full FS
  2019-07-12 14:15 ` [LTP] [PATCH 2/2] syscalls/acct02: Fix failures with nearly full FS Cyril Hrubis
@ 2019-07-15  8:13   ` Yang Xu
  2019-07-15 11:19     ` Cyril Hrubis
  0 siblings, 1 reply; 6+ messages in thread
From: Yang Xu @ 2019-07-15  8:13 UTC (permalink / raw)
  To: ltp


> While process accounting is running the kernel checks the percentage of
> available space on disk. If the accounting is enabled and the free space
> drops below 2% the accounting is disabled until we reach at least 4% of
> free space. Which especially means that we have to have more than 4% of
> free space when we start the accounting because we are starting in
> disabled state. And when accounting is disabled the data are dropped
> silently instead of being written to the file, which makes this test
> fail because we end up with an empty file.
>
> So this patch checks if there is at least 4.1% of free space before we
> start the test and exit with TCONF otherwise.
>
> Signed-off-by: Cyril Hrubis<chrubis@suse.cz>
> CC: Christian Amann<camann@suse.com>
> ---
>   testcases/kernel/syscalls/acct/acct02.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
> index f61faf206..6c375d5cb 100644
> --- a/testcases/kernel/syscalls/acct/acct02.c
> +++ b/testcases/kernel/syscalls/acct/acct02.c
> @@ -146,8 +146,20 @@ static void run(void)
>
>   static void setup(void)
>   {
> +	struct statfs buf;
> +
>   	clock_ticks = SAFE_SYSCONF(_SC_CLK_TCK);
>
> +	SAFE_STATFS(".",&buf);
> +
> +	float avail = (100.00 * buf.f_bavail) / buf.f_blocks;

Hi Cyril

  I met the same problem on last week when I ran acct02 on nearly full FS.  Since kernel/acct.c has defined the RESUME(4) and SUSPEND(2) macro,
4.1 is enough.  And I think we can leave a simple comment in here for why the limit is 4.1(even though the commit message has the reason).

Thanks
Yang Xu

> +
> +	if (avail<  4.1) {
> +		tst_brk(TCONF,
> +			"Less than 4.1%% (%.2f) of free space on filesystem",
> +			avail);
> +	}
> +
>   	TEST(acct(NULL));
>   	if (TST_RET == -1)
>   		tst_brk(TBROK | TTERRNO,




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] syscalls/acct02: Fix failures with nearly full FS
  2019-07-15  8:13   ` Yang Xu
@ 2019-07-15 11:19     ` Cyril Hrubis
  2019-07-15 11:27       ` Yang Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2019-07-15 11:19 UTC (permalink / raw)
  To: ltp

Hi!
> I met the same problem on last week when I ran acct02 on nearly full
> FS.  Since kernel/acct.c has defined the RESUME(4) and SUSPEND(2)
> macro, 4.1 is enough.  And I think we can leave a simple comment in
> here for why the limit is 4.1(even though the commit message has the
> reason).

I guess that short comment would help there, if it's OK I will add it
before I push the patch.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] syscalls/acct02: Fix failures with nearly full FS
  2019-07-15 11:19     ` Cyril Hrubis
@ 2019-07-15 11:27       ` Yang Xu
  0 siblings, 0 replies; 6+ messages in thread
From: Yang Xu @ 2019-07-15 11:27 UTC (permalink / raw)
  To: ltp


> Hi!
>> I met the same problem on last week when I ran acct02 on nearly full
>> FS.  Since kernel/acct.c has defined the RESUME(4) and SUSPEND(2)
>> macro, 4.1 is enough.  And I think we can leave a simple comment in
>> here for why the limit is 4.1(even though the commit message has the
>> reason).
> I guess that short comment would help there, if it's OK I will add it
> before I push the patch.
Hi

Yes, go ahead.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-15 11:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12 14:15 [LTP] [PATCH 0/2] Fix acct failures on nearly full FS Cyril Hrubis
2019-07-12 14:15 ` [LTP] [PATCH 1/2] safe_macros: Add SAFE_STATFS() Cyril Hrubis
2019-07-12 14:15 ` [LTP] [PATCH 2/2] syscalls/acct02: Fix failures with nearly full FS Cyril Hrubis
2019-07-15  8:13   ` Yang Xu
2019-07-15 11:19     ` Cyril Hrubis
2019-07-15 11:27       ` Yang Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.