1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2004-2005 Cluster File Systems, Inc.
5 * Author: jacob berkman <jacob@clusterfs.com>
7 * This file is part of Lustre, http://www.lustre.org.
9 * Lustre is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Lustre is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Lustre; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * Swabbing of llog datatypes (from disk or over the wire).
26 #define DEBUG_SUBSYSTEM S_LOG
28 #include <linux/lustre_log.h>
30 static void print_llogd_body(struct llogd_body *d)
32 CDEBUG(D_OTHER, "llogd body: %p\n", d);
33 CDEBUG(D_OTHER, "\tlgd_logid.lgl_oid: "LPX64"\n", d->lgd_logid.lgl_oid);
34 CDEBUG(D_OTHER, "\tlgd_logid.lgl_ogr: "LPX64"\n", d->lgd_logid.lgl_ogr);
35 CDEBUG(D_OTHER, "\tlgd_logid.lgl_ogen: %#x\n", d->lgd_logid.lgl_ogen);
36 CDEBUG(D_OTHER, "\tlgd_ctxt_idx: %#x\n", d->lgd_ctxt_idx);
37 CDEBUG(D_OTHER, "\tlgd_llh_flags: %#x\n", d->lgd_llh_flags);
38 CDEBUG(D_OTHER, "\tlgd_index: %#x\n", d->lgd_index);
39 CDEBUG(D_OTHER, "\tlgd_saved_index: %#x\n", d->lgd_saved_index);
40 CDEBUG(D_OTHER, "\tlgd_len: %#x\n", d->lgd_len);
41 CDEBUG(D_OTHER, "\tlgd_cur_offset: "LPX64"\n", d->lgd_cur_offset);
44 void lustre_swab_llogd_body (struct llogd_body *d)
48 __swab64s (&d->lgd_logid.lgl_oid);
49 __swab64s (&d->lgd_logid.lgl_ogr);
50 __swab32s (&d->lgd_logid.lgl_ogen);
51 __swab32s (&d->lgd_ctxt_idx);
52 __swab32s (&d->lgd_llh_flags);
53 __swab32s (&d->lgd_index);
54 __swab32s (&d->lgd_saved_index);
55 __swab32s (&d->lgd_len);
56 __swab64s (&d->lgd_cur_offset);
60 EXPORT_SYMBOL(lustre_swab_llogd_body);
62 void lustre_swab_llogd_conn_body (struct llogd_conn_body *d)
64 __swab64s (&d->lgdc_gen.mnt_cnt);
65 __swab64s (&d->lgdc_gen.conn_cnt);
66 __swab64s (&d->lgdc_logid.lgl_oid);
67 __swab64s (&d->lgdc_logid.lgl_ogr);
68 __swab32s (&d->lgdc_logid.lgl_ogen);
69 __swab32s (&d->lgdc_ctxt_idx);
71 EXPORT_SYMBOL(lustre_swab_llogd_conn_body);
73 void lustre_swab_llog_hdr (struct llog_log_hdr *h)
75 __swab32s (&h->llh_hdr.lrh_index);
76 __swab32s (&h->llh_hdr.lrh_len);
77 __swab32s (&h->llh_hdr.lrh_type);
78 __swab64s (&h->llh_timestamp);
79 __swab32s (&h->llh_count);
80 __swab32s (&h->llh_bitmap_offset);
81 __swab32s (&h->llh_flags);
82 __swab32s (&h->llh_tail.lrt_index);
83 __swab32s (&h->llh_tail.lrt_len);
85 EXPORT_SYMBOL(lustre_swab_llog_hdr);
87 #define PRINT_PCFG32(x) CDEBUG(D_OTHER, "\tpcfg->pcfg_"#x": %#x\n", pcfg->pcfg_##x)
88 #define PRINT_PCFG64(x) CDEBUG(D_OTHER, "\tpcfg->pcfg_"#x": "LPX64"\n", pcfg->pcfg_##x)
90 static void print_portals_cfg(struct portals_cfg *pcfg)
94 if (!(portal_debug & D_OTHER)) /* don't loop on nothing */
96 CDEBUG(D_OTHER, "portals_cfg: %p\n", pcfg);
97 PRINT_PCFG32(version);
98 PRINT_PCFG32(command);
103 PRINT_PCFG32(gw_nal);
120 void lustre_swab_portals_cfg(struct portals_cfg *pcfg)
124 __swab32s(&pcfg->pcfg_version);
125 __swab32s(&pcfg->pcfg_command);
127 __swab32s(&pcfg->pcfg_nal);
128 __swab32s(&pcfg->pcfg_flags);
130 __swab32s(&pcfg->pcfg_gw_nal);
131 __swab64s(&pcfg->pcfg_nid);
132 __swab64s(&pcfg->pcfg_nid2);
133 __swab64s(&pcfg->pcfg_nid3);
134 __swab32s(&pcfg->pcfg_id);
135 __swab32s(&pcfg->pcfg_misc);
136 __swab32s(&pcfg->pcfg_fd);
137 __swab32s(&pcfg->pcfg_count);
138 __swab32s(&pcfg->pcfg_size);
139 __swab32s(&pcfg->pcfg_wait);
141 __swab32s(&pcfg->pcfg_plen1);
142 __swab32s(&pcfg->pcfg_plen2);
144 print_portals_cfg(pcfg);
147 EXPORT_SYMBOL(lustre_swab_portals_cfg);
149 static void print_lustre_cfg(struct lustre_cfg *lcfg)
154 if (!(portal_debug & D_OTHER)) /* don't loop on nothing */
156 CDEBUG(D_OTHER, "lustre_cfg: %p\n", lcfg);
157 CDEBUG(D_OTHER, "\tlcfg->lcfg_version: %#x\n", lcfg->lcfg_version);
159 CDEBUG(D_OTHER, "\tlcfg->lcfg_command: %#x\n", lcfg->lcfg_command);
160 CDEBUG(D_OTHER, "\tlcfg->lcfg_num: %#x\n", lcfg->lcfg_num);
161 CDEBUG(D_OTHER, "\tlcfg->lcfg_flags: %#x\n", lcfg->lcfg_flags);
162 CDEBUG(D_OTHER, "\tlcfg->lcfg_nid: "LPX64"\n", lcfg->lcfg_nid);
163 CDEBUG(D_OTHER, "\tlcfg->lcfg_nal: %#x\n", lcfg->lcfg_nal);
165 CDEBUG(D_OTHER, "\tlcfg->lcfg_bufcount: %d\n", lcfg->lcfg_bufcount);
166 if (lcfg->lcfg_bufcount < LUSTRE_CFG_MAX_BUFCOUNT)
167 for (i = 0; i < lcfg->lcfg_bufcount; i++)
168 CDEBUG(D_OTHER, "\tlcfg->lcfg_buflens[%d]: %d\n",
169 i, lcfg->lcfg_buflens[i]);
173 void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg)
178 __swab32s(&lcfg->lcfg_version);
180 if (lcfg->lcfg_version != LUSTRE_CFG_VERSION) {
181 CERROR("not swabbing lustre_cfg version %#x (expecting %#x)\n",
182 lcfg->lcfg_version, LUSTRE_CFG_VERSION);
187 __swab32s(&lcfg->lcfg_command);
189 __swab32s(&lcfg->lcfg_num);
190 __swab32s(&lcfg->lcfg_flags);
191 __swab64s(&lcfg->lcfg_nid);
192 __swab32s(&lcfg->lcfg_nal);
194 __swab32s(&lcfg->lcfg_bufcount);
195 for (i = 0; i < lcfg->lcfg_bufcount && i < LUSTRE_CFG_MAX_BUFCOUNT; i++)
196 __swab32s(&lcfg->lcfg_buflens[i]);
198 print_lustre_cfg(lcfg);
202 EXPORT_SYMBOL(lustre_swab_lustre_cfg);