Skip to content

Commit 95cf780

Browse files
hreineckeaxboe
authored andcommitted
aoe: register default groups with device_add_disk()
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>
1 parent 33b14f6 commit 95cf780

3 files changed

Lines changed: 7 additions & 16 deletions

File tree

‎drivers/block/aoe/aoe.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ int aoeblk_init(void);
201201
void aoeblk_exit(void);
202202
void aoeblk_gdalloc(void *);
203203
void aoedisk_rm_debugfs(struct aoedev *d);
204-
void aoedisk_rm_sysfs(struct aoedev *d);
205204

206205
int aoechr_init(void);
207206
void aoechr_exit(void);

‎drivers/block/aoe/aoeblk.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,15 @@ static struct attribute *aoe_attrs[] = {
177177
NULL,
178178
};
179179

180-
static const struct attribute_group attr_group = {
180+
static const struct attribute_group aoe_attr_group = {
181181
.attrs = aoe_attrs,
182182
};
183183

184+
static const struct attribute_group *aoe_attr_groups[] = {
185+
&aoe_attr_group,
186+
NULL,
187+
};
188+
184189
static const struct file_operations aoe_debugfs_fops = {
185190
.open = aoe_debugfs_open,
186191
.read = seq_read,
@@ -219,17 +224,6 @@ aoedisk_rm_debugfs(struct aoedev *d)
219224
d->debugfs = NULL;
220225
}
221226

222-
static int
223-
aoedisk_add_sysfs(struct aoedev *d)
224-
{
225-
return sysfs_create_group(&disk_to_dev(d->gd)->kobj, &attr_group);
226-
}
227-
void
228-
aoedisk_rm_sysfs(struct aoedev *d)
229-
{
230-
sysfs_remove_group(&disk_to_dev(d->gd)->kobj, &attr_group);
231-
}
232-
233227
static int
234228
aoeblk_open(struct block_device *bdev, fmode_t mode)
235229
{
@@ -417,8 +411,7 @@ aoeblk_gdalloc(void *vp)
417411

418412
spin_unlock_irqrestore(&d->lock, flags);
419413

420-
add_disk(gd);
421-
aoedisk_add_sysfs(d);
414+
device_add_disk(NULL, gd, aoe_attr_groups);
422415
aoedisk_add_debugfs(d);
423416

424417
spin_lock_irqsave(&d->lock, flags);

‎drivers/block/aoe/aoedev.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ freedev(struct aoedev *d)
275275
del_timer_sync(&d->timer);
276276
if (d->gd) {
277277
aoedisk_rm_debugfs(d);
278-
aoedisk_rm_sysfs(d);
279278
del_gendisk(d->gd);
280279
put_disk(d->gd);
281280
blk_cleanup_queue(d->blkq);

0 commit comments

Comments
 (0)