[PATCH 48/58] staging/lustre/lov: Move suitable variables from procfs to sysfs

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

 



From: Oleg Drokin <green@xxxxxxxxxxxxxx>

Signed-off-by: Oleg Drokin <green@xxxxxxxxxxxxxx>
---
 drivers/staging/lustre/lustre/include/obd.h   |  2 ++
 drivers/staging/lustre/lustre/lov/lov_obd.c   | 44 ++++++++++-----------------
 drivers/staging/lustre/lustre/lov/lproc_lov.c | 39 +++++++++++++++---------
 drivers/staging/lustre/sysfs-fs-lustre        | 13 ++++++++
 4 files changed, 55 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index bb07ec7..2f7d08f 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -573,6 +573,8 @@ struct lov_obd {
 	void		       *lov_cache;
 
 	struct rw_semaphore     lov_notify_lock;
+
+	struct kobject		*lov_tgts_kobj;
 };
 
 struct lmv_tgt_desc {
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 44739ea..caf1aff 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -127,7 +127,6 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
 	struct obd_device *tgt_obd;
 	static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
 	struct obd_import *imp;
-	struct proc_dir_entry *lov_proc_dir;
 	int rc;
 
 	if (!lov->lov_tgts[index])
@@ -186,28 +185,10 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
 	CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index,
 	       obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
 
-	lov_proc_dir = obd->obd_proc_private;
-	if (lov_proc_dir) {
-		struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd;
-		struct proc_dir_entry *osc_symlink;
-
-		LASSERT(osc_obd != NULL);
-		LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC);
-		LASSERT(osc_obd->obd_type->typ_name != NULL);
-
-		osc_symlink = lprocfs_add_symlink(osc_obd->obd_name,
-						  lov_proc_dir,
-						  "../../../%s/%s",
-						  osc_obd->obd_type->typ_name,
-						  osc_obd->obd_name);
-		if (osc_symlink == NULL) {
-			CERROR("could not register LOV target /proc/fs/lustre/%s/%s/target_obds/%s.",
-			       obd->obd_type->typ_name, obd->obd_name,
-			       osc_obd->obd_name);
-			lprocfs_remove(&lov_proc_dir);
-			obd->obd_proc_private = NULL;
-		}
-	}
+	if (lov->lov_tgts_kobj)
+		/* Even if we failed, that's ok */
+		rc = sysfs_create_link(lov->lov_tgts_kobj, &tgt_obd->obd_kobj,
+				       tgt_obd->obd_name);
 
 	return 0;
 }
