Commit e8866cf2 authored by Ed Cashin's avatar Ed Cashin Committed by Linus Torvalds

aoe: add AoE-target files to debugfs

Signed-off-by: default avatarEd Cashin <ecashin@coraid.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 190519cd
...@@ -169,6 +169,7 @@ struct aoedev { ...@@ -169,6 +169,7 @@ struct aoedev {
ulong ref; ulong ref;
struct work_struct work;/* disk create work struct */ struct work_struct work;/* disk create work struct */
struct gendisk *gd; struct gendisk *gd;
struct dentry *debugfs;
struct request_queue *blkq; struct request_queue *blkq;
struct hd_geometry geo; struct hd_geometry geo;
sector_t ssize; sector_t ssize;
...@@ -206,6 +207,7 @@ struct ktstate { ...@@ -206,6 +207,7 @@ struct ktstate {
int aoeblk_init(void); int aoeblk_init(void);
void aoeblk_exit(void); void aoeblk_exit(void);
void aoeblk_gdalloc(void *); void aoeblk_gdalloc(void *);
void aoedisk_rm_debugfs(struct aoedev *d);
void aoedisk_rm_sysfs(struct aoedev *d); void aoedisk_rm_sysfs(struct aoedev *d);
int aoechr_init(void); int aoechr_init(void);
......
...@@ -132,6 +132,40 @@ static const struct attribute_group attr_group = { ...@@ -132,6 +132,40 @@ static const struct attribute_group attr_group = {
.attrs = aoe_attrs, .attrs = aoe_attrs,
}; };
static const struct file_operations aoe_debugfs_fops;
static void
aoedisk_add_debugfs(struct aoedev *d)
{
struct dentry *entry;
char *p;
if (aoe_debugfs_dir == NULL)
return;
p = strchr(d->gd->disk_name, '/');
if (p == NULL)
p = d->gd->disk_name;
else
p++;
BUG_ON(*p == '\0');
entry = debugfs_create_file(p, 0444, aoe_debugfs_dir, d,
&aoe_debugfs_fops);
if (IS_ERR_OR_NULL(entry)) {
pr_info("aoe: cannot create debugfs file for %s\n",
d->gd->disk_name);
return;
}
BUG_ON(d->debugfs);
d->debugfs = entry;
}
void
aoedisk_rm_debugfs(struct aoedev *d)
{
BUG_ON(d->debugfs == NULL);
debugfs_remove(d->debugfs);
d->debugfs = NULL;
}
static int static int
aoedisk_add_sysfs(struct aoedev *d) aoedisk_add_sysfs(struct aoedev *d)
{ {
...@@ -332,6 +366,7 @@ aoeblk_gdalloc(void *vp) ...@@ -332,6 +366,7 @@ aoeblk_gdalloc(void *vp)
add_disk(gd); add_disk(gd);
aoedisk_add_sysfs(d); aoedisk_add_sysfs(d);
aoedisk_add_debugfs(d);
spin_lock_irqsave(&d->lock, flags); spin_lock_irqsave(&d->lock, flags);
WARN_ON(!(d->flags & DEVFL_GD_NOW)); WARN_ON(!(d->flags & DEVFL_GD_NOW));
......
...@@ -278,6 +278,7 @@ freedev(struct aoedev *d) ...@@ -278,6 +278,7 @@ freedev(struct aoedev *d)
del_timer_sync(&d->timer); del_timer_sync(&d->timer);
if (d->gd) { if (d->gd) {
aoedisk_rm_debugfs(d);
aoedisk_rm_sysfs(d); aoedisk_rm_sysfs(d);
del_gendisk(d->gd); del_gendisk(d->gd);
put_disk(d->gd); put_disk(d->gd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment