Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ublk: restore auto buf unregister refcount optimization

Commit 1ceeedb59749 ("ublk: optimize UBLK_IO_UNREGISTER_IO_BUF on daemon
task") optimized ublk request buffer unregistration to use a non-atomic
reference count decrement when performed on the ublk_io's daemon task.
The optimization applied to auto buffer unregistration, which happens as
part of handling UBLK_IO_COMMIT_AND_FETCH_REQ on the daemon task.
However, commit b749965edda8 ("ublk: remove ublk_commit_and_fetch()")
reordered the ublk_sub_req_ref() for the completed request before the
io_buffer_unregister_bvec() call. As a result, task_registered_buffers
is already 0 when io_buffer_unregister_bvec() calls ublk_io_release()
and the non-atomic refcount optimization doesn't apply.
Move the io_buffer_unregister_bvec() call back to before
ublk_need_complete_req() to restore the reference counting optimization.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Fixes: b749965edda8 ("ublk: remove ublk_commit_and_fetch()")
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Caleb Sander Mateos and committed by
Jens Axboe
ad5f2e29 2719bd1e

+2 -2
+2 -2
drivers/block/ublk_drv.c
··· 3334 3334 io->res = result; 3335 3335 req = ublk_fill_io_cmd(io, cmd); 3336 3336 ret = ublk_config_io_buf(ub, io, cmd, addr, &buf_idx); 3337 + if (buf_idx != UBLK_INVALID_BUF_IDX) 3338 + io_buffer_unregister_bvec(cmd, buf_idx, issue_flags); 3337 3339 compl = ublk_need_complete_req(ub, io); 3338 3340 3339 3341 /* can't touch 'ublk_io' any more */ 3340 - if (buf_idx != UBLK_INVALID_BUF_IDX) 3341 - io_buffer_unregister_bvec(cmd, buf_idx, issue_flags); 3342 3342 if (req_op(req) == REQ_OP_ZONE_APPEND) 3343 3343 req->__sector = addr; 3344 3344 if (compl)