Skip to content

Commit d023626

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: clean up error handing of f2fs_submit_page_read()
Below two functions should never fail, clean up error handling in their callers: 1) f2fs_grab_read_bio() in f2fs_submit_page_read() 2) bio_add_folio() in f2fs_submit_page_read() Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 2f84e99 commit d023626

1 file changed

Lines changed: 8 additions & 33 deletions

File tree

fs/f2fs/data.c

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
10851085
}
10861086

10871087
/* This can handle encryption stuffs */
1088-
static int f2fs_submit_page_read(struct inode *inode, struct folio *folio,
1088+
static void f2fs_submit_page_read(struct inode *inode, struct folio *folio,
10891089
block_t blkaddr, blk_opf_t op_flags,
10901090
bool for_write)
10911091
{
@@ -1094,23 +1094,16 @@ static int f2fs_submit_page_read(struct inode *inode, struct folio *folio,
10941094

10951095
bio = f2fs_grab_read_bio(inode, blkaddr, 1, op_flags,
10961096
folio->index, for_write);
1097-
if (IS_ERR(bio))
1098-
return PTR_ERR(bio);
10991097

11001098
/* wait for GCed page writeback via META_MAPPING */
11011099
f2fs_wait_on_block_writeback(inode, blkaddr);
11021100

1103-
if (!bio_add_folio(bio, folio, PAGE_SIZE, 0)) {
1104-
iostat_update_and_unbind_ctx(bio);
1105-
if (bio->bi_private)
1106-
mempool_free(bio->bi_private, bio_post_read_ctx_pool);
1107-
bio_put(bio);
1108-
return -EFAULT;
1109-
}
1101+
if (!bio_add_folio(bio, folio, PAGE_SIZE, 0))
1102+
f2fs_bug_on(sbi, 1);
1103+
11101104
inc_page_count(sbi, F2FS_RD_DATA);
11111105
f2fs_update_iostat(sbi, NULL, FS_DATA_READ_IO, F2FS_BLKSIZE);
11121106
f2fs_submit_read_bio(sbi, bio, DATA);
1113-
return 0;
11141107
}
11151108

11161109
static void __set_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr)
@@ -1267,10 +1260,8 @@ struct folio *f2fs_get_read_data_folio(struct inode *inode, pgoff_t index,
12671260
return folio;
12681261
}
12691262

1270-
err = f2fs_submit_page_read(inode, folio, dn.data_blkaddr,
1263+
f2fs_submit_page_read(inode, folio, dn.data_blkaddr,
12711264
op_flags, for_write);
1272-
if (err)
1273-
goto put_err;
12741265
return folio;
12751266

12761267
put_err:
@@ -2147,16 +2138,10 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio,
21472138
f2fs_submit_read_bio(F2FS_I_SB(inode), bio, DATA);
21482139
bio = NULL;
21492140
}
2150-
if (bio == NULL) {
2141+
if (bio == NULL)
21512142
bio = f2fs_grab_read_bio(inode, block_nr, nr_pages,
21522143
f2fs_ra_op_flags(rac), index,
21532144
false);
2154-
if (IS_ERR(bio)) {
2155-
ret = PTR_ERR(bio);
2156-
bio = NULL;
2157-
goto out;
2158-
}
2159-
}
21602145

21612146
/*
21622147
* If the page is under writeback, we need to wait for
@@ -2305,18 +2290,10 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
23052290
bio = NULL;
23062291
}
23072292

2308-
if (!bio) {
2293+
if (!bio)
23092294
bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages - i,
23102295
f2fs_ra_op_flags(rac),
23112296
folio->index, for_write);
2312-
if (IS_ERR(bio)) {
2313-
ret = PTR_ERR(bio);
2314-
f2fs_decompress_end_io(dic, ret, true);
2315-
f2fs_put_dnode(&dn);
2316-
*bio_ret = NULL;
2317-
return ret;
2318-
}
2319-
}
23202297

23212298
if (!bio_add_folio(bio, folio, blocksize, 0))
23222299
goto submit_and_realloc;
@@ -3641,11 +3618,9 @@ static int f2fs_write_begin(const struct kiocb *iocb,
36413618
err = -EFSCORRUPTED;
36423619
goto put_folio;
36433620
}
3644-
err = f2fs_submit_page_read(use_cow ?
3621+
f2fs_submit_page_read(use_cow ?
36453622
F2FS_I(inode)->cow_inode : inode,
36463623
folio, blkaddr, 0, true);
3647-
if (err)
3648-
goto put_folio;
36493624

36503625
folio_lock(folio);
36513626
if (unlikely(folio->mapping != mapping)) {

0 commit comments

Comments
 (0)