Code Review
/
kvmfornfv.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git]
/
kernel
/
drivers
/
staging
/
lustre
/
lustre
/
lmv
/
lproc_lmv.c
diff --git
a/kernel/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
b/kernel/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
index
22e5c31
..
40cf4d9
100644
(file)
--- a/
kernel/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
+++ b/
kernel/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
@@
-42,17
+42,17
@@
#include "../include/obd_class.h"
#include "lmv_internal.h"
#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;
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);
}
}
-L
PROC_SEQ_FOPS_RO(lmv_
numobd);
+L
USTRE_RO_ATTR(
numobd);
static const char *placement_name[] = {
[PLACEMENT_CHAR_POLICY] = "CHAR",
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];
}
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;
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
}
#define MAX_POLICY_STRING_SIZE 64
-static ssize_t
lmv_placement_seq_write(struct file *file
,
-
const char __use
r *buffer,
-
size_t count, loff_t *off
)
+static ssize_t
placement_store(struct kobject *kobj, struct attribute *attr
,
+
const cha
r *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 (len > MAX_POLICY_STRING_SIZE)
- len = MAX_POLICY_STRING_SIZE;
+ if (count > MAX_POLICY_STRING_SIZE)
+ count = MAX_POLICY_STRING_SIZE;
- if (dummy[
len
- 1] == '\n')
-
len
--;
- dummy[
len
] = '\0';
+ if (dummy[
count
- 1] == '\n')
+
count
--;
+ dummy[
count
] = '\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 {
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;
}
return -EINVAL;
}
return count;
}
-L
PROC_SEQ_FOPS(lmv_
placement);
+L
USTRE_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;
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);
}
}
-L
PROC_SEQ_FOPS_RO(lmv_
activeobd);
+L
USTRE_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)
{
@@
-148,12
+143,14
@@
static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v)
seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid);
return 0;
}
seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid);
return 0;
}
+
LPROC_SEQ_FOPS_RO(lmv_desc_uuid);
static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos)
{
struct obd_device *dev = p->private;
struct lmv_obd *lmv = &dev->u.lmv;
LPROC_SEQ_FOPS_RO(lmv_desc_uuid);
static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos)
{
struct obd_device *dev = p->private;
struct lmv_obd *lmv = &dev->u.lmv;
+
return (*pos >= lmv->desc.ld_tgt_count) ? NULL : lmv->tgts[*pos];
}
return (*pos >= lmv->desc.ld_tgt_count) ? NULL : lmv->tgts[*pos];
}
@@
-182,7
+179,7
@@
static int lmv_tgt_seq_show(struct seq_file *p, void *v)
return 0;
}
return 0;
}
-static struct seq_operations lmv_tgt_sops = {
+static
const
struct seq_operations lmv_tgt_sops = {
.start = lmv_tgt_seq_start,
.stop = lmv_tgt_seq_stop,
.next = lmv_tgt_seq_next,
.start = lmv_tgt_seq_start,
.stop = lmv_tgt_seq_stop,
.next = lmv_tgt_seq_next,
@@
-199,29
+196,16
@@
static int lmv_target_seq_open(struct inode *inode, struct file *file)
return rc;
seq = file->private_data;
return rc;
seq = file->private_data;
- seq->private =
PDE_DATA(inode)
;
+ seq->private =
inode->i_private
;
return 0;
}
return 0;
}
-LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid);
-
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 },
- { "uuid", &lmv_uuid_fops, NULL, 0 },
{ "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 },
{ NULL }
};
{ "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 },
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs);
-
-static struct lprocfs_vars lprocfs_lmv_module_vars[] = {
- { "num_refs", &lmv_numrefs_fops, NULL, 0 },
- { NULL }
-};
-
struct file_operations lmv_proc_target_fops = {
.owner = THIS_MODULE,
.open = lmv_target_seq_open,
struct file_operations lmv_proc_target_fops = {
.owner = THIS_MODULE,
.open = lmv_target_seq_open,
@@
-230,8
+214,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->
module_vars = lprocfs_lmv_module_vars
;
+ lvars->
sysfs_vars = &lmv_attr_group
;
lvars->obd_vars = lprocfs_lmv_obd_vars;
}
lvars->obd_vars = lprocfs_lmv_obd_vars;
}