Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp828535pxb; Tue, 3 Nov 2020 13:43:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+73X/WjI5B/tt+Vbfbw0fDleLvZF7XGLeiOeIh2exayuHUmdA1enTE8rnuh4YQ5Vwf21E X-Received: by 2002:aa7:d7c1:: with SMTP id e1mr23804609eds.4.1604439811683; Tue, 03 Nov 2020 13:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439811; cv=none; d=google.com; s=arc-20160816; b=qeX4D11SoieP3Gy8w7om9AgV64X8z2aLpZ3k9ADsE58D24d84DxTiUQtSX+bMxYFvI BgoIE/CQTOszJZN+20IuBcFnFbU7IKMqAx847g4iGv08U+xg7aoLRg9j2or/oG+ARnXg NwBLFO3H9AjlnZg6nRv1jvoi0Rj6fV6PxWBK892WkBxjW9VAcqWjumIZmRIBzeTzdlvu 1Su4pSpViUNdhz6AHoNHXUa1Dkgz4NAvX8Y5B0WXlBsFLCiB1rMHhHM6K/7W3zdLy3d4 iKZsEAy9ZXow+qktkw2KeDg8q0E3vJ/cehta/8/mLXIiP/Bp/P1mJhUA0UgSyz4TkieK 5BCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ayr0ZoS/vM2egabouqp9s+gKl3Q9DFTAJKJvkytoVIU=; b=W4ZPdHyW2YQjkSqbGo+EyEhiC6fbNjxGPUVex5fZOcYR3aLH2Ios912flP1r5uhO30 clp7cYLEEfymX3BqDdQ+w8Kc0qf4W3YbmjsXroO04kVaGI3vPMGAmdgD5OuIR0DhH7WR dZ8APHN58oUcyTxbQaUvC5MgOI+XfWqG3xPRf/nmqpMD3/zqrVPyyM4eU8O26JEoACvI wO76WpbFy1OMdh8qrl0sFBCMf8Tay8I3WOcl8lACeiUkkWEl3/jFvNtj67pqOfkth4uI JvREyLQBCPluroyDrw7PZsAnmF0Yzr1gkD5ttXc19bbemnvmPGfA5adpvD1Yldt/+vOA pu+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BVzgPNjP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o11si16138793edz.483.2020.11.03.13.43.08; Tue, 03 Nov 2020 13:43:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BVzgPNjP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732694AbgKCU4T (ORCPT + 99 others); Tue, 3 Nov 2020 15:56:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:57820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732446AbgKCU4R (ORCPT ); Tue, 3 Nov 2020 15:56:17 -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 646DC2053B; Tue, 3 Nov 2020 20:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436976; bh=7mFk/CA0TIWoc/EhV77uWD+611/NhLjRBi2Jfe8I7qY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BVzgPNjPAhtA4dVwceN5ZGd2Ja9AVtDP44OSLs/NSCiVJS596ssvKC9RcoGWZWZ1J IRCXfUqNx8ONcWI4mrYFgCuMCf2Bd0tSoC3WWjXpQtUwGCPz4/eepfLTr3mBvf6pkZ NGiaMaPYlJng/O71/J0O5QqzLqgUqB/zy7gFkiv0= 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 5.4 093/214] nbd: make the config put is called before the notifying the waiter Date: Tue, 3 Nov 2020 21:35:41 +0100 Message-Id: <20201103203259.174472239@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@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 7c577cabb9c3b..742f8160b6e28 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -787,9 +787,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