]> www.infradead.org Git - users/hch/block.git/commitdiff
loop: initialize the worker tracking fields once
authorChristoph Hellwig <hch@lst.de>
Wed, 26 Jan 2022 14:47:11 +0000 (15:47 +0100)
committerChristoph Hellwig <hch@lst.de>
Tue, 29 Mar 2022 15:44:33 +0000 (17:44 +0200)
There is no need to reinitialize idle_worker_list, worker_tree and timer
every time a loop device is configured.  Just initialize them once at
allocation time.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Tested-by: Darrick J. Wong <djwong@kernel.org>
drivers/block/loop.c

index 762f0a18295d7778d6e6ec85d7e4fdbf8932d042..d1c1086beedcef93a4cb65b3fbc3f37b648bc7be 100644 (file)
@@ -1057,10 +1057,6 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
 
        INIT_WORK(&lo->rootcg_work, loop_rootcg_workfn);
        INIT_LIST_HEAD(&lo->rootcg_cmd_list);
-       INIT_LIST_HEAD(&lo->idle_worker_list);
-       lo->worker_tree = RB_ROOT;
-       timer_setup(&lo->timer, loop_free_idle_workers_timer,
-               TIMER_DEFERRABLE);
        lo->use_dio = lo->lo_flags & LO_FLAGS_DIRECT_IO;
        lo->lo_device = bdev;
        lo->lo_backing_file = file;
@@ -1973,6 +1969,9 @@ static int loop_add(int i)
        lo = kzalloc(sizeof(*lo), GFP_KERNEL);
        if (!lo)
                goto out;
+       lo->worker_tree = RB_ROOT;
+       INIT_LIST_HEAD(&lo->idle_worker_list);
+       timer_setup(&lo->timer, loop_free_idle_workers_timer, TIMER_DEFERRABLE);
        lo->lo_state = Lo_unbound;
 
        err = mutex_lock_killable(&loop_ctl_mutex);