1
0
Fork 0

f2fs: clean up the do_submit_bio flow

This patch introduces PAGE_TYPE_OF_BIO() and cleans up do_submit_bio() with it.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
hifive-unleashed-5.1
Jaegeuk Kim 2013-11-18 17:13:35 +09:00
parent 75c3c8bc88
commit 7d5e510944
2 changed files with 22 additions and 18 deletions

View File

@ -350,6 +350,7 @@ enum count_type {
* with waiting the bio's completion * with waiting the bio's completion
* ... Only can be used with META. * ... Only can be used with META.
*/ */
#define PAGE_TYPE_OF_BIO(type) ((type) > META ? META : (type))
enum page_type { enum page_type {
DATA, DATA,
NODE, NODE,

View File

@ -835,32 +835,35 @@ static void do_submit_bio(struct f2fs_sb_info *sbi,
enum page_type type, bool sync) enum page_type type, bool sync)
{ {
int rw = sync ? WRITE_SYNC : WRITE; int rw = sync ? WRITE_SYNC : WRITE;
enum page_type btype = type > META ? META : type; enum page_type btype = PAGE_TYPE_OF_BIO(type);
struct bio *bio = sbi->bio[btype];
struct bio_private *p;
if (!bio)
return;
sbi->bio[btype] = NULL;
if (type >= META_FLUSH) if (type >= META_FLUSH)
rw = WRITE_FLUSH_FUA; rw = WRITE_FLUSH_FUA;
if (btype == META) if (btype == META)
rw |= REQ_META; rw |= REQ_META;
if (sbi->bio[btype]) { p = bio->bi_private;
struct bio_private *p = sbi->bio[btype]->bi_private; p->sbi = sbi;
p->sbi = sbi; bio->bi_end_io = f2fs_end_io_write;
sbi->bio[btype]->bi_end_io = f2fs_end_io_write;
trace_f2fs_do_submit_bio(sbi->sb, btype, sync, sbi->bio[btype]); trace_f2fs_do_submit_bio(sbi->sb, btype, sync, bio);
if (type == META_FLUSH) { if (type == META_FLUSH) {
DECLARE_COMPLETION_ONSTACK(wait); DECLARE_COMPLETION_ONSTACK(wait);
p->is_sync = true; p->is_sync = true;
p->wait = &wait; p->wait = &wait;
submit_bio(rw, sbi->bio[btype]); submit_bio(rw, bio);
wait_for_completion(&wait); wait_for_completion(&wait);
} else { } else {
p->is_sync = false; p->is_sync = false;
submit_bio(rw, sbi->bio[btype]); submit_bio(rw, bio);
}
sbi->bio[btype] = NULL;
} }
} }