Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756346Ab0AFVsN (ORCPT ); Wed, 6 Jan 2010 16:48:13 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756328Ab0AFVsM (ORCPT ); Wed, 6 Jan 2010 16:48:12 -0500 Received: from mail-fx0-f225.google.com ([209.85.220.225]:56428 "EHLO mail-fx0-f225.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755807Ab0AFVsK (ORCPT ); Wed, 6 Jan 2010 16:48:10 -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=sYPBoAi1OaceDTdqHsuceViE7qH/qGCqBq7ZwvUGPFXVZeOQZhpzZ/OjXZU/bnxyzQ +vTHtCw4+IV2/rxuvzUFiwTw21M80HJD3kXr3UcvEJuKs4U0eXgxOicoLz8JJT5cFBZj lyLDtau1ZEO156rJM+uwUOipp4sCe3Wc3mwRE= Subject: [PATCH 4/9] mtd-make mtdtrans thread suspend friendly From: Maxim Levitsky To: linux-kernel Cc: linux-mtd , Alex Dubov , joern In-Reply-To: <1262814216.14552.22.camel@maxim-laptop> References: <1262814216.14552.22.camel@maxim-laptop> Content-Type: text/plain; charset="UTF-8" Date: Wed, 06 Jan 2010 23:48:05 +0200 Message-ID: <1262814485.14552.27.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: 1892 Lines: 76 >From 23892d5e002d63b7980742fa5445443547fcf8cf Mon Sep 17 00:00:00 2001 From: Maxim Levitsky Date: Tue, 5 Jan 2010 23:25:19 +0200 Subject: [PATCH 4/9] mtd-make mtdtrans thread suspend friendly Signed-of-by: Maxim Levitsky --- drivers/mtd/mtd_blkdevs.c | 15 +++++++-------- 1 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 6af4673..7070d35 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,37 +80,35 @@ static int mtd_blktrans_thread(void *arg) /* we might get involved when memory gets low, so use PF_MEMALLOC */ current->flags |= PF_MEMALLOC; - - 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/