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

Dominique Martinet asmadeus at codewreck.org
Tue Apr 18 05:07:53 CEST 2023


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.
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 :)

-- 
Dominique Martinet | Asmadeus


More information about the U-Boot mailing list