fsstress: improve error message on check_cwd() error
authorLuis Chamberlain <mcgrof@kernel.org>
Fri, 5 Nov 2021 16:44:32 +0000 (09:44 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 7 Nov 2021 13:58:17 +0000 (21:58 +0800)
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>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
ltp/fsstress.c

index ead7dd2bb4060cdd6cc9d65e72e67f3f3ada2f45..003e0e49a173b8cc58bac086f71af0d5b2d99494 100644 (file)
@@ -9,6 +9,7 @@
 #include <sys/uio.h>
 #include <stddef.h>
 #include <stdbool.h>
+#include <string.h>
 #include "global.h"
 
 #ifdef HAVE_BTRFSUTIL_H
@@ -950,9 +951,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();