Whamcloud - gitweb
LU-12616 obclass: fix MDS start/stop race
[fs/lustre-release.git] / lustre / utils / lustre_lfsck.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,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License version 2 for more details.  A copy is
14  * included in the COPYING file that accompanied this code.
15
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2012, 2017, Intel Corporation.
24  */
25 /*
26  * lustre/utils/lustre_lfsck.c
27  *
28  * Lustre user-space tools for LFSCK.
29  *
30  * Author: Fan Yong <yong.fan@whamcloud.com>
31  */
32
33 #include <stdio.h>
34 #include <unistd.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include <errno.h>
38 #include <getopt.h>
39 #include <sys/ioctl.h>
40 #include <time.h>
41
42 #include "obdctl.h"
43 #include "lustreapi_internal.h"
44
45 #include <linux/lnet/lnetctl.h>
46 #include <linux/lustre/lustre_ioctl.h>
47 #include <linux/lustre/lustre_lfsck_user.h>
48 /* Needs to be last to avoid clashes */
49 #include <libcfs/util/ioctl.h>
50 #include <libcfs/util/param.h>
51
52 static struct option long_opt_start[] = {
53 { .val = 'A',   .name = "all",                  .has_arg = no_argument },
54 { .val = 'c',   .name = "create_ostobj",        .has_arg = optional_argument },
55 { .val = 'c',   .name = "create-ostobj",        .has_arg = optional_argument },
56 { .val = 'C',   .name = "create_mdtobj",        .has_arg = optional_argument },
57 { .val = 'C',   .name = "create-mdtobj",        .has_arg = optional_argument },
58 { .val = 'd',   .name = "delay_create_ostobj",  .has_arg = optional_argument },
59 { .val = 'd',   .name = "delay-create-ostobj",  .has_arg = optional_argument },
60 { .val = 'e',   .name = "error",                .has_arg = required_argument },
61 { .val = 'h',   .name = "help",                 .has_arg = no_argument },
62 { .val = 'M',   .name = "device",               .has_arg = required_argument },
63 { .val = 'n',   .name = "dryrun",               .has_arg = optional_argument },
64 { .val = 'o',   .name = "orphan",               .has_arg = no_argument },
65 { .val = 'r',   .name = "reset",                .has_arg = no_argument },
66 { .val = 's',   .name = "speed",                .has_arg = required_argument },
67 { .val = 't',   .name = "type",                 .has_arg = required_argument },
68 { .val = 'w',   .name = "window_size",          .has_arg = required_argument },
69 { .val = 'w',   .name = "window-size",          .has_arg = required_argument },
70 { .name = NULL } };
71
72 static struct option long_opt_stop[] = {
73         { .val = 'A',   .name = "all",          .has_arg = no_argument },
74         { .val = 'h',   .name = "help",         .has_arg = no_argument },
75         { .val = 'M',   .name = "device",       .has_arg = required_argument },
76         { .name = NULL } };
77
78 static struct option long_opt_query[] = {
79         { .val = 'h',   .name = "help",         .has_arg = no_argument },
80         { .val = 'M',   .name = "device",       .has_arg = required_argument },
81         { .val = 't',   .name = "type",         .has_arg = required_argument },
82         { .val = 'w',   .name = "wait",         .has_arg = no_argument },
83         { .name = NULL } };
84
85 struct lfsck_type_name {
86         char            *ltn_name;
87         enum lfsck_type  ltn_type;
88 };
89
90 /* Note types must be in order of increasing value so we can iterate through
91  * this correctly.  See enum lfsck_type for values. LU-9894. */
92 static struct lfsck_type_name lfsck_types_names[] = {
93         { .ltn_name = "layout",         .ltn_type = LFSCK_TYPE_LAYOUT },
94         { .ltn_name = "namespace",      .ltn_type = LFSCK_TYPE_NAMESPACE },
95         { .ltn_name = "scrub",          .ltn_type = LFSCK_TYPE_SCRUB },
96         { .ltn_name = "all",            .ltn_type = LFSCK_TYPES_SUPPORTED },
97         { .ltn_name = "default",        .ltn_type = LFSCK_TYPES_DEF },
98         { .ltn_name = NULL } };
99
100 static enum lfsck_type lfsck_name2type(const char *name)
101 {
102         int i;
103
104         for (i = 0; lfsck_types_names[i].ltn_name != NULL; i++) {
105                 if (strcmp(lfsck_types_names[i].ltn_name, name) == 0)
106                         return lfsck_types_names[i].ltn_type;
107         }
108         return -1;
109 }
110
111 static const char *lfsck_type2name(__u16 type)
112 {
113         int i;
114
115         for (i = 0; lfsck_types_names[i].ltn_name != NULL; i++) {
116                 if (type == lfsck_types_names[i].ltn_type)
117                         return lfsck_types_names[i].ltn_name;
118         }
119
120         return NULL;
121 }
122
123 static void usage_start(void)
124 {
125         fprintf(stdout, "start LFSCK\n"
126                 "usage:\n"
127                 "lfsck_start [-M | --device {MDT,OST}_device]\n"
128                 "            [-A | --all] [-c | --create_ostobj [on | off]]\n"
129                 "            [-C | --create_mdtobj [on | off]]\n"
130                 "            [-d | --delay_create_ostobj [on | off]]\n"
131                 "            [-e | --error {continue | abort}] [-h | --help]\n"
132                 "            [-n | --dryrun [on | off]] [-o | --orphan]\n"
133                 "            [-r | --reset] [-s | --speed ops_per_sec_limit]\n"
134                 "            [-t | --type check_type[,check_type...]]\n"
135                 "            [-w | --window_size size]\n"
136                 "options:\n"
137                 "-M: device to start LFSCK/scrub on\n"
138                 "-A: start LFSCK on all nodes via the specified MDT device "
139                     "(see \"-M\" option) by single LFSCK command\n"
140                 "-c: create the lost OST-object for dangling LOV EA "
141                     "(default 'off', or 'on')\n"
142                 "-C: create the lost MDT-object for dangling name entry "
143                     "(default 'off', or 'on')\n"
144                 "-d: delay create the lost OST-object for dangling LOV EA "
145                     "until orphan OST-objects handled (default 'off', or 'on')\n"
146                 "-e: error handle mode (default 'continue', or 'abort')\n"
147                 "-h: this help message\n"
148                 "-n: check with no modification (default 'off', or 'on')\n"
149                 "-o: repair orphan OST-objects\n"
150                 "-r: reset scanning to the start of the device\n"
151                 "-s: maximum items to be scanned per second "
152                     "(default '%d' = no limit)\n"
153                 "-t: check type(s) to be performed (default all)\n"
154                 "-w: window size for async requests pipeline\n",
155                 LFSCK_SPEED_NO_LIMIT);
156 }
157
158 static void usage_stop(void)
159 {
160         fprintf(stdout, "stop LFSCK\n"
161                 "usage:\n"
162                 "lfsck_stop [-M | --device {MDT,OST}_device]\n"
163                 "           [-A | --all] [-h | --help]\n"
164                 "options:\n"
165                 "-M: device to stop LFSCK/scrub on\n"
166                 "-A: stop LFSCK on all nodes via the specified MDT device "
167                     "(see \"-M\" option) by single LFSCK command\n"
168                 "-h: this help message\n");
169 }
170
171 static void usage_query(void)
172 {
173         fprintf(stdout, "check the LFSCK global status\n"
174                 "usage:\n"
175                 "lfsck_query [-M | --device MDT_device] [-h | --help]\n"
176                 "            [-t | --type check_type[,check_type...]]\n"
177                 "            [-t | --wait]\n"
178                 "options:\n"
179                 "-M: device to query LFSCK on\n"
180                 "-t: LFSCK type(s) to be queried (default is all)\n"
181                 "-h: this help message\n"
182                 "-w: do not return until LFSCK not running\n");
183 }
184
185 static int lfsck_pack_dev(struct obd_ioctl_data *data, char *device, char *arg)
186 {
187         int len = strlen(arg) + 1;
188
189         if (len > MAX_OBD_NAME) {
190                 fprintf(stderr, "device name is too long. "
191                         "Valid length should be less than %d\n", MAX_OBD_NAME);
192                 return -EINVAL;
193         }
194
195         memcpy(device, arg, len);
196         data->ioc_inlbuf4 = device;
197         data->ioc_inllen4 = len;
198         data->ioc_dev = OBD_DEV_BY_DEVNAME;
199         return 0;
200 }
201
202 static int lfsck_get_dev_name(struct obd_ioctl_data *data, char *device,
203                               int types, bool multipe_devices)
204 {
205         glob_t param = { 0 };
206         size_t count = 0;
207         char *ptr;
208         int rc;
209         int i;
210
211         rc = cfs_get_param_paths(&param, "mdd/*-MDT*");
212         if (rc) {
213                 if (multipe_devices || errno != ENOENT ||
214                     types & LFSCK_TYPE_NAMESPACE) {
215                         fprintf(stderr, "Fail to get device name: rc = %d\n."
216                                 "You can specify the device explicitly "
217                                 "via '-M' option.\n", rc);
218                         return rc;
219                 }
220
221                 rc = cfs_get_param_paths(&param, "obdfilter/*-OST*");
222                 if (rc) {
223                         fprintf(stderr, "Fail to get device name: rc = %d\n."
224                                 "You can specify the device explicitly "
225                                 "via '-M' option.\n", rc);
226                         return rc;
227                 }
228         }
229
230         /* we have both sysfs and debugfs entries so to get the correct number
231          * of devices only count the entries in the sysfs tree
232          */
233         for (i = 0; i < param.gl_pathc; i++) {
234                 if (strstr(param.gl_pathv[i], "/sys/kernel/debug/lustre"))
235                         continue;
236                 count++;
237         }
238
239         if (count == 1)
240                 goto pack;
241
242         if (!multipe_devices) {
243                 fprintf(stderr,
244                         "Detect multiple devices on current node. "
245                         "Please specify the device explicitly "
246                         "via '-M' option or '-A' option for all.\n");
247                 rc = -EINVAL;
248                 goto out;
249         }
250
251         ptr = strrchr(param.gl_pathv[0], '-');
252         if (ptr == NULL) {
253                 rc = -EINVAL;
254                 goto out;
255         }
256
257         for (i = 1; i < param.gl_pathc; i++) {
258                 char *ptr2;
259
260                 if (strstr(param.gl_pathv[i], "/sys/kernel/debug/lustre"))
261                         continue;
262
263                 ptr2 = strrchr(param.gl_pathv[i], '-');
264                 if (ptr2 == NULL) {
265                         rc = -EINVAL;
266                         goto out;
267                 }
268
269                 if ((ptr - param.gl_pathv[0]) != (ptr2 - param.gl_pathv[i]) ||
270                     strncmp(param.gl_pathv[0], param.gl_pathv[i],
271                             (ptr - param.gl_pathv[0])) != 0) {
272                         fprintf(stderr,
273                                 "Detect multiple filesystems on current node. "
274                                 "Please specify the device explicitly "
275                                 "via '-M' option.\n");
276                         rc = -EINVAL;
277                         goto out;
278                 }
279         }
280
281 pack:
282         rc = lfsck_pack_dev(data, device, basename(param.gl_pathv[0]));
283
284 out:
285         cfs_free_param_data(&param);
286
287         return rc;
288 }
289
290 int jt_lfsck_start(int argc, char **argv)
291 {
292         struct obd_ioctl_data data;
293         char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
294         char device[MAX_OBD_NAME];
295         struct lfsck_start start;
296         char *short_opts = "Ac::C::d::e:hM:n::ors:t:w:";
297         int opt, index, rc, val, i;
298
299         memset(&data, 0, sizeof(data));
300         memset(&start, 0, sizeof(start));
301         memset(device, 0, MAX_OBD_NAME);
302         start.ls_version = LFSCK_VERSION_V1;
303         start.ls_active = LFSCK_TYPES_ALL;
304
305         /* Reset the 'optind' for the case of getopt_long() called multiple
306          * times under the same lctl. */
307         optind = 0;
308         while ((opt = getopt_long(argc, argv, short_opts, long_opt_start,
309                                   &index)) != EOF) {
310                 switch (opt) {
311                 case 'A':
312                         start.ls_flags |= LPF_ALL_TGT | LPF_BROADCAST;
313                         break;
314                 case 'c':
315                         if (optarg == NULL || strcmp(optarg, "on") == 0) {
316                                 start.ls_flags |= LPF_CREATE_OSTOBJ;
317                         } else if (strcmp(optarg, "off") != 0) {
318                                 fprintf(stderr, "invalid switch: -c '%s'. "
319                                         "valid switches are:\n"
320                                         "empty ('on'), or 'off' without space. "
321                                         "For example:\n"
322                                         "'-c', '-con', '-coff'\n", optarg);
323                                 return -EINVAL;
324                         }
325                         start.ls_valid |= LSV_CREATE_OSTOBJ;
326                         break;
327                 case 'C':
328                         if (optarg == NULL || strcmp(optarg, "on") == 0) {
329                                 start.ls_flags |= LPF_CREATE_MDTOBJ;
330                         } else if (strcmp(optarg, "off") != 0) {
331                                 fprintf(stderr, "invalid switch: -C '%s'. "
332                                         "valid switches are:\n"
333                                         "empty ('on'), or 'off' without space. "
334                                         "For example:\n"
335                                         "'-C', '-Con', '-Coff'\n", optarg);
336                                 return -EINVAL;
337                         }
338                         start.ls_valid |= LSV_CREATE_MDTOBJ;
339                         break;
340                 case 'd':
341                         if (optarg == NULL || strcmp(optarg, "on") == 0) {
342                                 start.ls_flags |= LPF_DELAY_CREATE_OSTOBJ;
343                         } else if (strcmp(optarg, "off") != 0) {
344                                 fprintf(stderr, "invalid switch: -c '%s'. "
345                                         "valid switches are:\n"
346                                         "empty ('on'), or 'off' without space. "
347                                         "For example:\n"
348                                         "'-c', '-con', '-coff'\n", optarg);
349                                 return -EINVAL;
350                         }
351                         start.ls_valid |= LSV_DELAY_CREATE_OSTOBJ;
352                         break;
353                 case 'e':
354                         if (strcmp(optarg, "abort") == 0) {
355                                 start.ls_flags |= LPF_FAILOUT;
356                         } else if (strcmp(optarg, "continue") != 0) {
357                                 fprintf(stderr, "invalid error mode: -e '%s'."
358                                         "valid modes are: "
359                                         "'continue' or 'abort'.\n", optarg);
360                                 return -EINVAL;
361                         }
362                         start.ls_valid |= LSV_ERROR_HANDLE;
363                         break;
364                 case 'h':
365                         usage_start();
366                         return 0;
367                 case 'M':
368                         rc = lfsck_pack_dev(&data, device, optarg);
369                         if (rc != 0)
370                                 return rc;
371                         break;
372                 case 'n':
373                         if (optarg == NULL || strcmp(optarg, "on") == 0) {
374                                 start.ls_flags |= LPF_DRYRUN;
375                         } else if (strcmp(optarg, "off") != 0) {
376                                 fprintf(stderr, "invalid switch: -n '%s'. "
377                                         "valid switches are:\n"
378                                         "empty ('on'), or 'off' without space. "
379                                         "For example:\n"
380                                         "'-n', '-non', '-noff'\n", optarg);
381                                 return -EINVAL;
382                         }
383                         start.ls_valid |= LSV_DRYRUN;
384                         break;
385                 case 'o':
386                         start.ls_flags |= LPF_ALL_TGT | LPF_BROADCAST |
387                                           LPF_OST_ORPHAN;
388                         break;
389                 case 'r':
390                         start.ls_flags |= LPF_RESET;
391                         break;
392                 case 's':
393                         val = atoi(optarg);
394                         start.ls_speed_limit = val;
395                         start.ls_valid |= LSV_SPEED_LIMIT;
396                         break;
397                 case 't': {
398                         char *typename;
399
400                         if (start.ls_active == LFSCK_TYPES_ALL)
401                                 start.ls_active = 0;
402                         while ((typename = strsep(&optarg, ",")) != NULL) {
403                                 enum lfsck_type type;
404
405                                 type = lfsck_name2type(typename);
406                                 if (type == -1)
407                                         goto bad_type;
408                                 start.ls_active |= type;
409                         }
410                         break;
411 bad_type:
412                         fprintf(stderr, "invalid check type -t '%s'. "
413                                 "valid types are:\n", typename);
414                         for (i = 0; lfsck_types_names[i].ltn_name != NULL; i++)
415                                 fprintf(stderr, "%s%s", i != 0 ? "," : "",
416                                         lfsck_types_names[i].ltn_name);
417                         fprintf(stderr, "\n");
418                         return -EINVAL;
419                 }
420                 case 'w':
421                         val = atoi(optarg);
422                         if (val < 1 || val > LFSCK_ASYNC_WIN_MAX) {
423                                 fprintf(stderr,
424                                         "Invalid async window size that "
425                                         "may cause memory issues. The valid "
426                                         "range is [1 - %u].\n",
427                                         LFSCK_ASYNC_WIN_MAX);
428                                 return -EINVAL;
429                         }
430
431                         start.ls_async_windows = val;
432                         start.ls_valid |= LSV_ASYNC_WINDOWS;
433                         break;
434                 default:
435                         fprintf(stderr, "Invalid option, '-h' for help.\n");
436                         return -EINVAL;
437                 }
438         }
439
440         if (start.ls_active == LFSCK_TYPES_ALL)
441                 start.ls_active = LFSCK_TYPES_DEF;
442
443         if (data.ioc_inlbuf4 == NULL) {
444                 rc = lfsck_get_dev_name(&data, device, start.ls_active,
445                                         start.ls_flags & LPF_ALL_TGT);
446                 if (rc != 0)
447                         return rc;
448         }
449
450         data.ioc_inlbuf1 = (char *)&start;
451         data.ioc_inllen1 = sizeof(start);
452         memset(buf, 0, sizeof(rawbuf));
453         rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
454         if (rc != 0) {
455                 fprintf(stderr, "Fail to pack ioctl data: rc = %d.\n", rc);
456                 return rc;
457         }
458
459         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_START_LFSCK, buf);
460         if (rc < 0) {
461                 perror("Fail to start LFSCK");
462                 return rc;
463         }
464
465         llapi_ioctl_unpack(&data, buf, sizeof(rawbuf));
466         printf("Started LFSCK on the device %s: scrub", device);
467         for (i = 0; lfsck_types_names[i].ltn_name != NULL; i++) {
468                 if (start.ls_active & lfsck_types_names[i].ltn_type) {
469                         printf(" %s", lfsck_types_names[i].ltn_name);
470                         start.ls_active &= ~lfsck_types_names[i].ltn_type;
471                 }
472         }
473         if (start.ls_active != 0)
474                 printf(" unknown(0x%x)", start.ls_active);
475         printf("\n");
476
477         return 0;
478 }
479
480 int jt_lfsck_stop(int argc, char **argv)
481 {
482         struct obd_ioctl_data data;
483         char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
484         char device[MAX_OBD_NAME];
485         struct lfsck_stop stop;
486         char *short_opts = "AhM:";
487         int opt, index, rc;
488
489         memset(&data, 0, sizeof(data));
490         memset(&stop, 0, sizeof(stop));
491         memset(device, 0, MAX_OBD_NAME);
492
493         /* Reset the 'optind' for the case of getopt_long() called multiple
494          * times under the same lctl. */
495         optind = 0;
496         while ((opt = getopt_long(argc, argv, short_opts, long_opt_stop,
497                                   &index)) != EOF) {
498                 switch (opt) {
499                 case 'A':
500                         stop.ls_flags |= LPF_ALL_TGT | LPF_BROADCAST;
501                         break;
502                 case 'h':
503                         usage_stop();
504                         return 0;
505                 case 'M':
506                         rc = lfsck_pack_dev(&data, device, optarg);
507                         if (rc != 0)
508                                 return rc;
509                         break;
510                 default:
511                         fprintf(stderr, "Invalid option, '-h' for help.\n");
512                         return -EINVAL;
513                 }
514         }
515
516         if (data.ioc_inlbuf4 == NULL) {
517                 rc = lfsck_get_dev_name(&data, device, 0,
518                                         stop.ls_flags & LPF_ALL_TGT);
519                 if (rc != 0)
520                         return rc;
521         }
522
523         data.ioc_inlbuf1 = (char *)&stop;
524         data.ioc_inllen1 = sizeof(stop);
525         memset(buf, 0, sizeof(rawbuf));
526         rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
527         if (rc != 0) {
528                 fprintf(stderr, "Fail to pack ioctl data: rc = %d.\n", rc);
529                 return rc;
530         }
531
532         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_STOP_LFSCK, buf);
533         if (rc < 0) {
534                 perror("Fail to stop LFSCK");
535                 return rc;
536         }
537
538         printf("Stopped LFSCK on the device %s.\n", device);
539         return 0;
540 }
541
542 int jt_lfsck_query(int argc, char **argv)
543 {
544         struct obd_ioctl_data data = { 0 };
545         char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
546         char device[MAX_OBD_NAME] = "";
547         struct lfsck_query query = { .lu_types = LFSCK_TYPES_ALL };
548         int opt, index, rc, i;
549         enum lfsck_type type;
550
551         while ((opt = getopt_long(argc, argv, "hM:t:w", long_opt_query,
552                                   &index)) != EOF) {
553                 switch (opt) {
554                 case 'h':
555                         usage_query();
556                         return 0;
557                 case 'M':
558                         rc = lfsck_pack_dev(&data, device, optarg);
559                         if (rc != 0)
560                                 return rc;
561                         break;
562                 case 't': {
563                         char *typename;
564
565                         if (query.lu_types == LFSCK_TYPES_ALL)
566                                 query.lu_types = 0;
567                         while ((typename = strsep(&optarg, ",")) != NULL) {
568                                 type = lfsck_name2type(typename);
569                                 if (type == -1)
570                                         goto bad_type;
571                                 query.lu_types |= type;
572                         }
573                         break;
574
575 bad_type:
576                         fprintf(stderr, "invalid LFSCK type -t '%s'. "
577                                 "valid types are:\n", typename);
578                         for (i = 0; lfsck_types_names[i].ltn_name != NULL; i++)
579                                 fprintf(stderr, "%s%s", i != 0 ? "," : "",
580                                         lfsck_types_names[i].ltn_name);
581                         fprintf(stderr, "\n");
582                         return -EINVAL;
583                 }
584                 case 'w':
585                         query.lu_flags |= LPF_WAIT;
586                         break;
587                 default:
588                         fprintf(stderr, "Invalid option, '-h' for help.\n");
589                         usage_query();
590                         return -EINVAL;
591                 }
592         }
593
594         if (data.ioc_inlbuf4 == NULL) {
595                 rc = lfsck_get_dev_name(&data, device, 0, true);
596                 if (rc != 0)
597                         return rc;
598         }
599
600         data.ioc_inlbuf1 = (char *)&query;
601         data.ioc_inllen1 = sizeof(query);
602         memset(buf, 0, sizeof(rawbuf));
603         rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
604         if (rc != 0) {
605                 fprintf(stderr, "Fail to pack ioctl data: rc = %d.\n", rc);
606                 return rc;
607         }
608
609         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_QUERY_LFSCK, buf);
610         if (rc < 0) {
611                 perror("Fail to query LFSCK");
612                 return rc;
613         }
614
615         llapi_ioctl_unpack(&data, buf, sizeof(rawbuf));
616         for (i = 0, type = 1 << i; i < LFSCK_TYPE_BITS; i++, type = 1 << i) {
617                 const char *name;
618                 int j;
619
620                 if (!(query.lu_types & type))
621                         continue;
622
623                 name = lfsck_type2name(type);
624                 for (j = 0; j <= LS_MAX; j++)
625                         printf("%s_mdts_%s: %d\n", name,
626                                lfsck_status2name(j), query.lu_mdts_count[i][j]);
627
628                 for (j = 0; j <= LS_MAX; j++)
629                         printf("%s_osts_%s: %d\n", name,
630                                lfsck_status2name(j), query.lu_osts_count[i][j]);
631
632                 printf("%s_repaired: %llu\n", name, query.lu_repaired[i]);
633         }
634
635         return 0;
636 }