Commit 0aed2f16 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: simplify struct io_context refcounting

Don't hold a reference to ->refcount for each active reference, but
just one for all active references.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20211209063131.18537-3-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 8a2ba178
...@@ -180,10 +180,8 @@ static void put_io_context_active(struct io_context *ioc) ...@@ -180,10 +180,8 @@ static void put_io_context_active(struct io_context *ioc)
{ {
struct io_cq *icq; struct io_cq *icq;
if (!atomic_dec_and_test(&ioc->active_ref)) { if (!atomic_dec_and_test(&ioc->active_ref))
put_io_context(ioc);
return; return;
}
spin_lock_irq(&ioc->lock); spin_lock_irq(&ioc->lock);
hlist_for_each_entry(icq, &ioc->icq_list, ioc_node) { hlist_for_each_entry(icq, &ioc->icq_list, ioc_node) {
...@@ -335,7 +333,6 @@ int __copy_io(unsigned long clone_flags, struct task_struct *tsk) ...@@ -335,7 +333,6 @@ int __copy_io(unsigned long clone_flags, struct task_struct *tsk)
* Share io context with parent, if CLONE_IO is set * Share io context with parent, if CLONE_IO is set
*/ */
if (clone_flags & CLONE_IO) { if (clone_flags & CLONE_IO) {
atomic_long_inc(&ioc->refcount);
atomic_inc(&ioc->active_ref); atomic_inc(&ioc->active_ref);
tsk->io_context = ioc; tsk->io_context = ioc;
} else if (ioprio_valid(ioc->ioprio)) { } else if (ioprio_valid(ioc->ioprio)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment