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

staging/lustre: Move /proc/fs/lustre root level files to sysfs

except devices, for now.
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarDmitry Eremin <dmitry.eremin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5e66f70e
......@@ -350,6 +350,8 @@ enum {
/* class_obd.c */
extern struct proc_dir_entry *proc_lustre_root;
extern struct kobject *lustre_kobj;
struct obd_device;
struct obd_histogram;
......
......@@ -64,6 +64,7 @@
#include <linux/uaccess.h>
#include <linux/miscdevice.h>
#include <linux/seq_file.h>
#include <linux/kobject.h>
#include "../../../include/linux/libcfs/libcfs.h"
#include "../../../include/linux/lnet/lnetctl.h"
......@@ -216,29 +217,27 @@ struct miscdevice obd_psdev = {
};
#if defined (CONFIG_PROC_FS)
static int obd_proc_version_seq_show(struct seq_file *m, void *v)
static ssize_t version_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
seq_printf(m, "lustre: %s\nkernel: %s\nbuild: %s\n",
LUSTRE_VERSION_STRING, "patchless_client", BUILD_VERSION);
return 0;
return sprintf(buf, "%s\n", LUSTRE_VERSION_STRING);
}
LPROC_SEQ_FOPS_RO(obd_proc_version);
int obd_proc_pinger_seq_show(struct seq_file *m, void *v)
static ssize_t pinger_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
seq_printf(m, "%s\n", "on");
return 0;
return sprintf(buf, "%s\n", "on");
}
LPROC_SEQ_FOPS_RO(obd_proc_pinger);
static int obd_proc_health_seq_show(struct seq_file *m, void *v)
static ssize_t health_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
bool healthy = true;
int i;
size_t len = 0;
if (libcfs_catastrophe)
seq_printf(m, "LBUG\n");
return sprintf(buf, "LBUG\n");
read_lock(&obd_dev_lock);
for (i = 0; i < class_devno_max(); i++) {
......@@ -256,8 +255,6 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v)
read_unlock(&obd_dev_lock);
if (obd_health_check(NULL, obd)) {
seq_printf(m, "device %s reported unhealthy\n",
obd->obd_name);
healthy = false;
}
class_decref(obd, __func__, current);
......@@ -266,32 +263,29 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v)
read_unlock(&obd_dev_lock);
if (healthy)
seq_puts(m, "healthy\n");
len = sprintf(buf, "healthy\n");
else
seq_puts(m, "NOT HEALTHY\n");
len = sprintf(buf, "NOT HEALTHY\n");
return 0;
return len;
}
LPROC_SEQ_FOPS_RO(obd_proc_health);
static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v)
static ssize_t jobid_var_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
seq_printf(m, "%s\n", obd_jobid_var);
return 0;
return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_var);
}
static ssize_t obd_proc_jobid_var_seq_write(struct file *file,
const char __user *buffer,
size_t count, loff_t *off)
static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
const char *buffer,
size_t count)
{
if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN)
return -EINVAL;
memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1);
/* This might leave the var invalid on error, which is probably fine.*/
if (copy_from_user(obd_jobid_var, buffer, count))
return -EFAULT;
memcpy(obd_jobid_var, buffer, count);
/* Trim the trailing '\n' if any */
if (obd_jobid_var[count - 1] == '\n')
......@@ -299,23 +293,21 @@ static ssize_t obd_proc_jobid_var_seq_write(struct file *file,
return count;
}
LPROC_SEQ_FOPS(obd_proc_jobid_var);
static int obd_proc_jobid_name_seq_show(struct seq_file *m, void *v)
static ssize_t jobid_name_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
seq_printf(m, "%s\n", obd_jobid_var);
return 0;
return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_node);
}
static ssize_t obd_proc_jobid_name_seq_write(struct file *file,
const char __user *buffer,
size_t count, loff_t *off)
static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
const char *buffer,
size_t count)
{
if (!count || count > JOBSTATS_JOBID_SIZE)
return -EINVAL;
if (copy_from_user(obd_jobid_node, buffer, count))
return -EFAULT;
memcpy(obd_jobid_node, buffer, count);
obd_jobid_node[count] = 0;
......@@ -325,20 +317,25 @@ static ssize_t obd_proc_jobid_name_seq_write(struct file *file,
return count;
}
LPROC_SEQ_FOPS(obd_proc_jobid_name);
#if defined(CONFIG_PROC_FS)
/* Root for /proc/fs/lustre */
struct proc_dir_entry *proc_lustre_root = NULL;
EXPORT_SYMBOL(proc_lustre_root);
struct lprocfs_vars lprocfs_base[] = {
{ "version", &obd_proc_version_fops },
{ "pinger", &obd_proc_pinger_fops },
{ "health_check", &obd_proc_health_fops },
{ "jobid_var", &obd_proc_jobid_var_fops },
{ .name = "jobid_name",
.fops = &obd_proc_jobid_name_fops},
{ NULL }
LUSTRE_RO_ATTR(version);
LUSTRE_RO_ATTR(pinger);
LUSTRE_RO_ATTR(health);
LUSTRE_RW_ATTR(jobid_var);
LUSTRE_RW_ATTR(jobid_name);
static struct attribute *lustre_attrs[] = {
&lustre_attr_version.attr,
&lustre_attr_pinger.attr,
&lustre_attr_health.attr,
&lustre_attr_jobid_name.attr,
&lustre_attr_jobid_var.attr,
NULL,
};
static void *obd_device_list_seq_start(struct seq_file *p, loff_t *pos)
......@@ -419,15 +416,34 @@ struct file_operations obd_device_list_fops = {
.release = seq_release,
};
struct kobject *lustre_kobj;
EXPORT_SYMBOL_GPL(lustre_kobj);
static struct attribute_group lustre_attr_group = {
.attrs = lustre_attrs,
};
int class_procfs_init(void)
{
int rc = 0;
lustre_kobj = kobject_create_and_add("lustre", fs_kobj);
if (lustre_kobj == NULL)
goto out;
/* Create the files associated with this kobject */
rc = sysfs_create_group(lustre_kobj, &lustre_attr_group);
if (rc) {
kobject_put(lustre_kobj);
goto out;
}
proc_lustre_root = lprocfs_register("fs/lustre", NULL,
lprocfs_base, NULL);
NULL, NULL);
if (IS_ERR(proc_lustre_root)) {
rc = PTR_ERR(proc_lustre_root);
proc_lustre_root = NULL;
kobject_put(lustre_kobj);
goto out;
}
......@@ -444,6 +460,9 @@ int class_procfs_clean(void)
if (proc_lustre_root) {
lprocfs_remove(&proc_lustre_root);
}
kobject_put(lustre_kobj);
return 0;
}
#endif /* CONFIG_PROC_FS */
What: /sys/fs/lustre/version
Date: May 2015
Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description:
Shows current running lustre version.
What: /sys/fs/lustre/pinger
Date: May 2015
Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description:
Shows if the lustre module has pinger support.
"on" means yes and "off" means no.
What: /sys/fs/lustre/health
Date: May 2015
Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description:
Shows whenever current system state believed to be "healthy",
"NOT HEALTHY", or "LBUG" whenever lustre has experienced
an internal assertion failure
What: /sys/fs/lustre/jobid_name
Date: May 2015
Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description:
Currently running job "name" for this node to be transferred
to Lustre servers for purposes of QoS and statistics gathering.
Writing into this file will change the name, reading outputs
currently set value.
What: /sys/fs/lustre/jobid_var
Date: May 2015
Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description:
Control file for lustre "jobstats" functionality, write new
value from the list below to change the mode:
disable - disable job name reporting to the servers (default)
procname_uid - form the job name as the current running
command name and pid with a dot in between
e.g. dd.1253
nodelocal - use jobid_name value from above.
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