Re: [PATCH 09/27] ext4: move out inode_lock into ext4_fallocate()

Jan Kara
2024-12-06T15:51:56Z

On Fri 06-12-24 16:13:14, Zhang Yi wrote:
> On 2024/12/4 20:05, Jan Kara wrote:
> > On Tue 22-10-24 19:10:40, Zhang Yi wrote:
> >> From: Zhang Yi <yi.zhang@huawei.com>
> >>
> >> Currently, all five sub-functions of ext4_fallocate() acquire the
> >> inode's i_rwsem at the beginning and release it before exiting. This
> >> process can be simplified by factoring out the management of i_rwsem
> >> into the ext4_fallocate() function.
> >>
> >> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> >
> > Ah, nice. Feel free to add:
> >
> > Reviewed-by: Jan Kara <jack@suse.cz>
> >
> > and please ignore my comments about renaming 'out' labels :).
> >
> > Honza
> >
>
> ...
>
> >> @@ -4774,9 +4765,8 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> >>
> >> inode_lock(inode);
> >> ret = ext4_convert_inline_data(inode);
> >> - inode_unlock(inode);
> >> if (ret)
> >> - return ret;
> >> + goto out;
> >>
> >> if (mode & FALLOC_FL_PUNCH_HOLE)
> >> ret = ext4_punch_hole(file, offset, len);
> >> @@ -4788,7 +4778,8 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> >> ret = ext4_zero_range(file, offset, len, mode);
> >> else
> >> ret = ext4_do_fallocate(file, offset, len, mode);
> >> -
> >> +out:
> >> + inode_unlock(inode);
> >> return ret;
> >> }
> >>
>
> I guess you may want to suggest rename this out to out_inode_lock as well.

Right. This one should better be out_inode_lock.

Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR