From nobody Fri Jun 12 11:37:16 2026 Received: from va-2-27.ptr.blmpb.com (va-2-27.ptr.blmpb.com [209.127.231.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 741D83A875C for ; Fri, 15 May 2026 09:30:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.231.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778837441; cv=none; b=YWpJ03hCUVyOkBVdoxGnVMHU4U2mMs7Z8WDSIh6XqGXi8wvqokGuAVENZuc5NoUnxPMJnLrmx668/9EcmoUQDr5g1w4OEaw7pRf0zGmYL86OR+2PjOLP8LFKDQpSvyJhjpfFvucXv8n1d1dyd1zW73wfkiSIwkHLFSYkBIeU6dA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778837441; c=relaxed/simple; bh=2opvUb4OtaoiL4k3wiPurNwrs5IfTPEgV53KDxFBQdw=; h=Content-Type:Mime-Version:Subject:Message-Id:From:Cc:Date:To; b=CZAV78KeGQYb6oToPVZ8ZjwNiQsQWmLNPxEAhXeQ5k4g8+ufSZlQ+7ccmpqlzpixkqa1T2iMANmPdsH1OcjIlOlC9Ku2WYUw8u/xDAaKGYfud8St3hfv9LrL2RLtLlMeHP3/ZYzM7+CziurmrFyUos/jFDLhFOGrzVTkwX+WNcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fnnas.com; spf=pass smtp.mailfrom=fnnas.com; dkim=pass (2048-bit key) header.d=fnnas-com.20200927.dkim.feishu.cn header.i=@fnnas-com.20200927.dkim.feishu.cn header.b=wsWrF9qF; arc=none smtp.client-ip=209.127.231.27 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fnnas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fnnas.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fnnas-com.20200927.dkim.feishu.cn header.i=@fnnas-com.20200927.dkim.feishu.cn header.b="wsWrF9qF" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=s1; d=fnnas-com.20200927.dkim.feishu.cn; t=1778837434; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=ANACnnkkHh07fsvxobSrkre4lrT57jSbJan6Hvii+tg=; b=wsWrF9qFSwFwCZW+y/4ORwNc78D1jzrN/ZrFy1fQfGGMEEutv6z9w0JaguO1GOog2h1zLe +a3pH2JpWS0FyUGMnHPFWP6V9oYim6MmeHil1dS5aqa0rSu1lMa7pGI7fZQmHBQJW0oaRq rh5bBaIilq0CiKUqVgPSZGJoWw8cb11uXb06OBII6c1SJCjapx7IfyjUhzLwrSSKxtwigr oyto43shXgwfP+XqA8vxJhf6moaoWYZ3poDNYm9T29G2fXqcLb/K7RcnGjZK28dqX59OZQ X5Gt27Cr/0q5EMu6j+f5aJ70NOGz2fP0vRhQ3kCrEeUWWaYqYmWlzoJ2WjZGYQ== X-Original-From: chencheng@fnnas.com Received: from localhost.localdomain ([113.111.244.134]) by smtp.feishu.cn with ESMTPS; Fri, 15 May 2026 17:30:32 +0800 X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Subject: [PATCH] raid10_handle_discard() reuses r10bio objects from r10bio_pool. Message-Id: <20260515093019.3436882-1-chencheng@fnnas.com> Content-Transfer-Encoding: quoted-printable From: "Chen Cheng" X-Lms-Return-Path: Cc: "Chen Cheng" , , Date: Fri, 15 May 2026 17:30:19 +0800 To: "Yu Kuai" Content-Type: text/plain; charset="utf-8" From: Chen Cheng put_all_bios() always drops devs[i].bio, but it only drops devs[i].repl_bio when r10_bio->read_slot < 0. If discard reuses an r10bio that was previously used for a read, read_slot can still be non-negative, and discard cleanup can skip bio_put() on repl_bio. Reset read_slot to -1 when preparing an r10bio for discard so the replacement bio is always released correctly. Signed-off-by: Chen Cheng Reviewed-by: Xiao Ni --- drivers/md/raid10.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 39085e7dd6d2..7dc2a5a127e8 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1727,6 +1727,7 @@ static int raid10_handle_discard(struct mddev *mddev,= struct bio *bio) r10_bio->mddev =3D mddev; r10_bio->state =3D 0; r10_bio->sectors =3D 0; + r10_bio->read_slot =3D -1; memset(r10_bio->devs, 0, sizeof(r10_bio->devs[0]) * geo->raid_disks); wait_blocked_dev(mddev, r10_bio); =20 --=20 2.54.0