staging/lustre/lov: Move suitable variables from procfs to sysfs
authorOleg Drokin <green@linuxhacker.ru>
Thu, 21 May 2015 19:32:22 +0000 (15:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 02:18:24 +0000 (11:18 +0900)
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/obd.h
drivers/staging/lustre/lustre/lov/lov_obd.c
drivers/staging/lustre/lustre/lov/lproc_lov.c
drivers/staging/lustre/sysfs-fs-lustre

index 7bba91260e31a5824a876e4a533068565e747468..d6746469170298d0e178d1607222edf3a4b0388d 100644 (file)
@@ -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 {
index 44739eae0108453722c40e024a0e0c644f56fef3..caf1aff2a0a5ab21c95a823847dabeb81170e476 100644 (file)
@@ -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:
index 92489daa5f32e1b5ac871c6b1780f0713d5118e8..41bb5b585a617a808e3a9ef7e3319508f6dc0538 100644 (file)
@@ -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 = {
index 5e2d55b5b173435a96da15724f292dc119ec9418..c7fe14cbbb2dd6f3e5166a53b3e359d0c13bb345 100644 (file)
@@ -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@intel.com>
+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@intel.com>
+Description:
+               Number of OSC targets managed by this LOV instance that are
+               actually active.