aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChangman Lee <cm224.lee@samsung.com>2013-11-06 22:48:25 -0500
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-11-08 00:10:29 -0500
commitfb51b5ef9c07844f80402702bd3d3002ceca5cd9 (patch)
tree203243206fd73a201d6e316079e26384baf9754b /fs
parent3b03f72445ba1437cfa29f9719bb3cfdb60558d9 (diff)
f2fs: cleanup waiting routine for writeback pages in cp
use genernal method supported by kernel o changes from v1 If any waiter exists at end io, wake up it. Signed-off-by: Changman Lee <cm224.lee@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/checkpoint.c25
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/segment.c5
-rw-r--r--fs/f2fs/super.c1
4 files changed, 21 insertions, 12 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index d430157ffe60..5716e5eb4e8e 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -634,6 +634,21 @@ static void unblock_operations(struct f2fs_sb_info *sbi)
634 f2fs_unlock_all(sbi); 634 f2fs_unlock_all(sbi);
635} 635}
636 636
637static void wait_on_all_pages_writeback(struct f2fs_sb_info *sbi)
638{
639 DEFINE_WAIT(wait);
640
641 for (;;) {
642 prepare_to_wait(&sbi->cp_wait, &wait, TASK_UNINTERRUPTIBLE);
643
644 if (!get_pages(sbi, F2FS_WRITEBACK))
645 break;
646
647 io_schedule();
648 }
649 finish_wait(&sbi->cp_wait, &wait);
650}
651
637static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount) 652static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
638{ 653{
639 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); 654 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
@@ -743,15 +758,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
743 f2fs_put_page(cp_page, 1); 758 f2fs_put_page(cp_page, 1);
744 759
745 /* wait for previous submitted node/meta pages writeback */ 760 /* wait for previous submitted node/meta pages writeback */
746 sbi->cp_task = current; 761 wait_on_all_pages_writeback(sbi);
747 while (get_pages(sbi, F2FS_WRITEBACK)) {
748 set_current_state(TASK_UNINTERRUPTIBLE);
749 if (!get_pages(sbi, F2FS_WRITEBACK))
750 break;
751 io_schedule();
752 }
753 __set_current_state(TASK_RUNNING);
754 sbi->cp_task = NULL;
755 762
756 filemap_fdatawait_range(sbi->node_inode->i_mapping, 0, LONG_MAX); 763 filemap_fdatawait_range(sbi->node_inode->i_mapping, 0, LONG_MAX);
757 filemap_fdatawait_range(sbi->meta_inode->i_mapping, 0, LONG_MAX); 764 filemap_fdatawait_range(sbi->meta_inode->i_mapping, 0, LONG_MAX);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 625eb4befad4..89dc7508faf2 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -372,7 +372,7 @@ struct f2fs_sb_info {
372 struct mutex writepages; /* mutex for writepages() */ 372 struct mutex writepages; /* mutex for writepages() */
373 bool por_doing; /* recovery is doing or not */ 373 bool por_doing; /* recovery is doing or not */
374 bool on_build_free_nids; /* build_free_nids is doing */ 374 bool on_build_free_nids; /* build_free_nids is doing */
375 struct task_struct *cp_task; /* checkpoint task */ 375 wait_queue_head_t cp_wait;
376 376
377 /* for orphan inode management */ 377 /* for orphan inode management */
378 struct list_head orphan_inode_list; /* orphan inode list */ 378 struct list_head orphan_inode_list; /* orphan inode list */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index ff363e686b7e..86dc28949192 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -592,8 +592,9 @@ static void f2fs_end_io_write(struct bio *bio, int err)
592 if (p->is_sync) 592 if (p->is_sync)
593 complete(p->wait); 593 complete(p->wait);
594 594
595 if (!get_pages(p->sbi, F2FS_WRITEBACK) && p->sbi->cp_task) 595 if (!get_pages(p->sbi, F2FS_WRITEBACK) &&
596 wake_up_process(p->sbi->cp_task); 596 !list_empty(&p->sbi->cp_wait.task_list))
597 wake_up(&p->sbi->cp_wait);
597 598
598 kfree(p); 599 kfree(p);
599 bio_put(bio); 600 bio_put(bio);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index e42351cbe166..00e79df5a34f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -876,6 +876,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
876 spin_lock_init(&sbi->stat_lock); 876 spin_lock_init(&sbi->stat_lock);
877 init_rwsem(&sbi->bio_sem); 877 init_rwsem(&sbi->bio_sem);
878 init_rwsem(&sbi->cp_rwsem); 878 init_rwsem(&sbi->cp_rwsem);
879 init_waitqueue_head(&sbi->cp_wait);
879 init_sb_info(sbi); 880 init_sb_info(sbi);
880 881
881 /* get an inode for meta space */ 882 /* get an inode for meta space */