|
@@ -42,17 +42,17 @@
|
|
|
#include "../include/obd_class.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 lmv_desc *desc;
|
|
|
+ struct obd_device *dev = container_of(kobj, struct obd_device,
|
|
|
+ obd_kobj);
|
|
|
+ struct lmv_desc *desc;
|
|
|
|
|
|
- LASSERT(dev != NULL);
|
|
|
desc = &dev->u.lmv.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(lmv_numobd);
|
|
|
+LUSTRE_RO_ATTR(numobd);
|
|
|
|
|
|
static const char *placement_name[] = {
|
|
|
[PLACEMENT_CHAR_POLICY] = "CHAR",
|
|
@@ -77,66 +77,61 @@ static const char *placement_policy2name(enum placement_policy 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 lmv_obd *lmv;
|
|
|
+ struct obd_device *dev = container_of(kobj, struct obd_device,
|
|
|
+ obd_kobj);
|
|
|
+ struct lmv_obd *lmv;
|
|
|
|
|
|
- LASSERT(dev != NULL);
|
|
|
lmv = &dev->u.lmv;
|
|
|
- seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement));
|
|
|
- return 0;
|
|
|
+ return sprintf(buf, "%s\n", placement_policy2name(lmv->lmv_placement));
|
|
|
}
|
|
|
|
|
|
#define MAX_POLICY_STRING_SIZE 64
|
|
|
|
|
|
-static ssize_t lmv_placement_seq_write(struct file *file,
|
|
|
- const char __user *buffer,
|
|
|
- size_t count, loff_t *off)
|
|
|
+static ssize_t placement_store(struct kobject *kobj, struct attribute *attr,
|
|
|
+ const char *buffer,
|
|
|
+ size_t count)
|
|
|
{
|
|
|
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
|
|
|
- char dummy[MAX_POLICY_STRING_SIZE + 1];
|
|
|
- int len = count;
|
|
|
- enum placement_policy policy;
|
|
|
- struct lmv_obd *lmv;
|
|
|
+ struct obd_device *dev = container_of(kobj, struct obd_device,
|
|
|
+ obd_kobj);
|
|
|
+ char dummy[MAX_POLICY_STRING_SIZE + 1];
|
|
|
+ enum placement_policy policy;
|
|
|
+ struct lmv_obd *lmv = &dev->u.lmv;
|
|
|
|
|
|
- if (copy_from_user(dummy, buffer, MAX_POLICY_STRING_SIZE))
|
|
|
- return -EFAULT;
|
|
|
+ memcpy(dummy, buffer, MAX_POLICY_STRING_SIZE);
|
|
|
|
|
|
- LASSERT(dev != NULL);
|
|
|
- lmv = &dev->u.lmv;
|
|
|
+ if (count > MAX_POLICY_STRING_SIZE)
|
|
|
+ count = MAX_POLICY_STRING_SIZE;
|
|
|
|
|
|
- if (len > MAX_POLICY_STRING_SIZE)
|
|
|
- len = MAX_POLICY_STRING_SIZE;
|
|
|
+ if (dummy[count - 1] == '\n')
|
|
|
+ count--;
|
|
|
+ dummy[count] = '\0';
|
|
|
|
|
|
- if (dummy[len - 1] == '\n')
|
|
|
- len--;
|
|
|
- dummy[len] = '\0';
|
|
|
-
|
|
|
- policy = placement_name2policy(dummy, len);
|
|
|
+ policy = placement_name2policy(dummy, count);
|
|
|
if (policy != PLACEMENT_INVAL_POLICY) {
|
|
|
spin_lock(&lmv->lmv_lock);
|
|
|
lmv->lmv_placement = policy;
|
|
|
spin_unlock(&lmv->lmv_lock);
|
|
|
} else {
|
|
|
- CERROR("Invalid placement policy \"%s\"!\n", dummy);
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
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 lmv_desc *desc;
|
|
|
+ struct obd_device *dev = container_of(kobj, struct obd_device,
|
|
|
+ obd_kobj);
|
|
|
+ struct lmv_desc *desc;
|
|
|
|
|
|
- LASSERT(dev != NULL);
|
|
|
desc = &dev->u.lmv.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(lmv_activeobd);
|
|
|
+LUSTRE_RO_ATTR(activeobd);
|
|
|
|
|
|
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)
|
|
|
}
|
|
|
|
|
|
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 },
|
|
|
{ NULL }
|
|
|
};
|
|
@@ -220,7 +212,19 @@ struct file_operations lmv_proc_target_fops = {
|
|
|
.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)
|
|
|
{
|
|
|
+ lvars->sysfs_vars = &lmv_attr_group;
|
|
|
lvars->obd_vars = lprocfs_lmv_obd_vars;
|
|
|
}
|