lkml.org 
[lkml]   [2015]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 18/18] jffs2: Use the new API for a sleep with a timeout
    Date
    It allows to maintain the checks for freezing, parking, and signal
    handling on a single place.

    Note that the sleep with the timeout is used here to slow down
    the progress a bit. It does not matter if we do it before or after
    calling jffs2_garbage_collect_pass().

    Signed-off-by: Petr Mladek <pmladek@suse.cz>
    ---
    fs/jffs2/background.c | 29 +++++++++++------------------
    1 file changed, 11 insertions(+), 18 deletions(-)

    diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
    index 50c16048ba2d..2d38d40e0ad1 100644
    --- a/fs/jffs2/background.c
    +++ b/fs/jffs2/background.c
    @@ -62,6 +62,16 @@ static void jffs2_garbage_collect_thread_func(void *_c)
    }
    spin_unlock(&c->erase_completion_lock);

    + /* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */
    + sigprocmask(SIG_BLOCK, &hupmask, NULL);
    +
    + jffs2_dbg(1, "%s(): pass\n", __func__);
    + if (jffs2_garbage_collect_pass(c) == -ENOSPC) {
    + pr_notice("No space for garbage collection. Aborting GC thread\n");
    + kthread_stop_current();
    + }
    + sigprocmask(SIG_UNBLOCK, &hupmask, NULL);
    +
    /* Problem - immediately after bootup, the GCD spends a lot
    * of time in places like jffs2_kill_fragtree(); so much so
    * that userspace processes (like gdm and X) are starved
    @@ -73,24 +83,7 @@ static void jffs2_garbage_collect_thread_func(void *_c)
    * inode in with read_inode() is much preferable to having
    * the GC thread get there first.
    */
    - schedule_timeout_interruptible(msecs_to_jiffies(50));
    -
    - if (kthread_should_stop()) {
    - jffs2_dbg(1, "%s(): kthread_stop() called\n", __func__);
    - return;
    - }
    -
    - try_to_freeze();
    -
    - /* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */
    - sigprocmask(SIG_BLOCK, &hupmask, NULL);
    -
    - jffs2_dbg(1, "%s(): pass\n", __func__);
    - if (jffs2_garbage_collect_pass(c) == -ENOSPC) {
    - pr_notice("No space for garbage collection. Aborting GC thread\n");
    - kthread_stop_current();
    - }
    - sigprocmask(SIG_UNBLOCK, &hupmask, NULL);
    + set_kthread_iterant_int_sleep_timeout(msecs_to_jiffies(50));
    }

    static void jffs2_garbage_collect_thread_destroy(void *_c)
    --
    1.8.5.6


    \
     
     \ /
      Last update: 2015-06-05 17:21    [W:2.827 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site