From nobody Tue Feb 10 08:27:39 2026 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 2616F2E8DE5 for ; Fri, 28 Nov 2025 08:32:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764318765; cv=none; b=YkoTMhqFyhT1fKcQYSbdt3XCpOx64Aj2on/lX7AGs/0Z3y+rPfdzns1jAolyJ+CusyfT9BC22ByczwnPyGbuiAuGVyQwkAVO/625Psr7CIJbxt+TgfeEqC/riAmY6SlbLwRcSEoG3UjkEL3pMoq2HLvJY9wluZT4v+Gl2ze3Q+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764318765; c=relaxed/simple; bh=nbYby2EM9de8liKCH6EPXwLAr+CXSG8jGQgCdHY1huE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n4rwibzc1cwO66wQiWoFspK68W2NsyQz/h/OMBzU5PjK4Mkfyzuik8CrKzYHmNxziIS7YDJe7f381+gAReT8pFRRkdAepeWS0mtMdP+DABbqMz+kxb+l9K3f57V1yMmfhuLTZhND+0lBv3w8Lk8NiMW7KFE+Lkkj/LkJKD1k324= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g0pYmYtI; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g0pYmYtI" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-7b852bb31d9so1825602b3a.0 for ; Fri, 28 Nov 2025 00:32:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764318763; x=1764923563; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wEXNzDk3PZG7Vl6bACrm82r4Ym6fDNxq87feOMpROvE=; b=g0pYmYtIS/P7dMpQ1erDvN2bSLVnJDU7lfPJm1A2SlMQjNBQa0vNrfvHR4fXZBhpk5 UHRMokyQSBTl0qaE3JcHHjjzO+j3PO6PZZw68b0dN4GXFSq6V9WKk82w6wWAT9R7RgJx Wh6GPPHmo2ZwNIyqiALQCK1pVIyYtvwQYG0de7CQmuQue6EWrwpTb1wqyydFo4rXcxLq Pr+zD9mGo2fPUSWhfV6YRfBEl2sspB1q7r70DKpOYneMHO9D1RsfGG9+nwBfqvatPs3q zb60/K0hz8NR7KTGUotMJkf8DtF0VssVC3nk19wz4i81NPAA1iiacVVw9QpzvP+yDqmA Dkew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764318763; x=1764923563; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wEXNzDk3PZG7Vl6bACrm82r4Ym6fDNxq87feOMpROvE=; b=oFU/nZ1YlUQPCLK3AJsKyfs2RT5I8bwbCHBZF9xiM4bwkLDiK19cYeNqyExZB347+9 3mx+rRZn3fveADCkFSQbagDrwA3rzB4RYyqVyGJoToL0QBG3ReVi4ZyahXl/4HpJQcfn mi1ipsNg6VsE0LGM0/QeoRI5dNiXCBlg890wFz1Zj7TNHi+4OuvJ/vj51upUfT2W655X FbppGEks84xDq7H+B8fKLhCxwcQMPuy0oCJR1dyRMhx9ZvJZW4wSqWdBXHU5qC7nJSUp yFU6/r/d09mcuKz0IEZKiQW/m0qqIBFzZqq5kIxlqYZWpp741FLERBvjLElVDY8pn8u+ urQQ== X-Forwarded-Encrypted: i=1; AJvYcCWQriWMa04kuReGWQMdUU+zjPGVnqxIEBTvK0Hyu1qWhVyc4AlPwmK9hT0apwM56LawcpqDo9J5dharA1o=@vger.kernel.org X-Gm-Message-State: AOJu0YwJCJWVBXV7GCFWYCLvPi5yUp4sibo2D9Bgu5C8wBGOfAG+RzTX nwLgFjd2p0GKhfbLTVIPCvpTKo1rtml0Y48Q4rGAWr6t8vcqrZzW70nq X-Gm-Gg: ASbGncv5vhCyqFtlNQD9jNafsRzKtB6Y+tEwZJIB+IK3R9eNbosfy5JVPpVz9zEDFgp F6lsG5iU2c8HyFEECZPBVWMBjO72YUuKaudpk0U8E2Qf0SYsm23QUWwPhhVh6wZLC0ckNhIjuUT ty7XjlEeXqXeaByPUlGvnWODJonq0KBLH4mLt+bDV5zFm8d7VRaHVHpatkHUzeoQ8wIQP8iOoXi eqD9G0DleqlDmLgTp+EuQwMxhl5zZSaLJ4FO+EA84iO7t01LGX4xP27lKmylNLlmslhWmOBPv0G NrRfcRZ4LJ9jLnCc5EyDIess1Bn/6vKBM0Ptg9flxLjgFWcfvvyjXYgfKb0cLNYEGh+YdoIeVUu DWoKTwnrauq/o4wA4HJg3wqdqt4ovmPCj3T4BHQhcmu0i9blJ4DYNe49HLBAUUdfz9vVBwn1Neg wJNMrD8DKZ3fHjlcTesJzkE31WbA== X-Google-Smtp-Source: AGHT+IF16ld9QNCqaVETJUBsXYjs2kY4Pw4mcEH3R6jDofKcar8TG/UX/uqF2Rs9fZ+s8kH1ElEzpw== X-Received: by 2002:a05:7022:7f1c:b0:119:e569:f615 with SMTP id a92af1059eb24-11c9d712704mr11436137c88.14.1764318762983; Fri, 28 Nov 2025 00:32:42 -0800 (PST) Received: from localhost.localdomain ([104.128.72.44]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11dcaed5f6bsm20941371c88.1.2025.11.28.00.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 00:32:42 -0800 (PST) From: zhangshida X-Google-Original-From: zhangshida To: Johannes.Thumshirn@wdc.com, hch@infradead.org, gruenba@redhat.com, ming.lei@redhat.com, siangkao@linux.alibaba.com Cc: linux-block@vger.kernel.org, linux-bcache@vger.kernel.org, nvdimm@lists.linux.dev, virtualization@lists.linux.dev, linux-nvme@lists.infradead.org, gfs2@lists.linux.dev, ntfs3@lists.linux.dev, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com Subject: [PATCH v2 01/12] block: fix incorrect logic in bio_chain_endio Date: Fri, 28 Nov 2025 16:32:08 +0800 Message-Id: <20251128083219.2332407-2-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251128083219.2332407-1-zhangshida@kylinos.cn> References: <20251128083219.2332407-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shida Zhang The `__bio_chain_endio` function, which was intended to serve only as a flag, contains faulty completion logic. When called, it decrements the `bi_remaining` count on the *next* bio in the chain without checking its own. Consider a bio chain where `bi_remaining` is decremented as each bio in the chain completes. For example, if a chain consists of three bios (bio1 -> bio2 -> bio3) with bi_remaining count: 1->2->2 if the bio completes in the reverse order, there will be a problem. if bio 3 completes first, it will become: 1->2->1 then bio 2 completes: 1->1->0 Because `bi_remaining` has reached zero, the final `end_io` callback for the entire chain is triggered, even though not all bios in the chain have actually finished processing. As a quick fix, removing `__bio_chain_endio` and allowing the standard `bio_endio` to handle the completion logic should resolve this issue, as `bio_endio` correctly manages the `bi_remaining` counter. Signed-off-by: Shida Zhang --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index b3a79285c27..55c2c1a0020 100644 --- a/block/bio.c +++ b/block/bio.c @@ -322,7 +322,7 @@ static struct bio *__bio_chain_endio(struct bio *bio) =20 static void bio_chain_endio(struct bio *bio) { - bio_endio(__bio_chain_endio(bio)); + bio_endio(bio); } =20 /** --=20 2.34.1