From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fg-out-1718.google.com ([72.14.220.159]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NYLYM-0001mW-K6 for linux-mtd@lists.infradead.org; Fri, 22 Jan 2010 15:36:11 +0000 Received: by fg-out-1718.google.com with SMTP id 16so531158fgg.0 for ; Fri, 22 Jan 2010 07:36:05 -0800 (PST) Subject: [PATCH 4/4] MTD: make mtdtrans thread freezeable. From: Maxim Levitsky To: David Woodhouse In-Reply-To: <1264174316.24012.17.camel@maxim-laptop> References: <1264174316.24012.17.camel@maxim-laptop> Content-Type: text/plain; charset="UTF-8" Date: Fri, 22 Jan 2010 17:36:00 +0200 Message-ID: <1264174560.24012.22.camel@maxim-laptop> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Cc: Thomas Gleixner , joern , linux-mtd , linux-kernel , Alex Dubov List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , >>From 0904b692e95b22564a570e03956e89911a5e56b3 Mon Sep 17 00:00:00 2001 From: Maxim Levitsky Date: Fri, 22 Jan 2010 15:00:55 +0200 Subject: [PATCH 4/4] MTD: make mtdtrans thread freezeable. This makes the mtd blktrans thread enter the freezer in between accesses to nand device. This will ensure that we aren't suspening the system in the middle of page read/write and even worse erase, which is a bad idea. Signed-off-by: Maxim Levitsky --- drivers/mtd/mtd_blkdevs.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 04a875f..db996d6 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "mtdcore.h" @@ -79,36 +80,35 @@ static int mtd_blktrans_thread(void *arg) struct request_queue *rq = dev->rq; struct request *req = NULL; - spin_lock_irq(rq->queue_lock); + set_freezable(); while (!kthread_should_stop()) { int res; + try_to_freeze(); + + spin_lock_irq(rq->queue_lock); if (!req && !(req = blk_fetch_request(rq))) { set_current_state(TASK_INTERRUPTIBLE); spin_unlock_irq(rq->queue_lock); schedule(); - spin_lock_irq(rq->queue_lock); continue; } - spin_unlock_irq(rq->queue_lock); + mutex_lock(&dev->lock); res = do_blktrans_request(dev->tr, dev, req); mutex_unlock(&dev->lock); spin_lock_irq(rq->queue_lock); - if (!__blk_end_request_cur(req, res)) req = NULL; + spin_unlock_irq(rq->queue_lock); } if (req) __blk_end_request_all(req, -EIO); - - spin_unlock_irq(rq->queue_lock); - return 0; } -- 1.6.3.3