summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2013-11-18 17:13:35 +0900
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-12-23 10:18:00 +0900
commit7d5e510944ce60ef0c6c2300a58547679df76db7 (patch)
tree37e16294356e0917f04daf1d8494e5ac14383f11
parent75c3c8bc88d573d6823fcf2576f5c47e4fc41710 (diff)
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>
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/segment.c39
2 files changed, 22 insertions, 18 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index c73e3dff6f13..38963b4b500a 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -350,6 +350,7 @@ enum count_type {
* with waiting the bio's completion
* ... Only can be used with META.
*/
+#define PAGE_TYPE_OF_BIO(type) ((type) > META ? META : (type))
enum page_type {
DATA,
NODE,
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index cfc0eb4f24d5..d5043bdaa1af 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -835,32 +835,35 @@ static void do_submit_bio(struct f2fs_sb_info *sbi,
enum page_type type, bool sync)
{
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)
rw = WRITE_FLUSH_FUA;
-
if (btype == META)
rw |= REQ_META;
- if (sbi->bio[btype]) {
- struct bio_private *p = sbi->bio[btype]->bi_private;
- p->sbi = sbi;
- sbi->bio[btype]->bi_end_io = f2fs_end_io_write;
+ p = bio->bi_private;
+ p->sbi = sbi;
+ bio->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) {
- DECLARE_COMPLETION_ONSTACK(wait);
- p->is_sync = true;
- p->wait = &wait;
- submit_bio(rw, sbi->bio[btype]);
- wait_for_completion(&wait);
- } else {
- p->is_sync = false;
- submit_bio(rw, sbi->bio[btype]);
- }
- sbi->bio[btype] = NULL;
+ if (type == META_FLUSH) {
+ DECLARE_COMPLETION_ONSTACK(wait);
+ p->is_sync = true;
+ p->wait = &wait;
+ submit_bio(rw, bio);
+ wait_for_completion(&wait);
+ } else {
+ p->is_sync = false;
+ submit_bio(rw, bio);
}
}