Re: [PATCH v2 12/12] nvmet: use bio_chain_and_submit to simplify bio chaining

From: Stephen Zhang

Date: Sun Nov 30 2025 - 21:41:44 EST


Sagi Grimberg <sagi@xxxxxxxxxxx> 于2025年12月1日周一 07:03写道:
>
> Acked-by: Sagi Grimberg <sagi@xxxxxxxxxxx>

Hello,

I already dropped this patch in v3:
https://lore.kernel.org/all/20251129090122.2457896-1-zhangshida@xxxxxxxxxx/
The reason is that the order of operations is critical. In the original code::
----------------
...
bio->bi_end_io = nvmet_bio_done;

for_each_sg(req->sg, sg, req->sg_cnt, i) {
...
struct bio *prev = bio;
....
bio_chain(bio, prev);
submit_bio(prev);
}
----------------

the oldest bio (i.e., prev) retains the real bi_end_io function:

bio -> bio -> ... -> prev
However, using bio_chain_and_submit(prev, bio) would create the reverse chain:

prev -> prev -> ... -> bio

where the newest bio would hold the real bi_end_io function, which does not
match the required behavior in this context.

Thanks,
Shida