aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/aoe
diff options
context:
space:
mode:
authorEd Cashin <ecashin@coraid.com>2013-09-11 17:25:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:59:23 -0400
commite8866cf2b90f3a29859d2113c0fd23daf189c282 (patch)
treedf02943b3755d6a284c6fd215a5c709f48d0be1d /drivers/block/aoe
parent190519cd30884215a63ed875ac074dc97a602522 (diff)
aoe: add AoE-target files to debugfs
Signed-off-by: Ed Cashin <ecashin@coraid.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/aoe')
-rw-r--r--drivers/block/aoe/aoe.h2
-rw-r--r--drivers/block/aoe/aoeblk.c35
-rw-r--r--drivers/block/aoe/aoedev.c1
3 files changed, 38 insertions, 0 deletions
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 025c41d3cb33..b1f24c5a6bd1 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -169,6 +169,7 @@ struct aoedev {
169 ulong ref; 169 ulong ref;
170 struct work_struct work;/* disk create work struct */ 170 struct work_struct work;/* disk create work struct */
171 struct gendisk *gd; 171 struct gendisk *gd;
172 struct dentry *debugfs;
172 struct request_queue *blkq; 173 struct request_queue *blkq;
173 struct hd_geometry geo; 174 struct hd_geometry geo;
174 sector_t ssize; 175 sector_t ssize;
@@ -206,6 +207,7 @@ struct ktstate {
206int aoeblk_init(void); 207int aoeblk_init(void);
207void aoeblk_exit(void); 208void aoeblk_exit(void);
208void aoeblk_gdalloc(void *); 209void aoeblk_gdalloc(void *);
210void aoedisk_rm_debugfs(struct aoedev *d);
209void aoedisk_rm_sysfs(struct aoedev *d); 211void aoedisk_rm_sysfs(struct aoedev *d);
210 212
211int aoechr_init(void); 213int aoechr_init(void);
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index cb508b754377..d76c5cb3c708 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -132,6 +132,40 @@ static const struct attribute_group attr_group = {
132 .attrs = aoe_attrs, 132 .attrs = aoe_attrs,
133}; 133};
134 134
135static const struct file_operations aoe_debugfs_fops;
136
137static void
138aoedisk_add_debugfs(struct aoedev *d)
139{
140 struct dentry *entry;
141 char *p;
142
143 if (aoe_debugfs_dir == NULL)
144 return;
145 p = strchr(d->gd->disk_name, '/');
146 if (p == NULL)
147 p = d->gd->disk_name;
148 else
149 p++;
150 BUG_ON(*p == '\0');
151 entry = debugfs_create_file(p, 0444, aoe_debugfs_dir, d,
152 &aoe_debugfs_fops);
153 if (IS_ERR_OR_NULL(entry)) {
154 pr_info("aoe: cannot create debugfs file for %s\n",
155 d->gd->disk_name);
156 return;
157 }
158 BUG_ON(d->debugfs);
159 d->debugfs = entry;
160}
161void
162aoedisk_rm_debugfs(struct aoedev *d)
163{
164 BUG_ON(d->debugfs == NULL);
165 debugfs_remove(d->debugfs);
166 d->debugfs = NULL;
167}
168
135static int 169static int
136aoedisk_add_sysfs(struct aoedev *d) 170aoedisk_add_sysfs(struct aoedev *d)
137{ 171{
@@ -332,6 +366,7 @@ aoeblk_gdalloc(void *vp)
332 366
333 add_disk(gd); 367 add_disk(gd);
334 aoedisk_add_sysfs(d); 368 aoedisk_add_sysfs(d);
369 aoedisk_add_debugfs(d);
335 370
336 spin_lock_irqsave(&d->lock, flags); 371 spin_lock_irqsave(&d->lock, flags);
337 WARN_ON(!(d->flags & DEVFL_GD_NOW)); 372 WARN_ON(!(d->flags & DEVFL_GD_NOW));
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 784c92e038d1..c9047675dfc9 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -278,6 +278,7 @@ freedev(struct aoedev *d)
278 278
279 del_timer_sync(&d->timer); 279 del_timer_sync(&d->timer);
280 if (d->gd) { 280 if (d->gd) {
281 aoedisk_rm_debugfs(d);
281 aoedisk_rm_sysfs(d); 282 aoedisk_rm_sysfs(d);
282 del_gendisk(d->gd); 283 del_gendisk(d->gd);
283 put_disk(d->gd); 284 put_disk(d->gd);