Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754727Ab0ALTcm (ORCPT ); Tue, 12 Jan 2010 14:32:42 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754414Ab0ALTcl (ORCPT ); Tue, 12 Jan 2010 14:32:41 -0500 Received: from fg-out-1718.google.com ([72.14.220.158]:48030 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753686Ab0ALTck (ORCPT ); Tue, 12 Jan 2010 14:32:40 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=WaXaiGG+l0N55KchTP7FvF7Jz4pqI/Xm2hN4Xmh+LYQ2yZivaun4H6zdcZBf9HJc2D 5UtFhK5G7LEmu/Jpsu9Augdyg4zK8yvBcavGJYn2pemNTN9hHFTL/TSD3VhLL9zUQ/u4 UiN8rbfAdi7MKBcugvK8MbynF6UR2I9Sw6KY0= Subject: [PATCH 4/9] MTD: make mtdtrans thread freezeable. From: Maxim Levitsky To: linux-kernel Cc: linux-mtd , joern , Alex Dubov In-Reply-To: <1263324518.6236.18.camel@maxim-laptop> References: <1263324518.6236.18.camel@maxim-laptop> Content-Type: text/plain; charset="UTF-8" Date: Tue, 12 Jan 2010 21:32:35 +0200 Message-ID: <1263324755.6236.22.camel@maxim-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2070 Lines: 80 >From c50bb924c12c742e53d66837ad8be48d93fc5fbe Mon Sep 17 00:00:00 2001 From: Maxim Levitsky Date: Tue, 12 Jan 2010 20:59:27 +0200 Subject: [PATCH 4/9] 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/