Commit 94e4e153 authored by Gao Xiang's avatar Gao Xiang Committed by Greg Kroah-Hartman

erofs: kill __submit_bio()

As Christoph pointed out [1], "
Why is there __submit_bio which really just obsfucates
what is going on?  Also why is __submit_bio using
bio_set_op_attrs instead of opencode it as the comment
right next to it asks you to? "

Let's use submit_bio directly instead.

[1] https://lore.kernel.org/r/20190830162812.GA10694@infradead.org/Reported-by: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarGao Xiang <gaoxiang25@huawei.com>
Link: https://lore.kernel.org/r/20190904020912.63925-18-gaoxiang25@huawei.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e655b5b3
...@@ -40,7 +40,8 @@ static inline void read_endio(struct bio *bio) ...@@ -40,7 +40,8 @@ static inline void read_endio(struct bio *bio)
static struct bio *erofs_grab_raw_bio(struct super_block *sb, static struct bio *erofs_grab_raw_bio(struct super_block *sb,
erofs_blk_t blkaddr, erofs_blk_t blkaddr,
unsigned int nr_pages) unsigned int nr_pages,
bool ismeta)
{ {
struct bio *bio = bio_alloc(GFP_NOIO, nr_pages); struct bio *bio = bio_alloc(GFP_NOIO, nr_pages);
...@@ -48,6 +49,11 @@ static struct bio *erofs_grab_raw_bio(struct super_block *sb, ...@@ -48,6 +49,11 @@ static struct bio *erofs_grab_raw_bio(struct super_block *sb,
bio_set_dev(bio, sb->s_bdev); bio_set_dev(bio, sb->s_bdev);
bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK; bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK;
bio->bi_private = sb; bio->bi_private = sb;
if (ismeta)
bio->bi_opf = REQ_OP_READ | REQ_META;
else
bio->bi_opf = REQ_OP_READ;
return bio; return bio;
} }
...@@ -69,14 +75,14 @@ struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr) ...@@ -69,14 +75,14 @@ struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr)
if (!PageUptodate(page)) { if (!PageUptodate(page)) {
struct bio *bio; struct bio *bio;
bio = erofs_grab_raw_bio(sb, blkaddr, 1); bio = erofs_grab_raw_bio(sb, blkaddr, 1, true);
if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) { if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
err = -EFAULT; err = -EFAULT;
goto err_out; goto err_out;
} }
__submit_bio(bio, REQ_OP_READ, REQ_META); submit_bio(bio);
lock_page(page); lock_page(page);
/* this page has been truncated by others */ /* this page has been truncated by others */
...@@ -201,7 +207,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, ...@@ -201,7 +207,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
/* not continuous */ /* not continuous */
*last_block + 1 != current_block) { *last_block + 1 != current_block) {
submit_bio_retry: submit_bio_retry:
__submit_bio(bio, REQ_OP_READ, 0); submit_bio(bio);
bio = NULL; bio = NULL;
} }
...@@ -271,7 +277,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, ...@@ -271,7 +277,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
if (nblocks > BIO_MAX_PAGES) if (nblocks > BIO_MAX_PAGES)
nblocks = BIO_MAX_PAGES; nblocks = BIO_MAX_PAGES;
bio = erofs_grab_raw_bio(sb, blknr, nblocks); bio = erofs_grab_raw_bio(sb, blknr, nblocks, false);
} }
err = bio_add_page(bio, page, PAGE_SIZE, 0); err = bio_add_page(bio, page, PAGE_SIZE, 0);
...@@ -302,8 +308,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, ...@@ -302,8 +308,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
/* if updated manually, continuous pages has a gap */ /* if updated manually, continuous pages has a gap */
if (bio) if (bio)
submit_bio_out: submit_bio_out:
__submit_bio(bio, REQ_OP_READ, 0); submit_bio(bio);
return err ? ERR_PTR(err) : NULL; return err ? ERR_PTR(err) : NULL;
} }
...@@ -367,7 +372,7 @@ static int erofs_raw_access_readpages(struct file *filp, ...@@ -367,7 +372,7 @@ static int erofs_raw_access_readpages(struct file *filp,
/* the rare case (end in gaps) */ /* the rare case (end in gaps) */
if (bio) if (bio)
__submit_bio(bio, REQ_OP_READ, 0); submit_bio(bio);
return 0; return 0;
} }
......
...@@ -409,13 +409,6 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode, ...@@ -409,13 +409,6 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
#endif /* !CONFIG_EROFS_FS_ZIP */ #endif /* !CONFIG_EROFS_FS_ZIP */
/* data.c */ /* data.c */
static inline void __submit_bio(struct bio *bio, unsigned int op,
unsigned int op_flags)
{
bio_set_op_attrs(bio, op, op_flags);
submit_bio(bio);
}
struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr); struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr);
int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int); int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);
......
...@@ -1258,7 +1258,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, ...@@ -1258,7 +1258,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
if (bio && force_submit) { if (bio && force_submit) {
submit_bio_retry: submit_bio_retry:
__submit_bio(bio, REQ_OP_READ, 0); submit_bio(bio);
bio = NULL; bio = NULL;
} }
...@@ -1270,6 +1270,8 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, ...@@ -1270,6 +1270,8 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
bio->bi_iter.bi_sector = (sector_t)(first_index + i) << bio->bi_iter.bi_sector = (sector_t)(first_index + i) <<
LOG_SECTORS_PER_BLOCK; LOG_SECTORS_PER_BLOCK;
bio->bi_private = bi_private; bio->bi_private = bi_private;
bio->bi_opf = REQ_OP_READ;
++nr_bios; ++nr_bios;
} }
...@@ -1290,7 +1292,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, ...@@ -1290,7 +1292,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
} while (owned_head != Z_EROFS_PCLUSTER_TAIL); } while (owned_head != Z_EROFS_PCLUSTER_TAIL);
if (bio) if (bio)
__submit_bio(bio, REQ_OP_READ, 0); submit_bio(bio);
if (postsubmit_is_all_bypassed(q, nr_bios, force_fg)) if (postsubmit_is_all_bypassed(q, nr_bios, force_fg))
return true; return true;
......
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