f2fs: cleanup waiting routine for writeback pages in cp
authorChangman Lee <cm224.lee@samsung.com>
Thu, 7 Nov 2013 03:48:25 +0000 (12:48 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Fri, 8 Nov 2013 05:10:29 +0000 (14:10 +0900)
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>
fs/f2fs/checkpoint.c
fs/f2fs/f2fs.h
fs/f2fs/segment.c
fs/f2fs/super.c

index d430157ffe607033531611213b79ba9ecbaaacd2..5716e5eb4e8ec7ab2c63c69079259e2c5d772918 100644 (file)
@@ -634,6 +634,21 @@ static void unblock_operations(struct f2fs_sb_info *sbi)
        f2fs_unlock_all(sbi);
 }
 
+static void wait_on_all_pages_writeback(struct f2fs_sb_info *sbi)
+{
+       DEFINE_WAIT(wait);
+
+       for (;;) {
+               prepare_to_wait(&sbi->cp_wait, &wait, TASK_UNINTERRUPTIBLE);
+
+               if (!get_pages(sbi, F2FS_WRITEBACK))
+                       break;
+
+               io_schedule();
+       }
+       finish_wait(&sbi->cp_wait, &wait);
+}
+
 static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
 {
        struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
@@ -743,15 +758,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
        f2fs_put_page(cp_page, 1);
 
        /* wait for previous submitted node/meta pages writeback */
-       sbi->cp_task = current;
-       while (get_pages(sbi, F2FS_WRITEBACK)) {
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               if (!get_pages(sbi, F2FS_WRITEBACK))
-                       break;
-               io_schedule();
-       }
-       __set_current_state(TASK_RUNNING);
-       sbi->cp_task = NULL;
+       wait_on_all_pages_writeback(sbi);
 
        filemap_fdatawait_range(sbi->node_inode->i_mapping, 0, LONG_MAX);
        filemap_fdatawait_range(sbi->meta_inode->i_mapping, 0, LONG_MAX);
index 625eb4befad4a64d29a193db9d1bc90591b79486..89dc7508faf2edf173441a9e25cad8a9ff4856aa 100644 (file)
@@ -372,7 +372,7 @@ struct f2fs_sb_info {
        struct mutex writepages;                /* mutex for writepages() */
        bool por_doing;                         /* recovery is doing or not */
        bool on_build_free_nids;                /* build_free_nids is doing */
-       struct task_struct *cp_task;            /* checkpoint task */
+       wait_queue_head_t cp_wait;
 
        /* for orphan inode management */
        struct list_head orphan_inode_list;     /* orphan inode list */
index ff363e686b7e4324433a7ec927e90da450798386..86dc28949192a12a5b8d55e5ef6e982d1e8d63e9 100644 (file)
@@ -592,8 +592,9 @@ static void f2fs_end_io_write(struct bio *bio, int err)
        if (p->is_sync)
                complete(p->wait);
 
-       if (!get_pages(p->sbi, F2FS_WRITEBACK) && p->sbi->cp_task)
-               wake_up_process(p->sbi->cp_task);
+       if (!get_pages(p->sbi, F2FS_WRITEBACK) &&
+                       !list_empty(&p->sbi->cp_wait.task_list))
+               wake_up(&p->sbi->cp_wait);
 
        kfree(p);
        bio_put(bio);
index e42351cbe1666657757777e9887df0bd50577da7..00e79df5a34f040df9860eb067c4a55946f4c0d6 100644 (file)
@@ -876,6 +876,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
        spin_lock_init(&sbi->stat_lock);
        init_rwsem(&sbi->bio_sem);
        init_rwsem(&sbi->cp_rwsem);
+       init_waitqueue_head(&sbi->cp_wait);
        init_sb_info(sbi);
 
        /* get an inode for meta space */