Re: [PATCH 2/3] block: untangle request_queue refcounting from sysfs

Christoph Hellwig
2022-11-09T13:01:44Z

On Mon, Nov 07, 2022 at 11:57:36AM -0800, Eric Biggers wrote:
> On Sat, Nov 05, 2022 at 09:08:14AM +0100, Christoph Hellwig wrote:
> > @@ -811,7 +772,8 @@ int blk_register_queue(struct gendisk *disk)
> >
> > mutex_lock(&q->sysfs_dir_lock);
> >
> > - ret = kobject_add(&q->kobj, &disk_to_dev(disk)->kobj, "queue");
> > + kobject_init(&disk->queue_kobj, &blk_queue_ktype);
> > + ret = kobject_add(&disk->queue_kobj, &disk_to_dev(disk)->kobj, "queue");
>
> Use kobject_init_and_add()?

I never found a good reason to use that over the two calls. It doesn't
clear up what is done, and doesn't save code size either.

> Also, kobject_put() needs to be called on error.

Indeed. Also for the later error cases.