X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flod%2Flproc_lod.c;h=cbf7160807a8e5dc7905ca3e81ee9b74a6934cd9;hb=083d62ee6de5ac6cee95c1d2f86b62b75034093b;hp=b02697f057d4eb0dc020d952fa6d4d47474a290b;hpb=6fc8da41f2ff5156639e89f379adcdbb73ac8567;p=fs%2Flustre-release.git diff --git a/lustre/lod/lproc_lod.c b/lustre/lod/lproc_lod.c index b02697f..cbf7160 100644 --- a/lustre/lod/lproc_lod.c +++ b/lustre/lod/lproc_lod.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved * Use is subject to license terms. * - * Copyright (c) 2012, 2015, Intel Corporation. + * Copyright (c) 2012, 2017, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -39,7 +35,7 @@ #include #include #include "lod_internal.h" -#include +#include /* * Notice, all the functions below (except for lod_procfs_init() and @@ -58,6 +54,80 @@ * \retval 0 on success * \retval negative error code if failed */ +static int lod_dom_stripesize_seq_show(struct seq_file *m, void *v) +{ + struct obd_device *dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); + seq_printf(m, "%u\n", lod->lod_dom_max_stripesize); + return 0; +} + +/** + * Set default stripe size. + * + * \param[in] file proc file + * \param[in] buffer string containing the maximum number of bytes stored in + * each object before moving to the next object in the + * layout (if any) + * \param[in] count @buffer length + * \param[in] off unused for single entry + * + * \retval @count on success + * \retval negative error code if failed + */ +static ssize_t +lod_dom_stripesize_seq_write(struct file *file, const char __user *buffer, + size_t count, loff_t *off) +{ + struct seq_file *m = file->private_data; + struct obd_device *dev = m->private; + struct lod_device *lod; + s64 val; + int rc; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); + rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1'); + if (rc) + return rc; + if (val < 0) + return -ERANGE; + + /* 1GB is the limit */ + if (val > (1ULL << 30)) + return -ERANGE; + else if (val > 0) { + if (val < LOV_MIN_STRIPE_SIZE) { + LCONSOLE_INFO("Increasing provided stripe size to " + "a minimum value %u\n", + LOV_MIN_STRIPE_SIZE); + val = LOV_MIN_STRIPE_SIZE; + } else if (val & (LOV_MIN_STRIPE_SIZE - 1)) { + val &= ~(LOV_MIN_STRIPE_SIZE - 1); + LCONSOLE_WARN("Changing provided stripe size to %llu " + "(a multiple of minimum %u)\n", + val, LOV_MIN_STRIPE_SIZE); + } + } + + lod->lod_dom_max_stripesize = val; + + return count; +} +LPROC_SEQ_FOPS(lod_dom_stripesize); + +/** + * Show default stripe size. + * + * \param[in] m seq file + * \param[in] v unused for single entry + * + * \retval 0 on success + * \retval negative error code if failed + */ static int lod_stripesize_seq_show(struct seq_file *m, void *v) { struct obd_device *dev = m->private; @@ -65,8 +135,9 @@ static int lod_stripesize_seq_show(struct seq_file *m, void *v) LASSERT(dev != NULL); lod = lu2lod_dev(dev->obd_lu_dev); - return seq_printf(m, LPU64"\n", - lod->lod_desc.ld_default_stripe_size); + seq_printf(m, "%llu\n", + lod->lod_desc.ld_default_stripe_size); + return 0; } /** @@ -86,20 +157,23 @@ static ssize_t lod_stripesize_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct seq_file *m = file->private_data; + struct seq_file *m = file->private_data; struct obd_device *dev = m->private; struct lod_device *lod; - __u64 val; + s64 val; int rc; LASSERT(dev != NULL); lod = lu2lod_dev(dev->obd_lu_dev); - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1'); if (rc) return rc; + if (val < 0) + return -ERANGE; lod_fix_desc_stripe_size(&val); lod->lod_desc.ld_default_stripe_size = val; + return count; } LPROC_SEQ_FOPS(lod_stripesize); @@ -113,15 +187,14 @@ LPROC_SEQ_FOPS(lod_stripesize); * \retval 0 on success * \retval negative error code if failed */ -static int lod_stripeoffset_seq_show(struct seq_file *m, void *v) +static ssize_t stripeoffset_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; - struct lod_device *lod; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - return seq_printf(m, LPU64"\n", - lod->lod_desc.ld_default_stripe_offset); + return sprintf(buf, "%lld\n", lod->lod_desc.ld_default_stripe_offset); } /** @@ -138,26 +211,27 @@ static int lod_stripeoffset_seq_show(struct seq_file *m, void *v) * \retval @count on success * \retval negative error code if failed */ -static ssize_t -lod_stripeoffset_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripeoffset_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct seq_file *m = file->private_data; - struct obd_device *dev = m->private; - struct lod_device *lod; - __u64 val; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); + long val; int rc; - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtol(buffer, 0, &val); if (rc) return rc; + if (val < -1 || val > LOV_MAX_STRIPE_COUNT) + return -ERANGE; + lod->lod_desc.ld_default_stripe_offset = val; + return count; } -LPROC_SEQ_FOPS(lod_stripeoffset); +LUSTRE_RW_ATTR(stripeoffset); /** * Show default striping pattern (LOV_PATTERN_*). @@ -168,14 +242,14 @@ LPROC_SEQ_FOPS(lod_stripeoffset); * \retval 0 on success * \retval negative error code if failed */ -static int lod_stripetype_seq_show(struct seq_file *m, void *v) +static ssize_t stripetype_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; - struct lod_device *lod; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - return seq_printf(m, "%u\n", lod->lod_desc.ld_pattern); + return sprintf(buf, "%u\n", lod->lod_desc.ld_pattern); } /** @@ -190,26 +264,25 @@ static int lod_stripetype_seq_show(struct seq_file *m, void *v) * \retval @count on success * \retval negative error code if failed */ -static ssize_t -lod_stripetype_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripetype_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct seq_file *m = file->private_data; - struct obd_device *dev = m->private; - struct lod_device *lod; - int val, rc; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); + u32 pattern; + int rc; - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtouint(buffer, 0, &pattern); if (rc) return rc; - lod_fix_desc_pattern(&val); - lod->lod_desc.ld_pattern = val; + lod_fix_desc_pattern(&pattern); + lod->lod_desc.ld_pattern = pattern; + return count; } -LPROC_SEQ_FOPS(lod_stripetype); +LUSTRE_RW_ATTR(stripetype); /** * Show default number of stripes. @@ -220,15 +293,15 @@ LPROC_SEQ_FOPS(lod_stripetype); * \retval 0 on success, * \retval negative error code if failed */ -static int lod_stripecount_seq_show(struct seq_file *m, void *v) +static ssize_t stripecount_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; - struct lod_device *lod; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - return seq_printf(m, "%d\n", - (__s16)(lod->lod_desc.ld_default_stripe_count + 1) - 1); + return sprintf(buf, "%d\n", + (s16)(lod->lod_desc.ld_default_stripe_count + 1) - 1); } /** @@ -243,26 +316,25 @@ static int lod_stripecount_seq_show(struct seq_file *m, void *v) * \retval @count on success * \retval negative error code otherwise */ -static ssize_t -lod_stripecount_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripecount_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct seq_file *m = file->private_data; - struct obd_device *dev = m->private; - struct lod_device *lod; - int val, rc; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); + u32 stripe_count; + int rc; - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtouint(buffer, 0, &stripe_count); if (rc) return rc; - lod_fix_desc_stripe_count(&val); - lod->lod_desc.ld_default_stripe_count = val; + lod_fix_desc_stripe_count(&stripe_count); + lod->lod_desc.ld_default_stripe_count = stripe_count; + return count; } -LPROC_SEQ_FOPS(lod_stripecount); +LUSTRE_RW_ATTR(stripecount); /** * Show number of targets. @@ -273,16 +345,16 @@ LPROC_SEQ_FOPS(lod_stripecount); * \retval 0 on success * \retval negative error code if failed */ -static int lod_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 = m->private; - struct lod_device *lod; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - return seq_printf(m, "%u\n", lod->lod_desc.ld_tgt_count); + return sprintf(buf, "%u\n", lod->lod_desc.ld_tgt_count); } -LPROC_SEQ_FOPS_RO(lod_numobd); +LUSTRE_RO_ATTR(numobd); /** * Show number of active targets. @@ -293,16 +365,16 @@ LPROC_SEQ_FOPS_RO(lod_numobd); * \retval 0 on success * \retval negative error code if failed */ -static int lod_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 = m->private; - struct lod_device *lod; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - return seq_printf(m, "%u\n", lod->lod_desc.ld_active_tgt_count); + return sprintf(buf, "%u\n", lod->lod_desc.ld_active_tgt_count); } -LPROC_SEQ_FOPS_RO(lod_activeobd); +LUSTRE_RO_ATTR(activeobd); /** * Show UUID of LOD device. @@ -313,16 +385,16 @@ LPROC_SEQ_FOPS_RO(lod_activeobd); * \retval 0 on success * \retval negative error code if failed */ -static int lod_desc_uuid_seq_show(struct seq_file *m, void *v) +static ssize_t desc_uuid_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; - struct lod_device *lod; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - return seq_printf(m, "%s\n", lod->lod_desc.ld_uuid.uuid); + return sprintf(buf, "%s\n", lod->lod_desc.ld_uuid.uuid); } -LPROC_SEQ_FOPS_RO(lod_desc_uuid); +LUSTRE_RO_ATTR(desc_uuid); /** * Show QoS priority parameter. @@ -338,14 +410,15 @@ LPROC_SEQ_FOPS_RO(lod_desc_uuid); * \retval 0 on success * \retval negative error code if failed */ -static int lod_qos_priofree_seq_show(struct seq_file *m, void *v) +static ssize_t qos_prio_free_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; - struct lod_device *lod = lu2lod_dev(dev->obd_lu_dev); + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); - LASSERT(lod != NULL); - return seq_printf(m, "%d%%\n", - (lod->lod_qos.lq_prio_free * 100 + 255) >> 8); + return sprintf(buf, "%d%%\n", + (lod->lod_qos.lq_prio_free * 100 + 255) >> 8); } /** @@ -364,19 +437,16 @@ static int lod_qos_priofree_seq_show(struct seq_file *m, void *v) * \retval @count on success * \retval negative error code if failed */ -static ssize_t -lod_qos_priofree_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +static ssize_t qos_prio_free_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct seq_file *m = file->private_data; - struct obd_device *dev = m->private; - struct lod_device *lod; - int val, rc; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); + unsigned int val; + int rc; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtouint(buffer, 0, &val); if (rc) return rc; @@ -385,9 +455,10 @@ lod_qos_priofree_seq_write(struct file *file, const char __user *buffer, lod->lod_qos.lq_prio_free = (val << 8) / 100; lod->lod_qos.lq_dirty = 1; lod->lod_qos.lq_reset = 1; + return count; } -LPROC_SEQ_FOPS(lod_qos_priofree); +LUSTRE_RW_ATTR(qos_prio_free); /** * Show threshold for "same space on all OSTs" rule. @@ -405,8 +476,9 @@ static int lod_qos_thresholdrr_seq_show(struct seq_file *m, void *v) LASSERT(dev != NULL); lod = lu2lod_dev(dev->obd_lu_dev); - return seq_printf(m, "%d%%\n", - (lod->lod_qos.lq_threshold_rr * 100 + 255) >> 8); + seq_printf(m, "%d%%\n", + (lod->lod_qos.lq_threshold_rr * 100 + 255) >> 8); + return 0; } /** @@ -430,15 +502,16 @@ static ssize_t lod_qos_thresholdrr_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { - struct seq_file *m = file->private_data; + struct seq_file *m = file->private_data; struct obd_device *dev = m->private; struct lod_device *lod; - int val, rc; + int rc; + __s64 val; LASSERT(dev != NULL); lod = lu2lod_dev(dev->obd_lu_dev); - rc = lprocfs_write_helper(buffer, count, &val); + rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '%'); if (rc) return rc; @@ -447,6 +520,7 @@ lod_qos_thresholdrr_seq_write(struct file *file, const char __user *buffer, lod->lod_qos.lq_threshold_rr = (val << 8) / 100; lod->lod_qos.lq_dirty = 1; + return count; } LPROC_SEQ_FOPS(lod_qos_thresholdrr); @@ -461,14 +535,14 @@ LPROC_SEQ_FOPS(lod_qos_thresholdrr); * \retval 0 on success * \retval negative error code if failed */ -static int lod_qos_maxage_seq_show(struct seq_file *m, void *v) +static ssize_t qos_maxage_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; - struct lod_device *lod; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - return seq_printf(m, "%u Sec\n", lod->lod_desc.ld_qos_maxage); + return sprintf(buf, "%u Sec\n", lod->lod_desc.ld_qos_maxage); } /** @@ -482,24 +556,21 @@ static int lod_qos_maxage_seq_show(struct seq_file *m, void *v) * \retval @count on success * \retval negative error code if failed */ -static ssize_t -lod_qos_maxage_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +static ssize_t qos_maxage_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct seq_file *m = file->private_data; - struct obd_device *dev = m->private; - struct lustre_cfg_bufs bufs; - struct lod_device *lod; - struct lu_device *next; - struct lustre_cfg *lcfg; - char str[32]; - unsigned int i; - int val, rc; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); + struct lustre_cfg_bufs bufs; + struct lu_device *next; + struct lustre_cfg *lcfg; + char str[32]; + unsigned int i; + int rc; + u32 val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtouint(buffer, 0, &val); if (rc) return rc; @@ -511,11 +582,12 @@ lod_qos_maxage_seq_write(struct file *file, const char __user *buffer, * propogate the value down to OSPs */ lustre_cfg_bufs_reset(&bufs, NULL); - sprintf(str, "%smaxage=%d", PARAM_OSP, val); + snprintf(str, 32, "%smaxage=%u", PARAM_OSP, val); lustre_cfg_bufs_set_string(&bufs, 1, str); - lcfg = lustre_cfg_new(LCFG_PARAM, &bufs); + OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen)); if (lcfg == NULL) return -ENOMEM; + lustre_cfg_init(lcfg, LCFG_PARAM, &bufs); lod_getref(&lod->lod_ost_descs); lod_foreach_ost(lod, i) { @@ -525,11 +597,11 @@ lod_qos_maxage_seq_write(struct file *file, const char __user *buffer, CERROR("can't set maxage on #%d: %d\n", i, rc); } lod_putref(lod, &lod->lod_ost_descs); - lustre_cfg_free(lcfg); + OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)); return count; } -LPROC_SEQ_FOPS(lod_qos_maxage); +LUSTRE_RW_ATTR(qos_maxage); static void *lod_osts_seq_start(struct seq_file *p, loff_t *pos) { @@ -612,9 +684,10 @@ static int lod_osts_seq_show(struct seq_file *p, void *v) } else if (rc) return rc; - return seq_printf(p, "%d: %s %sACTIVE\n", idx, - obd_uuid2str(&ost_desc->ltd_uuid), - active ? "" : "IN"); + seq_printf(p, "%d: %s %sACTIVE\n", idx, + obd_uuid2str(&ost_desc->ltd_uuid), + active ? "" : "IN"); + return 0; } static const struct seq_operations lod_osts_sops = { @@ -638,15 +711,6 @@ static int lod_osts_seq_open(struct inode *inode, struct file *file) return 0; } -LPROC_SEQ_FOPS_RO_TYPE(lod, uuid); - -LPROC_SEQ_FOPS_RO_TYPE(lod, dt_blksize); -LPROC_SEQ_FOPS_RO_TYPE(lod, dt_kbytestotal); -LPROC_SEQ_FOPS_RO_TYPE(lod, dt_kbytesfree); -LPROC_SEQ_FOPS_RO_TYPE(lod, dt_kbytesavail); -LPROC_SEQ_FOPS_RO_TYPE(lod, dt_filestotal); -LPROC_SEQ_FOPS_RO_TYPE(lod, dt_filesfree); - /** * Show whether special failout mode for testing is enabled or not. * @@ -656,15 +720,14 @@ LPROC_SEQ_FOPS_RO_TYPE(lod, dt_filesfree); * \retval 0 on success * \retval negative error code if failed */ -static int lod_lmv_failout_seq_show(struct seq_file *m, void *v) +static ssize_t lmv_failout_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; - struct lod_device *lod; + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); - - return seq_printf(m, "%d\n", lod->lod_lmv_failout ? 1 : 0); + return sprintf(buf, "%d\n", lod->lod_lmv_failout ? 1 : 0); } /** @@ -682,67 +745,32 @@ static int lod_lmv_failout_seq_show(struct seq_file *m, void *v) * \retval @count on success * \retval negative error code if failed */ -static ssize_t -lod_lmv_failout_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +static ssize_t lmv_failout_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct seq_file *m = file->private_data; - struct obd_device *dev = m->private; - struct lod_device *lod; - int val = 0; - int rc; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); + struct dt_device *dt = container_of(kobj, struct dt_device, + dd_kobj); + struct lod_device *lod = dt2lod_dev(dt); + bool val = 0; + int rc; - rc = lprocfs_write_helper(buffer, count, &val); - if (rc != 0) + rc = kstrtobool(buffer, &val); + if (rc) return rc; - if (val != 0) - lod->lod_lmv_failout = 1; - else - lod->lod_lmv_failout = 0; + lod->lod_lmv_failout = val; return count; } -LPROC_SEQ_FOPS(lod_lmv_failout); +LUSTRE_RW_ATTR(lmv_failout); static struct lprocfs_vars lprocfs_lod_obd_vars[] = { - { .name = "uuid", - .fops = &lod_uuid_fops }, { .name = "stripesize", .fops = &lod_stripesize_fops }, - { .name = "stripeoffset", - .fops = &lod_stripeoffset_fops }, - { .name = "stripecount", - .fops = &lod_stripecount_fops }, - { .name = "stripetype", - .fops = &lod_stripetype_fops }, - { .name = "numobd", - .fops = &lod_numobd_fops }, - { .name = "activeobd", - .fops = &lod_activeobd_fops }, - { .name = "desc_uuid", - .fops = &lod_desc_uuid_fops }, - { .name = "qos_prio_free", - .fops = &lod_qos_priofree_fops }, { .name = "qos_threshold_rr", .fops = &lod_qos_thresholdrr_fops }, - { .name = "qos_maxage", - .fops = &lod_qos_maxage_fops }, - { .name = "lmv_failout", - .fops = &lod_lmv_failout_fops }, - { NULL } -}; - -static struct lprocfs_vars lprocfs_lod_osd_vars[] = { - { "blocksize", &lod_dt_blksize_fops }, - { "kbytestotal", &lod_dt_kbytestotal_fops }, - { "kbytesfree", &lod_dt_kbytesfree_fops }, - { "kbytesavail", &lod_dt_kbytesavail_fops }, - { "filestotal", &lod_dt_filestotal_fops }, - { "filesfree", &lod_dt_filesfree_fops }, + { .name = "dom_stripesize", + .fops = &lod_dom_stripesize_fops }, { NULL } }; @@ -754,6 +782,19 @@ static const struct file_operations lod_proc_target_fops = { .release = lprocfs_seq_release, }; +static struct attribute *lod_attrs[] = { + &lustre_attr_stripeoffset.attr, + &lustre_attr_stripecount.attr, + &lustre_attr_stripetype.attr, + &lustre_attr_activeobd.attr, + &lustre_attr_desc_uuid.attr, + &lustre_attr_lmv_failout.attr, + &lustre_attr_numobd.attr, + &lustre_attr_qos_maxage.attr, + &lustre_attr_qos_prio_free.attr, + NULL, +}; + /** * Initialize procfs entries for LOD. * @@ -764,23 +805,28 @@ static const struct file_operations lod_proc_target_fops = { */ int lod_procfs_init(struct lod_device *lod) { - struct obd_device *obd = lod2obd(lod); - struct proc_dir_entry *lov_proc_dir = NULL; - struct obd_type *type; - int rc; + struct obd_device *obd = lod2obd(lod); + struct proc_dir_entry *lov_proc_dir; + struct obd_type *type; + struct kobject *lov; + int rc; - obd->obd_vars = lprocfs_lod_obd_vars; - rc = lprocfs_obd_setup(obd); + lod->lod_dt_dev.dd_ktype.default_attrs = lod_attrs; + rc = dt_tunables_init(&lod->lod_dt_dev, obd->obd_type, obd->obd_name, + NULL); if (rc) { - CERROR("%s: cannot setup procfs entry: %d\n", + CERROR("%s: failed to setup DT tunables: %d\n", obd->obd_name, rc); RETURN(rc); } - rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_lod_osd_vars, - &lod->lod_dt_dev); - if (rc) { - CERROR("%s: cannot setup procfs entry: %d\n", + obd->obd_vars = lprocfs_lod_obd_vars; + obd->obd_proc_entry = lprocfs_register(obd->obd_name, + obd->obd_type->typ_procroot, + obd->obd_vars, obd); + if (IS_ERR(obd->obd_proc_entry)) { + rc = PTR_ERR(obd->obd_proc_entry); + CERROR("%s: error %d setting up lprocfs\n", obd->obd_name, rc); GOTO(out, rc); } @@ -804,6 +850,19 @@ int lod_procfs_init(struct lod_device *lod) GOTO(out, rc); } + lov = kset_find_obj(lustre_kset, "lov"); + if (lov) { + rc = sysfs_create_link(lov, &lod->lod_dt_dev.dd_kobj, + obd->obd_name); + kobject_put(lov); + } + + lod->lod_debugfs = ldebugfs_add_symlink(obd->obd_name, "lov", + "../lod/%s", obd->obd_name); + if (!lod->lod_debugfs) + CERROR("%s: failed to create LOV debugfs symlink\n", + obd->obd_name); + /* If the real LOV is present which is the case for setups * with both server and clients on the same node then use * the LOV's proc root */ @@ -825,7 +884,7 @@ int lod_procfs_init(struct lod_device *lod) RETURN(0); out: - lprocfs_obd_cleanup(obd); + dt_tunables_fini(&lod->lod_dt_dev); return rc; } @@ -838,18 +897,28 @@ out: void lod_procfs_fini(struct lod_device *lod) { struct obd_device *obd = lod2obd(lod); + struct kobject *lov; if (lod->lod_symlink != NULL) { lprocfs_remove(&lod->lod_symlink); lod->lod_symlink = NULL; } - if (lod->lod_pool_proc_entry != NULL) { - lprocfs_remove(&lod->lod_pool_proc_entry); - lod->lod_pool_proc_entry = NULL; + lov = kset_find_obj(lustre_kset, "lov"); + if (lov) { + sysfs_remove_link(lov, obd->obd_name); + kobject_put(lov); + } + + if (!IS_ERR_OR_NULL(lod->lod_debugfs)) + ldebugfs_remove(&lod->lod_debugfs); + + if (obd->obd_proc_entry) { + lprocfs_remove(&obd->obd_proc_entry); + obd->obd_proc_entry = NULL; } - lprocfs_obd_cleanup(obd); + dt_tunables_fini(&lod->lod_dt_dev); } #endif /* CONFIG_PROC_FS */