diff options
author | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-02-03 10:50:22 +0900 |
---|---|---|
committer | Ziyan <jaraidaniel@gmail.com> | 2015-05-02 14:36:16 +0200 |
commit | 9c151ee32dab6cd48f99e5d6d8ca00eab1ca6ddf (patch) | |
tree | 6c7bdd2b2b22a1829384d1dcc6a0449b272ab842 /fs | |
parent | ae661c2f587b351535fb9e1a82bb5eb413c85c8c (diff) | |
download | kernel_samsung_tuna-9c151ee32dab6cd48f99e5d6d8ca00eab1ca6ddf.zip kernel_samsung_tuna-9c151ee32dab6cd48f99e5d6d8ca00eab1ca6ddf.tar.gz kernel_samsung_tuna-9c151ee32dab6cd48f99e5d6d8ca00eab1ca6ddf.tar.bz2 |
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>
Conflicts:
fs/f2fs/data.c
Diffstat (limited to 'fs')
-rw-r--r-- | fs/f2fs/data.c | 11 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 1 |
2 files changed, 8 insertions, 4 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index dd58694..ef9f53b 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -50,7 +50,7 @@ static void f2fs_write_end_io(struct bio *bio, int err) { const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; - struct f2fs_sb_info *sbi = F2FS_SB(bvec->bv_page->mapping->host->i_sb); + struct f2fs_sb_info *sbi = bio->bi_private; do { struct page *page = bvec->bv_page; @@ -67,8 +67,10 @@ static void f2fs_write_end_io(struct bio *bio, int err) dec_page_count(sbi, F2FS_WRITEBACK); } while (bvec >= bio->bi_io_vec); - if (bio->bi_private) - complete(bio->bi_private); + if (sbi->wait_io) { + complete(sbi->wait_io); + sbi->wait_io = NULL; + } if (!get_pages(sbi, F2FS_WRITEBACK) && !list_empty(&sbi->cp_wait.task_list)) @@ -91,6 +93,7 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr, bio->bi_bdev = sbi->sb->s_bdev; bio->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr); bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io; + bio->bi_private = sbi; return bio; } @@ -118,7 +121,7 @@ static void __submit_merged_bio(struct f2fs_bio_info *io) */ if (fio->type == META_FLUSH) { DECLARE_COMPLETION_ONSTACK(wait); - io->bio->bi_private = &wait; + io->sbi->wait_io = &wait; submit_bio(rw, io->bio); wait_for_completion(&wait); } else { diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 80a64fd..3f84ca4 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -398,6 +398,7 @@ struct f2fs_sb_info { /* for bio operations */ struct f2fs_bio_info read_io; /* for read bios */ struct f2fs_bio_info write_io[NR_PAGE_TYPE]; /* for write bios */ + struct completion *wait_io; /* for completion bios */ /* for checkpoint */ struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */ |