staging/lustre/obdclass: Move common obd proc files to sysfs
authorOleg Drokin <green@linuxhacker.ru>
Thu, 21 May 2015 19:32:17 +0000 (15:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 02:18:23 +0000 (11:18 +0900)
This moves uuid display and also underlying fs statistics.

Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/lprocfs_status.h
drivers/staging/lustre/lustre/lmv/lproc_lmv.c
drivers/staging/lustre/lustre/lov/lproc_lov.c
drivers/staging/lustre/lustre/mdc/lproc_mdc.c
drivers/staging/lustre/lustre/mgc/lproc_mgc.c
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
drivers/staging/lustre/lustre/osc/lproc_osc.c
drivers/staging/lustre/sysfs-fs-lustre

index 3225e3c20992cbced121e097a90fc659a36f2f94..bbacda6ebd9191337fc2d5aeed8611687ff2badf 100644 (file)
@@ -633,7 +633,6 @@ extern int lprocfs_wr_atomic(struct file *file, const char __user *buffer,
 extern int lprocfs_rd_uint(struct seq_file *m, void *data);
 extern int lprocfs_wr_uint(struct file *file, const char __user *buffer,
                           unsigned long count, void *data);
-extern int lprocfs_rd_uuid(struct seq_file *m, void *data);
 extern int lprocfs_rd_name(struct seq_file *m, void *data);
 extern int lprocfs_rd_server_uuid(struct seq_file *m, void *data);
 extern int lprocfs_rd_conn_uuid(struct seq_file *m, void *data);
@@ -658,12 +657,6 @@ extern int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
                                   size_t count, loff_t *off);
 
 /* Statfs helpers */
-extern int lprocfs_rd_blksize(struct seq_file *m, void *data);
-extern int lprocfs_rd_kbytestotal(struct seq_file *m, void *data);
-extern int lprocfs_rd_kbytesfree(struct seq_file *m, void *data);
-extern int lprocfs_rd_kbytesavail(struct seq_file *m, void *data);
-extern int lprocfs_rd_filestotal(struct seq_file *m, void *data);
-extern int lprocfs_rd_filesfree(struct seq_file *m, void *data);
 
 extern int lprocfs_write_helper(const char __user *buffer, unsigned long count,
                                int *val);
index 76b32d56eb081cedc1ec1a993c08a60d3ffa1cdd..debd8972f99f9f7ea37e2aea3542798e49b41547 100644 (file)
@@ -204,13 +204,10 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid);
-
 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 }
 };
index 18fdd7ec75c45b5590f28fd2def735e90f69228b..92489daa5f32e1b5ac871c6b1780f0713d5118e8 100644 (file)
@@ -262,29 +262,14 @@ static int lov_target_seq_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-LPROC_SEQ_FOPS_RO_TYPE(lov, uuid);
-LPROC_SEQ_FOPS_RO_TYPE(lov, filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(lov, filesfree);
-LPROC_SEQ_FOPS_RO_TYPE(lov, blksize);
-LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail);
-
 static struct lprocfs_vars lprocfs_lov_obd_vars[] = {
-       { "uuid",         &lov_uuid_fops,         NULL, 0 },
        { "stripesize",   &lov_stripesize_fops,   NULL },
        { "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 },
-       { "filestotal",   &lov_filestotal_fops,   NULL, 0 },
-       { "filesfree",    &lov_filesfree_fops,    NULL, 0 },
        /*{ "filegroups", lprocfs_rd_filegroups,  NULL, 0 },*/
-       { "blocksize",    &lov_blksize_fops,      NULL, 0 },
-       { "kbytestotal",  &lov_kbytestotal_fops,  NULL, 0 },
-       { "kbytesfree",   &lov_kbytesfree_fops,   NULL, 0 },
-       { "kbytesavail",  &lov_kbytesavail_fops,  NULL, 0 },
        { "desc_uuid",    &lov_desc_uuid_fops,    NULL, 0 },
        { NULL }
 };
index 5c38cd7c22e76f9ebe41db772cff12f25e7b718f..b1ef178b6f2fc5ae50268e034cd54a82e5fc8947 100644 (file)
@@ -155,14 +155,7 @@ static struct file_operations mdc_kuc_fops = {
 
 LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
 
-LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
@@ -178,15 +171,8 @@ LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
 
 static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
-       { "uuid",               &mdc_uuid_fops,                 NULL, 0 },
        { "ping",               &mdc_ping_fops,                 NULL, 0222 },
        { "connect_flags",      &mdc_connect_flags_fops,        NULL, 0 },
-       { "blocksize",          &mdc_blksize_fops,              NULL, 0 },
-       { "kbytestotal",        &mdc_kbytestotal_fops,          NULL, 0 },
-       { "kbytesfree",         &mdc_kbytesfree_fops,           NULL, 0 },
-       { "kbytesavail",        &mdc_kbytesavail_fops,          NULL, 0 },
-       { "filestotal",         &mdc_filestotal_fops,           NULL, 0 },
-       { "filesfree",          &mdc_filesfree_fops,            NULL, 0 },
        /*{ "filegroups",       lprocfs_rd_filegroups,          NULL, 0 },*/
        { "mds_server_uuid",    &mdc_server_uuid_fops,          NULL, 0 },
        { "mds_conn_uuid",      &mdc_conn_uuid_fops,            NULL, 0 },
index ad889e71bd6c48f97bcdc23e988257fe5d8afb4e..34a9317d6d63cf56013a9e6be4c153bdfe38238b 100644 (file)
@@ -40,7 +40,6 @@
 #include "../include/lprocfs_status.h"
 #include "mgc_internal.h"
 
-LPROC_SEQ_FOPS_RO_TYPE(mgc, uuid);
 LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags);
 LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(mgc, conn_uuid);
@@ -56,7 +55,6 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v)
 LPROC_SEQ_FOPS_RO(mgc_ir_state);
 
 static struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
