summaryrefslogtreecommitdiff
path: root/fs/f2fs/data.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-05-25 18:03:38 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2015-06-01 16:21:04 -0700
commit12377024719f08b7411afe9fc0169b13808dfefa (patch)
tree9cb12be8863a6fb4c020be9d9ca3726527c003e5 /fs/f2fs/data.c
parent26bf3dc7e25b813ff5c92234f8165941fdc12a63 (diff)
f2fs: avoid duplicated code by reusing f2fs_read_end_io
This patch tries to clean up code because part code of f2fs_read_end_io and mpage_end_io are the same, so it's better to merge and reuse them. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r--fs/f2fs/data.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8d04e24a889f..9bedfa8dd3a5 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -34,29 +34,6 @@ static void f2fs_read_end_io(struct bio *bio, int err)
struct bio_vec *bvec;
int i;
- bio_for_each_segment_all(bvec, bio, i) {
- struct page *page = bvec->bv_page;
-
- if (!err) {
- SetPageUptodate(page);
- } else {
- ClearPageUptodate(page);
- SetPageError(page);
- }
- unlock_page(page);
- }
- bio_put(bio);
-}
-
-/*
- * I/O completion handler for multipage BIOs.
- * copied from fs/mpage.c
- */
-static void mpage_end_io(struct bio *bio, int err)
-{
- struct bio_vec *bv;
- int i;
-
if (f2fs_bio_encrypted(bio)) {
if (err) {
f2fs_release_crypto_ctx(bio->bi_private);
@@ -66,8 +43,8 @@ static void mpage_end_io(struct bio *bio, int err)
}
}
- bio_for_each_segment_all(bv, bio, i) {
- struct page *page = bv->bv_page;
+ bio_for_each_segment_all(bvec, bio, i) {
+ struct page *page = bvec->bv_page;
if (!err) {
SetPageUptodate(page);
@@ -77,7 +54,6 @@ static void mpage_end_io(struct bio *bio, int err)
}
unlock_page(page);
}
-
bio_put(bio);
}
@@ -122,7 +98,7 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr,
bio->bi_bdev = sbi->sb->s_bdev;
bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(blk_addr);
bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io;
- bio->bi_private = sbi;
+ bio->bi_private = is_read ? NULL : sbi;
return bio;
}
@@ -1584,7 +1560,7 @@ submit_and_realloc:
}
bio->bi_bdev = bdev;
bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(block_nr);
- bio->bi_end_io = mpage_end_io;
+ bio->bi_end_io = f2fs_read_end_io;
bio->bi_private = ctx;
}