Skip to content

Commit bc804a8

Browse files
committed
erofs: handle end of filesystem properly for file-backed mounts
I/O requests beyond the end of the filesystem should be zeroed out, similar to loopback devices and that is what we expect. Fixes: ce63cb6 ("erofs: support unencoded inodes for fileio") Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent 7cef3c8 commit bc804a8

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

fs/erofs/fileio.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,17 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
2424
container_of(iocb, struct erofs_fileio_rq, iocb);
2525
struct folio_iter fi;
2626

27-
if (ret > 0) {
28-
if (ret != rq->bio.bi_iter.bi_size) {
29-
bio_advance(&rq->bio, ret);
30-
zero_fill_bio(&rq->bio);
31-
}
32-
ret = 0;
27+
if (ret >= 0 && ret != rq->bio.bi_iter.bi_size) {
28+
bio_advance(&rq->bio, ret);
29+
zero_fill_bio(&rq->bio);
3330
}
34-
if (rq->bio.bi_end_io) {
35-
if (ret < 0 && !rq->bio.bi_status)
36-
rq->bio.bi_status = errno_to_blk_status(ret);
37-
} else {
31+
if (!rq->bio.bi_end_io) {
3832
bio_for_each_folio_all(fi, &rq->bio) {
3933
DBG_BUGON(folio_test_uptodate(fi.folio));
40-
erofs_onlinefolio_end(fi.folio, ret, false);
34+
erofs_onlinefolio_end(fi.folio, ret < 0, false);
4135
}
36+
} else if (ret < 0 && !rq->bio.bi_status) {
37+
rq->bio.bi_status = errno_to_blk_status(ret);
4238
}
4339
bio_endio(&rq->bio);
4440
bio_uninit(&rq->bio);
@@ -48,7 +44,7 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
4844
static void erofs_fileio_rq_submit(struct erofs_fileio_rq *rq)
4945
{
5046
struct iov_iter iter;
51-
int ret;
47+
ssize_t ret;
5248

5349
if (!rq)
5450
return;

0 commit comments

Comments
 (0)