fsstress: improve error message on check_cwd() error
PATCH 1/1 fsstress: improve error message on check_cwd() error
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 down on.
--- ltp/fsstress.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
ltp/fsstress.c +14 -1
@@ -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,21 @@ check_cwd(void) {#ifdef DEBUG struct stat64 statbuf; +int ret; + + ret =stat64 ("." , &statbuf); +if (ret !=0 ) { +fprintf (stderr,"fsstress: check_cwd stat64 failed with: %d (%s)\n" , + ret,strerror (ret)); + 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 (%lu) != top_ino (%lu)\n" , + statbuf.st_ino, top_ino); +out:assert (chdir (homedir) ==0 );fprintf (stderr,"fsstress: check_cwd failure\n" );abort ();
Signature · 1 line
2.33.0
Quoted 9 lines · Luis Chamberlain
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-ENOMEMis my guess)
o the inode actually changedThrow a bone out to developers so that in case en error does happen they know which rabbit hole to go down on.
<cough> word choice on those last three words...
Quoted 20 lines
Cc Anthony Iliopoulos <[email protected]>Signed-off-by Luis Chamberlain <[email protected]>--- ltp/fsstress.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)ltp/fsstress.c +1
-0@@ -9,6 +9,7 @@#include <sys/uio.h> #include <stddef.h> #include <stdbool.h> +#include <string.h> #include "global.h" #ifdef HAVE_BTRFSUTIL_H
ltp/fsstress.c check_cwd(void) · line 950
Quoted 7 lines
ltp/fsstress.c +4
-0@@ -943,9 +944,21 @@ check_cwd(void) {#ifdef DEBUG struct stat64 statbuf; +int ret; + + ret =stat64 ("." , &statbuf); +if (ret !=0 ) {
Nit: space between '!=' and '0'.
ltp/fsstress.c check_cwd(void) · line 952
Quoted 2 lines
ltp/fsstress.c +2
-0+fprintf (stderr,"fsstress: check_cwd stat64 failed with: %d (%s)\n" , + ret,strerror (ret));
ret is set to -1 on error, according to the manpage; to get the real error you'd have to call strerror(errno) as the last arg, or be lazy and:
perror("fsstress check_cwd stat64");ltp/fsstress.c check_cwd(void) · line 960
Quoted 9 lines
ltp/fsstress.c +6
-1+ 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 (%lu) != top_ino (%lu)\n" , + statbuf.st_ino, top_ino);
This might want some explicit casting, since this can be defined as anything between unsigned long to uint64_t, at least according to the glibc headers on my system.
--D
Quoted 7 lines
ltp/fsstress.c +1
-0+out:assert (chdir (homedir) ==0 );fprintf (stderr,"fsstress: check_cwd failure\n" );abort ();Signature · 1 line
2.33.0
Quoted 5 lines · Darrick J. Wong
Quoted 4 lines · Luis Chamberlain
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:
Quoted 7 lines
Quoted 5 lines
o
stat64()failed (likely-ENOMEMis my guess)
o the inode actually changedThrow a bone out to developers so that in case en error does happen they know which rabbit hole to go down on.
<cough> word choice on those last three words...
Will fix thanks.
Quoted 18 lines
Quoted 18 lines
Cc Anthony Iliopoulos <[email protected]>Signed-off-by Luis Chamberlain <[email protected]>--- ltp/fsstress.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)ltp/fsstress.c +1
-0@@ -9,6 +9,7 @@#include <sys/uio.h> #include <stddef.h> #include <stdbool.h> +#include <string.h> #include "global.h"
Quoted 11 lines
ltp/fsstress.c check_cwd(void) · line 950
Quoted 9 lines
ltp/fsstress.c +4
-0#ifdef HAVE_BTRFSUTIL_H @@ -943,9 +944,21 @@ check_cwd(void) {#ifdef DEBUG struct stat64 statbuf; +int ret; + + ret =stat64 ("." , &statbuf); +if (ret !=0 ) {Nit: space between '!=' and '0'.
OK.
Quoted 6 lines
ltp/fsstress.c check_cwd(void) · line 952
Quoted 2 lines
ltp/fsstress.c +2
-0+fprintf (stderr,"fsstress: check_cwd stat64 failed with: %d (%s)\n" , + ret,strerror (ret));ret is set to -1 on error, according to the manpage; to get the real error you'd have to call strerror(errno) as the last arg, or be lazy and:
I don't want to be lazy here as this is a real issue.
Quoted 5 lines
perror("fsstress check_cwd stat64");Quoted 3 lines
ltp/fsstress.c +2
-0+ goto out; + }
Quoted 10 lines
ltp/fsstress.c check_cwd(void) · line 960
Quoted 6 lines
ltp/fsstress.c +4
-1-if (stat64 ("." , &statbuf) ==0 && statbuf.st_ino == top_ino) +if (statbuf.st_ino == top_ino)return ; + +fprintf (stderr,"fsstress: check_cwd statbuf.st_ino (%lu) != top_ino (%lu)\n" , + statbuf.st_ino, top_ino);This might want some explicit casting, since this can be defined as anything between unsigned long to
uint64_t, at least according to the glibc headers on my system.
Um, Filipe had suggested something a bit different before. Can you guys decide and let me know your final preference ? :)
Luis
Quoted 12 lines · Luis Chamberlain
Quoted 10 lines · Darrick J. Wong
ltp/fsstress.c check_cwd(void) · line 960
Quoted 6 lines
ltp/fsstress.c +4
-1-if (stat64 ("." , &statbuf) ==0 && statbuf.st_ino == top_ino) +if (statbuf.st_ino == top_ino)return ; + +fprintf (stderr,"fsstress: check_cwd statbuf.st_ino (%lu) != top_ino (%lu)\n" , + statbuf.st_ino, top_ino);This might want some explicit casting, since this can be defined as anything between unsigned long to
uint64_t, at least according to the glibc headers on my system.
Quoted 2 lines
Um, Filipe had suggested something a bit different before. Can you guys decide and let me know your final preference ? :)
Any final preference / recommendation?
Luis
Quoted 13 lines · Luis Chamberlain
Quoted 12 lines · Luis Chamberlain
Quoted 10 lines · Darrick J. Wong
ltp/fsstress.c check_cwd(void) · line 960
Quoted 6 lines
ltp/fsstress.c +4
-1-if (stat64 ("." , &statbuf) ==0 && statbuf.st_ino == top_ino) +if (statbuf.st_ino == top_ino)return ; + +fprintf (stderr,"fsstress: check_cwd statbuf.st_ino (%lu) != top_ino (%lu)\n" , + statbuf.st_ino, top_ino);This might want some explicit casting, since this can be defined as anything between unsigned long to
uint64_t, at least according to the glibc headers on my system.
Quoted 4 lines
Quoted 2 lines
Um, Filipe had suggested something a bit different before. Can you guys decide and let me know your final preference ? :)
Any final preference / recommendation?
Use %llu with explicit casts to (unsigned long long) and it should work fine everywhere.
--D
Quoted 1 line
Luis