4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 #define DEBUG_SUBSYSTEM S_CLASS
34 #include <lprocfs_status.h>
35 #include <obd_class.h>
36 #include <linux/seq_file.h>
37 #include "lod_internal.h"
38 #include <uapi/linux/lustre/lustre_param.h>
41 * Notice, all the functions below (except for lod_procfs_init() and
42 * lod_procfs_fini()) are not supposed to be used directly. They are
43 * called by Linux kernel's procfs.
49 * Show DoM default stripe size.
51 static ssize_t dom_stripesize_show(struct kobject *kobj, struct attribute *attr,
54 struct dt_device *dt = container_of(kobj, struct dt_device,
56 struct lod_device *lod = dt2lod_dev(dt);
58 return snprintf(buf, PAGE_SIZE, "%u\n", lod->lod_dom_max_stripesize);
62 * Set DoM default stripe size.
64 static ssize_t dom_stripesize_store(struct kobject *kobj,
65 struct attribute *attr, const char *buffer,
68 struct dt_device *dt = container_of(kobj, struct dt_device,
70 struct lod_device *lod = dt2lod_dev(dt);
74 rc = sysfs_memparse(buffer, count, &val, "B");
78 /* 1GB is the limit */
79 if (val > (1ULL << 30))
83 if (val < LOV_MIN_STRIPE_SIZE) {
84 LCONSOLE_INFO("Increasing provided stripe size to "
85 "a minimum value %u\n",
87 val = LOV_MIN_STRIPE_SIZE;
88 } else if (val & (LOV_MIN_STRIPE_SIZE - 1)) {
89 val &= ~(LOV_MIN_STRIPE_SIZE - 1);
90 LCONSOLE_WARN("Changing provided stripe size to %llu "
91 "(a multiple of minimum %u)\n",
92 val, LOV_MIN_STRIPE_SIZE);
96 lod->lod_dom_max_stripesize = val;
101 LUSTRE_RW_ATTR(dom_stripesize);
103 static ssize_t stripesize_show(struct kobject *kobj, struct attribute *attr,
106 struct dt_device *dt = container_of(kobj, struct dt_device,
108 struct lod_device *lod = dt2lod_dev(dt);
110 return snprintf(buf, PAGE_SIZE, "%llu\n",
111 lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_size);
114 static ssize_t stripesize_store(struct kobject *kobj, struct attribute *attr,
115 const char *buffer, size_t count)
117 struct dt_device *dt = container_of(kobj, struct dt_device,
119 struct lod_device *lod = dt2lod_dev(dt);
123 rc = sysfs_memparse(buffer, count, &val, "B");
127 lod_fix_desc_stripe_size(&val);
128 lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_size = val;
133 LUSTRE_RW_ATTR(stripesize);
136 * Show default stripe offset.
138 static ssize_t stripeoffset_show(struct kobject *kobj, struct attribute *attr,
141 struct dt_device *dt = container_of(kobj, struct dt_device,
143 struct lod_device *lod = dt2lod_dev(dt);
145 return snprintf(buf, PAGE_SIZE, "%lld\n",
146 lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_offset);
150 * Set default stripe offset.
152 * Usually contains -1 allowing Lustre to balance objects among OST
153 * otherwise may cause severe OST imbalance.
155 static ssize_t stripeoffset_store(struct kobject *kobj,
156 struct attribute *attr,
157 const char *buffer, size_t count)
159 struct dt_device *dt = container_of(kobj, struct dt_device,
161 struct lod_device *lod = dt2lod_dev(dt);
165 rc = kstrtol(buffer, 0, &val);
169 if (val < -1 || val > LOV_MAX_STRIPE_COUNT)
172 lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_offset = val;
177 LUSTRE_RW_ATTR(stripeoffset);
180 * Show default striping pattern (LOV_PATTERN_*).
182 static ssize_t __stripetype_show(struct kobject *kobj, struct attribute *attr,
183 char *buf, bool is_mdt)
185 struct dt_device *dt = container_of(kobj, struct dt_device,
187 struct lod_device *lod = dt2lod_dev(dt);
188 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
191 return snprintf(buf, PAGE_SIZE, "%u\n", ltd->ltd_lov_desc.ld_pattern);
194 static ssize_t mdt_stripetype_show(struct kobject *kobj, struct attribute *attr,
197 return __stripetype_show(kobj, attr, buf, true);
200 static ssize_t stripetype_show(struct kobject *kobj, struct attribute *attr,
203 return __stripetype_show(kobj, attr, buf, false);
207 * Set default striping pattern (a number, not a human-readable string).
209 static ssize_t __stripetype_store(struct kobject *kobj, struct attribute *attr,
210 const char *buffer, size_t count, bool is_mdt)
212 struct dt_device *dt = container_of(kobj, struct dt_device,
214 struct lod_device *lod = dt2lod_dev(dt);
215 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
220 rc = kstrtouint(buffer, 0, &pattern);
225 lod_fix_lmv_desc_pattern(&pattern);
227 lod_fix_desc_pattern(&pattern);
229 ltd->ltd_lov_desc.ld_pattern = pattern;
234 static ssize_t mdt_stripetype_store(struct kobject *kobj,
235 struct attribute *attr, const char *buffer,
238 return __stripetype_store(kobj, attr, buffer, count, true);
241 static ssize_t stripetype_store(struct kobject *kobj,
242 struct attribute *attr, const char *buffer,
245 return __stripetype_store(kobj, attr, buffer, count, false);
248 LUSTRE_RW_ATTR(mdt_stripetype);
249 LUSTRE_RW_ATTR(stripetype);
252 * Show default number of stripes.
254 static ssize_t __stripecount_show(struct kobject *kobj, struct attribute *attr,
255 char *buf, bool is_mdt)
257 struct dt_device *dt = container_of(kobj, struct dt_device,
259 struct lod_device *lod = dt2lod_dev(dt);
260 struct lov_desc *desc = is_mdt ? &lod->lod_mdt_descs.ltd_lov_desc :
261 &lod->lod_ost_descs.ltd_lov_desc;
263 return snprintf(buf, PAGE_SIZE, "%d\n",
264 (s16)(desc->ld_default_stripe_count + 1) - 1);
267 static ssize_t mdt_stripecount_show(struct kobject *kobj,
268 struct attribute *attr, char *buf)
270 return __stripecount_show(kobj, attr, buf, true);
273 static ssize_t stripecount_show(struct kobject *kobj, struct attribute *attr,
276 return __stripecount_show(kobj, attr, buf, false);
280 * Set default number of stripes.
282 static ssize_t __stripecount_store(struct kobject *kobj, struct attribute *attr,
283 const char *buffer, size_t count,
286 struct dt_device *dt = container_of(kobj, struct dt_device,
288 struct lod_device *lod = dt2lod_dev(dt);
289 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
294 rc = kstrtoint(buffer, 0, &stripe_count);
298 if (stripe_count < -1)
301 lod_fix_desc_stripe_count(&stripe_count);
302 ltd->ltd_lov_desc.ld_default_stripe_count = stripe_count;
307 static ssize_t mdt_stripecount_store(struct kobject *kobj,
308 struct attribute *attr,
309 const char *buffer, size_t count)
311 return __stripecount_store(kobj, attr, buffer, count, true);
314 static ssize_t stripecount_store(struct kobject *kobj,
315 struct attribute *attr,
316 const char *buffer, size_t count)
318 return __stripecount_store(kobj, attr, buffer, count, false);
321 LUSTRE_RW_ATTR(mdt_stripecount);
322 LUSTRE_RW_ATTR(stripecount);
325 * Show number of targets.
327 static ssize_t __numobd_show(struct kobject *kobj, struct attribute *attr,
328 char *buf, bool is_mdt)
330 struct dt_device *dt = container_of(kobj, struct dt_device,
332 struct lod_device *lod = dt2lod_dev(dt);
333 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
336 return snprintf(buf, PAGE_SIZE, "%u\n", ltd->ltd_lov_desc.ld_tgt_count);
339 static ssize_t mdt_numobd_show(struct kobject *kobj, struct attribute *attr,
342 return __numobd_show(kobj, attr, buf, true);
345 static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr,
348 return __numobd_show(kobj, attr, buf, false);
351 LUSTRE_RO_ATTR(mdt_numobd);
352 LUSTRE_RO_ATTR(numobd);
355 * Show number of active targets.
357 static ssize_t __activeobd_show(struct kobject *kobj, struct attribute *attr,
358 char *buf, bool is_mdt)
360 struct dt_device *dt = container_of(kobj, struct dt_device,
362 struct lod_device *lod = dt2lod_dev(dt);
363 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
366 return snprintf(buf, PAGE_SIZE, "%u\n",
367 ltd->ltd_lov_desc.ld_active_tgt_count);
370 static ssize_t mdt_activeobd_show(struct kobject *kobj, struct attribute *attr,
373 return __activeobd_show(kobj, attr, buf, true);
376 static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr,
379 return __activeobd_show(kobj, attr, buf, false);
382 LUSTRE_RO_ATTR(mdt_activeobd);
383 LUSTRE_RO_ATTR(activeobd);
386 * Show UUID of LOD device.
388 static ssize_t desc_uuid_show(struct kobject *kobj, struct attribute *attr,
391 struct dt_device *dt = container_of(kobj, struct dt_device,
393 struct lod_device *lod = dt2lod_dev(dt);
395 return snprintf(buf, PAGE_SIZE, "%s\n",
396 lod->lod_ost_descs.ltd_lov_desc.ld_uuid.uuid);
398 LUSTRE_RO_ATTR(desc_uuid);
401 * Show QoS priority parameter.
403 * The printed value is a percentage value (0-100%) indicating the priority
404 * of free space compared to performance. 0% means select OSTs equally
405 * regardless of their free space, 100% means select OSTs only by their free
406 * space even if it results in very imbalanced load on the OSTs.
408 static ssize_t __qos_prio_free_show(struct kobject *kobj,
409 struct attribute *attr, char *buf,
412 struct dt_device *dt = container_of(kobj, struct dt_device,
414 struct lod_device *lod = dt2lod_dev(dt);
415 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
418 return snprintf(buf, PAGE_SIZE, "%d%%\n",
419 (ltd->ltd_qos.lq_prio_free * 100 + 255) >> 8);
422 static ssize_t mdt_qos_prio_free_show(struct kobject *kobj,
423 struct attribute *attr, char *buf)
425 return __qos_prio_free_show(kobj, attr, buf, true);
428 static ssize_t qos_prio_free_show(struct kobject *kobj,
429 struct attribute *attr, char *buf)
431 return __qos_prio_free_show(kobj, attr, buf, false);
435 * Set QoS free space priority parameter.
437 * Set the relative priority of free OST space compared to OST load when OSTs
438 * are space imbalanced. See qos_priofree_show() for description of
439 * this parameter. See qos_threshold_rr_store() and lq_threshold_rr to
440 * determine what constitutes "space imbalanced" OSTs.
442 static ssize_t __qos_prio_free_store(struct kobject *kobj,
443 struct attribute *attr,
444 const char *buffer, size_t count,
447 struct dt_device *dt = container_of(kobj, struct dt_device,
449 struct lod_device *lod = dt2lod_dev(dt);
450 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
455 rc = kstrtouint(buffer, 0, &val);
461 ltd->ltd_qos.lq_prio_free = (val << 8) / 100;
462 ltd->ltd_qos.lq_dirty = 1;
463 ltd->ltd_qos.lq_reset = 1;
468 static ssize_t mdt_qos_prio_free_store(struct kobject *kobj,
469 struct attribute *attr,
470 const char *buffer, size_t count)
472 return __qos_prio_free_store(kobj, attr, buffer, count, true);
475 static ssize_t qos_prio_free_store(struct kobject *kobj, struct attribute *attr,
476 const char *buffer, size_t count)
478 return __qos_prio_free_store(kobj, attr, buffer, count, false);
481 LUSTRE_RW_ATTR(mdt_qos_prio_free);
482 LUSTRE_RW_ATTR(qos_prio_free);
485 * Show threshold for "same space on all OSTs" rule.
487 static ssize_t __qos_threshold_rr_show(struct kobject *kobj,
488 struct attribute *attr, char *buf,
491 struct dt_device *dt = container_of(kobj, struct dt_device,
493 struct lod_device *lod = dt2lod_dev(dt);
494 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
497 return snprintf(buf, PAGE_SIZE, "%d%%\n",
498 (ltd->ltd_qos.lq_threshold_rr * 100 + 255) >> 8);
501 static ssize_t mdt_qos_threshold_rr_show(struct kobject *kobj,
502 struct attribute *attr, char *buf)
504 return __qos_threshold_rr_show(kobj, attr, buf, true);
507 static ssize_t qos_threshold_rr_show(struct kobject *kobj,
508 struct attribute *attr, char *buf)
510 return __qos_threshold_rr_show(kobj, attr, buf, false);
514 * Set threshold for "same space on all OSTs" rule.
516 * This sets the maximum percentage difference of free space between the most
517 * full and most empty OST in the currently available OSTs. If this percentage
518 * is exceeded, use the QoS allocator to select OSTs based on their available
519 * space so that more full OSTs are chosen less often, otherwise use the
520 * round-robin allocator for efficiency and performance.
522 static ssize_t __qos_threshold_rr_store(struct kobject *kobj,
523 struct attribute *attr,
524 const char *buffer, size_t count,
527 struct dt_device *dt = container_of(kobj, struct dt_device,
529 struct lod_device *lod = dt2lod_dev(dt);
530 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
536 /* "100%\n\0" should be largest string */
537 if (count >= sizeof(buf))
540 strncpy(buf, buffer, sizeof(buf));
541 buf[sizeof(buf) - 1] = '\0';
542 tmp = strchr(buf, '%');
546 rc = kstrtouint(buf, 0, &val);
552 ltd->ltd_qos.lq_threshold_rr = (val << 8) / 100;
553 ltd->ltd_qos.lq_dirty = 1;
558 static ssize_t mdt_qos_threshold_rr_store(struct kobject *kobj,
559 struct attribute *attr,
560 const char *buffer, size_t count)
562 return __qos_threshold_rr_store(kobj, attr, buffer, count, true);
565 static ssize_t qos_threshold_rr_store(struct kobject *kobj,
566 struct attribute *attr,
567 const char *buffer, size_t count)
569 return __qos_threshold_rr_store(kobj, attr, buffer, count, false);
572 LUSTRE_RW_ATTR(mdt_qos_threshold_rr);
573 LUSTRE_RW_ATTR(qos_threshold_rr);
576 * Show expiration period used to refresh cached statfs data, which
577 * is used to implement QoS/RR striping allocation algorithm.
579 static ssize_t __qos_maxage_show(struct kobject *kobj, struct attribute *attr,
580 char *buf, bool is_mdt)
582 struct dt_device *dt = container_of(kobj, struct dt_device,
584 struct lod_device *lod = dt2lod_dev(dt);
585 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
588 return snprintf(buf, PAGE_SIZE, "%u Sec\n",
589 ltd->ltd_lov_desc.ld_qos_maxage);
592 static ssize_t mdt_qos_maxage_show(struct kobject *kobj, struct attribute *attr,
595 return __qos_maxage_show(kobj, attr, buf, true);
598 static ssize_t qos_maxage_show(struct kobject *kobj, struct attribute *attr,
601 return __qos_maxage_show(kobj, attr, buf, true);
605 * Set expiration period used to refresh cached statfs data.
607 static ssize_t __qos_maxage_store(struct kobject *kobj, struct attribute *attr,
608 const char *buffer, size_t count, bool is_mdt)
610 struct dt_device *dt = container_of(kobj, struct dt_device,
612 struct lod_device *lod = dt2lod_dev(dt);
613 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
615 struct lustre_cfg_bufs bufs;
616 struct lu_device *next;
617 struct lustre_cfg *lcfg;
619 struct lu_tgt_desc *tgt;
623 rc = kstrtouint(buffer, 0, &val);
630 ltd->ltd_lov_desc.ld_qos_maxage = val;
633 * propogate the value down to OSPs
635 lustre_cfg_bufs_reset(&bufs, NULL);
636 snprintf(str, 32, "%smaxage=%u", PARAM_OSP, val);
637 lustre_cfg_bufs_set_string(&bufs, 1, str);
638 OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
641 lustre_cfg_init(lcfg, LCFG_PARAM, &bufs);
644 ltd_foreach_tgt(ltd, tgt) {
645 next = &tgt->ltd_tgt->dd_lu_dev;
646 rc = next->ld_ops->ldo_process_config(NULL, next, lcfg);
648 CERROR("can't set maxage on #%d: %d\n",
651 lod_putref(lod, ltd);
652 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
657 static ssize_t mdt_qos_maxage_store(struct kobject *kobj,
658 struct attribute *attr,
659 const char *buffer, size_t count)
661 return __qos_maxage_store(kobj, attr, buffer, count, true);
664 static ssize_t qos_maxage_store(struct kobject *kobj, struct attribute *attr,
665 const char *buffer, size_t count)
667 return __qos_maxage_store(kobj, attr, buffer, count, false);
670 LUSTRE_RW_ATTR(mdt_qos_maxage);
671 LUSTRE_RW_ATTR(qos_maxage);
673 static void *lod_tgts_seq_start(struct seq_file *p, loff_t *pos, bool is_mdt)
675 struct obd_device *dev = p->private;
676 struct lod_device *lod = lu2lod_dev(dev->obd_lu_dev);
677 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
680 LASSERT(dev != NULL);
682 lod_getref(ltd); /* released in lod_tgts_seq_stop */
683 if (*pos >= ltd->ltd_tgt_bitmap->size)
686 *pos = find_next_bit(ltd->ltd_tgt_bitmap->data,
687 ltd->ltd_tgt_bitmap->size, *pos);
688 if (*pos < ltd->ltd_tgt_bitmap->size)
689 return LTD_TGT(ltd, *pos);
694 static void *lod_mdts_seq_start(struct seq_file *p, loff_t *pos)
696 return lod_tgts_seq_start(p, pos, true);
699 static void *lod_osts_seq_start(struct seq_file *p, loff_t *pos)
701 return lod_tgts_seq_start(p, pos, false);
704 static void lod_tgts_seq_stop(struct seq_file *p, void *v, bool is_mdt)
706 struct obd_device *dev = p->private;
707 struct lod_device *lod = lu2lod_dev(dev->obd_lu_dev);
708 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
711 LASSERT(dev != NULL);
712 lod_putref(lod, ltd);
715 static void lod_mdts_seq_stop(struct seq_file *p, void *v)
717 lod_tgts_seq_stop(p, v, true);
720 static void lod_osts_seq_stop(struct seq_file *p, void *v)
722 lod_tgts_seq_stop(p, v, false);
725 static void *lod_tgts_seq_next(struct seq_file *p, void *v, loff_t *pos,
728 struct obd_device *dev = p->private;
729 struct lod_device *lod = lu2lod_dev(dev->obd_lu_dev);
730 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
733 if (*pos >= ltd->ltd_tgt_bitmap->size - 1)
736 *pos = find_next_bit(ltd->ltd_tgt_bitmap->data,
737 ltd->ltd_tgt_bitmap->size, *pos + 1);
738 if (*pos < ltd->ltd_tgt_bitmap->size)
739 return LTD_TGT(ltd, *pos);
744 static void *lod_mdts_seq_next(struct seq_file *p, void *v, loff_t *pos)
746 return lod_tgts_seq_next(p, v, pos, true);
749 static void *lod_osts_seq_next(struct seq_file *p, void *v, loff_t *pos)
751 return lod_tgts_seq_next(p, v, pos, false);
755 * Show active/inactive status for OST found by lod_osts_seq_next().
757 * \param[in] m seq file
758 * \param[in] v unused for single entry
760 * \retval 0 on success
761 * \retval negative error code if failed
763 static int lod_tgts_seq_show(struct seq_file *p, void *v)
765 struct obd_device *obd = p->private;
766 struct lu_tgt_desc *tgt = v;
767 struct dt_device *next;
770 LASSERT(obd->obd_lu_dev);
776 /* XXX: should be non-NULL env, but it's very expensive */
778 rc = dt_statfs(NULL, next, &tgt->ltd_statfs);
779 if (rc == -ENOTCONN) {
785 seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index,
786 obd_uuid2str(&tgt->ltd_uuid),
791 static const struct seq_operations lod_mdts_sops = {
792 .start = lod_mdts_seq_start,
793 .stop = lod_mdts_seq_stop,
794 .next = lod_mdts_seq_next,
795 .show = lod_tgts_seq_show,
798 static const struct seq_operations lod_osts_sops = {
799 .start = lod_osts_seq_start,
800 .stop = lod_osts_seq_stop,
801 .next = lod_osts_seq_next,
802 .show = lod_tgts_seq_show,
805 static int lod_mdts_seq_open(struct inode *inode, struct file *file)
807 struct seq_file *seq;
810 rc = seq_open(file, &lod_mdts_sops);
814 seq = file->private_data;
815 seq->private = PDE_DATA(inode);
819 static int lod_osts_seq_open(struct inode *inode, struct file *file)
821 struct seq_file *seq;
824 rc = seq_open(file, &lod_osts_sops);
828 seq = file->private_data;
829 seq->private = PDE_DATA(inode);
834 * Show whether special failout mode for testing is enabled or not.
836 static ssize_t lmv_failout_show(struct kobject *kobj, struct attribute *attr,
839 struct dt_device *dt = container_of(kobj, struct dt_device,
841 struct lod_device *lod = dt2lod_dev(dt);
843 return snprintf(buf, PAGE_SIZE, "%d\n", lod->lod_lmv_failout ? 1 : 0);
847 * Enable/disable a special failout mode for testing.
849 * This determines whether the LMV will try to continue processing a striped
850 * directory even if it has a (partly) corrupted entry in the master directory,
851 * or if it will abort upon finding a corrupted slave directory entry.
853 static ssize_t lmv_failout_store(struct kobject *kobj, struct attribute *attr,
854 const char *buffer, size_t count)
856 struct dt_device *dt = container_of(kobj, struct dt_device,
858 struct lod_device *lod = dt2lod_dev(dt);
862 rc = kstrtobool(buffer, &val);
866 lod->lod_lmv_failout = val;
870 LUSTRE_RW_ATTR(lmv_failout);
872 static struct lprocfs_vars lprocfs_lod_obd_vars[] = {
876 static const struct file_operations lod_proc_mdt_fops = {
877 .owner = THIS_MODULE,
878 .open = lod_mdts_seq_open,
881 .release = lprocfs_seq_release,
884 static const struct file_operations lod_proc_target_fops = {
885 .owner = THIS_MODULE,
886 .open = lod_osts_seq_open,
889 .release = lprocfs_seq_release,
892 static struct attribute *lod_attrs[] = {
893 &lustre_attr_dom_stripesize.attr,
894 &lustre_attr_stripesize.attr,
895 &lustre_attr_stripeoffset.attr,
896 &lustre_attr_stripecount.attr,
897 &lustre_attr_stripetype.attr,
898 &lustre_attr_activeobd.attr,
899 &lustre_attr_desc_uuid.attr,
900 &lustre_attr_lmv_failout.attr,
901 &lustre_attr_numobd.attr,
902 &lustre_attr_qos_maxage.attr,
903 &lustre_attr_qos_prio_free.attr,
904 &lustre_attr_qos_threshold_rr.attr,
905 &lustre_attr_mdt_stripecount.attr,
906 &lustre_attr_mdt_stripetype.attr,
907 &lustre_attr_mdt_activeobd.attr,
908 &lustre_attr_mdt_numobd.attr,
909 &lustre_attr_mdt_qos_maxage.attr,
910 &lustre_attr_mdt_qos_prio_free.attr,
911 &lustre_attr_mdt_qos_threshold_rr.attr,
916 * Initialize procfs entries for LOD.
918 * \param[in] lod LOD device
920 * \retval 0 on success
921 * \retval negative error code if failed
923 int lod_procfs_init(struct lod_device *lod)
925 struct lprocfs_vars ldebugfs_obd_vars[] = { { NULL } };
926 struct obd_device *obd = lod2obd(lod);
927 struct obd_type *type;
931 lod->lod_dt_dev.dd_ktype.default_attrs = lod_attrs;
932 rc = dt_tunables_init(&lod->lod_dt_dev, obd->obd_type, obd->obd_name,
935 CERROR("%s: failed to setup DT tunables: %d\n",
940 obd->obd_vars = lprocfs_lod_obd_vars;
941 obd->obd_proc_entry = lprocfs_register(obd->obd_name,
942 obd->obd_type->typ_procroot,
944 if (IS_ERR(obd->obd_proc_entry)) {
945 rc = PTR_ERR(obd->obd_proc_entry);
946 CERROR("%s: error %d setting up lprocfs\n",
951 rc = lprocfs_seq_create(obd->obd_proc_entry, "mdt_obd",
952 0444, &lod_proc_mdt_fops, obd);
954 CWARN("%s: Error adding the target_obd file %d\n",
959 rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
960 0444, &lod_proc_target_fops, obd);
962 CWARN("%s: Error adding the target_obd file %d\n",
967 lod->lod_pool_proc_entry = lprocfs_register("pools",
970 if (IS_ERR(lod->lod_pool_proc_entry)) {
971 rc = PTR_ERR(lod->lod_pool_proc_entry);
972 lod->lod_pool_proc_entry = NULL;
973 CWARN("%s: Failed to create pool proc file: %d\n",
978 lov = kset_find_obj(lustre_kset, "lov");
980 CERROR("%s: lov subsystem not found\n", obd->obd_name);
981 GOTO(out, rc = -ENODEV);
984 rc = sysfs_create_link(lov, &lod->lod_dt_dev.dd_kobj,
987 CERROR("%s: failed to create LOV sysfs symlink\n",
991 lod->lod_debugfs = ldebugfs_add_symlink(obd->obd_name, "lov",
992 "../lod/%s", obd->obd_name);
993 if (!lod->lod_debugfs)
994 CERROR("%s: failed to create LOV debugfs symlink\n",
997 type = container_of(lov, struct obd_type, typ_kobj);
998 if (!type->typ_procroot)
1001 /* for compatibility we link old procfs's LOV entries to lod ones */
1002 lod->lod_symlink = lprocfs_add_symlink(obd->obd_name,
1004 "../lod/%s", obd->obd_name);
1005 if (lod->lod_symlink == NULL)
1006 CERROR("cannot create LOV symlink for /proc/fs/lustre/lod/%s\n",
1011 dt_tunables_fini(&lod->lod_dt_dev);
1017 * Cleanup procfs entries registred for LOD.
1019 * \param[in] lod LOD device
1021 void lod_procfs_fini(struct lod_device *lod)
1023 struct obd_device *obd = lod2obd(lod);
1024 struct kobject *lov;
1026 if (lod->lod_symlink != NULL) {
1027 lprocfs_remove(&lod->lod_symlink);
1028 lod->lod_symlink = NULL;
1031 lov = kset_find_obj(lustre_kset, "lov");
1033 sysfs_remove_link(lov, obd->obd_name);
1037 debugfs_remove_recursive(lod->lod_debugfs);
1039 if (obd->obd_proc_entry) {
1040 lprocfs_remove(&obd->obd_proc_entry);
1041 obd->obd_proc_entry = NULL;
1044 dt_tunables_fini(&lod->lod_dt_dev);
1047 #endif /* CONFIG_PROC_FS */