aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/segment.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2012-12-10 09:26:05 +0900
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2012-12-11 13:43:45 +0900
commit3cd8a23948b29301f8f67b8d70c5c18fabbc05e1 (patch)
treee4d9c11d55446e547b4a7830d733126f17ef3e37 /fs/f2fs/segment.c
parent457d08ee4fd91c8df17917ff2d32565e6adacbfc (diff)
downloadkernel_goldelico_gta04-3cd8a23948b29301f8f67b8d70c5c18fabbc05e1.zip
kernel_goldelico_gta04-3cd8a23948b29301f8f67b8d70c5c18fabbc05e1.tar.gz
kernel_goldelico_gta04-3cd8a23948b29301f8f67b8d70c5c18fabbc05e1.tar.bz2
f2fs: cleanup the f2fs_bio_alloc routine
Do cleanup more for better code readability. - Change the parameter set of f2fs_bio_alloc() This function should allocate a bio only since it is not something like f2fs_bio_init(). Instead, the caller should initialize the allocated bio. - Introduce SECTOR_FROM_BLOCK This macro translates a block address to its sector address. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com> Reviewed-by: Namjae Jeon <namjae.jeon@samsung.com>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r--fs/f2fs/segment.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8894b39..1b26e4e 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -643,23 +643,21 @@ static void f2fs_end_io_write(struct bio *bio, int err)
bio_put(bio);
}
-struct bio *f2fs_bio_alloc(struct block_device *bdev, sector_t first_sector,
- int nr_vecs, gfp_t gfp_flags)
+struct bio *f2fs_bio_alloc(struct block_device *bdev, int npages)
{
struct bio *bio;
-
- /* allocate new bio */
- bio = bio_alloc(gfp_flags, nr_vecs);
-
- bio->bi_bdev = bdev;
- bio->bi_sector = first_sector;
+ struct bio_private *priv;
retry:
- bio->bi_private = kmalloc(sizeof(struct bio_private),
- GFP_NOFS | __GFP_HIGH);
- if (!bio->bi_private) {
+ priv = kmalloc(sizeof(struct bio_private), GFP_NOFS);
+ if (!priv) {
cond_resched();
goto retry;
}
+
+ /* No failure on bio allocation */
+ bio = bio_alloc(GFP_NOIO, npages);
+ bio->bi_bdev = bdev;
+ bio->bi_private = priv;
return bio;
}
@@ -711,10 +709,15 @@ static void submit_write_page(struct f2fs_sb_info *sbi, struct page *page,
if (sbi->bio[type] && sbi->last_block_in_bio[type] != blk_addr - 1)
do_submit_bio(sbi, type, false);
alloc_new:
- if (sbi->bio[type] == NULL)
- sbi->bio[type] = f2fs_bio_alloc(bdev,
- blk_addr << (sbi->log_blocksize - 9),
- bio_get_nr_vecs(bdev), GFP_NOFS | __GFP_HIGH);
+ if (sbi->bio[type] == NULL) {
+ sbi->bio[type] = f2fs_bio_alloc(bdev, bio_get_nr_vecs(bdev));
+ sbi->bio[type]->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
+ /*
+ * The end_io will be assigned at the sumbission phase.
+ * Until then, let bio_add_page() merge consecutive IOs as much
+ * as possible.
+ */
+ }
if (bio_add_page(sbi->bio[type], page, PAGE_CACHE_SIZE, 0) <
PAGE_CACHE_SIZE) {