From: Oleg Drokin Date: Thu, 21 May 2015 19:32:22 +0000 (-0400) Subject: staging/lustre/lov: Move suitable variables from procfs to sysfs X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cb1debff6d8b254536ec6ff642a2bdd22c86cb85;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git staging/lustre/lov: Move suitable variables from procfs to sysfs Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 7bba91260e31..d67464691702 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 44739eae0108..caf1aff2a0a5 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 92489daa5f32..41bb5b585a61 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 5e2d55b5b173..c7fe14cbbb2d 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" +Description: + Number of OSC targets managed by this LOV instance. + +What: /sys/fs/lustre/lov/{connection_name}/activeobd +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Number of OSC targets managed by this LOV instance that are + actually active.