aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/data.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2014-02-02 20:50:22 -0500
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2014-02-17 00:58:52 -0500
commit1b1f559fc362f96869b7e04ef9825b1039b9a67d (patch)
tree27587baf23c768fdd26dfdc615959bb6f243bd19 /fs/f2fs/data.c
parentabb2366c82c3d2dac3d7e9a74332137da8fc9399 (diff)
f2fs: remove the ugly pointer conversion
This patch modifies the use of bi_private to remove pointer chasing for sbi. Previously, we had a bi_private structure, but it needs memory allocation. So this patch uses bi_private by the sbi pointer and adds a completion pointer into the sbi. This can achieve no memory allocation and nice use of the bi_private. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r--fs/f2fs/data.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 20c3c648e56d..d175ae3b612a 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -45,7 +45,7 @@ static void f2fs_read_end_io(struct bio *bio, int err)
45 45
46static void f2fs_write_end_io(struct bio *bio, int err) 46static void f2fs_write_end_io(struct bio *bio, int err)
47{ 47{
48 struct f2fs_sb_info *sbi = F2FS_SB(bio->bi_io_vec->bv_page->mapping->host->i_sb); 48 struct f2fs_sb_info *sbi = bio->bi_private;
49 struct bio_vec *bvec; 49 struct bio_vec *bvec;
50 int i; 50 int i;
51 51
@@ -61,8 +61,10 @@ static void f2fs_write_end_io(struct bio *bio, int err)
61 dec_page_count(sbi, F2FS_WRITEBACK); 61 dec_page_count(sbi, F2FS_WRITEBACK);
62 } 62 }
63 63
64 if (bio->bi_private) 64 if (sbi->wait_io) {
65 complete(bio->bi_private); 65 complete(sbi->wait_io);
66 sbi->wait_io = NULL;
67 }
66 68
67 if (!get_pages(sbi, F2FS_WRITEBACK) && 69 if (!get_pages(sbi, F2FS_WRITEBACK) &&
68 !list_empty(&sbi->cp_wait.task_list)) 70 !list_empty(&sbi->cp_wait.task_list))
@@ -85,6 +87,7 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr,
85 bio->bi_bdev = sbi->sb->s_bdev; 87 bio->bi_bdev = sbi->sb->s_bdev;
86 bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr); 88 bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
87 bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io; 89 bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io;
90 bio->bi_private = sbi;
88 91
89 return bio; 92 return bio;
90} 93}
@@ -112,7 +115,7 @@ static void __submit_merged_bio(struct f2fs_bio_info *io)
112 */ 115 */
113 if (fio->type == META_FLUSH) { 116 if (fio->type == META_FLUSH) {
114 DECLARE_COMPLETION_ONSTACK(wait); 117 DECLARE_COMPLETION_ONSTACK(wait);
115 io->bio->bi_private = &wait; 118 io->sbi->wait_io = &wait;
116 submit_bio(rw, io->bio); 119 submit_bio(rw, io->bio);
117 wait_for_completion(&wait); 120 wait_for_completion(&wait);
118 } else { 121 } else {