Re: [PATCH v2] RDMA/srpt: Fix srpt_alloc_rw_ctxs() unwind counters

From: Bart Van Assche

Date: Fri Jul 17 2026 - 18:15:07 EST


On 7/16/26 7:00 PM, kensanya wrote:
I have a question about restoring n_rw_ctx/n_rdma from local
snapshots versus clearing them to 0 on the unwind path.

Looking at the call chain:
srpt_handle_new_iu()
-> srpt_get_send_ioctx() /* sets n_rdma = 0, n_rw_ctx = 0 */
-> srpt_get_desc_tbl()
-> srpt_alloc_rw_ctxs()

so when srpt_alloc_rw_ctxs() is entered, both counters are already
0. On the current call path, assigning 0 on unwind seems
equivalent to restoring the values saved at function entry.

Is the save/restore preferred because the loop starts from
ioctx->n_rw_ctx (i.e. the function is written as if it may extend
an existing allocation), or is there another reason to prefer it
over clearing to 0?

Your analysis seems correct to me. I misremembered how the code works
when I wrote the message you replied to. It was a while ago when I
implemented srpt_get_send_ioctx() - in 2010 according to the git
history of the original implementation
(https://github.com/SCST-project/scst).

Bart.