[PATCH RFC v0 37/49] pnfsd: make /proc/fs/nfsd/pnfs_dlm_device report dlm device list.

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

 



From: Eric Anderle <eanderle@xxxxxxxxx>

The ability to read the current device list is useful for debugging.

Signed-off-by: Eric Anderle <eanderle@xxxxxxxxx>
Signed-off-by: J. Bruce Fields <bfields@xxxxxxxxxxxxxx>
[pnfsd: fix dlm device naming]
Signed-off-by: Andy Adamson <andros@xxxxxxxxxx>
Signed-off-by: Benny Halevy <bhalevy@xxxxxxxxxxx>
Signed-off-by: Benny Halevy <bhalevy@xxxxxxxxxxxxxxx>
---
 fs/nfsd/nfs4pnfsdlm.c            | 44 +++++++++++++++++++++++++++++++++++++---
 fs/nfsd/nfsctl.c                 |  4 +++-
 include/linux/nfsd/nfs4pnfsdlm.h |  2 ++
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfs4pnfsdlm.c b/fs/nfsd/nfs4pnfsdlm.c
index 19002c1..4c2ab87 100644
--- a/fs/nfsd/nfs4pnfsdlm.c
+++ b/fs/nfsd/nfs4pnfsdlm.c
@@ -28,6 +28,8 @@
 #include <linux/nfsd/nfs4layoutxdr.h>
 #include <linux/sunrpc/addr.h>
 
+#include "nfsd.h"
+
 #define NFSDDBG_FACILITY                NFSDDBG_FILELAYOUT
 
 /* Just use a linked list. Do not expect more than 32 dlm_device_entries
@@ -45,12 +47,15 @@ struct dlm_device_entry {
 };
 
 static struct dlm_device_entry *
-nfsd4_find_pnfs_dlm_device(char *disk_name)
+_nfsd4_find_pnfs_dlm_device(char *disk_name)
 {
 	struct dlm_device_entry *dlm_pdev;
 
+	dprintk("--> %s  disk name %s\n", __func__, disk_name);
 	spin_lock(&dlm_device_list_lock);
 	list_for_each_entry(dlm_pdev, &dlm_device_list, dlm_dev_list) {
+		dprintk("%s Look for dlm_pdev %s\n", __func__,
+			dlm_pdev->disk_name);
 		if (!memcmp(dlm_pdev->disk_name, disk_name, strlen(disk_name))) {
 			spin_unlock(&dlm_device_list_lock);
 			return dlm_pdev;
@@ -60,6 +65,39 @@ struct dlm_device_entry {
 	return NULL;
 }
 
+static struct dlm_device_entry *
+nfsd4_find_pnfs_dlm_device(struct super_block *sb) {
+	char dname[BDEVNAME_SIZE];
+
+	bdevname(sb->s_bdev, dname);
+	return _nfsd4_find_pnfs_dlm_device(dname);
+}
+
+ssize_t
+nfsd4_get_pnfs_dlm_device_list(char *buf, ssize_t buflen)
+{
+	char *pos = buf;
+	ssize_t size = 0;
+	struct dlm_device_entry *dlm_pdev;
+	int ret = -EINVAL;
+
+	spin_lock(&dlm_device_list_lock);
+	list_for_each_entry(dlm_pdev, &dlm_device_list, dlm_dev_list)
+	{
+		int advanced;
+		advanced = snprintf(pos, buflen - size, "%s:%s\n", dlm_pdev->disk_name, dlm_pdev->ds_list);
+		if (advanced >= buflen - size)
+			goto out;
+		size += advanced;
+		pos += advanced;
+	}
+	ret = size;
+
+out:
+	spin_unlock(&dlm_device_list_lock);
+	return ret;
+}
+
 bool nfsd4_validate_pnfs_dlm_device(char *ds_list, int *num_ds)
 {
 	char *start = ds_list;
@@ -140,7 +178,7 @@ bool nfsd4_validate_pnfs_dlm_device(char *ds_list, int *num_ds)
 	dprintk("%s disk_name %s num_ds %d ds_list %s\n", __func__,
 		new->disk_name, new->num_ds, new->ds_list);
 
-	found = nfsd4_find_pnfs_dlm_device(new->disk_name);
+	found = _nfsd4_find_pnfs_dlm_device(new->disk_name);
 	if (found) {
 		/* FIXME: should compare found->ds_list with new->ds_list
 		 * and if it is different, kick off a CB_NOTIFY change
@@ -235,7 +273,7 @@ static int nfsd4_pnfs_dlm_getdevinfo(struct super_block *sb,
 	/*
 	 * If the DS list has not been established, return -EINVAL
 	 */
-	dlm_pdev = nfsd4_find_pnfs_dlm_device(sb->s_bdev->bd_disk->disk_name);
+	dlm_pdev = nfsd4_find_pnfs_dlm_device(sb);
 	if (!dlm_pdev) {
 		dprintk("%s: DEBUG: disk %s Not Found\n", __func__,
 			sb->s_bdev->bd_disk->disk_name);
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 7da8584..4fafa2a 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -1068,7 +1068,9 @@ static ssize_t __write_pnfs_dlm_device(struct file *file, char *buf,
 			return ret;
 
 		ret = nfsd4_set_pnfs_dlm_device(pnfs_dlm_device, len);
-	}
+	} else
+		return nfsd4_get_pnfs_dlm_device_list(buf, SIMPLE_TRANSACTION_LIMIT);
+
 	return ret <= 0 ? ret : strlen(buf);
 }
 
diff --git a/include/linux/nfsd/nfs4pnfsdlm.h b/include/linux/nfsd/nfs4pnfsdlm.h
index 63248aa..a4f3477 100644
--- a/include/linux/nfsd/nfs4pnfsdlm.h
+++ b/include/linux/nfsd/nfs4pnfsdlm.h
@@ -39,6 +39,8 @@
 
 void nfsd4_pnfs_dlm_shutdown(void);
 
+ssize_t nfsd4_get_pnfs_dlm_device_list(char *buf, ssize_t buflen);
+
 #else /* CONFIG_PNFSD */
 
 static inline void nfsd4_pnfs_dlm_shutdown(void)
-- 
1.8.3.1

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




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux