Commit 1b1f559f authored by Jaegeuk Kim's avatar Jaegeuk Kim

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: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
parent abb2366c
...@@ -45,7 +45,7 @@ static void f2fs_read_end_io(struct bio *bio, int err) ...@@ -45,7 +45,7 @@ static void f2fs_read_end_io(struct bio *bio, int err)
static void f2fs_write_end_io(struct bio *bio, int err) static void f2fs_write_end_io(struct bio *bio, int err)
{ {
struct f2fs_sb_info *sbi = F2FS_SB(bio->bi_io_vec->bv_page->mapping->host->i_sb); struct f2fs_sb_info *sbi = bio->bi_private;
struct bio_vec *bvec; struct bio_vec *bvec;
int i; int i;
...@@ -61,8 +61,10 @@ static void f2fs_write_end_io(struct bio *bio, int err) ...@@ -61,8 +61,10 @@ static void f2fs_write_end_io(struct bio *bio, int err)
dec_page_count(sbi, F2FS_WRITEBACK); dec_page_count(sbi, F2FS_WRITEBACK);
} }
if (bio->bi_private) if (sbi->wait_io) {
complete(bio->bi_private); complete(sbi->wait_io);
sbi->wait_io = NULL;
}
if (!get_pages(sbi, F2FS_WRITEBACK) && if (!get_pages(sbi, F2FS_WRITEBACK) &&
!list_empty(&sbi->cp_wait.task_list)) !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,6 +87,7 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr,
bio->bi_bdev = sbi->sb->s_bdev; bio->bi_bdev = sbi->sb->s_bdev;
bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr); bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io; bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io;
bio->bi_private = sbi;
return bio; return bio;
} }
...@@ -112,7 +115,7 @@ static void __submit_merged_bio(struct f2fs_bio_info *io) ...@@ -112,7 +115,7 @@ static void __submit_merged_bio(struct f2fs_bio_info *io)
*/ */
if (fio->type == META_FLUSH) { if (fio->type == META_FLUSH) {
DECLARE_COMPLETION_ONSTACK(wait); DECLARE_COMPLETION_ONSTACK(wait);
io->bio->bi_private = &wait; io->sbi->wait_io = &wait;
submit_bio(rw, io->bio); submit_bio(rw, io->bio);
wait_for_completion(&wait); wait_for_completion(&wait);
} else { } else {
......
...@@ -398,6 +398,7 @@ struct f2fs_sb_info { ...@@ -398,6 +398,7 @@ struct f2fs_sb_info {
/* for bio operations */ /* for bio operations */
struct f2fs_bio_info read_io; /* for read bios */ struct f2fs_bio_info read_io; /* for read bios */
struct f2fs_bio_info write_io[NR_PAGE_TYPE]; /* for write bios */ struct f2fs_bio_info write_io[NR_PAGE_TYPE]; /* for write bios */
struct completion *wait_io; /* for completion bios */
/* for checkpoint */ /* for checkpoint */
struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */ struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
......
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