Skip to content

Commit 94e4e15

Browse files
Gao Xianggregkh
authored andcommitted
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: Christoph Hellwig <hch@infradead.org> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com> Link: https://lore.kernel.org/r/20190904020912.63925-18-gaoxiang25@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e655b5b commit 94e4e15

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

‎fs/erofs/data.c‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,20 @@ static inline void read_endio(struct bio *bio)
4040

4141
static struct bio *erofs_grab_raw_bio(struct super_block *sb,
4242
erofs_blk_t blkaddr,
43-
unsigned int nr_pages)
43+
unsigned int nr_pages,
44+
bool ismeta)
4445
{
4546
struct bio *bio = bio_alloc(GFP_NOIO, nr_pages);
4647

4748
bio->bi_end_io = read_endio;
4849
bio_set_dev(bio, sb->s_bdev);
4950
bio->bi_iter.bi_sector = (sector_t)blkaddr << LOG_SECTORS_PER_BLOCK;
5051
bio->bi_private = sb;
52+
if (ismeta)
53+
bio->bi_opf = REQ_OP_READ | REQ_META;
54+
else
55+
bio->bi_opf = REQ_OP_READ;
56+
5157
return bio;
5258
}
5359

@@ -69,14 +75,14 @@ struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr)
6975
if (!PageUptodate(page)) {
7076
struct bio *bio;
7177

72-
bio = erofs_grab_raw_bio(sb, blkaddr, 1);
78+
bio = erofs_grab_raw_bio(sb, blkaddr, 1, true);
7379

7480
if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) {
7581
err = -EFAULT;
7682
goto err_out;
7783
}
7884

79-
__submit_bio(bio, REQ_OP_READ, REQ_META);
85+
submit_bio(bio);
8086
lock_page(page);
8187

8288
/* this page has been truncated by others */
@@ -201,7 +207,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
201207
/* not continuous */
202208
*last_block + 1 != current_block) {
203209
submit_bio_retry:
204-
__submit_bio(bio, REQ_OP_READ, 0);
210+
submit_bio(bio);
205211
bio = NULL;
206212
}
207213

@@ -271,7 +277,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
271277
if (nblocks > BIO_MAX_PAGES)
272278
nblocks = BIO_MAX_PAGES;
273279

274-
bio = erofs_grab_raw_bio(sb, blknr, nblocks);
280+
bio = erofs_grab_raw_bio(sb, blknr, nblocks, false);
275281
}
276282

277283
err = bio_add_page(bio, page, PAGE_SIZE, 0);
@@ -302,8 +308,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
302308
/* if updated manually, continuous pages has a gap */
303309
if (bio)
304310
submit_bio_out:
305-
__submit_bio(bio, REQ_OP_READ, 0);
306-
311+
submit_bio(bio);
307312
return err ? ERR_PTR(err) : NULL;
308313
}
309314

@@ -367,7 +372,7 @@ static int erofs_raw_access_readpages(struct file *filp,
367372

368373
/* the rare case (end in gaps) */
369374
if (bio)
370-
__submit_bio(bio, REQ_OP_READ, 0);
375+
submit_bio(bio);
371376
return 0;
372377
}
373378

‎fs/erofs/internal.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,6 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
409409
#endif /* !CONFIG_EROFS_FS_ZIP */
410410

411411
/* data.c */
412-
static inline void __submit_bio(struct bio *bio, unsigned int op,
413-
unsigned int op_flags)
414-
{
415-
bio_set_op_attrs(bio, op, op_flags);
416-
submit_bio(bio);
417-
}
418-
419412
struct page *erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr);
420413

421414
int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);

‎fs/erofs/zdata.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
12581258

12591259
if (bio && force_submit) {
12601260
submit_bio_retry:
1261-
__submit_bio(bio, REQ_OP_READ, 0);
1261+
submit_bio(bio);
12621262
bio = NULL;
12631263
}
12641264

@@ -1270,6 +1270,8 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
12701270
bio->bi_iter.bi_sector = (sector_t)(first_index + i) <<
12711271
LOG_SECTORS_PER_BLOCK;
12721272
bio->bi_private = bi_private;
1273+
bio->bi_opf = REQ_OP_READ;
1274+
12731275
++nr_bios;
12741276
}
12751277

@@ -1290,7 +1292,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
12901292
} while (owned_head != Z_EROFS_PCLUSTER_TAIL);
12911293

12921294
if (bio)
1293-
__submit_bio(bio, REQ_OP_READ, 0);
1295+
submit_bio(bio);
12941296

12951297
if (postsubmit_is_all_bypassed(q, nr_bios, force_fg))
12961298
return true;

0 commit comments

Comments
 (0)