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=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 EBEBFC4363A for ; Tue, 27 Oct 2020 00:06:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B044B20791 for ; Tue, 27 Oct 2020 00:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603757206; bh=bSj/q4/hq/Q14gAQAwVMoVYEege+f8Xo6lkoyQgRVQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rbf7jJHp1I7HX193tSncw97onGOFqx9UJyvN1/QHHsMvmVWq0fuK4zg8LPiwdKxAl nAjtcdG38ahbdO1mFLk6nuDWIbYqzo1CIAbEXJLk8SztANsdatEPORgdqbP14uNMZl jCPx0TFCCfXDEQqUKkWR5j8EslUsjilSn1smCQcI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438806AbgJ0AGn (ORCPT ); Mon, 26 Oct 2020 20:06:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:54328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438266AbgJ0AFY (ORCPT ); Mon, 26 Oct 2020 20:05:24 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 72DD921707; Tue, 27 Oct 2020 00:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603757124; bh=bSj/q4/hq/Q14gAQAwVMoVYEege+f8Xo6lkoyQgRVQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CM32RrvbheAbpzYmdxsyEZDNx2abxsfbxwhQ5mN8z4bp0k7N17nIgqLYlhZBuUl8C 9/j6JTsPy9Ve2lFQH8hD5Cqa0XrY7/KDLyfkGgUk2KVxOVvmC/2QkRn7iR5kDjTZeH YbnPDWniu13svezSfO0z7WnVyRNeHgYlKAu03DP4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xiubo Li , Josef Bacik , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org, nbd@other.debian.org Subject: [PATCH AUTOSEL 4.19 58/60] nbd: make the config put is called before the notifying the waiter Date: Mon, 26 Oct 2020 20:04:13 -0400 Message-Id: <20201027000415.1026364-58-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201027000415.1026364-1-sashal@kernel.org> References: <20201027000415.1026364-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-block@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.25.1