block: simplify struct io_context refcounting
authorChristoph Hellwig <hch@lst.de>
Thu, 9 Dec 2021 06:31:22 +0000 (07:31 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 16 Dec 2021 17:59:01 +0000 (10:59 -0700)
Don't hold a reference to ->refcount for each active reference, but
just one for all active references.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20211209063131.18537-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-ioc.c

index 96336c2134efa11479be91863fb3b93cb316667a..9cde3906be3c6a766ad26684dd2730f71779fce5 100644 (file)
@@ -180,10 +180,8 @@ static void put_io_context_active(struct io_context *ioc)
 {
        struct io_cq *icq;
 
-       if (!atomic_dec_and_test(&ioc->active_ref)) {
-               put_io_context(ioc);
+       if (!atomic_dec_and_test(&ioc->active_ref))
                return;
-       }
 
        spin_lock_irq(&ioc->lock);
        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)
         * Share io context with parent, if CLONE_IO is set
         */
        if (clone_flags & CLONE_IO) {
-               atomic_long_inc(&ioc->refcount);
                atomic_inc(&ioc->active_ref);
                tsk->io_context = ioc;
        } else if (ioprio_valid(ioc->ioprio)) {