@@ -239,6 +220,10 @@ static int lov_connect(const struct lu_env *env,
 		lov->lov_ocd = *data;
 
 	obd_getref(obd);
+
+	lov->lov_tgts_kobj = kobject_create_and_add("target_obds",
+						    &obd->obd_kobj);
+
 	for (i = 0; i < lov->desc.ld_tgt_count; i++) {
 		tgt = lov->lov_tgts[i];
 		if (!tgt || obd_uuid_empty(&tgt->ltd_uuid))
@@ -268,7 +253,6 @@ static int lov_connect(const struct lu_env *env,
 
 static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
 {
-	struct proc_dir_entry *lov_proc_dir;
 	struct lov_obd *lov = &obd->u.lov;
 	struct obd_device *osc_obd;
 	int rc;
@@ -284,10 +268,10 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
 	}
 
 	if (osc_obd) {
-		lov_proc_dir = obd->obd_proc_private;
-		if (lov_proc_dir) {
-			lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir);
-		}
+		if (lov->lov_tgts_kobj)
+			sysfs_remove_link(lov->lov_tgts_kobj,
+					  osc_obd->obd_name);
+
 		/* Pass it on to our clients.
 		 * XXX This should be an argument to disconnect,
 		 * XXX not a back-door flag on the OBD.  Ah well.
@@ -337,6 +321,10 @@ static int lov_disconnect(struct obd_export *exp)
 			lov_del_target(obd, i, NULL, lov->lov_tgts[i]->ltd_gen);
 		}
 	}
+
+	if (lov->lov_tgts_kobj)
+		kobject_put(lov->lov_tgts_kobj);
+
 	obd_putref(obd);
 
 out:
diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c
index 92489da..41bb5b5 100644
--- a/drivers/staging/lustre/lustre/lov/lproc_lov.c
+++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c
@@ -166,29 +166,29 @@ static ssize_t lov_stripecount_seq_write(struct file *file,
 }
 LPROC_SEQ_FOPS(lov_stripecount);
 
-static int lov_numobd_seq_show(struct seq_file *m, void *v)
+static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr,
+			   char *buf)
 {
-	struct obd_device *dev = (struct obd_device *)m->private;
+	struct obd_device *dev = container_of(kobj, struct obd_device,
+					      obd_kobj);
 	struct lov_desc *desc;
 
-	LASSERT(dev != NULL);
 	desc = &dev->u.lov.desc;
-	seq_printf(m, "%u\n", desc->ld_tgt_count);
-	return 0;
+	return sprintf(buf, "%u\n", desc->ld_tgt_count);
 }
-LPROC_SEQ_FOPS_RO(lov_numobd);
+LUSTRE_RO_ATTR(numobd);
 
-static int lov_activeobd_seq_show(struct seq_file *m, void *v)
+static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr,
+			      char *buf)
 {
-	struct obd_device *dev = (struct obd_device *)m->private;
+	struct obd_device *dev = container_of(kobj, struct obd_device,
+					      obd_kobj);
 	struct lov_desc *desc;
 
-	LASSERT(dev != NULL);
 	desc = &dev->u.lov.desc;
-	seq_printf(m, "%u\n", desc->ld_active_tgt_count);
-	return 0;
+	return sprintf(buf, "%u\n", desc->ld_active_tgt_count);
 }
-LPROC_SEQ_FOPS_RO(lov_activeobd);
+LUSTRE_RO_ATTR(activeobd);
 
 static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
 {
@@ -267,16 +267,25 @@ static struct lprocfs_vars lprocfs_lov_obd_vars[] = {
 	{ "stripeoffset", &lov_stripeoffset_fops, NULL },
 	{ "stripecount",  &lov_stripecount_fops,  NULL },
 	{ "stripetype",   &lov_stripetype_fops,   NULL },
-	{ "numobd",       &lov_numobd_fops,	  NULL, 0 },
-	{ "activeobd",    &lov_activeobd_fops,	  NULL, 0 },
 	/*{ "filegroups", lprocfs_rd_filegroups,  NULL, 0 },*/
 	{ "desc_uuid",    &lov_desc_uuid_fops,    NULL, 0 },
 	{ NULL }
 };
 
+static struct attribute *lov_attrs[] = {
+	&lustre_attr_activeobd.attr,
+	&lustre_attr_numobd.attr,
+	NULL,
+};
+
+static struct attribute_group lov_attr_group = {
+	.attrs = lov_attrs,
+};
+
 void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars)
 {
-    lvars->obd_vars     = lprocfs_lov_obd_vars;
+	lvars->sysfs_vars = &lov_attr_group;
+	lvars->obd_vars = lprocfs_lov_obd_vars;
 }
 
 const struct file_operations lov_proc_target_fops = {
diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre
index 5e2d55b..c7fe14c 100644
--- a/drivers/staging/lustre/sysfs-fs-lustre
+++ b/drivers/staging/lustre/sysfs-fs-lustre
@@ -505,3 +505,16 @@ Description:
 		Controls how many times to try and resend RPCs to this target
 		that failed with "recoverable" status, such as EAGAIN,
 		ENOMEM.
+
+What:		/sys/fs/lustre/lov/{connection_name}/numobd
+Date:		May 2015
+Contact:	"Oleg Drokin" <oleg.drokin@xxxxxxxxx>
+Description:
+		Number of OSC targets managed by this LOV instance.
+
+What:		/sys/fs/lustre/lov/{connection_name}/activeobd
+Date:		May 2015
+Contact:	"Oleg Drokin" <oleg.drokin@xxxxxxxxx>
+Description:
+		Number of OSC targets managed by this LOV instance that are
+		actually active.
-- 
2.1.0

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux