From patchwork Mon Feb 15 16:03:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 45396 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2352DB7CC1 for ; Tue, 16 Feb 2010 03:05:32 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Nh3Q4-0006Lm-FQ; Mon, 15 Feb 2010 16:03:32 +0000 Received: from gw1.transmode.se ([213.115.205.20]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1Nh3Ph-0006Kw-Lx for linux-mtd@lists.infradead.org; Mon, 15 Feb 2010 16:03:14 +0000 Received: from sesr04.transmode.se (sesr04.transmode.se [192.168.201.15]) by gw1.transmode.se (Postfix) with ESMTP id 76F47650002 for ; Mon, 15 Feb 2010 17:03:04 +0100 (CET) Received: from gentoo-jocke.transmode.se ([192.168.1.15]) by sesr04.transmode.se (Lotus Domino Release 8.5.1) with ESMTP id 2010021517030418-7425 ; Mon, 15 Feb 2010 17:03:04 +0100 Received: from gentoo-jocke.transmode.se (gentoo-jocke.transmode.se [127.0.0.1]) by gentoo-jocke.transmode.se (8.14.4/8.14.0) with ESMTP id o1FG34Kr028012; Mon, 15 Feb 2010 17:03:04 +0100 Received: (from jocke@localhost) by gentoo-jocke.transmode.se (8.14.4/8.14.4/Submit) id o1FG33S6028011; Mon, 15 Feb 2010 17:03:03 +0100 From: Joakim Tjernlund To: linux-mtd@lists.infradead.org Subject: [PATCH 1/2] jffs:2 Move erasing from write_super to GC. Date: Mon, 15 Feb 2010 17:03:00 +0100 Message-Id: <1266249781-27970-1-git-send-email-Joakim.Tjernlund@transmode.se> X-Mailer: git-send-email 1.6.4.4 X-MIMETrack: Itemize by SMTP Server on sesr04/Transmode(Release 8.5.1|September 28, 2009) at 2010-02-15 17:03:04, Serialize by Router on sesr04/Transmode(Release 8.5.1|September 28, 2009) at 2010-02-15 17:03:04, Serialize complete at 2010-02-15 17:03:04 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100215_110310_047786_84517BA0 X-CRM114-Status: GOOD ( 17.04 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ Cc: Joakim Tjernlund X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Erasing blocks is a form of GC and therefor it should live in the GC task. By moving it there two problems will be solved: 1) umounting will not hang until all pending blocks has been erased. 2) Erasing can be paused by sending a SIGSTOP to the GC thread which allowes for time critical tasks work in peace. Signed-off-by: Joakim Tjernlund --- fs/jffs2/background.c | 1 + fs/jffs2/erase.c | 5 +++++ fs/jffs2/nodemgmt.c | 4 ++++ fs/jffs2/super.c | 1 - 4 files changed, 10 insertions(+), 1 deletions(-) diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c index 3ff50da..a8e0140 100644 --- a/fs/jffs2/background.c +++ b/fs/jffs2/background.c @@ -146,6 +146,7 @@ static int jffs2_garbage_collect_thread(void *_c) disallow_signal(SIGHUP); D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): pass\n")); + jffs2_erase_pending_blocks(c, 0); if (jffs2_garbage_collect_pass(c) == -ENOSPC) { printk(KERN_NOTICE "No space for garbage collection. Aborting GC thread\n"); goto die; diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index b47679b..1ca2559 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c @@ -114,6 +114,11 @@ void jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) while (!list_empty(&c->erase_complete_list) || !list_empty(&c->erase_pending_list)) { + if (signal_pending(current)) { + spin_unlock(&c->erase_completion_lock); + mutex_unlock(&c->erase_free_sem); + goto done; + } if (!list_empty(&c->erase_complete_list)) { jeb = list_entry(c->erase_complete_list.next, struct jffs2_eraseblock, list); list_move(&jeb->list, &c->erase_checking_list); diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index 21a0529..155fd63 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c @@ -733,6 +733,10 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c) int nr_very_dirty = 0; struct jffs2_eraseblock *jeb; + if (!list_empty(&c->erase_complete_list) || + !list_empty(&c->erase_pending_list)) + return 1; + if (c->unchecked_size) { D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): unchecked_size %d, checked_ino #%d\n", c->unchecked_size, c->checked_ino)); diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 9a80e8e..5162329 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c @@ -64,7 +64,6 @@ static void jffs2_write_super(struct super_block *sb) if (!(sb->s_flags & MS_RDONLY)) { D1(printk(KERN_DEBUG "jffs2_write_super()\n")); jffs2_garbage_collect_trigger(c); - jffs2_erase_pending_blocks(c, 0); jffs2_flush_wbuf_gc(c, 0); }