]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
aoe: register default groups with device_add_disk()
authorHannes Reinecke <hare@suse.de>
Fri, 28 Sep 2018 06:17:21 +0000 (08:17 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 28 Sep 2018 14:30:30 +0000 (08:30 -0600)
Register default sysfs groups during device_add_disk() to avoid a
race condition with udev during startup.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Ed L. Cachin <ed.cashin@acm.org>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/aoe/aoe.h
drivers/block/aoe/aoeblk.c
drivers/block/aoe/aoedev.c

index c0ebda1283ccaae201b9ca03aaec18df11e76efd..015c68017a1c9cb08eb876a98d6bde2b7d630e2f 100644 (file)
@@ -201,7 +201,6 @@ int aoeblk_init(void);
 void aoeblk_exit(void);
 void aoeblk_gdalloc(void *);
 void aoedisk_rm_debugfs(struct aoedev *d);
-void aoedisk_rm_sysfs(struct aoedev *d);
 
 int aoechr_init(void);
 void aoechr_exit(void);
index 429ebb84b5926b62c9eea4deeddc452012450063..ff770e7d9e5287a1abf6654de08c6eaac37f382c 100644 (file)
@@ -177,10 +177,15 @@ static struct attribute *aoe_attrs[] = {
        NULL,
 };
 
-static const struct attribute_group attr_group = {
+static const struct attribute_group aoe_attr_group = {
        .attrs = aoe_attrs,
 };
 
+static const struct attribute_group *aoe_attr_groups[] = {
+       &aoe_attr_group,
+       NULL,
+};
+
 static const struct file_operations aoe_debugfs_fops = {
        .open = aoe_debugfs_open,
        .read = seq_read,
@@ -219,17 +224,6 @@ aoedisk_rm_debugfs(struct aoedev *d)
        d->debugfs = NULL;
 }
 
-static int
-aoedisk_add_sysfs(struct aoedev *d)
-{
-       return sysfs_create_group(&disk_to_dev(d->gd)->kobj, &attr_group);
-}
-void
-aoedisk_rm_sysfs(struct aoedev *d)
-{
-       sysfs_remove_group(&disk_to_dev(d->gd)->kobj, &attr_group);
-}
-
 static int
 aoeblk_open(struct block_device *bdev, fmode_t mode)
 {
@@ -417,8 +411,7 @@ aoeblk_gdalloc(void *vp)
 
        spin_unlock_irqrestore(&d->lock, flags);
 
-       add_disk(gd);
-       aoedisk_add_sysfs(d);
+       device_add_disk(NULL, gd, aoe_attr_groups);
        aoedisk_add_debugfs(d);
 
        spin_lock_irqsave(&d->lock, flags);
index 41060e9cedf20c882816c1c83ca21e15512152a2..f29a140cdbc131aaf09f176afafcbabe35832592 100644 (file)
@@ -275,7 +275,6 @@ freedev(struct aoedev *d)
        del_timer_sync(&d->timer);
        if (d->gd) {
                aoedisk_rm_debugfs(d);
-               aoedisk_rm_sysfs(d);
                del_gendisk(d->gd);
                put_disk(d->gd);
                blk_cleanup_queue(d->blkq);