[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5tsjb3wlierqa4cnevn4vv5dnwved7fsg55ggxlqf5coyptsjz@uco7crwg6x4m>
Date: Fri, 13 Jun 2025 17:55:45 +0200
From: Jan Kara <jack@...e.cz>
To: Wei Gao <wegao@...e.com>
Cc: Jan Kara <jack@...e.cz>, linux-kernel@...r.kernel.org,
linux-ext4@...r.kernel.org
Subject: Re: [PATCH v2] ext2: Handle fiemap on empty files to prevent EINVAL
On Fri 13-06-25 18:59:05, Wei Gao wrote:
> On Fri, Jun 13, 2025 at 11:42:17AM +0200, Jan Kara wrote:
> > On Fri 13-06-25 11:18:38, Wei Gao wrote:
> > > Previously, ext2_fiemap would unconditionally apply "len = min_t(u64, len,
> > > i_size_read(inode));", When inode->i_size was 0 (for an empty file), this
> > > would reduce the requested len to 0. Passing len = 0 to iomap_fiemap could
> > > then result in an -EINVAL error, even for valid queries on empty files.
> > >
> > > Link: https://github.com/linux-test-project/ltp/issues/1246
> > > Signed-off-by: Wei Gao <wegao@...e.com>
> >
> > ...
> >
> > > diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> > > index 30f8201c155f..591db2b4390a 100644
> > > --- a/fs/ext2/inode.c
> > > +++ b/fs/ext2/inode.c
> > > @@ -895,9 +895,15 @@ int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
> > > u64 start, u64 len)
> > > {
> > > int ret;
> > > + u64 i_size;
> > >
> > > inode_lock(inode);
> > > - len = min_t(u64, len, i_size_read(inode));
> > > +
> > > + i_size = i_size_read(inode);
> > > +
> > > + if (i_size > 0)
> > > + len = min_t(u64, len, i_size_read(inode));
> >
> >
> > Thanks! This would actually lead to excessively slow fiemap for 0-length
> > files. So what I've ended up with is attached modification of your patch.
> Thank you for your patient review, I really appreciate it.
>
> BTW i have stupid question:
> Where can I see the real-time status of this patch? such as whether it has been merged?
> I have checked https://patchwork.kernel.org/project/linux-fsdevel/list/
> but do not find current patch, maybe this patch need specific sent it to
> linux-fsdevel@...r.kernel.org? I just get maillist through scripts/get_maintainer.pl but
> mail list not contain linux-fsdevel@...r.kernel.org.
You cannot easily check it. You can see the patch is sitting in
git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git for_next
branch. During the next merge window, I'll push it to Linus.
Honza
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists