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

Stephen Zhang starzhangzsd at gmail.com
Sun Nov 30 18:41:06 PST 2025


Sagi Grimberg <sagi at grimberg.me> 于2025年12月1日周一 07:03写道:
>
> Acked-by: Sagi Grimberg <sagi at grimberg.me>

Hello,

I already dropped this patch in v3:
https://lore.kernel.org/all/20251129090122.2457896-1-zhangshida@kylinos.cn/
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



More information about the Linux-nvme mailing list