* [PATCH] t_stripealign: Fix fibmap error handling
@ 2019-08-23 9:25 Carlos Maiolino
2019-08-23 14:36 ` Darrick J. Wong
0 siblings, 1 reply; 4+ messages in thread
From: Carlos Maiolino @ 2019-08-23 9:25 UTC (permalink / raw)
To: fstests; +Cc: linux-xfs
FIBMAP only returns a negative value when the underlying filesystem does
not support FIBMAP or on permission error. For the remaining errors,
i.e. those usually returned from the filesystem itself, zero will be
returned.
We can not trust a zero return from the FIBMAP, and such behavior made
generic/223 succeed when it should not.
Also, we can't use perror() only to print errors when FIBMAP failed, or
it will simply print 'success' when a zero is returned.
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
src/t_stripealign.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/t_stripealign.c b/src/t_stripealign.c
index 5cdadaae..164831f8 100644
--- a/src/t_stripealign.c
+++ b/src/t_stripealign.c
@@ -76,8 +76,11 @@ int main(int argc, char ** argv)
unsigned int bmap = 0;
ret = ioctl(fd, FIBMAP, &bmap);
- if (ret < 0) {
- perror("fibmap");
+ if (ret <= 0) {
+ if (ret < 0)
+ perror("fibmap");
+ else
+ fprintf(stderr, "fibmap error\n");
free(fie);
close(fd);
return 1;
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] t_stripealign: Fix fibmap error handling
2019-08-23 9:25 [PATCH] t_stripealign: Fix fibmap error handling Carlos Maiolino
@ 2019-08-23 14:36 ` Darrick J. Wong
2019-08-25 13:41 ` Eryu Guan
0 siblings, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2019-08-23 14:36 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: fstests, linux-xfs
On Fri, Aug 23, 2019 at 11:25:30AM +0200, Carlos Maiolino wrote:
> FIBMAP only returns a negative value when the underlying filesystem does
> not support FIBMAP or on permission error. For the remaining errors,
> i.e. those usually returned from the filesystem itself, zero will be
> returned.
>
> We can not trust a zero return from the FIBMAP, and such behavior made
> generic/223 succeed when it should not.
>
> Also, we can't use perror() only to print errors when FIBMAP failed, or
> it will simply print 'success' when a zero is returned.
>
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> src/t_stripealign.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/t_stripealign.c b/src/t_stripealign.c
> index 5cdadaae..164831f8 100644
> --- a/src/t_stripealign.c
> +++ b/src/t_stripealign.c
> @@ -76,8 +76,11 @@ int main(int argc, char ** argv)
> unsigned int bmap = 0;
>
> ret = ioctl(fd, FIBMAP, &bmap);
> - if (ret < 0) {
> - perror("fibmap");
> + if (ret <= 0) {
> + if (ret < 0)
> + perror("fibmap");
> + else
> + fprintf(stderr, "fibmap error\n");
"fibmap returned no result"?
--D
> free(fie);
> close(fd);
> return 1;
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] t_stripealign: Fix fibmap error handling
2019-08-23 14:36 ` Darrick J. Wong
@ 2019-08-25 13:41 ` Eryu Guan
2019-08-26 6:48 ` Carlos Maiolino
0 siblings, 1 reply; 4+ messages in thread
From: Eryu Guan @ 2019-08-25 13:41 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Carlos Maiolino, fstests, linux-xfs
On Fri, Aug 23, 2019 at 07:36:50AM -0700, Darrick J. Wong wrote:
> On Fri, Aug 23, 2019 at 11:25:30AM +0200, Carlos Maiolino wrote:
> > FIBMAP only returns a negative value when the underlying filesystem does
> > not support FIBMAP or on permission error. For the remaining errors,
> > i.e. those usually returned from the filesystem itself, zero will be
> > returned.
> >
> > We can not trust a zero return from the FIBMAP, and such behavior made
> > generic/223 succeed when it should not.
> >
> > Also, we can't use perror() only to print errors when FIBMAP failed, or
> > it will simply print 'success' when a zero is returned.
> >
> > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> > ---
> > src/t_stripealign.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/t_stripealign.c b/src/t_stripealign.c
> > index 5cdadaae..164831f8 100644
> > --- a/src/t_stripealign.c
> > +++ b/src/t_stripealign.c
> > @@ -76,8 +76,11 @@ int main(int argc, char ** argv)
> > unsigned int bmap = 0;
> >
> > ret = ioctl(fd, FIBMAP, &bmap);
> > - if (ret < 0) {
> > - perror("fibmap");
> > + if (ret <= 0) {
> > + if (ret < 0)
> > + perror("fibmap");
> > + else
> > + fprintf(stderr, "fibmap error\n");
>
> "fibmap returned no result"?
Fixed on commit. Thanks!
Eryu
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] t_stripealign: Fix fibmap error handling
2019-08-25 13:41 ` Eryu Guan
@ 2019-08-26 6:48 ` Carlos Maiolino
0 siblings, 0 replies; 4+ messages in thread
From: Carlos Maiolino @ 2019-08-26 6:48 UTC (permalink / raw)
To: Eryu Guan; +Cc: Darrick J. Wong, fstests, linux-xfs
On Sun, Aug 25, 2019 at 09:41:54PM +0800, Eryu Guan wrote:
> On Fri, Aug 23, 2019 at 07:36:50AM -0700, Darrick J. Wong wrote:
> > On Fri, Aug 23, 2019 at 11:25:30AM +0200, Carlos Maiolino wrote:
> > > FIBMAP only returns a negative value when the underlying filesystem does
> > > not support FIBMAP or on permission error. For the remaining errors,
> > > i.e. those usually returned from the filesystem itself, zero will be
> > > returned.
> > >
> > > We can not trust a zero return from the FIBMAP, and such behavior made
> > > generic/223 succeed when it should not.
> > >
> > > Also, we can't use perror() only to print errors when FIBMAP failed, or
> > > it will simply print 'success' when a zero is returned.
> > >
> > > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> > > ---
> > > src/t_stripealign.c | 7 +++++--
> > > 1 file changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/src/t_stripealign.c b/src/t_stripealign.c
> > > index 5cdadaae..164831f8 100644
> > > --- a/src/t_stripealign.c
> > > +++ b/src/t_stripealign.c
> > > @@ -76,8 +76,11 @@ int main(int argc, char ** argv)
> > > unsigned int bmap = 0;
> > >
> > > ret = ioctl(fd, FIBMAP, &bmap);
> > > - if (ret < 0) {
> > > - perror("fibmap");
> > > + if (ret <= 0) {
> > > + if (ret < 0)
> > > + perror("fibmap");
> > > + else
> > > + fprintf(stderr, "fibmap error\n");
> >
> > "fibmap returned no result"?
>
> Fixed on commit. Thanks!
TZ discrepancy. Thanks for fixing it on commit Eryu :)
>
> Eryu
--
Carlos
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-26 6:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-23 9:25 [PATCH] t_stripealign: Fix fibmap error handling Carlos Maiolino
2019-08-23 14:36 ` Darrick J. Wong
2019-08-25 13:41 ` Eryu Guan
2019-08-26 6:48 ` Carlos Maiolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox