[PATCH] erofs: mark fileio folios uptodate based on the number of bytes read
Sheng Yong
shengyong2021 at gmail.com
Thu Feb 26 20:50:37 AEDT 2026
On 2/26/26 17:36, Gao Xiang wrote:
>
>
> On 2026/2/26 17:28, Gao Xiang wrote:
>> Hi Yong,
>>
>> On 2026/2/26 17:09, Sheng Yong wrote:
>>> From: Sheng Yong <shengyong1 at xiaomi.com>
>>>
>>> For file-backed mount, IO requests are handled by vfs_iocb_iter_read().
>>> However, it can be interrupted by SIGKILL, returning the number of
>>> bytes actually copied. Although unused folios are zero filled, they
>>> are unexpectedly marked as uptodate.
>>> This patch addresses this by setting folios uptodate based on the actual
>>> number of bytes read for the plain backing file. And for the compressed
>>> backing file, there may not have sufficient data for decompression,
>>> in such case, the bio is marked with an error directly.
>>>
>>> Fixes: ce63cb62d794 ("erofs: support unencoded inodes for fileio")
>>> Reported-by: chenguanyou <chenguanyou at xiaomi.com>
>>> Signed-off-by: Yunlei He <heyunlei at xiaomi.com>
>>> Signed-off-by: Sheng Yong <shengyong1 at xiaomi.com>
>>
>> Yes, it sounds possible. But can we just fail the
>> whole I/O for both cases?
>>
>> In principle, we should retry the remaining I/O once more
>> for short read, but failing the whole I/O could be one
>> short-term solution.
>
> I wonder if we should simply:
>
> diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c
> index abe873f01297..98cdaa1cd1a7 100644
> --- a/fs/erofs/fileio.c
> +++ b/fs/erofs/fileio.c
> @@ -25,10 +25,8 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
> container_of(iocb, struct erofs_fileio_rq, iocb);
> struct folio_iter fi;
>
> - if (ret >= 0 && ret != rq->bio.bi_iter.bi_size) {
> - bio_advance(&rq->bio, ret);
> - zero_fill_bio(&rq->bio);
> - }
> + if (ret >= 0 && ret != rq->bio.bi_iter.bi_size)
> + ret = -EIO;
>
> instead. IOWs, filling zeros means nothing for us.
That makes sense. I'll send a v2.
thanks,
shengyong
>
> Thanks,
> Gao Xiang
>
>>
>> Thanks,
>> Gao Xiang
>>
>
More information about the Linux-erofs
mailing list