+ nbd-show-nbd-client-pid-in-sysfs.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     nbd: show nbd client pid in sysfs
has been added to the -mm tree.  Its filename is
     nbd-show-nbd-client-pid-in-sysfs.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: nbd: show nbd client pid in sysfs
From: Paul Clements <paul.clements@xxxxxxxxxxxx>

Allow nbd to expose the nbd-client daemon's PID in /sys/block/nbd<x>/pid. 
This is helpful for tracking connection status of a device and for
determining which nbd devices are currently in use.

Signed-off-by: Paul Clements <paul.clements@xxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 drivers/block/nbd.c |   16 ++++++++++++++++
 include/linux/nbd.h |    1 +
 2 files changed, 17 insertions(+)

diff -puN drivers/block/nbd.c~nbd-show-nbd-client-pid-in-sysfs drivers/block/nbd.c
--- a/drivers/block/nbd.c~nbd-show-nbd-client-pid-in-sysfs
+++ a/drivers/block/nbd.c
@@ -355,14 +355,30 @@ harderror:
 	return NULL;
 }
 
+static ssize_t pid_show(struct gendisk *disk, char *page)
+{
+	return sprintf(page, "%ld\n",
+		(long) ((struct nbd_device *)disk->private_data)->pid);
+}
+
+static struct disk_attribute pid_attr = {
+	.attr = { .name = "pid", .mode = S_IRUGO },
+	.show = pid_show,
+};
+
 static void nbd_do_it(struct nbd_device *lo)
 {
 	struct request *req;
 
 	BUG_ON(lo->magic != LO_MAGIC);
 
+	lo->pid = current->pid;
+	sysfs_create_file(&lo->disk->kobj, &pid_attr.attr);
+
 	while ((req = nbd_read_stat(lo)) != NULL)
 		nbd_end_request(req);
+
+	sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr);
 	return;
 }
 
diff -puN include/linux/nbd.h~nbd-show-nbd-client-pid-in-sysfs include/linux/nbd.h
--- a/include/linux/nbd.h~nbd-show-nbd-client-pid-in-sysfs
+++ a/include/linux/nbd.h
@@ -64,6 +64,7 @@ struct nbd_device {
 	struct gendisk *disk;
 	int blksize;
 	u64 bytesize;
+	pid_t pid; /* pid of nbd-client, if attached */
 };
 
 #endif
_

Patches currently in -mm which might be from paul.clements@xxxxxxxxxxxx are

nbd-show-nbd-client-pid-in-sysfs.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux