Commit 28321371 authored by Gao Xiang's avatar Gao Xiang

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: default avatarSandeep Dhavale <dhavale@google.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240830032840.3783206-3-hsiangkao@linux.alibaba.com
parent ce63cb62
...@@ -23,7 +23,6 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret) ...@@ -23,7 +23,6 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
container_of(iocb, struct erofs_fileio_rq, iocb); container_of(iocb, struct erofs_fileio_rq, iocb);
struct folio_iter fi; struct folio_iter fi;
DBG_BUGON(rq->bio.bi_end_io);
if (ret > 0) { if (ret > 0) {
if (ret != rq->bio.bi_iter.bi_size) { if (ret != rq->bio.bi_iter.bi_size) {
bio_advance(&rq->bio, ret); bio_advance(&rq->bio, ret);
...@@ -31,9 +30,13 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret) ...@@ -31,9 +30,13 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
} }
ret = 0; ret = 0;
} }
bio_for_each_folio_all(fi, &rq->bio) { if (rq->bio.bi_end_io) {
DBG_BUGON(folio_test_uptodate(fi.folio)); rq->bio.bi_end_io(&rq->bio);
erofs_onlinefolio_end(fi.folio, ret); } else {
bio_for_each_folio_all(fi, &rq->bio) {
DBG_BUGON(folio_test_uptodate(fi.folio));
erofs_onlinefolio_end(fi.folio, ret);
}
} }
bio_uninit(&rq->bio); bio_uninit(&rq->bio);
kfree(rq); kfree(rq);
...@@ -68,6 +71,17 @@ static struct erofs_fileio_rq *erofs_fileio_rq_alloc(struct erofs_map_dev *mdev) ...@@ -68,6 +71,17 @@ static struct erofs_fileio_rq *erofs_fileio_rq_alloc(struct erofs_map_dev *mdev)
return rq; return rq;
} }
struct bio *erofs_fileio_bio_alloc(struct erofs_map_dev *mdev)
{
return &erofs_fileio_rq_alloc(mdev)->bio;
}
void erofs_fileio_submit_bio(struct bio *bio)
{
return erofs_fileio_rq_submit(container_of(bio, struct erofs_fileio_rq,
bio));
}
static int erofs_fileio_scan_folio(struct erofs_fileio *io, struct folio *folio) static int erofs_fileio_scan_folio(struct erofs_fileio *io, struct folio *folio)
{ {
struct inode *inode = folio_inode(folio); struct inode *inode = folio_inode(folio);
......
...@@ -252,12 +252,6 @@ static int erofs_fill_inode(struct inode *inode) ...@@ -252,12 +252,6 @@ static int erofs_fill_inode(struct inode *inode)
mapping_set_large_folios(inode->i_mapping); mapping_set_large_folios(inode->i_mapping);
if (erofs_inode_is_data_compressed(vi->datalayout)) { if (erofs_inode_is_data_compressed(vi->datalayout)) {
#ifdef CONFIG_EROFS_FS_ZIP #ifdef CONFIG_EROFS_FS_ZIP
#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
if (erofs_is_fileio_mode(EROFS_SB(inode->i_sb))) {
err = -EOPNOTSUPP;
goto out_unlock;
}
#endif
DO_ONCE_LITE_IF(inode->i_blkbits != PAGE_SHIFT, DO_ONCE_LITE_IF(inode->i_blkbits != PAGE_SHIFT,
erofs_info, inode->i_sb, erofs_info, inode->i_sb,
"EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!"); "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!");
......
...@@ -489,6 +489,14 @@ static inline void z_erofs_exit_subsystem(void) {} ...@@ -489,6 +489,14 @@ static inline void z_erofs_exit_subsystem(void) {}
static inline int erofs_init_managed_cache(struct super_block *sb) { return 0; } static inline int erofs_init_managed_cache(struct super_block *sb) { return 0; }
#endif /* !CONFIG_EROFS_FS_ZIP */ #endif /* !CONFIG_EROFS_FS_ZIP */
#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
struct bio *erofs_fileio_bio_alloc(struct erofs_map_dev *mdev);
void erofs_fileio_submit_bio(struct bio *bio);
#else
static inline struct bio *erofs_fileio_bio_alloc(struct erofs_map_dev *mdev) { return NULL; }
static inline void erofs_fileio_submit_bio(struct bio *bio) {}
#endif
#ifdef CONFIG_EROFS_FS_ONDEMAND #ifdef CONFIG_EROFS_FS_ONDEMAND
int erofs_fscache_register_fs(struct super_block *sb); int erofs_fscache_register_fs(struct super_block *sb);
void erofs_fscache_unregister_fs(struct super_block *sb); void erofs_fscache_unregister_fs(struct super_block *sb);
......
...@@ -1618,10 +1618,12 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f, ...@@ -1618,10 +1618,12 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
if (bio && (cur != last_pa || if (bio && (cur != last_pa ||
bio->bi_bdev != mdev.m_bdev)) { bio->bi_bdev != mdev.m_bdev)) {
drain_io: drain_io:
if (!erofs_is_fscache_mode(sb)) if (erofs_is_fileio_mode(EROFS_SB(sb)))
submit_bio(bio); erofs_fileio_submit_bio(bio);
else else if (erofs_is_fscache_mode(sb))
erofs_fscache_submit_bio(bio); erofs_fscache_submit_bio(bio);
else
submit_bio(bio);
if (memstall) { if (memstall) {
psi_memstall_leave(&pflags); psi_memstall_leave(&pflags);
...@@ -1646,10 +1648,13 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f, ...@@ -1646,10 +1648,13 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
} }
if (!bio) { if (!bio) {
bio = erofs_is_fscache_mode(sb) ? if (erofs_is_fileio_mode(EROFS_SB(sb)))
erofs_fscache_bio_alloc(&mdev) : bio = erofs_fileio_bio_alloc(&mdev);
bio_alloc(mdev.m_bdev, BIO_MAX_VECS, else if (erofs_is_fscache_mode(sb))
REQ_OP_READ, GFP_NOIO); bio = erofs_fscache_bio_alloc(&mdev);
else
bio = bio_alloc(mdev.m_bdev, BIO_MAX_VECS,
REQ_OP_READ, GFP_NOIO);
bio->bi_end_io = z_erofs_endio; bio->bi_end_io = z_erofs_endio;
bio->bi_iter.bi_sector = cur >> 9; bio->bi_iter.bi_sector = cur >> 9;
bio->bi_private = q[JQ_SUBMIT]; bio->bi_private = q[JQ_SUBMIT];
...@@ -1672,10 +1677,12 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f, ...@@ -1672,10 +1677,12 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f,
} while (owned_head != Z_EROFS_PCLUSTER_TAIL); } while (owned_head != Z_EROFS_PCLUSTER_TAIL);
if (bio) { if (bio) {
if (!erofs_is_fscache_mode(sb)) if (erofs_is_fileio_mode(EROFS_SB(sb)))
submit_bio(bio); erofs_fileio_submit_bio(bio);
else else if (erofs_is_fscache_mode(sb))
erofs_fscache_submit_bio(bio); erofs_fscache_submit_bio(bio);
else
submit_bio(bio);
if (memstall) if (memstall)
psi_memstall_leave(&pflags); psi_memstall_leave(&pflags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment