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);
75 if (count > (sizeof(tbuf) - 1))
78 memcpy(tbuf, buffer, count);
80 rc = lu_str_to_s64(tbuf, count, &val, '1');
87 /* 1GB is the limit */
88 if (val > (1ULL << 30))
92 if (val < LOV_MIN_STRIPE_SIZE) {
93 LCONSOLE_INFO("Increasing provided stripe size to "
94 "a minimum value %u\n",
96 val = LOV_MIN_STRIPE_SIZE;
97 } else if (val & (LOV_MIN_STRIPE_SIZE - 1)) {
98 val &= ~(LOV_MIN_STRIPE_SIZE - 1);
99 LCONSOLE_WARN("Changing provided stripe size to %llu "
100 "(a multiple of minimum %u)\n",
101 val, LOV_MIN_STRIPE_SIZE);
105 lod->lod_dom_max_stripesize = val;
110 LUSTRE_RW_ATTR(dom_stripesize);
112 static ssize_t stripesize_show(struct kobject *kobj, struct attribute *attr,
115 struct dt_device *dt = container_of(kobj, struct dt_device,
117 struct lod_device *lod = dt2lod_dev(dt);
119 return snprintf(buf, PAGE_SIZE, "%llu\n",
120 lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_size);
123 static ssize_t stripesize_store(struct kobject *kobj, struct attribute *attr,
124 const char *buffer, size_t count)
126 struct dt_device *dt = container_of(kobj, struct dt_device,
128 struct lod_device *lod = dt2lod_dev(dt);
133 if (count > (sizeof(tbuf) - 1))
136 memcpy(tbuf, buffer, count);
138 rc = lu_str_to_s64(tbuf, count, &val, '1');
145 lod_fix_desc_stripe_size(&val);
146 lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_size = val;
151 LUSTRE_RW_ATTR(stripesize);
154 * Show default stripe offset.
156 static ssize_t stripeoffset_show(struct kobject *kobj, struct attribute *attr,
159 struct dt_device *dt = container_of(kobj, struct dt_device,
161 struct lod_device *lod = dt2lod_dev(dt);
163 return snprintf(buf, PAGE_SIZE, "%lld\n",
164 lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_offset);
168 * Set default stripe offset.
170 * Usually contains -1 allowing Lustre to balance objects among OST
171 * otherwise may cause severe OST imbalance.
173 static ssize_t stripeoffset_store(struct kobject *kobj,
174 struct attribute *attr,
175 const char *buffer, size_t count)
177 struct dt_device *dt = container_of(kobj, struct dt_device,
179 struct lod_device *lod = dt2lod_dev(dt);
183 rc = kstrtol(buffer, 0, &val);
187 if (val < -1 || val > LOV_MAX_STRIPE_COUNT)
190 lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_offset = val;
195 LUSTRE_RW_ATTR(stripeoffset);
198 * Show default striping pattern (LOV_PATTERN_*).
200 static ssize_t __stripetype_show(struct kobject *kobj, struct attribute *attr,
201 char *buf, bool is_mdt)
203 struct dt_device *dt = container_of(kobj, struct dt_device,
205 struct lod_device *lod = dt2lod_dev(dt);
206 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
209 return snprintf(buf, PAGE_SIZE, "%u\n", ltd->ltd_lov_desc.ld_pattern);
212 static ssize_t mdt_stripetype_show(struct kobject *kobj, struct attribute *attr,
215 return __stripetype_show(kobj, attr, buf, true);
218 static ssize_t stripetype_show(struct kobject *kobj, struct attribute *attr,
221 return __stripetype_show(kobj, attr, buf, false);
225 * Set default striping pattern (a number, not a human-readable string).
227 static ssize_t __stripetype_store(struct kobject *kobj, struct attribute *attr,
228 const char *buffer, size_t count, bool is_mdt)
230 struct dt_device *dt = container_of(kobj, struct dt_device,
232 struct lod_device *lod = dt2lod_dev(dt);
233 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
238 rc = kstrtouint(buffer, 0, &pattern);
243 lod_fix_lmv_desc_pattern(&pattern);
245 lod_fix_desc_pattern(&pattern);
247 ltd->ltd_lov_desc.ld_pattern = pattern;
252 static ssize_t mdt_stripetype_store(struct kobject *kobj,
253 struct attribute *attr, const char *buffer,
256 return __stripetype_store(kobj, attr, buffer, count, true);
259 static ssize_t stripetype_store(struct kobject *kobj,
260 struct attribute *attr, const char *buffer,
263 return __stripetype_store(kobj, attr, buffer, count, false);
266 LUSTRE_RW_ATTR(mdt_stripetype);
267 LUSTRE_RW_ATTR(stripetype);
270 * Show default number of stripes.
272 static ssize_t __stripecount_show(struct kobject *kobj, struct attribute *attr,
273 char *buf, bool is_mdt)
275 struct dt_device *dt = container_of(kobj, struct dt_device,
277 struct lod_device *lod = dt2lod_dev(dt);
278 struct lov_desc *desc = is_mdt ? &lod->lod_mdt_descs.ltd_lov_desc :
279 &lod->lod_ost_descs.ltd_lov_desc;
281 return snprintf(buf, PAGE_SIZE, "%d\n",
282 (s16)(desc->ld_default_stripe_count + 1) - 1);
285 static ssize_t mdt_stripecount_show(struct kobject *kobj,
286 struct attribute *attr, char *buf)
288 return __stripecount_show(kobj, attr, buf, true);
291 static ssize_t stripecount_show(struct kobject *kobj, struct attribute *attr,
294 return __stripecount_show(kobj, attr, buf, false);
298 * Set default number of stripes.
300 static ssize_t __stripecount_store(struct kobject *kobj, struct attribute *attr,
301 const char *buffer, size_t count,
304 struct dt_device *dt = container_of(kobj, struct dt_device,
306 struct lod_device *lod = dt2lod_dev(dt);
307 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
312 rc = kstrtoint(buffer, 0, &stripe_count);
316 if (stripe_count < -1)
319 lod_fix_desc_stripe_count(&stripe_count);
320 ltd->ltd_lov_desc.ld_default_stripe_count = stripe_count;
325 static ssize_t mdt_stripecount_store(struct kobject *kobj,
326 struct attribute *attr,
327 const char *buffer, size_t count)
329 return __stripecount_store(kobj, attr, buffer, count, true);
332 static ssize_t stripecount_store(struct kobject *kobj,
333 struct attribute *attr,
334 const char *buffer, size_t count)
336 return __stripecount_store(kobj, attr, buffer, count, false);
339 LUSTRE_RW_ATTR(mdt_stripecount);
340 LUSTRE_RW_ATTR(stripecount);
343 * Show number of targets.
345 static ssize_t __numobd_show(struct kobject *kobj, struct attribute *attr,
346 char *buf, bool is_mdt)
348 struct dt_device *dt = container_of(kobj, struct dt_device,
350 struct lod_device *lod = dt2lod_dev(dt);
351 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
354 return snprintf(buf, PAGE_SIZE, "%u\n", ltd->ltd_lov_desc.ld_tgt_count);
357 static ssize_t mdt_numobd_show(struct kobject *kobj, struct attribute *attr,
360 return __numobd_show(kobj, attr, buf, true);
363 static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr,
366 return __numobd_show(kobj, attr, buf, false);
369 LUSTRE_RO_ATTR(mdt_numobd);
370 LUSTRE_RO_ATTR(numobd);
373 * Show number of active targets.
375 static ssize_t __activeobd_show(struct kobject *kobj, struct attribute *attr,
376 char *buf, bool is_mdt)
378 struct dt_device *dt = container_of(kobj, struct dt_device,
380 struct lod_device *lod = dt2lod_dev(dt);
381 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
384 return snprintf(buf, PAGE_SIZE, "%u\n",
385 ltd->ltd_lov_desc.ld_active_tgt_count);
388 static ssize_t mdt_activeobd_show(struct kobject *kobj, struct attribute *attr,
391 return __activeobd_show(kobj, attr, buf, true);
394 static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr,
397 return __activeobd_show(kobj, attr, buf, false);
400 LUSTRE_RO_ATTR(mdt_activeobd);
401 LUSTRE_RO_ATTR(activeobd);
404 * Show UUID of LOD device.
406 static ssize_t desc_uuid_show(struct kobject *kobj, struct attribute *attr,
409 struct dt_device *dt = container_of(kobj, struct dt_device,
411 struct lod_device *lod = dt2lod_dev(dt);
413 return snprintf(buf, PAGE_SIZE, "%s\n",
414 lod->lod_ost_descs.ltd_lov_desc.ld_uuid.uuid);
416 LUSTRE_RO_ATTR(desc_uuid);
419 * Show QoS priority parameter.
421 * The printed value is a percentage value (0-100%) indicating the priority
422 * of free space compared to performance. 0% means select OSTs equally
423 * regardless of their free space, 100% means select OSTs only by their free
424 * space even if it results in very imbalanced load on the OSTs.
426 static ssize_t __qos_prio_free_show(struct kobject *kobj,
427 struct attribute *attr, char *buf,
430 struct dt_device *dt = container_of(kobj, struct dt_device,
432 struct lod_device *lod = dt2lod_dev(dt);
433 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
436 return snprintf(buf, PAGE_SIZE, "%d%%\n",
437 (ltd->ltd_qos.lq_prio_free * 100 + 255) >> 8);
440 static ssize_t mdt_qos_prio_free_show(struct kobject *kobj,
441 struct attribute *attr, char *buf)
443 return __qos_prio_free_show(kobj, attr, buf, true);
446 static ssize_t qos_prio_free_show(struct kobject *kobj,
447 struct attribute *attr, char *buf)
449 return __qos_prio_free_show(kobj, attr, buf, false);
453 * Set QoS free space priority parameter.
455 * Set the relative priority of free OST space compared to OST load when OSTs
456 * are space imbalanced. See qos_priofree_show() for description of
457 * this parameter. See qos_threshold_rr_store() and lq_threshold_rr to
458 * determine what constitutes "space imbalanced" OSTs.
460 static ssize_t __qos_prio_free_store(struct kobject *kobj,
461 struct attribute *attr,
462 const char *buffer, size_t count,
465 struct dt_device *dt = container_of(kobj, struct dt_device,
467 struct lod_device *lod = dt2lod_dev(dt);
468 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
473 rc = kstrtouint(buffer, 0, &val);
479 ltd->ltd_qos.lq_prio_free = (val << 8) / 100;
480 ltd->ltd_qos.lq_dirty = 1;
481 ltd->ltd_qos.lq_reset = 1;
486 static ssize_t mdt_qos_prio_free_store(struct kobject *kobj,
487 struct attribute *attr,
488 const char *buffer, size_t count)
490 return __qos_prio_free_store(kobj, attr, buffer, count, true);
493 static ssize_t qos_prio_free_store(struct kobject *kobj, struct attribute *attr,
494 const char *buffer, size_t count)
496 return __qos_prio_free_store(kobj, attr, buffer, count, false);
499 LUSTRE_RW_ATTR(mdt_qos_prio_free);
500 LUSTRE_RW_ATTR(qos_prio_free);
503 * Show threshold for "same space on all OSTs" rule.
505 static ssize_t __qos_threshold_rr_show(struct kobject *kobj,
506 struct attribute *attr, char *buf,
509 struct dt_device *dt = container_of(kobj, struct dt_device,
511 struct lod_device *lod = dt2lod_dev(dt);
512 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
515 return snprintf(buf, PAGE_SIZE, "%d%%\n",
516 (ltd->ltd_qos.lq_threshold_rr * 100 + 255) >> 8);
519 static ssize_t mdt_qos_threshold_rr_show(struct kobject *kobj,
520 struct attribute *attr, char *buf)
522 return __qos_threshold_rr_show(kobj, attr, buf, true);
525 static ssize_t qos_threshold_rr_show(struct kobject *kobj,
526 struct attribute *attr, char *buf)
528 return __qos_threshold_rr_show(kobj, attr, buf, false);
532 * Set threshold for "same space on all OSTs" rule.
534 * This sets the maximum percentage difference of free space between the most
535 * full and most empty OST in the currently available OSTs. If this percentage
536 * is exceeded, use the QoS allocator to select OSTs based on their available
537 * space so that more full OSTs are chosen less often, otherwise use the
538 * round-robin allocator for efficiency and performance.
540 static ssize_t __qos_threshold_rr_store(struct kobject *kobj,
541 struct attribute *attr,
542 const char *buffer, size_t count,
545 struct dt_device *dt = container_of(kobj, struct dt_device,
547 struct lod_device *lod = dt2lod_dev(dt);
548 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
554 /* "100%\n\0" should be largest string */
555 if (count >= sizeof(buf))
558 strncpy(buf, buffer, sizeof(buf));
559 buf[sizeof(buf) - 1] = '\0';
560 tmp = strchr(buf, '%');
564 rc = kstrtouint(buf, 0, &val);
570 ltd->ltd_qos.lq_threshold_rr = (val << 8) / 100;
571 ltd->ltd_qos.lq_dirty = 1;
576 static ssize_t mdt_qos_threshold_rr_store(struct kobject *kobj,
577 struct attribute *attr,
578 const char *buffer, size_t count)
580 return __qos_threshold_rr_store(kobj, attr, buffer, count, true);
583 static ssize_t qos_threshold_rr_store(struct kobject *kobj,
584 struct attribute *attr,
585 const char *buffer, size_t count)
587 return __qos_threshold_rr_store(kobj, attr, buffer, count, false);
590 LUSTRE_RW_ATTR(mdt_qos_threshold_rr);
591 LUSTRE_RW_ATTR(qos_threshold_rr);
594 * Show expiration period used to refresh cached statfs data, which
595 * is used to implement QoS/RR striping allocation algorithm.
597 static ssize_t __qos_maxage_show(struct kobject *kobj, struct attribute *attr,
598 char *buf, bool is_mdt)
600 struct dt_device *dt = container_of(kobj, struct dt_device,
602 struct lod_device *lod = dt2lod_dev(dt);
603 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
606 return snprintf(buf, PAGE_SIZE, "%u Sec\n",
607 ltd->ltd_lov_desc.ld_qos_maxage);
610 static ssize_t mdt_qos_maxage_show(struct kobject *kobj, struct attribute *attr,
613 return __qos_maxage_show(kobj, attr, buf, true);
616 static ssize_t qos_maxage_show(struct kobject *kobj, struct attribute *attr,
619 return __qos_maxage_show(kobj, attr, buf, true);
623 * Set expiration period used to refresh cached statfs data.
625 static ssize_t __qos_maxage_store(struct kobject *kobj, struct attribute *attr,
626 const char *buffer, size_t count, bool is_mdt)
628 struct dt_device *dt = container_of(kobj, struct dt_device,
630 struct lod_device *lod = dt2lod_dev(dt);
631 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
633 struct lustre_cfg_bufs bufs;
634 struct lu_device *next;
635 struct lustre_cfg *lcfg;
637 struct lu_tgt_desc *tgt;
641 rc = kstrtouint(buffer, 0, &val);
648 ltd->ltd_lov_desc.ld_qos_maxage = val;
651 * propogate the value down to OSPs
653 lustre_cfg_bufs_reset(&bufs, NULL);
654 snprintf(str, 32, "%smaxage=%u", PARAM_OSP, val);
655 lustre_cfg_bufs_set_string(&bufs, 1, str);
656 OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
659 lustre_cfg_init(lcfg, LCFG_PARAM, &bufs);
662 ltd_foreach_tgt(ltd, tgt) {
663 next = &tgt->ltd_tgt->dd_lu_dev;
664 rc = next->ld_ops->ldo_process_config(NULL, next, lcfg);
666 CERROR("can't set maxage on #%d: %d\n",
669 lod_putref(lod, ltd);
670 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
675 static ssize_t mdt_qos_maxage_store(struct kobject *kobj,
676 struct attribute *attr,
677 const char *buffer, size_t count)
679 return __qos_maxage_store(kobj, attr, buffer, count, true);
682 static ssize_t qos_maxage_store(struct kobject *kobj, struct attribute *attr,
683 const char *buffer, size_t count)
685 return __qos_maxage_store(kobj, attr, buffer, count, false);
688 LUSTRE_RW_ATTR(mdt_qos_maxage);
689 LUSTRE_RW_ATTR(qos_maxage);
691 static void *lod_tgts_seq_start(struct seq_file *p, loff_t *pos, bool is_mdt)
693 struct obd_device *dev = p->private;
694 struct lod_device *lod = lu2lod_dev(dev->obd_lu_dev);
695 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
698 LASSERT(dev != NULL);
700 lod_getref(ltd); /* released in lod_tgts_seq_stop */
701 if (*pos >= ltd->ltd_tgt_bitmap->size)
704 *pos = find_next_bit(ltd->ltd_tgt_bitmap->data,
705 ltd->ltd_tgt_bitmap->size, *pos);
706 if (*pos < ltd->ltd_tgt_bitmap->size)
707 return LTD_TGT(ltd, *pos);
712 static void *lod_mdts_seq_start(struct seq_file *p, loff_t *pos)
714 return lod_tgts_seq_start(p, pos, true);
717 static void *lod_osts_seq_start(struct seq_file *p, loff_t *pos)
719 return lod_tgts_seq_start(p, pos, false);
722 static void lod_tgts_seq_stop(struct seq_file *p, void *v, bool is_mdt)
724 struct obd_device *dev = p->private;
725 struct lod_device *lod = lu2lod_dev(dev->obd_lu_dev);
726 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
729 LASSERT(dev != NULL);
730 lod_putref(lod, ltd);
733 static void lod_mdts_seq_stop(struct seq_file *p, void *v)
735 lod_tgts_seq_stop(p, v, true);
738 static void lod_osts_seq_stop(struct seq_file *p, void *v)
740 lod_tgts_seq_stop(p, v, false);
743 static void *lod_tgts_seq_next(struct seq_file *p, void *v, loff_t *pos,
746 struct obd_device *dev = p->private;
747 struct lod_device *lod = lu2lod_dev(dev->obd_lu_dev);
748 struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
751 if (*pos >= ltd->ltd_tgt_bitmap->size - 1)
754 *pos = find_next_bit(ltd->ltd_tgt_bitmap->data,
755 ltd->ltd_tgt_bitmap->size, *pos + 1);
756 if (*pos < ltd->ltd_tgt_bitmap->size)
757 return LTD_TGT(ltd, *pos);
762 static void *lod_mdts_seq_next(struct seq_file *p, void *v, loff_t *pos)
764 return lod_tgts_seq_next(p, v, pos, true);
767 static void *lod_osts_seq_next(struct seq_file *p, void *v, loff_t *pos)
769 return lod_tgts_seq_next(p, v, pos, false);
773 * Show active/inactive status for OST found by lod_osts_seq_next().
775 * \param[in] m seq file
776 * \param[in] v unused for single entry
778 * \retval 0 on success
779 * \retval negative error code if failed
781 static int lod_tgts_seq_show(struct seq_file *p, void *v)
783 struct obd_device *obd = p->private;
784 struct lu_tgt_desc *tgt = v;
785 struct dt_device *next;
788 LASSERT(obd->obd_lu_dev);
794 /* XXX: should be non-NULL env, but it's very expensive */
796 rc = dt_statfs(NULL, next, &tgt->ltd_statfs);
797 if (rc == -ENOTCONN) {
803 seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index,
804 obd_uuid2str(&tgt->ltd_uuid),
809 static const struct seq_operations lod_mdts_sops = {
810 .start = lod_mdts_seq_start,
811 .stop = lod_mdts_seq_stop,
812 .next = lod_mdts_seq_next,
813 .show = lod_tgts_seq_show,
816 static const struct seq_operations lod_osts_sops = {
817 .start = lod_osts_seq_start,
818 .stop = lod_osts_seq_stop,
819 .next = lod_osts_seq_next,
820 .show = lod_tgts_seq_show,
823 static int lod_mdts_seq_open(struct inode *inode, struct file *file)
825 struct seq_file *seq;
828 rc = seq_open(file, &lod_mdts_sops);
832 seq = file->private_data;
833 seq->private = PDE_DATA(inode);
837 static int lod_osts_seq_open(struct inode *inode, struct file *file)
839 struct seq_file *seq;
842 rc = seq_open(file, &lod_osts_sops);
846 seq = file->private_data;
847 seq->private = PDE_DATA(inode);
852 * Show whether special failout mode for testing is enabled or not.
854 static ssize_t lmv_failout_show(struct kobject *kobj, struct attribute *attr,
857 struct dt_device *dt = container_of(kobj, struct dt_device,
859 struct lod_device *lod = dt2lod_dev(dt);
861 return snprintf(buf, PAGE_SIZE, "%d\n", lod->lod_lmv_failout ? 1 : 0);
865 * Enable/disable a special failout mode for testing.
867 * This determines whether the LMV will try to continue processing a striped
868 * directory even if it has a (partly) corrupted entry in the master directory,
869 * or if it will abort upon finding a corrupted slave directory entry.
871 static ssize_t lmv_failout_store(struct kobject *kobj, struct attribute *attr,
872 const char *buffer, size_t count)
874 struct dt_device *dt = container_of(kobj, struct dt_device,
876 struct lod_device *lod = dt2lod_dev(dt);
880 rc = kstrtobool(buffer, &val);
884 lod->lod_lmv_failout = val;
888 LUSTRE_RW_ATTR(lmv_failout);
890 static struct lprocfs_vars lprocfs_lod_obd_vars[] = {
894 static const struct file_operations lod_proc_mdt_fops = {
895 .owner = THIS_MODULE,
896 .open = lod_mdts_seq_open,
899 .release = lprocfs_seq_release,
902 static const struct file_operations lod_proc_target_fops = {
903 .owner = THIS_MODULE,
904 .open = lod_osts_seq_open,
907 .release = lprocfs_seq_release,
910 static struct attribute *lod_attrs[] = {
911 &lustre_attr_dom_stripesize.attr,
912 &lustre_attr_stripesize.attr,
913 &lustre_attr_stripeoffset.attr,
914 &lustre_attr_stripecount.attr,
915 &lustre_attr_stripetype.attr,
916 &lustre_attr_activeobd.attr,
917 &lustre_attr_desc_uuid.attr,
918 &lustre_attr_lmv_failout.attr,
919 &lustre_attr_numobd.attr,
920 &lustre_attr_qos_maxage.attr,
921 &lustre_attr_qos_prio_free.attr,
922 &lustre_attr_qos_threshold_rr.attr,
923 &lustre_attr_mdt_stripecount.attr,
924 &lustre_attr_mdt_stripetype.attr,
925 &lustre_attr_mdt_activeobd.attr,
926 &lustre_attr_mdt_numobd.attr,
927 &lustre_attr_mdt_qos_maxage.attr,
928 &lustre_attr_mdt_qos_prio_free.attr,
929 &lustre_attr_mdt_qos_threshold_rr.attr,
934 * Initialize procfs entries for LOD.
936 * \param[in] lod LOD device
938 * \retval 0 on success
939 * \retval negative error code if failed
941 int lod_procfs_init(struct lod_device *lod)
943 struct lprocfs_vars ldebugfs_obd_vars[] = { { NULL } };
944 struct obd_device *obd = lod2obd(lod);
945 struct obd_type *type;
949 lod->lod_dt_dev.dd_ktype.default_attrs = lod_attrs;
950 rc = dt_tunables_init(&lod->lod_dt_dev, obd->obd_type, obd->obd_name,
953 CERROR("%s: failed to setup DT tunables: %d\n",
958 obd->obd_vars = lprocfs_lod_obd_vars;
959 obd->obd_proc_entry = lprocfs_register(obd->obd_name,
960 obd->obd_type->typ_procroot,
962 if (IS_ERR(obd->obd_proc_entry)) {
963 rc = PTR_ERR(obd->obd_proc_entry);
964 CERROR("%s: error %d setting up lprocfs\n",
969 rc = lprocfs_seq_create(obd->obd_proc_entry, "mdt_obd",
970 0444, &lod_proc_mdt_fops, obd);
972 CWARN("%s: Error adding the target_obd file %d\n",
977 rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
978 0444, &lod_proc_target_fops, obd);
980 CWARN("%s: Error adding the target_obd file %d\n",
985 lod->lod_pool_proc_entry = lprocfs_register("pools",
988 if (IS_ERR(lod->lod_pool_proc_entry)) {
989 rc = PTR_ERR(lod->lod_pool_proc_entry);
990 lod->lod_pool_proc_entry = NULL;
991 CWARN("%s: Failed to create pool proc file: %d\n",
996 lov = kset_find_obj(lustre_kset, "lov");
998 CERROR("%s: lov subsystem not found\n", obd->obd_name);
999 GOTO(out, rc = -ENODEV);
1002 rc = sysfs_create_link(lov, &lod->lod_dt_dev.dd_kobj,
1005 CERROR("%s: failed to create LOV sysfs symlink\n",
1009 lod->lod_debugfs = ldebugfs_add_symlink(obd->obd_name, "lov",
1010 "../lod/%s", obd->obd_name);
1011 if (!lod->lod_debugfs)
1012 CERROR("%s: failed to create LOV debugfs symlink\n",
1015 type = container_of(lov, struct obd_type, typ_kobj);
1016 if (!type->typ_procroot)
1019 /* for compatibility we link old procfs's LOV entries to lod ones */
1020 lod->lod_symlink = lprocfs_add_symlink(obd->obd_name,
1022 "../lod/%s", obd->obd_name);
1023 if (lod->lod_symlink == NULL)
1024 CERROR("cannot create LOV symlink for /proc/fs/lustre/lod/%s\n",
1029 dt_tunables_fini(&lod->lod_dt_dev);
1035 * Cleanup procfs entries registred for LOD.
1037 * \param[in] lod LOD device
1039 void lod_procfs_fini(struct lod_device *lod)
1041 struct obd_device *obd = lod2obd(lod);
1042 struct kobject *lov;
1044 if (lod->lod_symlink != NULL) {
1045 lprocfs_remove(&lod->lod_symlink);
1046 lod->lod_symlink = NULL;
1049 lov = kset_find_obj(lustre_kset, "lov");
1051 sysfs_remove_link(lov, obd->obd_name);
1055 debugfs_remove_recursive(lod->lod_debugfs);
1057 if (obd->obd_proc_entry) {
1058 lprocfs_remove(&obd->obd_proc_entry);
1059 obd->obd_proc_entry = NULL;
1062 dt_tunables_fini(&lod->lod_dt_dev);
1065 #endif /* CONFIG_PROC_FS */