[PATCH 4/4] ubifs: Convert do_writepage() to take a folio
Richard Weinberger
richard at nod.at
Tue Jun 6 06:41:31 PDT 2023
----- Ursprüngliche Mail -----
> Von: "Matthew Wilcox" <willy at infradead.org>
> On Tue, Jun 06, 2023 at 08:13:55AM +0200, Richard Weinberger wrote:
>> Matthew,
>>
>> ----- Ursprüngliche Mail -----
>> > Von: "Matthew Wilcox" <willy at infradead.org>
>> > len is folio_size(), which is not 0.
>> >
>> > len = offset_in_folio(folio, i_size);
>>
>> offset_in_folio(folio, i_size) can give 0.
>
> Oh! There is a bug, because it shouldn't get here!
>
> /* Is the folio fully inside i_size? */
> if (folio_pos(folio) + len < i_size) {
>
> should be:
>
> /* Is the folio fully inside i_size? */
> if (folio_pos(folio) + len <= i_size) {
>
> right? Consider a file with i_size 4096. its single-page folio will
> have a pos of 0 and a length of 4096. so it should be written back by
> the first call to do_writepage(), not the case where the folio straddles
> i_size.
Indeed.
With that change I agree that do_writepage() cannot get called with zero len.
I'll run more tests, so far all is nice an shiny. :-)
Thanks,
//richard
More information about the linux-mtd
mailing list