Re: [PATCH] xfs: fix the judgment of whether the file already has extents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 28 Oct 2024 18:33:32 +0800, alexjlzheng@xxxxxxxxxxx wrote:
> On Mon, 28 Oct 2024 02:41:01 -0700, hch@xxxxxxxxxxxxx wrote:
> > On Sun, Oct 27, 2024 at 02:01:16AM +0800, alexjlzheng@xxxxxxxxx wrote:
> > > From: Jinliang Zheng <alexjlzheng@xxxxxxxxxxx>
> > > 
> > > When we call create(), lseek() and write() sequentially, offset != 0
> > > cannot be used as a judgment condition for whether the file already
> > > has extents.
> > > 
> > > This patch uses prev.br_startoff instead of offset != 0.
> >
> > This changed the predicate from "are we at offset 0" to "are there
> > any allocations before that".  That's a pretty big semantic change.
> > Maybe a good one, maybe not.  Can you explain what workload it helps
> > you with?
> 
> 
> Thanks for your reply.
> 
> I noticed this because I was confused when reading the code here. The code
> comment here says:
> 
> /*
>  * If there are already extents in the file, try an exact EOF block
>  * allocation to extend the file as a contiguous extent. If that fails,
>  * or it's the first allocation in a file, just try for a stripe aligned
>  * allocation.
>  */
> 
> But as you said, the semantics of the current code is "are we at offset 0",
> not "are there any allocations before that".

By the way, we only get here if got is or after EOF, so "are there any allocations
before that" means "are there already extents in the file".

Thank you, again. :)
Jinliang Zheng

> 
> Therefore, I think it is better to use "prev.br_startoff != NULLFILEOFF"
> instead of the current "offset != 0", at least its semantics are more
> consistent with the intention in the code comment and reduce confusion.
> 
> But if the semantics here have indeed changed to the point where it is
> inconsistent with the code comment, my suggestion is to update the code
> comment here.
> 
> Thank you. :)
> Jinliang Zheng




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux