Commit b5fa70d7 authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman

staging/lustre/lmv: Move suitable entries from procfs to sysfs

Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cb1debff
...@@ -613,6 +613,7 @@ struct lmv_obd { ...@@ -613,6 +613,7 @@ struct lmv_obd {
struct lmv_tgt_desc **tgts; struct lmv_tgt_desc **tgts;
struct obd_connect_data conn_data; struct obd_connect_data conn_data;
struct kobject *lmv_tgts_kobj;
}; };
struct niobuf_local { struct niobuf_local {
...@@ -917,7 +918,6 @@ struct obd_device { ...@@ -917,7 +918,6 @@ struct obd_device {
struct lprocfs_stats *md_stats; struct lprocfs_stats *md_stats;
struct proc_dir_entry *obd_proc_entry; struct proc_dir_entry *obd_proc_entry;
void *obd_proc_private; /* type private PDEs */
struct proc_dir_entry *obd_proc_exports_entry; struct proc_dir_entry *obd_proc_exports_entry;
struct proc_dir_entry *obd_svc_procroot; struct proc_dir_entry *obd_svc_procroot;
struct lprocfs_stats *obd_svc_stats; struct lprocfs_stats *obd_svc_stats;
......
...@@ -199,7 +199,6 @@ static int lmv_connect(const struct lu_env *env, ...@@ -199,7 +199,6 @@ static int lmv_connect(const struct lu_env *env,
struct obd_uuid *cluuid, struct obd_connect_data *data, struct obd_uuid *cluuid, struct obd_connect_data *data,
void *localdata) void *localdata)
{ {
struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv; struct lmv_obd *lmv = &obd->u.lmv;
struct lustre_handle conn = { 0 }; struct lustre_handle conn = { 0 };
int rc = 0; int rc = 0;
...@@ -230,19 +229,8 @@ static int lmv_connect(const struct lu_env *env, ...@@ -230,19 +229,8 @@ static int lmv_connect(const struct lu_env *env,
if (data) if (data)
lmv->conn_data = *data; lmv->conn_data = *data;
if (obd->obd_proc_private != NULL) { lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds",
lmv_proc_dir = obd->obd_proc_private; &obd->obd_kobj);
} else {
lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry,
NULL, NULL);
if (IS_ERR(lmv_proc_dir)) {
CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.",
obd->obd_type->typ_name, obd->obd_name);
lmv_proc_dir = NULL;
}
obd->obd_proc_private = lmv_proc_dir;
}
/* /*
* All real clients should perform actual connection right away, because * All real clients should perform actual connection right away, because
* it is possible, that LMV will not have opportunity to connect targets * it is possible, that LMV will not have opportunity to connect targets
...@@ -252,10 +240,8 @@ static int lmv_connect(const struct lu_env *env, ...@@ -252,10 +240,8 @@ static int lmv_connect(const struct lu_env *env,
if (data->ocd_connect_flags & OBD_CONNECT_REAL) if (data->ocd_connect_flags & OBD_CONNECT_REAL)
rc = lmv_check_connect(obd); rc = lmv_check_connect(obd);
if (rc && lmv_proc_dir) { if (rc && lmv->lmv_tgts_kobj)
lprocfs_remove(&lmv_proc_dir); kobject_put(lmv->lmv_tgts_kobj);
obd->obd_proc_private = NULL;
}
return rc; return rc;
} }
...@@ -337,7 +323,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, ...@@ -337,7 +323,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize,
static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
{ {
struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv; struct lmv_obd *lmv = &obd->u.lmv;
struct obd_uuid *cluuid = &lmv->cluuid; struct obd_uuid *cluuid = &lmv->cluuid;
struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" }; struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" };
...@@ -415,25 +400,10 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) ...@@ -415,25 +400,10 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
mdc_obd->obd_name, mdc_obd->obd_uuid.uuid, mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
atomic_read(&obd->obd_refcount)); atomic_read(&obd->obd_refcount));
lmv_proc_dir = obd->obd_proc_private; if (lmv->lmv_tgts_kobj)
if (lmv_proc_dir) { /* Even if we failed to create the link, that's fine */
struct proc_dir_entry *mdc_symlink; rc = sysfs_create_link(lmv->lmv_tgts_kobj, &mdc_obd->obd_kobj,
mdc_obd->obd_name);
LASSERT(mdc_obd->obd_type != NULL);
LASSERT(mdc_obd->obd_type->typ_name != NULL);
mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name,
lmv_proc_dir,
"../../../%s/%s",
mdc_obd->obd_type->typ_name,
mdc_obd->obd_name);
if (mdc_symlink == NULL) {
CERROR("Could not register LMV target /proc/fs/lustre/%s/%s/target_obds/%s.",
obd->obd_type->typ_name, obd->obd_name,
mdc_obd->obd_name);
lprocfs_remove(&lmv_proc_dir);
obd->obd_proc_private = NULL;
}
}
return 0; return 0;
} }
...@@ -610,7 +580,6 @@ int lmv_check_connect(struct obd_device *obd) ...@@ -610,7 +580,6 @@ int lmv_check_connect(struct obd_device *obd)
static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
{ {
struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv; struct lmv_obd *lmv = &obd->u.lmv;
struct obd_device *mdc_obd; struct obd_device *mdc_obd;
int rc; int rc;
...@@ -626,9 +595,9 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) ...@@ -626,9 +595,9 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
mdc_obd->obd_no_recov = obd->obd_no_recov; mdc_obd->obd_no_recov = obd->obd_no_recov;
} }
lmv_proc_dir = obd->obd_proc_private; if (lmv->lmv_tgts_kobj)
if (lmv_proc_dir) sysfs_remove_link(lmv->lmv_tgts_kobj,
lprocfs_remove_proc_entry(mdc_obd->obd_name, lmv_proc_dir); mdc_obd->obd_name);
rc = obd_fid_fini(tgt->ltd_exp->exp_obd); rc = obd_fid_fini(tgt->ltd_exp->exp_obd);
if (rc) if (rc)
...@@ -676,11 +645,8 @@ static int lmv_disconnect(struct obd_export *exp) ...@@ -676,11 +645,8 @@ static int lmv_disconnect(struct obd_export *exp)
lmv_disconnect_mdc(obd, lmv->tgts[i]); lmv_disconnect_mdc(obd, lmv->tgts[i]);
} }
if (obd->obd_proc_private) if (lmv->lmv_tgts_kobj)
lprocfs_remove((struct proc_dir_entry **)&obd->obd_proc_private); kobject_put(lmv->lmv_tgts_kobj);
else
CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n",
obd->obd_type->typ_name, obd->obd_name);
out_local: out_local:
/* /*
......
...@@ -42,17 +42,17 @@ ...@@ -42,17 +42,17 @@
#include "../include/obd_class.h" #include "../include/obd_class.h"
#include "lmv_internal.h" #include "lmv_internal.h"
static int lmv_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,
struct lmv_desc *desc; obd_kobj);
struct lmv_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lmv.desc; desc = &dev->u.lmv.desc;
seq_printf(m, "%u\n", desc->ld_tgt_count); return sprintf(buf, "%u\n", desc->ld_tgt_count);
return 0;
} }
LPROC_SEQ_FOPS_RO(lmv_numobd); LUSTRE_RO_ATTR(numobd);
static const char *placement_name[] = { static const char *placement_name[] = {
[PLACEMENT_CHAR_POLICY] = "CHAR", [PLACEMENT_CHAR_POLICY] = "CHAR",
...@@ -77,66 +77,61 @@ static const char *placement_policy2name(enum placement_policy placement) ...@@ -77,66 +77,61 @@ static const char *placement_policy2name(enum placement_policy placement)
return placement_name[placement]; return placement_name[placement];
} }
static int lmv_placement_seq_show(struct seq_file *m, void *v) static ssize_t placement_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,
struct lmv_obd *lmv; obd_kobj);
struct lmv_obd *lmv;
LASSERT(dev != NULL);
lmv = &dev->u.lmv; lmv = &dev->u.lmv;
seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement)); return sprintf(buf, "%s\n", placement_policy2name(lmv->lmv_placement));
return 0;
} }
#define MAX_POLICY_STRING_SIZE 64 #define MAX_POLICY_STRING_SIZE 64
static ssize_t lmv_placement_seq_write(struct file *file, static ssize_t placement_store(struct kobject *kobj, struct attribute *attr,
const char __user *buffer, const char *buffer,
size_t count, loff_t *off) size_t count)
{ {
struct obd_device *dev = ((struct seq_file *)file->private_data)->private; struct obd_device *dev = container_of(kobj, struct obd_device,
char dummy[MAX_POLICY_STRING_SIZE + 1]; obd_kobj);
int len = count; char dummy[MAX_POLICY_STRING_SIZE + 1];
enum placement_policy policy; enum placement_policy policy;
struct lmv_obd *lmv; struct lmv_obd *lmv = &dev->u.lmv;
if (copy_from_user(dummy, buffer, MAX_POLICY_STRING_SIZE)) memcpy(dummy, buffer, MAX_POLICY_STRING_SIZE);
return -EFAULT;
LASSERT(dev != NULL); if (count > MAX_POLICY_STRING_SIZE)
lmv = &dev->u.lmv; count = MAX_POLICY_STRING_SIZE;
if (len > MAX_POLICY_STRING_SIZE) if (dummy[count - 1] == '\n')
len = MAX_POLICY_STRING_SIZE; count--;
dummy[count] = '\0';
if (dummy[len - 1] == '\n') policy = placement_name2policy(dummy, count);
len--;
dummy[len] = '\0';
policy = placement_name2policy(dummy, len);
if (policy != PLACEMENT_INVAL_POLICY) { if (policy != PLACEMENT_INVAL_POLICY) {
spin_lock(&lmv->lmv_lock); spin_lock(&lmv->lmv_lock);
lmv->lmv_placement = policy; lmv->lmv_placement = policy;
spin_unlock(&lmv->lmv_lock); spin_unlock(&lmv->lmv_lock);
} else { } else {
CERROR("Invalid placement policy \"%s\"!\n", dummy);
return -EINVAL; return -EINVAL;
} }
return count; return count;
} }
LPROC_SEQ_FOPS(lmv_placement); LUSTRE_RW_ATTR(placement);
static int lmv_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,
struct lmv_desc *desc; obd_kobj);
struct lmv_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lmv.desc; desc = &dev->u.lmv.desc;
seq_printf(m, "%u\n", desc->ld_active_tgt_count); return sprintf(buf, "%u\n", desc->ld_active_tgt_count);
return 0;
} }
LPROC_SEQ_FOPS_RO(lmv_activeobd); LUSTRE_RO_ATTR(activeobd);
static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v) static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v)
{ {
...@@ -205,9 +200,6 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) ...@@ -205,9 +200,6 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file)
} }
static struct lprocfs_vars lprocfs_lmv_obd_vars[] = { static struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
{ "numobd", &lmv_numobd_fops, NULL, 0 },
{ "placement", &lmv_placement_fops, NULL, 0 },
{ "activeobd", &lmv_activeobd_fops, NULL, 0 },
{ "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 }, { "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 },
{ NULL } { NULL }
}; };
...@@ -220,7 +212,19 @@ struct file_operations lmv_proc_target_fops = { ...@@ -220,7 +212,19 @@ struct file_operations lmv_proc_target_fops = {
.release = seq_release, .release = seq_release,
}; };
static struct attribute *lmv_attrs[] = {
&lustre_attr_activeobd.attr,
&lustre_attr_numobd.attr,
&lustre_attr_placement.attr,
NULL,
};
static struct attribute_group lmv_attr_group = {
.attrs = lmv_attrs,
};
void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars) void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars)
{ {
lvars->sysfs_vars = &lmv_attr_group;
lvars->obd_vars = lprocfs_lmv_obd_vars; lvars->obd_vars = lprocfs_lmv_obd_vars;
} }
...@@ -518,3 +518,26 @@ Contact: "Oleg Drokin" <oleg.drokin@intel.com> ...@@ -518,3 +518,26 @@ Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description: Description:
Number of OSC targets managed by this LOV instance that are Number of OSC targets managed by this LOV instance that are
actually active. actually active.
What: /sys/fs/lustre/lmv/{connection_name}/numobd
Date: May 2015
Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description:
Number of MDC targets managed by this LMV instance.
What: /sys/fs/lustre/lmv/{connection_name}/activeobd
Date: May 2015
Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description:
Number of MDC targets managed by this LMV instance that are
actually active.
What: /sys/fs/lustre/lmv/{connection_name}/placement
Date: May 2015
Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description:
Determines policy of inode placement in case of multiple
metadata servers:
CHAR - based on a hash of the file name used at creation time
(Default)
NID - based on a hash of creating client network id.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment