From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B004C31E45 for ; Thu, 13 Jun 2019 16:01:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33B9620679 for ; Thu, 13 Jun 2019 16:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560441707; bh=E5UbYvVCXRmNxOfHlKZINw1XeuPFmN2QSPmi70zTzmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rR0WW7dKAo1h/xDTJM22ZEy/6DM8SH0n2EFxJKgb4+DmRSBJPJ6dKBa9ZEjO+V/WT 1ZKe+XvAto4w5ZyS0lX2klMC2yIjP1xT/EV4LlejFIN04B5k9dap++SkTuekuld0z9 zDrUzMugPavjZqr8yrLMW6cs5J0a7lH/Mc2n0LC8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390829AbfFMQBl (ORCPT ); Thu, 13 Jun 2019 12:01:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:36280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731421AbfFMIsU (ORCPT ); Thu, 13 Jun 2019 04:48:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9E027206BA; Thu, 13 Jun 2019 08:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560415700; bh=E5UbYvVCXRmNxOfHlKZINw1XeuPFmN2QSPmi70zTzmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=toP3uT9MGiNwnGprHTwFBW5ZS0HC9svQG7e3TfAAHH4D8nhnGvSHIxWmoGuKk0rZd WVsWJnEUuIGtTlZll3LhX0TGy4Ie3BzfQEh4I4t0z7MQ+LrsqlwUsQ6Eol/NZVtYvh DlkuTY15mb+CdsBDkjS+hdJNp4rQvIPKjUBZGGBM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dongli Zhang , James Smart , Bart Van Assche , Bart Van Assche , Johannes Thumshirn , Hannes Reinecke , Christoph Hellwig , Ming Lei , Jens Axboe , Sasha Levin , linux-scsi@vger.kernel.org, "Martin K . Petersen" , "James E . J . Bottomley" Subject: [PATCH 5.1 070/155] blk-mq: move cancel of requeue_work into blk_mq_release Date: Thu, 13 Jun 2019 10:33:02 +0200 Message-Id: <20190613075656.897201625@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075652.691765927@linuxfoundation.org> References: <20190613075652.691765927@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit fbc2a15e3433058582e5635aabe48a3011a644a8 ] With holding queue's kobject refcount, it is safe for driver to schedule requeue. However, blk_mq_kick_requeue_list() may be called after blk_sync_queue() is done because of concurrent requeue activities, then requeue work may not be completed when freeing queue, and kernel oops is triggered. So moving the cancel of requeue_work into blk_mq_release() for avoiding race between requeue and freeing queue. Cc: Dongli Zhang Cc: James Smart Cc: Bart Van Assche Cc: linux-scsi@vger.kernel.org, Cc: Martin K . Petersen , Cc: Christoph Hellwig , Cc: James E . J . Bottomley , Reviewed-by: Bart Van Assche Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Tested-by: James Smart Signed-off-by: Ming Lei Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-core.c | 1 - block/blk-mq.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index b375cfea024c..2dd94b3e9ece 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -237,7 +237,6 @@ void blk_sync_queue(struct request_queue *q) struct blk_mq_hw_ctx *hctx; int i; - cancel_delayed_work_sync(&q->requeue_work); queue_for_each_hw_ctx(q, hctx, i) cancel_delayed_work_sync(&hctx->run_work); } diff --git a/block/blk-mq.c b/block/blk-mq.c index 8a41cc5974fe..11efca3534ad 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2666,6 +2666,8 @@ void blk_mq_release(struct request_queue *q) struct blk_mq_hw_ctx *hctx; unsigned int i; + cancel_delayed_work_sync(&q->requeue_work); + /* hctx kobj stays in hctx */ queue_for_each_hw_ctx(q, hctx, i) { if (!hctx) -- 2.20.1