All of lore.kernel.org
 help / color / mirror / Atom feed
From: Filipe Manana <fdmanana@gmail.com>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: fstests <fstests@vger.kernel.org>,
	Anthony Iliopoulos <ailiopoulos@suse.de>
Subject: Re: [PATCH] fsstress: improve error message on check_cwd() error
Date: Thu, 23 Sep 2021 13:37:04 +0100	[thread overview]
Message-ID: <CAL3q7H6yykw_roQvF-vS3DHyMh9hLmagq1ZamQqqWJWLwafsYA@mail.gmail.com> (raw)
In-Reply-To: <YUuM/h7zGaAsPggl@bombadil.infradead.org>

On Wed, Sep 22, 2021 at 9:07 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> On Wed, Sep 22, 2021 at 11:15:08AM +0100, Filipe Manana wrote:
> > On Tue, Sep 21, 2021 at 6:51 PM Luis Chamberlain <mcgrof@kernel.org> 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
> > >
> > > Thow a bone out to developers so that in case en error does happen
> > > they know which rabbit hole to go down on.
> > >
> > > Cc: Anthony Iliopoulos <ailiopoulos@suse.de>
> > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> > > ---
> > >  ltp/fsstress.c | 15 ++++++++++++++-
> > >  1 file changed, 14 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/ltp/fsstress.c b/ltp/fsstress.c
> > > index b4ddf5e2..d2f09901 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,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));
> >
> > The error is not in 'ret' but instead in 'errno', so it should print
> > errno and strerror(errno).
>
> Good call will fix.
>
> > > +               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 (%ld) != top_ino (%ld)\n",
> > > +               (long)statbuf.st_ino, (long)top_ino);
> >
> > ino_t is guaranteed to be an unsigned integer, and can be either 64 or
> > 32 bits wide [1].
> > Casting to unsigned 64 bits would be better imo.
>
> There are other similar mi-uses in the code, should I fix those to
> then?

If you want to, as a separate patch.
Noticing now that since the code is using struct stat64, using %llu
for the printfs without any casts should be fine [1].

Thanks.

[1] https://www.mkssoftware.com/docs/man5/struct_stat.5.asp

>
>   Luis
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

  reply	other threads:[~2021-09-23 12:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 17:50 [PATCH] fsstress: improve error message on check_cwd() error Luis Chamberlain
2021-09-22 10:15 ` Filipe Manana
2021-09-22 20:07   ` Luis Chamberlain
2021-09-23 12:37     ` Filipe Manana [this message]
2021-11-01 15:50       ` Luis Chamberlain
2021-11-01 15:55 Luis Chamberlain
2021-11-03 16:24 ` Darrick J. Wong
2021-11-03 18:18   ` Luis Chamberlain
2021-11-05 16:04     ` Luis Chamberlain
2021-11-05 16:09       ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAL3q7H6yykw_roQvF-vS3DHyMh9hLmagq1ZamQqqWJWLwafsYA@mail.gmail.com \
    --to=fdmanana@gmail.com \
    --cc=ailiopoulos@suse.de \
    --cc=fstests@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.