-       { "uuid",            &mgc_uuid_fops,      NULL, 0 },
        { "ping",            &mgc_ping_fops,      NULL, 0222 },
        { "connect_flags",   &mgc_connect_flags_fops, NULL, 0 },
        { "mgs_server_uuid", &mgc_server_uuid_fops,   NULL, 0 },
index e6f0d11205c907628040cdc5856ddb22f62589c9..5b1b59a6187b607c86e21bfb8ae798f157759444 100644 (file)
@@ -501,15 +501,15 @@ int lprocfs_wr_atomic(struct file *file, const char __user *buffer,
 }
 EXPORT_SYMBOL(lprocfs_wr_atomic);
 
-int lprocfs_rd_uuid(struct seq_file *m, void *data)
+static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
+                        char *buf)
 {
-       struct obd_device *obd = data;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kobj);
 
-       LASSERT(obd != NULL);
-       seq_printf(m, "%s\n", obd->obd_uuid.uuid);
-       return 0;
+       return sprintf(buf, "%s\n", obd->obd_uuid.uuid);
 }
-EXPORT_SYMBOL(lprocfs_rd_uuid);
+LUSTRE_RO_ATTR(uuid);
 
 int lprocfs_rd_name(struct seq_file *m, void *data)
 {
@@ -521,23 +521,27 @@ int lprocfs_rd_name(struct seq_file *m, void *data)
 }
 EXPORT_SYMBOL(lprocfs_rd_name);
 
-int lprocfs_rd_blksize(struct seq_file *m, void *data)
+static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
+                             char *buf)
 {
-       struct obd_device *obd = data;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kobj);
        struct obd_statfs  osfs;
        int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                            OBD_STATFS_NODELAY);
        if (!rc)
-               seq_printf(m, "%u\n", osfs.os_bsize);
+               return sprintf(buf, "%u\n", osfs.os_bsize);
 
        return rc;
 }
-EXPORT_SYMBOL(lprocfs_rd_blksize);
+LUSTRE_RO_ATTR(blocksize);
 
-int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
+static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
+                               char *buf)
 {
-       struct obd_device *obd = data;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kobj);
        struct obd_statfs  osfs;
        int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
@@ -549,16 +553,18 @@ int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               seq_printf(m, "%llu\n", result);
+               return sprintf(buf, "%llu\n", result);
        }
 
        return rc;
 }
-EXPORT_SYMBOL(lprocfs_rd_kbytestotal);
+LUSTRE_RO_ATTR(kbytestotal);
 
-int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
+static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
+                              char *buf)
 {
-       struct obd_device *obd = data;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kobj);
        struct obd_statfs  osfs;
        int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
@@ -570,16 +576,18 @@ int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               seq_printf(m, "%llu\n", result);
+               return sprintf(buf, "%llu\n", result);
        }
 
        return rc;
 }
-EXPORT_SYMBOL(lprocfs_rd_kbytesfree);
+LUSTRE_RO_ATTR(kbytesfree);
 
-int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
+static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
+                               char *buf)
 {
-       struct obd_device *obd = data;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kobj);
        struct obd_statfs  osfs;
        int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
@@ -591,40 +599,44 @@ int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               seq_printf(m, "%llu\n", result);
+               return sprintf(buf, "%llu\n", result);
        }
 
        return rc;
 }
-EXPORT_SYMBOL(lprocfs_rd_kbytesavail);
+LUSTRE_RO_ATTR(kbytesavail);
 
-int lprocfs_rd_filestotal(struct seq_file *m, void *data)
+static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
+                              char *buf)
 {
-       struct obd_device *obd = data;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kobj);
        struct obd_statfs  osfs;
        int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                            OBD_STATFS_NODELAY);
        if (!rc)
-               seq_printf(m, "%llu\n", osfs.os_files);
+               return sprintf(buf, "%llu\n", osfs.os_files);
 
        return rc;
 }
-EXPORT_SYMBOL(lprocfs_rd_filestotal);
+LUSTRE_RO_ATTR(filestotal);
 
-int lprocfs_rd_filesfree(struct seq_file *m, void *data)
+static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
+                             char *buf)
 {
-       struct obd_device *obd = data;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kobj);
        struct obd_statfs  osfs;
        int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                            OBD_STATFS_NODELAY);
        if (!rc)
-               seq_printf(m, "%llu\n", osfs.os_ffree);
+               return sprintf(buf, "%llu\n", osfs.os_ffree);
 
        return rc;
 }
-EXPORT_SYMBOL(lprocfs_rd_filesfree);
+LUSTRE_RO_ATTR(filesfree);
 
 int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
 {
@@ -995,6 +1007,13 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
 EXPORT_SYMBOL(lprocfs_rd_connect_flags);
 
 static struct attribute *obd_def_attrs[] = {
+       &lustre_attr_blocksize.attr,
+       &lustre_attr_kbytestotal.attr,
+       &lustre_attr_kbytesfree.attr,
+       &lustre_attr_kbytesavail.attr,
+       &lustre_attr_filestotal.attr,
+       &lustre_attr_filesfree.attr,
+       &lustre_attr_uuid.attr,
        NULL,
 };
 
index 93ad272fe46dd294304ca7d5cfa9d46df50eb798..199913d7dddfba19a63c56b34ec047b6a3aabb9e 100644 (file)
@@ -520,14 +520,7 @@ static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
 }
 LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc);
 
-LPROC_SEQ_FOPS_RO_TYPE(osc, uuid);
 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
-LPROC_SEQ_FOPS_RO_TYPE(osc, blksize);
-LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail);
-LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree);
 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
@@ -539,15 +532,8 @@ LPROC_SEQ_FOPS_RW_TYPE(osc, import);
 LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
 
 static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
-       { "uuid",            &osc_uuid_fops,    NULL, 0 },
        { "ping",            &osc_ping_fops,    NULL, 0222 },
        { "connect_flags",   &osc_connect_flags_fops, NULL, 0 },
-       { "blocksize",       &osc_blksize_fops,     NULL, 0 },
-       { "kbytestotal",     &osc_kbytestotal_fops, NULL, 0 },
-       { "kbytesfree",      &osc_kbytesfree_fops,  NULL, 0 },
-       { "kbytesavail",     &osc_kbytesavail_fops, NULL, 0 },
-       { "filestotal",      &osc_filestotal_fops,  NULL, 0 },
-       { "filesfree",       &osc_filesfree_fops,   NULL, 0 },
        /*{ "filegroups",      lprocfs_rd_filegroups,  NULL, 0 },*/
        { "ost_server_uuid", &osc_server_uuid_fops, NULL, 0 },
        { "ost_conn_uuid",   &osc_conn_uuid_fops, NULL, 0 },
index 9817cb37020a70395b0c5da4e0baeeb6b6548d75..61101f272a39ef50f17817b21fd940229d30b60e 100644 (file)
@@ -336,3 +336,51 @@ Contact:   "Oleg Drokin" <oleg.drokin@intel.com>
 Description:
                Controls what percentage of ldlm callback threads is dedicated
                to "high priority" incoming requests.
+
+What:          /sys/fs/lustre/{obdtype}/{connection_name}/blocksize
+Date:          May 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Blocksize on backend filesystem for service behind this obd
+               device (or biggest blocksize for compound devices like lov
+               and lmv)
+
+What:          /sys/fs/lustre/{obdtype}/{connection_name}/kbytestotal
+Date:          May 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Total number of kilobytes of space on backend filesystem
+               for service behind this obd (or total amount for compound
+               devices like lov lmv)
+
+What:          /sys/fs/lustre/{obdtype}/{connection_name}/kbytesfree
+Date:          May 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Number of free kilobytes on backend filesystem for service
+               behind this obd (or total amount for compound devices
+               like lov lmv)
+
+What:          /sys/fs/lustre/{obdtype}/{connection_name}/kbytesavail
+Date:          May 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Number of kilobytes of free space on backend filesystem
+               for service behind this obd (or total amount for compound
+               devices like lov lmv) that is actually available for use
+               (taking into account per-client and filesystem reservations).
+
+What:          /sys/fs/lustre/{obdtype}/{connection_name}/filestotal
+Date:          May 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Number of inodes on backend filesystem for service behind this
+               obd.
+
+What:          /sys/fs/lustre/{obdtype}/{connection_name}/filesfree
+Date:          May 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Number of free inodes on backend filesystem for service
+               behind this obd.
+