Whamcloud - gitweb
LU-14659 test: improve generate_uneven_mdts() in sanity.sh
[fs/lustre-release.git] / lustre / lod / lproc_lod.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2012, 2017, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  */
31 #define DEBUG_SUBSYSTEM S_CLASS
32
33 #include <lprocfs_status.h>
34 #include <obd_class.h>
35 #include <linux/seq_file.h>
36 #include "lod_internal.h"
37 #include <uapi/linux/lustre/lustre_param.h>
38
39 /*
40  * Notice, all the functions below (except for lod_procfs_init() and
41  * lod_procfs_fini()) are not supposed to be used directly. They are
42  * called by Linux kernel's procfs.
43  */
44
45 #ifdef CONFIG_PROC_FS
46
47 static ssize_t dom_stripesize_show(struct kobject *kobj,
48                                    struct attribute *attr,
49                                    char *buf)
50 {
51         struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
52         struct lod_device *lod = dt2lod_dev(dt);
53
54         return scnprintf(buf, PAGE_SIZE, "%u\n",
55                          lod->lod_dom_stripesize_max_kb << 10);
56 }
57
58 static inline int dom_stripesize_max_kb_update(struct lod_device *lod,
59                                                __u64 val)
60 {
61         /* 1GB is the limit */
62         if (val > (1ULL << 20))
63                 return -ERANGE;
64
65         if (val > 0) {
66                 if (val < LOD_DOM_MIN_SIZE_KB) {
67                         LCONSOLE_INFO("Increasing provided stripe size to a minimum value %u\n",
68                                       LOD_DOM_MIN_SIZE_KB);
69                         val = LOD_DOM_MIN_SIZE_KB;
70                 } else if (val & (LOD_DOM_MIN_SIZE_KB - 1)) {
71                         val &= ~(LOD_DOM_MIN_SIZE_KB - 1);
72                         LCONSOLE_WARN("Changing provided stripe size to %llu (a multiple of minimum %u)\n",
73                                       val, LOD_DOM_MIN_SIZE_KB);
74                 }
75         }
76         spin_lock(&lod->lod_lsfs_lock);
77         lod->lod_dom_stripesize_max_kb = val;
78         lod_dom_stripesize_recalc(lod);
79         spin_unlock(&lod->lod_lsfs_lock);
80         return 0;
81 }
82
83 static ssize_t dom_stripesize_store(struct kobject *kobj,
84                                     struct attribute *attr,
85                                     const char *buffer, size_t count)
86 {
87         struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
88         struct lod_device *lod = dt2lod_dev(dt);
89         u64 val;
90         int rc;
91
92         rc = sysfs_memparse(buffer, count, &val, "B");
93         if (rc < 0)
94                 return rc;
95
96         rc = dom_stripesize_max_kb_update(lod, val >> 10);
97         if (rc)
98                 return rc;
99         return count;
100 }
101
102 /* Old attribute name is still supported */
103 LUSTRE_RW_ATTR(dom_stripesize);
104
105 /**
106  * Show DoM maximum allowed stripe size.
107  */
108 static ssize_t dom_stripesize_max_kb_show(struct kobject *kobj,
109                                           struct attribute *attr,
110                                           char *buf)
111 {
112         struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
113         struct lod_device *lod = dt2lod_dev(dt);
114
115         return scnprintf(buf, PAGE_SIZE, "%u\n",
116                          lod->lod_dom_stripesize_max_kb);
117 }
118
119 /**
120  * Set DoM maximum allowed stripe size.
121  */
122 static ssize_t dom_stripesize_max_kb_store(struct kobject *kobj,
123                                            struct attribute *attr,
124                                            const char *buffer, size_t count)
125 {
126         struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
127         struct lod_device *lod = dt2lod_dev(dt);
128         u64 val;
129         int rc;
130
131         rc = sysfs_memparse(buffer, count, &val, "KiB");
132         if (rc < 0)
133                 return rc;
134
135         rc = dom_stripesize_max_kb_update(lod, val >> 10);
136         if (rc)
137                 return rc;
138         return count;
139 }
140 LUSTRE_RW_ATTR(dom_stripesize_max_kb);
141
142 /**
143  * Show DoM default stripe size.
144  */
145 static ssize_t dom_stripesize_cur_kb_show(struct kobject *kobj,
146                                           struct attribute *attr,
147                                           char *buf)
148 {
149         struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
150         struct lod_device *lod = dt2lod_dev(dt);
151
152         return scnprintf(buf, PAGE_SIZE, "%u\n",
153                          lod->lod_dom_stripesize_cur_kb);
154 }
155
156 LUSTRE_RO_ATTR(dom_stripesize_cur_kb);
157
158 /**
159  * Show DoM threshold.
160  */
161 static ssize_t dom_threshold_free_mb_show(struct kobject *kobj,
162                                           struct attribute *attr, char *buf)
163 {
164         struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
165         struct lod_device *lod = dt2lod_dev(dt);
166
167         return scnprintf(buf, PAGE_SIZE, "%llu\n",
168                          lod->lod_dom_threshold_free_mb);
169 }
170
171 /**
172  * Set DoM default stripe size.
173  */
174 static ssize_t dom_threshold_free_mb_store(struct kobject *kobj,
175                                            struct attribute *attr,
176                                            const char *buffer, size_t count)
177 {
178         struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
179         struct lod_device *lod = dt2lod_dev(dt);
180         u64 val;
181         int rc;
182         char *pct;
183
184         pct = strnchr(buffer, count, '%');
185         if (pct) {
186                 rc = string_to_size(&val, buffer, pct - buffer);
187                 if (rc < 0)
188                         return rc;
189                 val = mult_frac(lod->lod_lsfs_total_mb,
190                                 min_t(unsigned int, val, 100), 100);
191         } else {
192                 rc = sysfs_memparse(buffer, count, &val, "MiB");
193                 if (rc < 0)
194                         return rc;
195                 val >>= 20;
196         }
197
198         spin_lock(&lod->lod_lsfs_lock);
199         lod->lod_dom_threshold_free_mb = val;
200         lod_dom_stripesize_recalc(lod);
201         spin_unlock(&lod->lod_lsfs_lock);
202
203         return count;
204 }
205
206 LUSTRE_RW_ATTR(dom_threshold_free_mb);
207
208 static ssize_t stripesize_show(struct kobject *kobj, struct attribute *attr,
209                                char *buf)
210 {
211         struct dt_device *dt = container_of(kobj, struct dt_device,
212                                             dd_kobj);
213         struct lod_device *lod = dt2lod_dev(dt);
214
215         return scnprintf(buf, PAGE_SIZE, "%llu\n",
216                          lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_size);
217 }
218
219 static ssize_t stripesize_store(struct kobject *kobj, struct attribute *attr,
220                                 const char *buffer, size_t count)
221 {
222         struct dt_device *dt = container_of(kobj, struct dt_device,
223                                             dd_kobj);
224         struct lod_device *lod = dt2lod_dev(dt);
225         u64 val;
226         int rc;
227
228         rc = sysfs_memparse(buffer, count, &val, "B");
229         if (rc < 0)
230                 return rc;
231
232         lod_fix_desc_stripe_size(&val);
233         lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_size = val;
234
235         return count;
236 }
237
238 LUSTRE_RW_ATTR(stripesize);
239
240 /**
241  * Show default stripe offset.
242  */
243 static ssize_t stripeoffset_show(struct kobject *kobj, struct attribute *attr,
244                                  char *buf)
245 {
246         struct dt_device *dt = container_of(kobj, struct dt_device,
247                                             dd_kobj);
248         struct lod_device *lod = dt2lod_dev(dt);
249
250         return scnprintf(buf, PAGE_SIZE, "%lld\n",
251                 lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_offset);
252 }
253
254 /**
255  * Set default stripe offset.
256  *
257  * Usually contains -1 allowing Lustre to balance objects among OST
258  * otherwise may cause severe OST imbalance.
259  */
260 static ssize_t stripeoffset_store(struct kobject *kobj,
261                                     struct attribute *attr,
262                                     const char *buffer, size_t count)
263 {
264         struct dt_device *dt = container_of(kobj, struct dt_device,
265                                             dd_kobj);
266         struct lod_device *lod = dt2lod_dev(dt);
267         long val;
268         int rc;
269
270         rc = kstrtol(buffer, 0, &val);
271         if (rc)
272                 return rc;
273
274         if (val < -1 || val > LOV_MAX_STRIPE_COUNT)
275                 return -ERANGE;
276
277         lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_offset = val;
278
279         return count;
280 }
281
282 LUSTRE_RW_ATTR(stripeoffset);
283
284 /**
285  * Show default striping pattern (LOV_PATTERN_*).
286  */
287 static ssize_t __stripetype_show(struct kobject *kobj, struct attribute *attr,
288                                  char *buf, bool is_mdt)
289 {
290         struct dt_device *dt = container_of(kobj, struct dt_device,
291                                             dd_kobj);
292         struct lod_device *lod = dt2lod_dev(dt);
293         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
294                                             &lod->lod_ost_descs;
295
296         return scnprintf(buf, PAGE_SIZE, "%u\n", ltd->ltd_lov_desc.ld_pattern);
297 }
298
299 static ssize_t mdt_stripetype_show(struct kobject *kobj, struct attribute *attr,
300                                    char *buf)
301 {
302         return __stripetype_show(kobj, attr, buf, true);
303 }
304
305 static ssize_t stripetype_show(struct kobject *kobj, struct attribute *attr,
306                                char *buf)
307 {
308         return __stripetype_show(kobj, attr, buf, false);
309 }
310
311 /**
312  * Set default striping pattern (a number, not a human-readable string).
313  */
314 static ssize_t __stripetype_store(struct kobject *kobj, struct attribute *attr,
315                                   const char *buffer, size_t count, bool is_mdt)
316 {
317         struct dt_device *dt = container_of(kobj, struct dt_device,
318                                             dd_kobj);
319         struct lod_device *lod = dt2lod_dev(dt);
320         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
321                                             &lod->lod_ost_descs;
322         u32 pattern;
323         int rc;
324
325         rc = kstrtouint(buffer, 0, &pattern);
326         if (rc)
327                 return rc;
328
329         if (is_mdt)
330                 lod_fix_lmv_desc_pattern(&pattern);
331         else
332                 lod_fix_desc_pattern(&pattern);
333
334         ltd->ltd_lov_desc.ld_pattern = pattern;
335
336         return count;
337 }
338
339 static ssize_t mdt_stripetype_store(struct kobject *kobj,
340                                     struct attribute *attr, const char *buffer,
341                                     size_t count)
342 {
343         return __stripetype_store(kobj, attr, buffer, count, true);
344 }
345
346 static ssize_t stripetype_store(struct kobject *kobj,
347                                     struct attribute *attr, const char *buffer,
348                                     size_t count)
349 {
350         return __stripetype_store(kobj, attr, buffer, count, false);
351 }
352
353 LUSTRE_RW_ATTR(mdt_stripetype);
354 LUSTRE_RW_ATTR(stripetype);
355
356 /**
357  * Show default number of stripes.
358  */
359 static ssize_t __stripecount_show(struct kobject *kobj, struct attribute *attr,
360                                   char *buf, bool is_mdt)
361 {
362         struct dt_device *dt = container_of(kobj, struct dt_device,
363                                             dd_kobj);
364         struct lod_device *lod = dt2lod_dev(dt);
365         struct lov_desc *desc = is_mdt ? &lod->lod_mdt_descs.ltd_lov_desc :
366                                          &lod->lod_ost_descs.ltd_lov_desc;
367
368         return scnprintf(buf, PAGE_SIZE, "%d\n",
369                          (s16)(desc->ld_default_stripe_count + 1) - 1);
370 }
371
372 static ssize_t mdt_stripecount_show(struct kobject *kobj,
373                                     struct attribute *attr, char *buf)
374 {
375         return __stripecount_show(kobj, attr, buf, true);
376 }
377
378 static ssize_t stripecount_show(struct kobject *kobj, struct attribute *attr,
379                                 char *buf)
380 {
381         return __stripecount_show(kobj, attr, buf, false);
382 }
383
384 /**
385  * Set default number of stripes.
386  */
387 static ssize_t __stripecount_store(struct kobject *kobj, struct attribute *attr,
388                                    const char *buffer, size_t count,
389                                    bool is_mdt)
390 {
391         struct dt_device *dt = container_of(kobj, struct dt_device,
392                                             dd_kobj);
393         struct lod_device *lod = dt2lod_dev(dt);
394         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
395                                             &lod->lod_ost_descs;
396         int stripe_count;
397         int rc;
398
399         rc = kstrtoint(buffer, 0, &stripe_count);
400         if (rc)
401                 return rc;
402
403         if (stripe_count < -1)
404                 return -ERANGE;
405
406         lod_fix_desc_stripe_count(&stripe_count);
407         ltd->ltd_lov_desc.ld_default_stripe_count = stripe_count;
408
409         return count;
410 }
411
412 static ssize_t mdt_stripecount_store(struct kobject *kobj,
413                                      struct attribute *attr,
414                                      const char *buffer, size_t count)
415 {
416         return __stripecount_store(kobj, attr, buffer, count, true);
417 }
418
419 static ssize_t stripecount_store(struct kobject *kobj,
420                                  struct attribute *attr,
421                                  const char *buffer, size_t count)
422 {
423         return __stripecount_store(kobj, attr, buffer, count, false);
424 }
425
426 LUSTRE_RW_ATTR(mdt_stripecount);
427 LUSTRE_RW_ATTR(stripecount);
428
429 /**
430  * Show number of targets.
431  */
432 static ssize_t __numobd_show(struct kobject *kobj, struct attribute *attr,
433                              char *buf, bool is_mdt)
434 {
435         struct dt_device *dt = container_of(kobj, struct dt_device,
436                                             dd_kobj);
437         struct lod_device *lod = dt2lod_dev(dt);
438         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
439                                             &lod->lod_ost_descs;
440
441         return scnprintf(buf, PAGE_SIZE, "%u\n",
442                          ltd->ltd_lov_desc.ld_tgt_count);
443 }
444
445 static ssize_t mdt_numobd_show(struct kobject *kobj, struct attribute *attr,
446                                char *buf)
447 {
448         return __numobd_show(kobj, attr, buf, true);
449 }
450
451 static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr,
452                            char *buf)
453 {
454         return __numobd_show(kobj, attr, buf, false);
455 }
456
457 LUSTRE_RO_ATTR(mdt_numobd);
458 LUSTRE_RO_ATTR(numobd);
459
460 /**
461  * Show number of active targets.
462  */
463 static ssize_t __activeobd_show(struct kobject *kobj, struct attribute *attr,
464                                 char *buf, bool is_mdt)
465 {
466         struct dt_device *dt = container_of(kobj, struct dt_device,
467                                             dd_kobj);
468         struct lod_device *lod = dt2lod_dev(dt);
469         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
470                                             &lod->lod_ost_descs;
471
472         return scnprintf(buf, PAGE_SIZE, "%u\n",
473                          ltd->ltd_lov_desc.ld_active_tgt_count);
474 }
475
476 static ssize_t mdt_activeobd_show(struct kobject *kobj, struct attribute *attr,
477                                   char *buf)
478 {
479         return __activeobd_show(kobj, attr, buf, true);
480 }
481
482 static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr,
483                               char *buf)
484 {
485         return __activeobd_show(kobj, attr, buf, false);
486 }
487
488 LUSTRE_RO_ATTR(mdt_activeobd);
489 LUSTRE_RO_ATTR(activeobd);
490
491 /**
492  * Show UUID of LOD device.
493  */
494 static ssize_t desc_uuid_show(struct kobject *kobj, struct attribute *attr,
495                               char *buf)
496 {
497         struct dt_device *dt = container_of(kobj, struct dt_device,
498                                             dd_kobj);
499         struct lod_device *lod = dt2lod_dev(dt);
500
501         return scnprintf(buf, PAGE_SIZE, "%s\n",
502                          lod->lod_ost_descs.ltd_lov_desc.ld_uuid.uuid);
503 }
504 LUSTRE_RO_ATTR(desc_uuid);
505
506 /**
507  * Show QoS priority parameter.
508  *
509  * The printed value is a percentage value (0-100%) indicating the priority
510  * of free space compared to performance. 0% means select OSTs equally
511  * regardless of their free space, 100% means select OSTs only by their free
512  * space even if it results in very imbalanced load on the OSTs.
513  */
514 static ssize_t __qos_prio_free_show(struct kobject *kobj,
515                                     struct attribute *attr, char *buf,
516                                     bool is_mdt)
517 {
518         struct dt_device *dt = container_of(kobj, struct dt_device,
519                                             dd_kobj);
520         struct lod_device *lod = dt2lod_dev(dt);
521         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
522                                             &lod->lod_ost_descs;
523
524         return scnprintf(buf, PAGE_SIZE, "%d%%\n",
525                          (ltd->ltd_qos.lq_prio_free * 100 + 255) >> 8);
526 }
527
528 static ssize_t mdt_qos_prio_free_show(struct kobject *kobj,
529                                       struct attribute *attr, char *buf)
530 {
531         return __qos_prio_free_show(kobj, attr, buf, true);
532 }
533
534 static ssize_t qos_prio_free_show(struct kobject *kobj,
535                                   struct attribute *attr, char *buf)
536 {
537         return __qos_prio_free_show(kobj, attr, buf, false);
538 }
539
540 /**
541  * Set QoS free space priority parameter.
542  *
543  * Set the relative priority of free OST space compared to OST load when OSTs
544  * are space imbalanced.  See qos_priofree_show() for description of
545  * this parameter.  See qos_threshold_rr_store() and lq_threshold_rr to
546  * determine what constitutes "space imbalanced" OSTs.
547  */
548 static ssize_t __qos_prio_free_store(struct kobject *kobj,
549                                      struct attribute *attr,
550                                      const char *buffer, size_t count,
551                                      bool is_mdt)
552 {
553         struct dt_device *dt = container_of(kobj, struct dt_device,
554                                             dd_kobj);
555         struct lod_device *lod = dt2lod_dev(dt);
556         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
557                                             &lod->lod_ost_descs;
558         char buf[6], *tmp;
559         unsigned int val;
560         int rc;
561
562         /* "100%\n\0" should be largest string */
563         if (count >= sizeof(buf))
564                 return -ERANGE;
565
566         strncpy(buf, buffer, sizeof(buf));
567         buf[sizeof(buf) - 1] = '\0';
568         tmp = strchr(buf, '%');
569         if (tmp)
570                 *tmp = '\0';
571
572         rc = kstrtouint(buf, 0, &val);
573         if (rc)
574                 return rc;
575
576         if (val > 100)
577                 return -EINVAL;
578
579         ltd->ltd_qos.lq_prio_free = (val << 8) / 100;
580         set_bit(LQ_DIRTY, &ltd->ltd_qos.lq_flags);
581         set_bit(LQ_RESET, &ltd->ltd_qos.lq_flags);
582
583         return count;
584 }
585
586 static ssize_t mdt_qos_prio_free_store(struct kobject *kobj,
587                                        struct attribute *attr,
588                                        const char *buffer, size_t count)
589 {
590         return __qos_prio_free_store(kobj, attr, buffer, count, true);
591 }
592
593 static ssize_t qos_prio_free_store(struct kobject *kobj, struct attribute *attr,
594                                    const char *buffer, size_t count)
595 {
596         return __qos_prio_free_store(kobj, attr, buffer, count, false);
597 }
598
599 LUSTRE_RW_ATTR(mdt_qos_prio_free);
600 LUSTRE_RW_ATTR(qos_prio_free);
601
602 /**
603  * Show threshold for "same space on all OSTs" rule.
604  */
605 static ssize_t __qos_threshold_rr_show(struct kobject *kobj,
606                                        struct attribute *attr, char *buf,
607                                        bool is_mdt)
608 {
609         struct dt_device *dt = container_of(kobj, struct dt_device,
610                                             dd_kobj);
611         struct lod_device *lod = dt2lod_dev(dt);
612         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
613                                             &lod->lod_ost_descs;
614
615         return scnprintf(buf, PAGE_SIZE, "%d%%\n",
616                          (ltd->ltd_qos.lq_threshold_rr * 100 + 255) >> 8);
617 }
618
619 static ssize_t mdt_qos_threshold_rr_show(struct kobject *kobj,
620                                          struct attribute *attr, char *buf)
621 {
622         return __qos_threshold_rr_show(kobj, attr, buf, true);
623 }
624
625 static ssize_t qos_threshold_rr_show(struct kobject *kobj,
626                                      struct attribute *attr, char *buf)
627 {
628         return __qos_threshold_rr_show(kobj, attr, buf, false);
629 }
630
631 /**
632  * Set threshold for "same space on all OSTs" rule.
633  *
634  * This sets the maximum percentage difference of free space between the most
635  * full and most empty OST in the currently available OSTs. If this percentage
636  * is exceeded, use the QoS allocator to select OSTs based on their available
637  * space so that more full OSTs are chosen less often, otherwise use the
638  * round-robin allocator for efficiency and performance.
639  */
640 static ssize_t __qos_threshold_rr_store(struct kobject *kobj,
641                                         struct attribute *attr,
642                                         const char *buffer, size_t count,
643                                         bool is_mdt)
644 {
645         struct dt_device *dt = container_of(kobj, struct dt_device,
646                                             dd_kobj);
647         struct lod_device *lod = dt2lod_dev(dt);
648         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
649                                             &lod->lod_ost_descs;
650         char buf[6], *tmp;
651         unsigned int val;
652         int rc;
653
654         /* "100%\n\0" should be largest string */
655         if (count >= sizeof(buf))
656                 return -ERANGE;
657
658         strncpy(buf, buffer, sizeof(buf));
659         buf[sizeof(buf) - 1] = '\0';
660         tmp = strchr(buf, '%');
661         if (tmp)
662                 *tmp = '\0';
663
664         rc = kstrtouint(buf, 0, &val);
665         if (rc)
666                 return rc;
667
668         if (val > 100)
669                 return -EINVAL;
670         ltd->ltd_qos.lq_threshold_rr = (val << 8) / 100;
671         set_bit(LQ_DIRTY, &ltd->ltd_qos.lq_flags);
672
673         return count;
674 }
675
676 static ssize_t mdt_qos_threshold_rr_store(struct kobject *kobj,
677                                           struct attribute *attr,
678                                           const char *buffer, size_t count)
679 {
680         return __qos_threshold_rr_store(kobj, attr, buffer, count, true);
681 }
682
683 static ssize_t qos_threshold_rr_store(struct kobject *kobj,
684                                       struct attribute *attr,
685                                       const char *buffer, size_t count)
686 {
687         return __qos_threshold_rr_store(kobj, attr, buffer, count, false);
688 }
689
690 LUSTRE_RW_ATTR(mdt_qos_threshold_rr);
691 LUSTRE_RW_ATTR(qos_threshold_rr);
692
693 /**
694  * Show expiration period used to refresh cached statfs data, which
695  * is used to implement QoS/RR striping allocation algorithm.
696  */
697 static ssize_t __qos_maxage_show(struct kobject *kobj, struct attribute *attr,
698                                  char *buf, bool is_mdt)
699 {
700         struct dt_device *dt = container_of(kobj, struct dt_device,
701                                             dd_kobj);
702         struct lod_device *lod = dt2lod_dev(dt);
703         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
704                                             &lod->lod_ost_descs;
705
706         return scnprintf(buf, PAGE_SIZE, "%u\n",
707                          ltd->ltd_lov_desc.ld_qos_maxage);
708 }
709
710 static ssize_t mdt_qos_maxage_show(struct kobject *kobj, struct attribute *attr,
711                                    char *buf)
712 {
713         return __qos_maxage_show(kobj, attr, buf, true);
714 }
715
716 static ssize_t qos_maxage_show(struct kobject *kobj, struct attribute *attr,
717                                char *buf)
718 {
719         return __qos_maxage_show(kobj, attr, buf, true);
720 }
721
722 /**
723  * Set expiration period used to refresh cached statfs data.
724  */
725 static ssize_t __qos_maxage_store(struct kobject *kobj, struct attribute *attr,
726                                   const char *buffer, size_t count, bool is_mdt)
727 {
728         struct dt_device *dt = container_of(kobj, struct dt_device,
729                                             dd_kobj);
730         struct lod_device *lod = dt2lod_dev(dt);
731         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
732                                             &lod->lod_ost_descs;
733         struct lustre_cfg_bufs bufs;
734         struct lu_device *next;
735         struct lustre_cfg *lcfg;
736         char str[32];
737         struct lu_tgt_desc *tgt;
738         int rc;
739         u32 val;
740
741         rc = kstrtouint(buffer, 0, &val);
742         if (rc)
743                 return rc;
744
745         if (val <= 0)
746                 return -EINVAL;
747
748         ltd->ltd_lov_desc.ld_qos_maxage = val;
749
750         /*
751          * propogate the value down to OSPs
752          */
753         lustre_cfg_bufs_reset(&bufs, NULL);
754         snprintf(str, 32, "%smaxage=%u", PARAM_OSP, val);
755         lustre_cfg_bufs_set_string(&bufs, 1, str);
756         OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
757         if (lcfg == NULL)
758                 return -ENOMEM;
759         lustre_cfg_init(lcfg, LCFG_PARAM, &bufs);
760
761         lod_getref(ltd);
762         ltd_foreach_tgt(ltd, tgt) {
763                 next = &tgt->ltd_tgt->dd_lu_dev;
764                 rc = next->ld_ops->ldo_process_config(NULL, next, lcfg);
765                 if (rc)
766                         CERROR("can't set maxage on #%d: %d\n",
767                                tgt->ltd_index, rc);
768         }
769         lod_putref(lod, ltd);
770         OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
771
772         return count;
773 }
774
775 static ssize_t mdt_qos_maxage_store(struct kobject *kobj,
776                                     struct attribute *attr,
777                                     const char *buffer, size_t count)
778 {
779         return __qos_maxage_store(kobj, attr, buffer, count, true);
780 }
781
782 static ssize_t qos_maxage_store(struct kobject *kobj, struct attribute *attr,
783                                 const char *buffer, size_t count)
784 {
785         return __qos_maxage_store(kobj, attr, buffer, count, false);
786 }
787
788 LUSTRE_RW_ATTR(mdt_qos_maxage);
789 LUSTRE_RW_ATTR(qos_maxage);
790
791 static void *lod_tgts_seq_start(struct seq_file *p, loff_t *pos, bool is_mdt)
792 {
793         struct obd_device *obd = p->private;
794         struct lod_device *lod = lu2lod_dev(obd->obd_lu_dev);
795         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
796                                             &lod->lod_ost_descs;
797
798         LASSERT(obd != NULL);
799
800         lod_getref(ltd); /* released in lod_tgts_seq_stop */
801         if (*pos >= ltd->ltd_tgts_size)
802                 return NULL;
803
804         *pos = find_next_bit(ltd->ltd_tgt_bitmap,
805                              ltd->ltd_tgts_size, *pos);
806         if (*pos < ltd->ltd_tgts_size)
807                 return LTD_TGT(ltd, *pos);
808         else
809                 return NULL;
810 }
811
812 static void *lod_mdts_seq_start(struct seq_file *p, loff_t *pos)
813 {
814         return lod_tgts_seq_start(p, pos, true);
815 }
816
817 static void *lod_osts_seq_start(struct seq_file *p, loff_t *pos)
818 {
819         return lod_tgts_seq_start(p, pos, false);
820 }
821
822 static void lod_tgts_seq_stop(struct seq_file *p, void *v, bool is_mdt)
823 {
824         struct obd_device *obd = p->private;
825         struct lod_device *lod = lu2lod_dev(obd->obd_lu_dev);
826         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
827                                             &lod->lod_ost_descs;
828
829         LASSERT(obd != NULL);
830         lod_putref(lod, ltd);
831 }
832
833 static void lod_mdts_seq_stop(struct seq_file *p, void *v)
834 {
835         lod_tgts_seq_stop(p, v, true);
836 }
837
838 static void lod_osts_seq_stop(struct seq_file *p, void *v)
839 {
840         lod_tgts_seq_stop(p, v, false);
841 }
842
843 static void *lod_tgts_seq_next(struct seq_file *p, void *v, loff_t *pos,
844                                bool is_mdt)
845 {
846         struct obd_device *obd = p->private;
847         struct lod_device *lod = lu2lod_dev(obd->obd_lu_dev);
848         struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
849                                             &lod->lod_ost_descs;
850
851         (*pos)++;
852         if (*pos > ltd->ltd_tgts_size - 1)
853                 return NULL;
854
855         *pos = find_next_bit(ltd->ltd_tgt_bitmap,
856                              ltd->ltd_tgts_size, *pos);
857         if (*pos < ltd->ltd_tgts_size)
858                 return LTD_TGT(ltd, *pos);
859         else
860                 return NULL;
861 }
862
863 static void *lod_mdts_seq_next(struct seq_file *p, void *v, loff_t *pos)
864 {
865         return lod_tgts_seq_next(p, v, pos, true);
866 }
867
868 static void *lod_osts_seq_next(struct seq_file *p, void *v, loff_t *pos)
869 {
870         return lod_tgts_seq_next(p, v, pos, false);
871 }
872
873 /**
874  * Show active/inactive status for OST found by lod_osts_seq_next().
875  *
876  * \param[in] m         seq file
877  * \param[in] v         unused for single entry
878  *
879  * \retval 0            on success
880  * \retval negative     error code if failed
881  */
882 static int lod_tgts_seq_show(struct seq_file *p, void *v)
883 {
884         struct obd_device *obd = p->private;
885         struct lu_tgt_desc *tgt = v;
886         struct dt_device *next;
887         int rc, active;
888
889         LASSERT(obd->obd_lu_dev);
890
891         next = tgt->ltd_tgt;
892         if (!next)
893                 return -EINVAL;
894
895         /* XXX: should be non-NULL env, but it's very expensive */
896         active = 1;
897         rc = dt_statfs(NULL, next, &tgt->ltd_statfs);
898         if (rc == -ENOTCONN) {
899                 active = 0;
900                 rc = 0;
901         } else if (rc)
902                 return rc;
903
904         seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index,
905                    obd_uuid2str(&tgt->ltd_uuid),
906                    active ? "" : "IN");
907         return 0;
908 }
909
910 static const struct seq_operations lod_mdts_sops = {
911         .start  = lod_mdts_seq_start,
912         .stop   = lod_mdts_seq_stop,
913         .next   = lod_mdts_seq_next,
914         .show   = lod_tgts_seq_show,
915 };
916
917 static const struct seq_operations lod_osts_sops = {
918         .start  = lod_osts_seq_start,
919         .stop   = lod_osts_seq_stop,
920         .next   = lod_osts_seq_next,
921         .show   = lod_tgts_seq_show,
922 };
923
924 static int lod_mdts_seq_open(struct inode *inode, struct file *file)
925 {
926         struct seq_file *seq;
927         int rc;
928
929         rc = seq_open(file, &lod_mdts_sops);
930         if (rc)
931                 return rc;
932
933         seq = file->private_data;
934         seq->private = PDE_DATA(inode);
935         return 0;
936 }
937
938 static int lod_osts_seq_open(struct inode *inode, struct file *file)
939 {
940         struct seq_file *seq;
941         int rc;
942
943         rc = seq_open(file, &lod_osts_sops);
944         if (rc)
945                 return rc;
946
947         seq = file->private_data;
948         seq->private = PDE_DATA(inode);
949         return 0;
950 }
951
952 /**
953  * Show whether special failout mode for testing is enabled or not.
954  */
955 static ssize_t lmv_failout_show(struct kobject *kobj, struct attribute *attr,
956                                 char *buf)
957 {
958         struct dt_device *dt = container_of(kobj, struct dt_device,
959                                             dd_kobj);
960         struct lod_device *lod = dt2lod_dev(dt);
961
962         return scnprintf(buf, PAGE_SIZE, "%d\n", lod->lod_lmv_failout ? 1 : 0);
963 }
964
965 /**
966  * Enable/disable a special failout mode for testing.
967  *
968  * This determines whether the LMV will try to continue processing a striped
969  * directory even if it has a (partly) corrupted entry in the master directory,
970  * or if it will abort upon finding a corrupted slave directory entry.
971  */
972 static ssize_t lmv_failout_store(struct kobject *kobj, struct attribute *attr,
973                                  const char *buffer, size_t count)
974 {
975         struct dt_device *dt = container_of(kobj, struct dt_device,
976                                             dd_kobj);
977         struct lod_device *lod = dt2lod_dev(dt);
978         bool val = 0;
979         int rc;
980
981         rc = kstrtobool(buffer, &val);
982         if (rc)
983                 return rc;
984
985         lod->lod_lmv_failout = val;
986
987         return count;
988 }
989 LUSTRE_RW_ATTR(lmv_failout);
990
991 static ssize_t mdt_hash_show(struct kobject *kobj, struct attribute *attr,
992                              char *buf)
993 {
994         struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
995         struct lod_device *lod = dt2lod_dev(dt);
996
997         return scnprintf(buf, PAGE_SIZE, "%s\n",
998                 mdt_hash_name[lod->lod_mdt_descs.ltd_lmv_desc.ld_pattern]);
999 }
1000
1001 static ssize_t mdt_hash_store(struct kobject *kobj, struct attribute *attr,
1002                               const char *buffer, size_t count)
1003 {
1004         struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
1005         struct lod_device *lod = dt2lod_dev(dt);
1006         char *hash;
1007         int len;
1008         int i;
1009
1010         hash = kstrndup(buffer, count, GFP_KERNEL);
1011         if (!hash)
1012                 return -ENOMEM;
1013
1014         len = strcspn(hash, "\n ");
1015         hash[len] = '\0';
1016         for (i = LMV_HASH_TYPE_ALL_CHARS; i < LMV_HASH_TYPE_MAX; i++) {
1017                 if (!strcmp(hash, mdt_hash_name[i])) {
1018                         lod->lod_mdt_descs.ltd_lmv_desc.ld_pattern = i;
1019                         kfree(hash);
1020                         return count;
1021                 }
1022         }
1023         kfree(hash);
1024
1025         return -EINVAL;
1026 }
1027 LUSTRE_RW_ATTR(mdt_hash);
1028
1029 static const struct proc_ops lod_proc_mdt_fops = {
1030         PROC_OWNER(THIS_MODULE)
1031         .proc_open      = lod_mdts_seq_open,
1032         .proc_read      = seq_read,
1033         .proc_lseek     = seq_lseek,
1034         .proc_release   = lprocfs_seq_release,
1035 };
1036
1037 static int lod_spill_threshold_pct_seq_show(struct seq_file *m, void *v)
1038 {
1039         struct pool_desc *pool = m->private;
1040
1041         LASSERT(pool != NULL);
1042         seq_printf(m, "%d\n", pool->pool_spill_threshold_pct);
1043
1044         return 0;
1045 }
1046
1047 static ssize_t
1048 lod_spill_threshold_pct_seq_write(struct file *file, const char __user *buffer,
1049                                   size_t count, loff_t *off)
1050 {
1051         struct seq_file *m = file->private_data;
1052         struct pool_desc *pool = m->private;
1053         int rc;
1054         int val;
1055
1056         LASSERT(pool != NULL);
1057
1058         rc = kstrtoint_from_user(buffer, count, 0, &val);
1059         if (rc)
1060                 return rc;
1061
1062         if (val > 100 || val < 0)
1063                 return -EINVAL;
1064
1065         pool->pool_spill_threshold_pct = val;
1066         pool->pool_spill_expire = 0;
1067         if (pool->pool_spill_threshold_pct == 0)
1068                 pool->pool_spill_is_active = false;
1069
1070         return count;
1071 }
1072 LPROC_SEQ_FOPS(lod_spill_threshold_pct);
1073
1074 static int lod_spill_target_seq_show(struct seq_file *m, void *v)
1075 {
1076         struct pool_desc *pool = m->private;
1077
1078         LASSERT(pool != NULL);
1079         seq_printf(m, "%s\n", pool->pool_spill_target);
1080
1081         return 0;
1082 }
1083
1084 static ssize_t
1085 lod_spill_target_seq_write(struct file *file, const char __user *buffer,
1086                            size_t count, loff_t *off)
1087 {
1088         struct seq_file *m = file->private_data;
1089         struct pool_desc *pool = m->private;
1090         struct lod_device *lod;
1091
1092         LASSERT(pool != NULL);
1093         lod = lu2lod_dev(pool->pool_lobd->obd_lu_dev);
1094
1095         if (count == 0) {
1096                 pool->pool_spill_target[0] = '\0';
1097                 pool->pool_spill_is_active = false;
1098                 return count;
1099         }
1100
1101         if (count > LOV_MAXPOOLNAME - 1)
1102                 return -E2BIG;
1103         if (copy_from_user(pool->pool_spill_target, buffer, count))
1104                 return -EFAULT;
1105
1106         pool->pool_spill_target[count] = '\0';
1107         if (strcmp(pool->pool_name, pool->pool_spill_target) == 0)
1108                 return -ELOOP;
1109         if (!lod_pool_exists(lod, pool->pool_spill_target)) {
1110                 pool->pool_spill_target[0] = '\0';
1111                 pool->pool_spill_expire = 0;
1112                 return -ENODEV;
1113         }
1114
1115         return count;
1116 }
1117 LPROC_SEQ_FOPS(lod_spill_target);
1118
1119 static int lod_spill_is_active_seq_show(struct seq_file *m, void *v)
1120 {
1121         struct pool_desc *pool = m->private;
1122         struct lod_device *lod;
1123         struct lu_env env;
1124         int rc;
1125
1126         if (!pool)
1127                 return -ENODEV;
1128
1129         rc = lu_env_init(&env, LCT_LOCAL);
1130         if (rc)
1131                 return rc;
1132
1133         lod = lu2lod_dev(pool->pool_lobd->obd_lu_dev);
1134         lod_spill_target_refresh(&env, lod, pool);
1135         lu_env_fini(&env);
1136
1137         seq_printf(m, "%d\n", pool->pool_spill_is_active ? 1 : 0);
1138
1139         return 0;
1140 }
1141 LPROC_SEQ_FOPS_RO(lod_spill_is_active);
1142
1143 struct lprocfs_vars lprocfs_lod_spill_vars[] = {
1144         { .name =       "spill_threshold_pct",
1145           .fops =       &lod_spill_threshold_pct_fops },
1146         { .name =       "spill_target",
1147           .fops =       &lod_spill_target_fops },
1148         { .name =       "spill_is_active",
1149           .fops =       &lod_spill_is_active_fops },
1150         { NULL }
1151 };
1152
1153 static struct proc_ops lod_proc_target_fops = {
1154         PROC_OWNER(THIS_MODULE)
1155         .proc_open      = lod_osts_seq_open,
1156         .proc_read      = seq_read,
1157         .proc_lseek     = seq_lseek,
1158         .proc_release   = lprocfs_seq_release,
1159 };
1160
1161 static struct attribute *lod_attrs[] = {
1162         &lustre_attr_dom_stripesize.attr,
1163         &lustre_attr_dom_stripesize_max_kb.attr,
1164         &lustre_attr_dom_stripesize_cur_kb.attr,
1165         &lustre_attr_dom_threshold_free_mb.attr,
1166         &lustre_attr_stripesize.attr,
1167         &lustre_attr_stripeoffset.attr,
1168         &lustre_attr_stripecount.attr,
1169         &lustre_attr_stripetype.attr,
1170         &lustre_attr_activeobd.attr,
1171         &lustre_attr_desc_uuid.attr,
1172         &lustre_attr_lmv_failout.attr,
1173         &lustre_attr_numobd.attr,
1174         &lustre_attr_qos_maxage.attr,
1175         &lustre_attr_qos_prio_free.attr,
1176         &lustre_attr_qos_threshold_rr.attr,
1177         &lustre_attr_mdt_stripecount.attr,
1178         &lustre_attr_mdt_stripetype.attr,
1179         &lustre_attr_mdt_activeobd.attr,
1180         &lustre_attr_mdt_numobd.attr,
1181         &lustre_attr_mdt_qos_maxage.attr,
1182         &lustre_attr_mdt_qos_prio_free.attr,
1183         &lustre_attr_mdt_qos_threshold_rr.attr,
1184         &lustre_attr_mdt_hash.attr,
1185         NULL,
1186 };
1187
1188 /**
1189  * Initialize procfs entries for LOD.
1190  *
1191  * \param[in] lod       LOD device
1192  *
1193  * \retval 0            on success
1194  * \retval negative     error code if failed
1195  */
1196 int lod_procfs_init(struct lod_device *lod)
1197 {
1198         struct obd_device *obd = lod2obd(lod);
1199         struct obd_type *type;
1200         struct kobject *lov;
1201         int rc;
1202
1203         lod->lod_dt_dev.dd_ktype.default_attrs = lod_attrs;
1204         rc = dt_tunables_init(&lod->lod_dt_dev, obd->obd_type, obd->obd_name,
1205                               NULL);
1206         if (rc) {
1207                 CERROR("%s: failed to setup DT tunables: %d\n",
1208                        obd->obd_name, rc);
1209                 RETURN(rc);
1210         }
1211
1212         obd->obd_proc_entry = lprocfs_register(obd->obd_name,
1213                                                obd->obd_type->typ_procroot,
1214                                                NULL, obd);
1215         if (IS_ERR(obd->obd_proc_entry)) {
1216                 rc = PTR_ERR(obd->obd_proc_entry);
1217                 CERROR("%s: error %d setting up lprocfs\n",
1218                        obd->obd_name, rc);
1219                 GOTO(out, rc);
1220         }
1221
1222         rc = lprocfs_seq_create(obd->obd_proc_entry, "mdt_obd",
1223                                 0444, &lod_proc_mdt_fops, obd);
1224         if (rc) {
1225                 CWARN("%s: Error adding the target_obd file %d\n",
1226                       obd->obd_name, rc);
1227                 GOTO(out, rc);
1228         }
1229
1230         rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
1231                                 0444, &lod_proc_target_fops, obd);
1232         if (rc) {
1233                 CWARN("%s: Error adding the target_obd file %d\n",
1234                       obd->obd_name, rc);
1235                 GOTO(out, rc);
1236         }
1237
1238         lod->lod_pool_proc_entry = lprocfs_register("pools",
1239                                                     obd->obd_proc_entry,
1240                                                     NULL, NULL);
1241         if (IS_ERR(lod->lod_pool_proc_entry)) {
1242                 rc = PTR_ERR(lod->lod_pool_proc_entry);
1243                 lod->lod_pool_proc_entry = NULL;
1244                 CWARN("%s: Failed to create pools proc file: %d\n",
1245                       obd->obd_name, rc);
1246                 GOTO(out, rc);
1247         }
1248
1249         lod->lod_spill_proc_entry = lprocfs_register("pool",
1250                                                     obd->obd_proc_entry,
1251                                                     NULL, NULL);
1252         if (IS_ERR(lod->lod_spill_proc_entry)) {
1253                 rc = PTR_ERR(lod->lod_spill_proc_entry);
1254                 lod->lod_spill_proc_entry = NULL;
1255                 CWARN("%s: Failed to create pool proc file: %d\n",
1256                       obd->obd_name, rc);
1257                 GOTO(out, rc);
1258         }
1259
1260         lov = kset_find_obj(lustre_kset, "lov");
1261         if (!lov) {
1262                 CERROR("%s: lov subsystem not found\n", obd->obd_name);
1263                 GOTO(out, rc = -ENODEV);
1264         }
1265
1266         rc = sysfs_create_link(lov, &lod->lod_dt_dev.dd_kobj,
1267                                obd->obd_name);
1268         if (rc)
1269                 CERROR("%s: failed to create LOV sysfs symlink\n",
1270                        obd->obd_name);
1271         kobject_put(lov);
1272
1273         obd->obd_debugfs_entry = debugfs_create_dir(obd->obd_name,
1274                                                     obd->obd_type->typ_debugfs_entry);
1275
1276         lod->lod_debugfs = ldebugfs_add_symlink(obd->obd_name, "lov",
1277                                                 "../lod/%s", obd->obd_name);
1278         if (!lod->lod_debugfs)
1279                 CERROR("%s: failed to create LOV debugfs symlink\n",
1280                        obd->obd_name);
1281
1282         type = container_of(lov, struct obd_type, typ_kobj);
1283         if (!type->typ_procroot)
1284                 RETURN(0);
1285
1286         /* for compatibility we link old procfs's LOV entries to lod ones */
1287         lod->lod_symlink = lprocfs_add_symlink(obd->obd_name,
1288                                                type->typ_procroot,
1289                                                "../lod/%s", obd->obd_name);
1290         if (lod->lod_symlink == NULL)
1291                 CERROR("cannot create LOV symlink for /proc/fs/lustre/lod/%s\n",
1292                        obd->obd_name);
1293         RETURN(0);
1294
1295 out:
1296         dt_tunables_fini(&lod->lod_dt_dev);
1297
1298         return rc;
1299 }
1300
1301 /**
1302  * Cleanup procfs entries registred for LOD.
1303  *
1304  * \param[in] lod       LOD device
1305  */
1306 void lod_procfs_fini(struct lod_device *lod)
1307 {
1308         struct obd_device *obd = lod2obd(lod);
1309         struct kobject *lov;
1310
1311         if (lod->lod_symlink != NULL) {
1312                 lprocfs_remove(&lod->lod_symlink);
1313                 lod->lod_symlink = NULL;
1314         }
1315
1316         lov = kset_find_obj(lustre_kset, "lov");
1317         if (lov) {
1318                 sysfs_remove_link(lov, obd->obd_name);
1319                 kobject_put(lov);
1320         }
1321
1322         debugfs_remove_recursive(lod->lod_debugfs);
1323
1324         if (obd->obd_proc_entry) {
1325                 lprocfs_remove(&obd->obd_proc_entry);
1326                 obd->obd_proc_entry = NULL;
1327         }
1328
1329         dt_tunables_fini(&lod->lod_dt_dev);
1330 }
1331
1332 #endif /* CONFIG_PROC_FS */