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=-12.8 required=3.0 tests=BAYES_00,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 3F6CCC388F7 for ; Tue, 3 Nov 2020 21:05:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0AD5120757 for ; Tue, 3 Nov 2020 21:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437523; bh=jrRtNSCNVrksncJAZyQSt7kVNwPnXNwSAdxIsmN4yJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ask+clIsXokCzJuTm72Wb8iA/OO2JnZ47GUoMkYRLYB+OatSPioP57z6rZyk8vHWg tpc/6CFNFaH+0lx6m4qQ+QK9EWgfvj+DJRYfDGy2EnKsEt2V14W3gBu7AtMJR8rqZD L6HAbyjL05UJIfaedB5yPY4nUguvCE8VsJ3EvEz8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387798AbgKCVFV (ORCPT ); Tue, 3 Nov 2020 16:05:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:43684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387743AbgKCVFO (ORCPT ); Tue, 3 Nov 2020 16:05:14 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 06FB7205ED; Tue, 3 Nov 2020 21:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437514; bh=jrRtNSCNVrksncJAZyQSt7kVNwPnXNwSAdxIsmN4yJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cLdcu9zgw2MCpRl1iAm19rkam9hMgAIIuZRTb9F9GeKPfj1snTWBn9JTMRXyv62WD X4YuGlAYyCzwDbDv0fzS7qqHXX6dYgt0HjC6lc7dmBA7NAs2tFnqGueKKzlIBuEjam OiVHox6aEQdLg1KZKK5Buho28C2n8D/dxpVKh2Ik= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiubo Li , Josef Bacik , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 109/191] nbd: make the config put is called before the notifying the waiter Date: Tue, 3 Nov 2020 21:36:41 +0100 Message-Id: <20201103203243.735216554@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiubo Li [ Upstream commit 87aac3a80af5cbad93e63250e8a1e19095ba0d30 ] There has one race case for ceph's rbd-nbd tool. When do mapping it may fail with EBUSY from ioctl(nbd, NBD_DO_IT), but actually the nbd device has already unmaped. It dues to if just after the wake_up(), the recv_work() is scheduled out and defers calling the nbd_config_put(), though the map process has exited the "nbd->recv_task" is not cleared. Signed-off-by: Xiubo Li Reviewed-by: Josef Bacik Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index d7c7232e438c9..52e1e71e81241 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -740,9 +740,9 @@ static void recv_work(struct work_struct *work) blk_mq_complete_request(blk_mq_rq_from_pdu(cmd)); } + nbd_config_put(nbd); atomic_dec(&config->recv_threads); wake_up(&config->recv_wq); - nbd_config_put(nbd); kfree(args); } -- 2.27.0