Skip to content

Commit 2832137

Browse files
committed
erofs: support compressed inodes for fileio
Use pseudo bios just like the previous fscache approach since merged bio_vecs can be filled properly with unique interfaces. Reviewed-by: Sandeep Dhavale <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ce63cb6 commit 2832137

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

fs/erofs/fileio.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
2323
container_of(iocb, struct erofs_fileio_rq, iocb);
2424
struct folio_iter fi;
2525

26-
DBG_BUGON(rq->bio.bi_end_io);
2726
if (ret > 0) {
2827
if (ret != rq->bio.bi_iter.bi_size) {
2928
bio_advance(&rq->bio, ret);
3029
zero_fill_bio(&rq->bio);
3130
}
3231
ret = 0;
3332
}
34-
bio_for_each_folio_all(fi, &rq->bio) {
35-
DBG_BUGON(folio_test_uptodate(fi.folio));
36-
erofs_onlinefolio_end(fi.folio, ret);
33+
if (rq->bio.bi_end_io) {
34+
rq->bio.bi_end_io(&rq->bio);
35+
} else {
36+
bio_for_each_folio_all(fi, &rq->bio) {
37+
DBG_BUGON(folio_test_uptodate(fi.folio));
38+
erofs_onlinefolio_end(fi.folio, ret);
39+
}
3740
}
3841
bio_uninit(&rq->bio);
3942
kfree(rq);
@@ -68,6 +71,17 @@ static struct erofs_fileio_rq *erofs_fileio_rq_alloc(struct erofs_map_dev *mdev)
6871
return rq;
6972
}
7073

74+
struct bio *erofs_fileio_bio_alloc(struct erofs_map_dev *mdev)
75+
{
76+
return &erofs_fileio_rq_alloc(mdev)->bio;
77+
}
78+
79+
void erofs_fileio_submit_bio(struct bio *bio)
80+
{
81+
return erofs_fileio_rq_submit(container_of(bio, struct erofs_fileio_rq,
82+
bio));
83+
}
84+
7185
static int erofs_fileio_scan_folio(struct erofs_fileio *io, struct folio *folio)
7286
{
7387
struct inode *inode = folio_inode(folio);

fs/erofs/inode.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,6 @@ static int erofs_fill_inode(struct inode *inode)
252252
mapping_set_large_folios(inode->i_mapping);
253253
if (erofs_inode_is_data_compressed(vi->datalayout)) {
254254
#ifdef CONFIG_EROFS_FS_ZIP
255-
#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
256-
if (erofs_is_fileio_mode(EROFS_SB(inode->i_sb))) {
257-
err = -EOPNOTSUPP;
258-
goto out_unlock;
259-
}
260-
#endif
261255
DO_ONCE_LITE_IF(inode->i_blkbits != PAGE_SHIFT,
262256
erofs_info, inode->i_sb,
263257
"EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!");

fs/erofs/internal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,14 @@ static inline void z_erofs_exit_subsystem(void) {}
489489
static inline int erofs_init_managed_cache(struct super_block *sb) { return 0; }
490490
#endif /* !CONFIG_EROFS_FS_ZIP */
491491

492+
#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
493+
struct bio *erofs_fileio_bio_alloc(struct erofs_map_dev *mdev);
494+
void erofs_fileio_submit_bio(struct bio *bio);
495+
#else
496+
static inline struct bio *erofs_fileio_bio_alloc(struct erofs_map_dev *mdev) { return NULL; }
497+
static inline void erofs_fileio_submit_bio(struct bio *bio) {}
498+
#endif
499+
492500
#ifdef CONFIG_EROFS_FS_ONDEMAND
493501
int erofs_fscache_register_fs(struct super_block *sb);
494502
void erofs_fscache_unregister_fs(struct super_block *sb);

fs/erofs/zdata.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,10 +1618,12 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
16181618
if (bio && (cur != last_pa ||
16191619
bio->bi_bdev != mdev.m_bdev)) {
16201620
drain_io:
1621-
if (!erofs_is_fscache_mode(sb))
1622-
submit_bio(bio);
1623-
else
1621+
if (erofs_is_fileio_mode(EROFS_SB(sb)))
1622+
erofs_fileio_submit_bio(bio);
1623+
else if (erofs_is_fscache_mode(sb))
16241624
erofs_fscache_submit_bio(bio);
1625+
else
1626+
submit_bio(bio);
16251627

16261628
if (memstall) {
16271629
psi_memstall_leave(&pflags);
@@ -1646,10 +1648,13 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
16461648
}
16471649

16481650
if (!bio) {
1649-
bio = erofs_is_fscache_mode(sb) ?
1650-
erofs_fscache_bio_alloc(&mdev) :
1651-
bio_alloc(mdev.m_bdev, BIO_MAX_VECS,
1652-
REQ_OP_READ, GFP_NOIO);
1651+
if (erofs_is_fileio_mode(EROFS_SB(sb)))
1652+
bio = erofs_fileio_bio_alloc(&mdev);
1653+
else if (erofs_is_fscache_mode(sb))
1654+
bio = erofs_fscache_bio_alloc(&mdev);
1655+
else
1656+
bio = bio_alloc(mdev.m_bdev, BIO_MAX_VECS,
1657+
REQ_OP_READ, GFP_NOIO);
16531658
bio->bi_end_io = z_erofs_endio;
16541659
bio->bi_iter.bi_sector = cur >> 9;
16551660
bio->bi_private = q[JQ_SUBMIT];
@@ -1672,10 +1677,12 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
16721677
} while (owned_head != Z_EROFS_PCLUSTER_TAIL);
16731678

16741679
if (bio) {
1675-
if (!erofs_is_fscache_mode(sb))
1676-
submit_bio(bio);
1677-
else
1680+
if (erofs_is_fileio_mode(EROFS_SB(sb)))
1681+
erofs_fileio_submit_bio(bio);
1682+
else if (erofs_is_fscache_mode(sb))
16781683
erofs_fscache_submit_bio(bio);
1684+
else
1685+
submit_bio(bio);
16791686
if (memstall)
16801687
psi_memstall_leave(&pflags);
16811688
}

0 commit comments

Comments
 (0)