Re: [PATCH 2/3] fs/ufs: Change the signature of ufs_get_page()

From: Fabio M. De Francesco
Date: Mon Dec 12 2022 - 15:09:06 EST


On domenica 11 dicembre 2022 23:42:26 CET Al Viro wrote:
> On Sun, Dec 11, 2022 at 10:31:10PM +0100, Fabio M. De Francesco wrote:
> > out_put:
> > ufs_put_page(page);
> >
> > -out:
> > - return err;
> >
> > out_unlock:
> > unlock_page(page);
> > goto out_put;
>
> Something strange has happened, all right - look at the situation
> after that patch. You've got
>
> out_put:
> ufs_put_page(page);
> out_unlock:
> unlock_page(page);
> goto out_put;
>
> Which is obviously bogus.

I finally could go back to this small series and while working to fix the
errors that yesterday you had found out I think I saw what happened...

Are you talking about ufs_add_link, right?

If so, you wrote what follows at point 14 of one of your emails:

-----

14) ufs_add_link() - similar adjustment to new calling conventions
for ufs_get_page(). Uses of page_addr: fed to ufs_put_page() (same as
in ufs_find_entry() kaddr is guaranteed to point into the same page and
thus can be used instead) and calculation of position in directory, same
as we'd seen in ufs_set_link(). The latter becomes page_offset(page) +
offset_in_page(de), killing page_addr off. BTW, we get
kaddr = ufs_get_page(dir, n, &page);
err = PTR_ERR(kaddr);
if (IS_ERR(kaddr))
goto out;
with out: being just 'return err;', which suggests
kaddr = ufs_get_page(dir, n, &page);
if (IS_ERR(kaddr))
return ERR_PTR(kaddr);
instead (and that was the only goto out; so the label can be removed).
The value stored in err in case !IS_ERR(kaddr) is (thankfully) never
used - would've been a bug otherwise. So this is an equivalent
transformation.

-----

Did you notice "so the label can be removed"?
I must have misinterpreted what you wrote there. Did I?

I removed the "out" label, according to what it seemed to me the correct way
to interpret your words.

However at that moment I didn't see the endless loop at the end of the
function. Then I "fixed" (sigh!) it in 3/3 by terminating that endless loop
with a "return 0".

However that was another mistake because after "got_it:" label we have "err =
ufs_commit_chunk(page, pos, rec_len);".

To summarize: I can delete _only_ the label and leave the "return err;" in the
block after the "out_put:" label.

Am I looking at it correctly now?

Thanks,

Fabio