* [PATCH v3] fsstress: improve error message on check_cwd() error
@ 2021-11-05 16:44 Luis Chamberlain
2021-11-05 16:50 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Luis Chamberlain @ 2021-11-05 16:44 UTC (permalink / raw)
To: fstests, fdmanana, djwong; +Cc: Luis Chamberlain, Anthony Iliopoulos
I ran into an error with generic/083 with xfs due to check_cwd() but
why it failed is not clear because there are two types of
failures:
o stat64() failed (likely -ENOMEM is my guess)
o the inode actually changed
Throw a bone out to developers so that in case en error does happen
they know which rabbit hole to go into.
Cc: Anthony Iliopoulos <ailiopoulos@suse.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
Changes on this v3:
o Minor nitpick on spaces
o Changed rabbit hole language
o enhanced stat64() error message to include errno as well
o cast things as suggested
ltp/fsstress.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 90ae432e..aab64f33 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -9,6 +9,7 @@
#include <sys/uio.h>
#include <stddef.h>
#include <stdbool.h>
+#include <string.h>
#include "global.h"
#ifdef HAVE_BTRFSUTIL_H
@@ -943,9 +944,22 @@ check_cwd(void)
{
#ifdef DEBUG
struct stat64 statbuf;
+ int ret;
+
+ ret = stat64(".", &statbuf);
+ if (ret != 0) {
+ fprintf(stderr, "fsstress: check_cwd stat64() returned %d with errno: %d (%s)\n",
+ ret, errno, strerror(errno));
+ goto out;
+ }
- if (stat64(".", &statbuf) == 0 && statbuf.st_ino == top_ino)
+ if (statbuf.st_ino == top_ino)
return;
+
+ fprintf(stderr, "fsstress: check_cwd statbuf.st_ino (%llu) != top_ino (%llu)\n",
+ (unsigned long long) statbuf.st_ino,
+ (unsigned long long) top_ino);
+out:
assert(chdir(homedir) == 0);
fprintf(stderr, "fsstress: check_cwd failure\n");
abort();
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v3] fsstress: improve error message on check_cwd() error
2021-11-05 16:44 [PATCH v3] fsstress: improve error message on check_cwd() error Luis Chamberlain
@ 2021-11-05 16:50 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2021-11-05 16:50 UTC (permalink / raw)
To: Luis Chamberlain; +Cc: fstests, fdmanana, Anthony Iliopoulos
On Fri, Nov 05, 2021 at 09:44:32AM -0700, Luis Chamberlain wrote:
> I ran into an error with generic/083 with xfs due to check_cwd() but
> why it failed is not clear because there are two types of
> failures:
>
> o stat64() failed (likely -ENOMEM is my guess)
> o the inode actually changed
>
> Throw a bone out to developers so that in case en error does happen
> they know which rabbit hole to go into.
>
> Cc: Anthony Iliopoulos <ailiopoulos@suse.de>
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
LGTM,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
>
> Changes on this v3:
>
> o Minor nitpick on spaces
> o Changed rabbit hole language
> o enhanced stat64() error message to include errno as well
> o cast things as suggested
>
> ltp/fsstress.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/ltp/fsstress.c b/ltp/fsstress.c
> index 90ae432e..aab64f33 100644
> --- a/ltp/fsstress.c
> +++ b/ltp/fsstress.c
> @@ -9,6 +9,7 @@
> #include <sys/uio.h>
> #include <stddef.h>
> #include <stdbool.h>
> +#include <string.h>
> #include "global.h"
>
> #ifdef HAVE_BTRFSUTIL_H
> @@ -943,9 +944,22 @@ check_cwd(void)
> {
> #ifdef DEBUG
> struct stat64 statbuf;
> + int ret;
> +
> + ret = stat64(".", &statbuf);
> + if (ret != 0) {
> + fprintf(stderr, "fsstress: check_cwd stat64() returned %d with errno: %d (%s)\n",
> + ret, errno, strerror(errno));
> + goto out;
> + }
>
> - if (stat64(".", &statbuf) == 0 && statbuf.st_ino == top_ino)
> + if (statbuf.st_ino == top_ino)
> return;
> +
> + fprintf(stderr, "fsstress: check_cwd statbuf.st_ino (%llu) != top_ino (%llu)\n",
> + (unsigned long long) statbuf.st_ino,
> + (unsigned long long) top_ino);
> +out:
> assert(chdir(homedir) == 0);
> fprintf(stderr, "fsstress: check_cwd failure\n");
> abort();
> --
> 2.33.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-05 16:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-05 16:44 [PATCH v3] fsstress: improve error message on check_cwd() error Luis Chamberlain
2021-11-05 16:50 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox