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=unavailable 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 9C17FC31E45 for ; Thu, 13 Jun 2019 16:17:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70F6F20665 for ; Thu, 13 Jun 2019 16:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560442667; bh=K58WltlMNhs1+FZaQsfXOufacxo/p5eUMRzFey6WUos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FcnLeXlyW+JrrkafMA/PNJujDF1ROlt4nh6FT/JRyvhIdqcAdyEURcKRIiRrVGCeK 1jbrnb1co2E495Y94Diucgk/zd1yATGDuVEU7ZoYA4ugecPT1Q2d4RasoxKcEY+y1A WNUEqAwbBEQrPbNS86Olj2SqCQvf53P7yoSvi7jw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403841AbfFMQRq (ORCPT ); Thu, 13 Jun 2019 12:17:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:58122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731129AbfFMIkp (ORCPT ); Thu, 13 Jun 2019 04:40:45 -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 1D51B21473; Thu, 13 Jun 2019 08:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560415244; bh=K58WltlMNhs1+FZaQsfXOufacxo/p5eUMRzFey6WUos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CWSr9YyvsDXmprJCIOY4n0AzFRhmECkDZ7PNFkFxYwwkYrWpcqymeH5XhH4CiLo2B 1+Zo25oBbL0+2q+udaNIRBJwF1w5kkZ6McLJhLqGwir1GlL/mJZ2w9TpRpevrA+o5R BwMjOueVnkEGerle86psnttkYamY23Hhsw8AjMoA= 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 4.19 055/118] blk-mq: move cancel of requeue_work into blk_mq_release Date: Thu, 13 Jun 2019 10:33:13 +0200 Message-Id: <20190613075646.936104246@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075643.642092651@linuxfoundation.org> References: <20190613075643.642092651@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 33488b1426b7..6eed5d84c2ef 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -411,7 +411,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); } else { diff --git a/block/blk-mq.c b/block/blk-mq.c index 4e563ee462cb..70d839b9c3b0 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2465,6 +2465,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