diff options
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r-- | drivers/block/nbd.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 9d1035e8d9d8..7bf2cfbd6285 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -355,14 +355,30 @@ harderror: | |||
355 | return NULL; | 355 | return NULL; |
356 | } | 356 | } |
357 | 357 | ||
358 | static ssize_t pid_show(struct gendisk *disk, char *page) | ||
359 | { | ||
360 | return sprintf(page, "%ld\n", | ||
361 | (long) ((struct nbd_device *)disk->private_data)->pid); | ||
362 | } | ||
363 | |||
364 | static struct disk_attribute pid_attr = { | ||
365 | .attr = { .name = "pid", .mode = S_IRUGO }, | ||
366 | .show = pid_show, | ||
367 | }; | ||
368 | |||
358 | static void nbd_do_it(struct nbd_device *lo) | 369 | static void nbd_do_it(struct nbd_device *lo) |
359 | { | 370 | { |
360 | struct request *req; | 371 | struct request *req; |
361 | 372 | ||
362 | BUG_ON(lo->magic != LO_MAGIC); | 373 | BUG_ON(lo->magic != LO_MAGIC); |
363 | 374 | ||
375 | lo->pid = current->pid; | ||
376 | sysfs_create_file(&lo->disk->kobj, &pid_attr.attr); | ||
377 | |||
364 | while ((req = nbd_read_stat(lo)) != NULL) | 378 | while ((req = nbd_read_stat(lo)) != NULL) |
365 | nbd_end_request(req); | 379 | nbd_end_request(req); |
380 | |||
381 | sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr); | ||
366 | return; | 382 | return; |
367 | } | 383 | } |
368 | 384 | ||