From patchwork Thu Feb 4 23:30:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 44571 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 DEE1BB7D66 for ; Fri, 5 Feb 2010 10:34:54 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NdBAb-0007CP-TW; Thu, 04 Feb 2010 23:31:33 +0000 Received: from mail-fx0-f228.google.com ([209.85.220.228]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NdBAU-00071Q-OU for linux-mtd@lists.infradead.org; Thu, 04 Feb 2010 23:31:32 +0000 Received: by mail-fx0-f228.google.com with SMTP id 28so3537500fxm.20 for ; Thu, 04 Feb 2010 15:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=esLAyjVWle+Cg1e4kf4clC5qaE0wr6oFabI8XhC50+E=; b=w/C8lURgqp9zxsngI8kjWbzQLZ+xjUz1/ACp0B693Gwhb0zYtoLIGffl8rAgNmAGIE 2xYBi9XLWrayxDqhOB0PW2KjI6oqbmUXpT7AOWAiKhCQ/zQRZElsT7w6Mdp8G8Wzo8+8 /HcuwLpw/jdJ2a7DRIeqzYmzLuOcSq2pCI5aI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=fFMSY9XdkW1NN41pE2td7pI9Uk5QEMDwRNQNUxCQTWMoIGUUhhm5zjgUl6ItyaMTj4 bWHWhkR12RTcgR9vgR7y2ajp/zVjG9znMaDNTPVmpaQKUpcEcrjnabZPIdoMwHhVWmUJ uubYP+gBuAZXgQp/LV6wcNXSwE8jEaB0xKyhg= Received: by 10.102.174.11 with SMTP id w11mr1248711mue.17.1265326285332; Thu, 04 Feb 2010 15:31:25 -0800 (PST) Received: from localhost.localdomain (IGLD-84-229-248-49.inter.net.il [84.229.248.49]) by mx.google.com with ESMTPS id u9sm3865749muf.18.2010.02.04.15.31.23 (version=SSLv3 cipher=RC4-MD5); Thu, 04 Feb 2010 15:31:24 -0800 (PST) From: Maxim Levitsky To: David Woodhouse Subject: [PATCH 06/17] blktrans: flush all requests before we remove the device Date: Fri, 5 Feb 2010 01:30:46 +0200 Message-Id: <1265326257-4446-7-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1265326257-4446-1-git-send-email-maximlevitsky@gmail.com> References: <1265326257-4446-1-git-send-email-maximlevitsky@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100204_183126_906894_2A541E67 X-CRM114-Status: GOOD ( 17.70 ) 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: Maxim Levitsky , Alex Dubov , Artem Bityutskiy , joern , linux-kernel , linux-mtd , Thomas Gleixner 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 Flush all requests, so we can be sure we don't deadlock the system later when we remove the disk queue. Signed-off-by: Maxim Levitsky --- drivers/mtd/mtd_blkdevs.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 082969c..9992b2d 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -115,7 +115,13 @@ static int mtd_blktrans_thread(void *arg) static void mtd_blktrans_request(struct request_queue *rq) { struct mtd_blktrans_dev *dev = rq->queuedata; - wake_up_process(dev->thread); + struct request *req = NULL; + + if (dev->deleted) + while ((req = blk_fetch_request(rq)) != NULL) + __blk_end_request_all(req, -ENODEV); + else + wake_up_process(dev->thread); } @@ -357,6 +363,8 @@ error1: int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old) { + unsigned long flags; + if (mutex_trylock(&mtd_table_mutex)) { mutex_unlock(&mtd_table_mutex); BUG(); @@ -367,7 +375,11 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old) /* stop new requests to arrive */ del_gendisk(old->disk); + /* flush current requests */ + spin_lock_irqsave(&old->queue_lock, flags); old->deleted = 1; + blk_start_queue(old->rq); + spin_unlock_irqrestore(&old->queue_lock, flags); /* Stop the thread */ kthread_stop(old->thread);