Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp885996pxx; Tue, 27 Oct 2020 03:03:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRoXi8hY3ZJgI+YTIM4EPGKMoLiUIanYfN4d6PQE8L63/iSco3eWEIUoV9zZV9vAmAc79x X-Received: by 2002:a50:99cd:: with SMTP id n13mr1391021edb.10.1603793002551; Tue, 27 Oct 2020 03:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603793002; cv=none; d=google.com; s=arc-20160816; b=ik5Sxq4DZLMLW8jHj9UICY4YfA6IOKHsayq57+1m3eKUSMj2Wc60WYA2AG8scC+ifE kUgtC2h0DRETI8QHsRbJKV6UCa4QAPftpx6XYVZjnevMEHhtHM7G1WHScLM+acpMelb+ L9emfcOj34fT3Lrh2KE/Zz2W6iEpl3m1wtqSTtR6MS6q3GWHj3rjnTnKIF04/Z7REycA 1sfY72tqb7hbCsIchv/W36nigGk64lswaQ1Zu0nn1NprK3pK827mUvZrI6m7INfQJtqI cSwDJrDmsoVdwcsD3PTpGG+IIWQ53tcse0n+9Ir53nRpRCDtdiXz0i6Xgzm0ccDWCKXx TfmQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jCtnVZzqm0t/ygZzIgFoxT4ub4Pml6s1LNOj3W2ULuQ=; b=xJT7TitrdIG+a9ZnxYwDc4pmUnJGYQVRKMqr0K53CqizAEZQ29AUYhInwcubi1Ahei OOCow4lHgarZZAseQSlR2Zo0x8fgwrSQSPqL6gTsIGPE/WWMCCRnZbwtmX/hWPAl/XF/ abWID8vEUQzC0DsQFPSBYfAgCtNLUafHsYW8KOjtksq7sELp+zQNFLq0sZbhk5Obp4X4 Vah65mV3IL3sZFN2RQox6jvr/15JNom6512Q4chn1iB3tYpVgexq9nRnGygyMe+cRWiv EhTHO+DLPeUztEyRU/y4HKvVexyPK2ERrP5SYLwlidi49KE6rcD6Ok2AU2kHeaIGtndk /lLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cvexm3YB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si618517ejt.206.2020.10.27.03.03.00; Tue, 27 Oct 2020 03:03:22 -0700 (PDT) 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=cvexm3YB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2411162AbgJZX7o (ORCPT + 99 others); Mon, 26 Oct 2020 19:59:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:37240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436621AbgJZX4v (ORCPT ); Mon, 26 Oct 2020 19:56:51 -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 7FCA520882; Mon, 26 Oct 2020 23:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756611; bh=cGWIoh6h6aOYlfAIP7Hm21DZreYR0Se6xpETKsgYV8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvexm3YBGmxPaCliIvS4g18uCwtzLrkgfUxyJF5SSEFev4tfd9oCJoHdRRv30QriH fjkQqs+Sa5UvUp8ka7ibKrJ++3b9gagdJR6z3EW8/MKTJcIN0nRsOLQYQWUNSFzZh+ 9mqzT0fjU3N+W2JUqf7EfJEXhf0YHYhqJ/haVjsg= 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 5.4 78/80] nbd: make the config put is called before the notifying the waiter Date: Mon, 26 Oct 2020 19:55:14 -0400 Message-Id: <20201026235516.1025100-78-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-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-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.25.1