[PATCH U-BOOT 2/3] btrfs: btrfs_file_read: allow opportunistic read until the end

Qu Wenruo quwenruo.btrfs at gmx.com
Tue Apr 18 05:21:00 CEST 2023



On 2023/4/18 11:07, Dominique Martinet wrote:
> Qu Wenruo wrote on Tue, Apr 18, 2023 at 10:53:41AM +0800:
>>> I have a feeling the loop could just be updated to go to the end
>>> `while (cur < end)` as it doesn't seem to care about the end
>>> alignment... Should I update v2 to do that instead?
>>
>> Yeah, it would be very awesome if you can remove the tailing part
>> completely.
> 
> Ok, will give it a try.
> I'll want to test this a bit so might take a day or two as I have other
> work to finish first.
> 
>>> This made me look at the "Read out the leading unaligned part" initial
>>> part, and its check only looks at the sector size but it probably has
>>> the same problem -- we want to make sure we read any leftover from a
>>> previous extent e.g. this file:
>>
>> If you're talking about the same problem mentioned in patch 1, then yes, any
>> read in the middle of an extent would cause problems.
> 
> No, was just thinking the leading part being a separate loop doesn't
> seem to make sense either as the code shouldn't care about sector size
> alignemnt but about full extents.

The main concern related to the leading unaligned part is, we need to 
skip something unaligned from the beginning , while all other situations 
never need to skip such case (they at most skip the tailing part).

Maybe we can do some extra calculation to handle it, but I'm not in a 
hurry to address the leading part.

Another thing is, for all other fs-ish interface (kernel/fuse etc), they 
all read/write in certain block size, then handle unaligned part from a 
higher layer.
Thus I prefer to have most things handled in an aligned fashion, and 
only handle the unaligned part specially.

But if you can find an elegant way to handle all cases, that would be 
really awesome!

Thanks,
Qu

> If the main loop handles everything correctly then the leading if can
> also be removed along with "read_and_truncate_page" that would no longer
> be used.
> 
> I'll give this a try as well and report back.
> 
>> No matter if it's aligned or not, as btrfs would convert any unaligned part
>> into aligned read.
> 
> Yes I don't see where it would fail (except that my board does crash),
> I guess that at this point I should spend some time building a qemu
> u-boot and hooking up gdb will be faster..
> 
>> My initial plan is to merge the tailing part into the aligned loop, but
>> since you're already working in this part, feel free to do it.
> 
> Yes, sure -- removing the if is easy, I'd just rather not make it fail
> for someone else :)
> 


More information about the U-Boot mailing list