Whamcloud - gitweb
LU-1222 ldlm: Fix the race in AST sender vs multiple arriving RPCs
[fs/lustre-release.git] / lustre / utils / req-layout.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  *
32  * Copyright (c) 2011, Whamcloud, Inc.
33  */
34 /*
35  * This file is part of Lustre, http://www.lustre.org/
36  * Lustre is a trademark of Sun Microsystems, Inc.
37  *
38  * lustre/utils/req-layout.c
39  *
40  * User-level tool for printing request layouts
41  *
42  * Author: Nikita Danilov <nikita@clusterfs.com>
43  */
44
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <unistd.h>
48
49 #include <liblustre.h>
50 #include <lustre/lustre_idl.h>
51
52 #define __REQ_LAYOUT_USER__ (1)
53
54 #define lustre_swab_generic_32s NULL
55 #define lustre_swab_lu_seq_range NULL
56 #define lustre_swab_mdt_body NULL
57 #define lustre_swab_mdt_ioepoch NULL
58 #define lustre_swab_ptlrpc_body NULL
59 #define lustre_swab_obd_statfs NULL
60 #define lustre_swab_connect NULL
61 #define lustre_swab_ldlm_request NULL
62 #define lustre_swab_ldlm_reply NULL
63 #define lustre_swab_ldlm_intent NULL
64 /* #define lustre_swab_lov_mds_md NULL */
65 #define lustre_swab_mdt_rec_reint NULL
66 #define lustre_swab_lustre_capa NULL
67 #define lustre_swab_lustre_capa_key NULL
68 #define lustre_swab_llogd_conn_body NULL
69 #define lustre_swab_llog_hdr NULL
70 #define lustre_swab_llogd_body NULL
71 #define lustre_swab_obd_quotactl NULL
72 #define lustre_swab_quota_adjust_qunit NULL
73 #define lustre_swab_mgs_target_info NULL
74 #define lustre_swab_niobuf_remote NULL
75 #define lustre_swab_obd_ioobj NULL
76 #define lustre_swab_ost_body NULL
77 #define lustre_swab_ost_last_id NULL
78 #define lustre_swab_fiemap NULL
79 #define lustre_swab_qdata NULL
80 #define lustre_swab_ost_lvb NULL
81 #define lustre_swab_mgs_config_body NULL
82 #define lustre_swab_mgs_config_res NULL
83 #define dump_rniobuf NULL
84 #define dump_ioo NULL
85 #define dump_obdo NULL
86 #define dump_ost_body NULL
87 #define dump_rcs NULL
88
89 /*
90  * Yes, include .c file.
91  */
92 #include "../ptlrpc/layout.c"
93
94 void usage(void)
95 {
96         fprintf(stderr, "req-layout -- prints lustre request layouts\n");
97 }
98
99 void printt_field(const char *prefix, const struct req_msg_field *fld)
100 {
101 }
102
103 void print_layout(const struct req_format *rf)
104 {
105         int j;
106         int k;
107
108         int offset;
109         int variable;
110
111         static const char *prefix[RCL_NR] = {
112                 [RCL_CLIENT] = "C",
113                 [RCL_SERVER] = "S"
114         };
115
116         printf("L %s (%i/%i)\n", rf->rf_name,
117                rf->rf_fields[RCL_CLIENT].nr, rf->rf_fields[RCL_SERVER].nr);
118
119         for (j = 0; j < RCL_NR; ++j) {
120                 offset = 0;
121                 variable = 0;
122                 for (k = 0; k < rf->rf_fields[j].nr; ++k) {
123                         const struct req_msg_field *fld;
124
125                         fld = rf->rf_fields[j].d[k];
126
127                         printf("        F%s %i [%3.3i%s %-20.20s (",
128                                prefix[j], k, offset,
129                                variable ? " + ...]" : "]      ",
130                                fld->rmf_name);
131                         if (fld->rmf_size > 0) {
132                                 printf("%3.3i) ", fld->rmf_size);
133                                 offset += fld->rmf_size;
134                         } else {
135                                 printf("var) ");
136                                 variable = 1;
137                         }
138                         if (fld->rmf_flags & RMF_F_STRING)
139                                 printf("string");
140                         printf("\n");
141                 }
142                 if (k > 0 && j != RCL_NR - 1)
143                         printf("        -----------------------------------\n");
144         }
145 }
146
147 void print_layouts(void)
148 {
149         int i;
150
151         for (i = 0; i < ARRAY_SIZE(req_formats); ++i) {
152                 print_layout(req_formats[i]);
153                 printf("\n");
154         }
155 }
156
157 int main(int argc, char **argv)
158 {
159         int opt;
160         int verbose;
161
162         verbose = 0;
163         do {
164                 opt = getopt(argc, argv, "hb:k:r:p:v");
165                 switch (opt) {
166                 case 'v':
167                         verbose++;
168                 case -1:
169                         break;
170                 case '?':
171                 default:
172                         fprintf(stderr, "Unable to parse options.");
173                 case 'h':
174                         usage();
175                         return 0;
176                 }
177         } while (opt != -1);
178         print_layouts();
179         return 0;
180 }