aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/ondisk.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2/ondisk.c')
-rw-r--r--fs/gfs2/ondisk.c138
1 files changed, 41 insertions, 97 deletions
diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c
index 1025960b0e6e..f2495f1e21ad 100644
--- a/fs/gfs2/ondisk.c
+++ b/fs/gfs2/ondisk.c
@@ -15,6 +15,8 @@
15 15
16#include "gfs2.h" 16#include "gfs2.h"
17#include <linux/gfs2_ondisk.h> 17#include <linux/gfs2_ondisk.h>
18#include <linux/lm_interface.h>
19#include "incore.h"
18 20
19#define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", \ 21#define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", \
20 struct->member); 22 struct->member);
@@ -32,7 +34,7 @@
32 * first arg: the cpu-order structure 34 * first arg: the cpu-order structure
33 */ 35 */
34 36
35void gfs2_inum_in(struct gfs2_inum *no, const void *buf) 37void gfs2_inum_in(struct gfs2_inum_host *no, const void *buf)
36{ 38{
37 const struct gfs2_inum *str = buf; 39 const struct gfs2_inum *str = buf;
38 40
@@ -40,7 +42,7 @@ void gfs2_inum_in(struct gfs2_inum *no, const void *buf)
40 no->no_addr = be64_to_cpu(str->no_addr); 42 no->no_addr = be64_to_cpu(str->no_addr);
41} 43}
42 44
43void gfs2_inum_out(const struct gfs2_inum *no, void *buf) 45void gfs2_inum_out(const struct gfs2_inum_host *no, void *buf)
44{ 46{
45 struct gfs2_inum *str = buf; 47 struct gfs2_inum *str = buf;
46 48
@@ -48,13 +50,13 @@ void gfs2_inum_out(const struct gfs2_inum *no, void *buf)
48 str->no_addr = cpu_to_be64(no->no_addr); 50 str->no_addr = cpu_to_be64(no->no_addr);
49} 51}
50 52
51static void gfs2_inum_print(const struct gfs2_inum *no) 53static void gfs2_inum_print(const struct gfs2_inum_host *no)
52{ 54{
53 printk(KERN_INFO " no_formal_ino = %llu\n", (unsigned long long)no->no_formal_ino); 55 printk(KERN_INFO " no_formal_ino = %llu\n", (unsigned long long)no->no_formal_ino);
54 printk(KERN_INFO " no_addr = %llu\n", (unsigned long long)no->no_addr); 56 printk(KERN_INFO " no_addr = %llu\n", (unsigned long long)no->no_addr);
55} 57}
56 58
57static void gfs2_meta_header_in(struct gfs2_meta_header *mh, const void *buf) 59static void gfs2_meta_header_in(struct gfs2_meta_header_host *mh, const void *buf)
58{ 60{
59 const struct gfs2_meta_header *str = buf; 61 const struct gfs2_meta_header *str = buf;
60 62
@@ -63,23 +65,7 @@ static void gfs2_meta_header_in(struct gfs2_meta_header *mh, const void *buf)
63 mh->mh_format = be32_to_cpu(str->mh_format); 65 mh->mh_format = be32_to_cpu(str->mh_format);
64} 66}
65 67
66static void gfs2_meta_header_out(const struct gfs2_meta_header *mh, void *buf) 68void gfs2_sb_in(struct gfs2_sb_host *sb, const void *buf)
67{
68 struct gfs2_meta_header *str = buf;
69
70 str->mh_magic = cpu_to_be32(mh->mh_magic);
71 str->mh_type = cpu_to_be32(mh->mh_type);
72 str->mh_format = cpu_to_be32(mh->mh_format);
73}
74
75static void gfs2_meta_header_print(const struct gfs2_meta_header *mh)
76{
77 pv(mh, mh_magic, "0x%.8X");
78 pv(mh, mh_type, "%u");
79 pv(mh, mh_format, "%u");
80}
81
82void gfs2_sb_in(struct gfs2_sb *sb, const void *buf)
83{ 69{
84 const struct gfs2_sb *str = buf; 70 const struct gfs2_sb *str = buf;
85 71
@@ -97,7 +83,7 @@ void gfs2_sb_in(struct gfs2_sb *sb, const void *buf)
97 memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN); 83 memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN);
98} 84}
99 85
100void gfs2_rindex_in(struct gfs2_rindex *ri, const void *buf) 86void gfs2_rindex_in(struct gfs2_rindex_host *ri, const void *buf)
101{ 87{
102 const struct gfs2_rindex *str = buf; 88 const struct gfs2_rindex *str = buf;
103 89
@@ -109,7 +95,7 @@ void gfs2_rindex_in(struct gfs2_rindex *ri, const void *buf)
109 95
110} 96}
111 97
112void gfs2_rindex_print(const struct gfs2_rindex *ri) 98void gfs2_rindex_print(const struct gfs2_rindex_host *ri)
113{ 99{
114 printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)ri->ri_addr); 100 printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)ri->ri_addr);
115 pv(ri, ri_length, "%u"); 101 pv(ri, ri_length, "%u");
@@ -120,22 +106,20 @@ void gfs2_rindex_print(const struct gfs2_rindex *ri)
120 pv(ri, ri_bitbytes, "%u"); 106 pv(ri, ri_bitbytes, "%u");
121} 107}
122 108
123void gfs2_rgrp_in(struct gfs2_rgrp *rg, const void *buf) 109void gfs2_rgrp_in(struct gfs2_rgrp_host *rg, const void *buf)
124{ 110{
125 const struct gfs2_rgrp *str = buf; 111 const struct gfs2_rgrp *str = buf;
126 112
127 gfs2_meta_header_in(&rg->rg_header, buf);
128 rg->rg_flags = be32_to_cpu(str->rg_flags); 113 rg->rg_flags = be32_to_cpu(str->rg_flags);
129 rg->rg_free = be32_to_cpu(str->rg_free); 114 rg->rg_free = be32_to_cpu(str->rg_free);
130 rg->rg_dinodes = be32_to_cpu(str->rg_dinodes); 115 rg->rg_dinodes = be32_to_cpu(str->rg_dinodes);
131 rg->rg_igeneration = be64_to_cpu(str->rg_igeneration); 116 rg->rg_igeneration = be64_to_cpu(str->rg_igeneration);
132} 117}
133 118
134void gfs2_rgrp_out(const struct gfs2_rgrp *rg, void *buf) 119void gfs2_rgrp_out(const struct gfs2_rgrp_host *rg, void *buf)
135{ 120{
136 struct gfs2_rgrp *str = buf; 121 struct gfs2_rgrp *str = buf;
137 122
138 gfs2_meta_header_out(&rg->rg_header, buf);
139 str->rg_flags = cpu_to_be32(rg->rg_flags); 123 str->rg_flags = cpu_to_be32(rg->rg_flags);
140 str->rg_free = cpu_to_be32(rg->rg_free); 124 str->rg_free = cpu_to_be32(rg->rg_free);
141 str->rg_dinodes = cpu_to_be32(rg->rg_dinodes); 125 str->rg_dinodes = cpu_to_be32(rg->rg_dinodes);
@@ -144,7 +128,7 @@ void gfs2_rgrp_out(const struct gfs2_rgrp *rg, void *buf)
144 memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); 128 memset(&str->rg_reserved, 0, sizeof(str->rg_reserved));
145} 129}
146 130
147void gfs2_quota_in(struct gfs2_quota *qu, const void *buf) 131void gfs2_quota_in(struct gfs2_quota_host *qu, const void *buf)
148{ 132{
149 const struct gfs2_quota *str = buf; 133 const struct gfs2_quota *str = buf;
150 134
@@ -153,96 +137,56 @@ void gfs2_quota_in(struct gfs2_quota *qu, const void *buf)
153 qu->qu_value = be64_to_cpu(str->qu_value); 137 qu->qu_value = be64_to_cpu(str->qu_value);
154} 138}
155 139
156void gfs2_dinode_in(struct gfs2_dinode *di, const void *buf) 140void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
157{
158 const struct gfs2_dinode *str = buf;
159
160 gfs2_meta_header_in(&di->di_header, buf);
161 gfs2_inum_in(&di->di_num, &str->di_num);
162
163 di->di_mode = be32_to_cpu(str->di_mode);
164 di->di_uid = be32_to_cpu(str->di_uid);
165 di->di_gid = be32_to_cpu(str->di_gid);
166 di->di_nlink = be32_to_cpu(str->di_nlink);
167 di->di_size = be64_to_cpu(str->di_size);
168 di->di_blocks = be64_to_cpu(str->di_blocks);
169 di->di_atime = be64_to_cpu(str->di_atime);
170 di->di_mtime = be64_to_cpu(str->di_mtime);
171 di->di_ctime = be64_to_cpu(str->di_ctime);
172 di->di_major = be32_to_cpu(str->di_major);
173 di->di_minor = be32_to_cpu(str->di_minor);
174
175 di->di_goal_meta = be64_to_cpu(str->di_goal_meta);
176 di->di_goal_data = be64_to_cpu(str->di_goal_data);
177 di->di_generation = be64_to_cpu(str->di_generation);
178
179 di->di_flags = be32_to_cpu(str->di_flags);
180 di->di_payload_format = be32_to_cpu(str->di_payload_format);
181 di->di_height = be16_to_cpu(str->di_height);
182
183 di->di_depth = be16_to_cpu(str->di_depth);
184 di->di_entries = be32_to_cpu(str->di_entries);
185
186 di->di_eattr = be64_to_cpu(str->di_eattr);
187
188}
189
190void gfs2_dinode_out(const struct gfs2_dinode *di, void *buf)
191{ 141{
142 const struct gfs2_dinode_host *di = &ip->i_di;
192 struct gfs2_dinode *str = buf; 143 struct gfs2_dinode *str = buf;
193 144
194 gfs2_meta_header_out(&di->di_header, buf); 145 str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
195 gfs2_inum_out(&di->di_num, (char *)&str->di_num); 146 str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI);
147 str->di_header.__pad0 = 0;
148 str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI);
149 str->di_header.__pad1 = 0;
196 150
197 str->di_mode = cpu_to_be32(di->di_mode); 151 gfs2_inum_out(&ip->i_num, &str->di_num);
198 str->di_uid = cpu_to_be32(di->di_uid); 152
199 str->di_gid = cpu_to_be32(di->di_gid); 153 str->di_mode = cpu_to_be32(ip->i_inode.i_mode);
200 str->di_nlink = cpu_to_be32(di->di_nlink); 154 str->di_uid = cpu_to_be32(ip->i_inode.i_uid);
155 str->di_gid = cpu_to_be32(ip->i_inode.i_gid);
156 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink);
201 str->di_size = cpu_to_be64(di->di_size); 157 str->di_size = cpu_to_be64(di->di_size);
202 str->di_blocks = cpu_to_be64(di->di_blocks); 158 str->di_blocks = cpu_to_be64(di->di_blocks);
203 str->di_atime = cpu_to_be64(di->di_atime); 159 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
204 str->di_mtime = cpu_to_be64(di->di_mtime); 160 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec);
205 str->di_ctime = cpu_to_be64(di->di_ctime); 161 str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec);
206 str->di_major = cpu_to_be32(di->di_major);
207 str->di_minor = cpu_to_be32(di->di_minor);
208 162
209 str->di_goal_meta = cpu_to_be64(di->di_goal_meta); 163 str->di_goal_meta = cpu_to_be64(di->di_goal_meta);
210 str->di_goal_data = cpu_to_be64(di->di_goal_data); 164 str->di_goal_data = cpu_to_be64(di->di_goal_data);
211 str->di_generation = cpu_to_be64(di->di_generation); 165 str->di_generation = cpu_to_be64(di->di_generation);
212 166
213 str->di_flags = cpu_to_be32(di->di_flags); 167 str->di_flags = cpu_to_be32(di->di_flags);
214 str->di_payload_format = cpu_to_be32(di->di_payload_format);
215 str->di_height = cpu_to_be16(di->di_height); 168 str->di_height = cpu_to_be16(di->di_height);
216 169 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
170 !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ?
171 GFS2_FORMAT_DE : 0);
217 str->di_depth = cpu_to_be16(di->di_depth); 172 str->di_depth = cpu_to_be16(di->di_depth);
218 str->di_entries = cpu_to_be32(di->di_entries); 173 str->di_entries = cpu_to_be32(di->di_entries);
219 174
220 str->di_eattr = cpu_to_be64(di->di_eattr); 175 str->di_eattr = cpu_to_be64(di->di_eattr);
221
222} 176}
223 177
224void gfs2_dinode_print(const struct gfs2_dinode *di) 178void gfs2_dinode_print(const struct gfs2_inode *ip)
225{ 179{
226 gfs2_meta_header_print(&di->di_header); 180 const struct gfs2_dinode_host *di = &ip->i_di;
227 gfs2_inum_print(&di->di_num); 181
182 gfs2_inum_print(&ip->i_num);
228 183
229 pv(di, di_mode, "0%o");
230 pv(di, di_uid, "%u");
231 pv(di, di_gid, "%u");
232 pv(di, di_nlink, "%u");
233 printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size); 184 printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size);
234 printk(KERN_INFO " di_blocks = %llu\n", (unsigned long long)di->di_blocks); 185 printk(KERN_INFO " di_blocks = %llu\n", (unsigned long long)di->di_blocks);
235 printk(KERN_INFO " di_atime = %lld\n", (long long)di->di_atime);
236 printk(KERN_INFO " di_mtime = %lld\n", (long long)di->di_mtime);
237 printk(KERN_INFO " di_ctime = %lld\n", (long long)di->di_ctime);
238 pv(di, di_major, "%u");
239 pv(di, di_minor, "%u");
240
241 printk(KERN_INFO " di_goal_meta = %llu\n", (unsigned long long)di->di_goal_meta); 186 printk(KERN_INFO " di_goal_meta = %llu\n", (unsigned long long)di->di_goal_meta);
242 printk(KERN_INFO " di_goal_data = %llu\n", (unsigned long long)di->di_goal_data); 187 printk(KERN_INFO " di_goal_data = %llu\n", (unsigned long long)di->di_goal_data);
243 188
244 pv(di, di_flags, "0x%.8X"); 189 pv(di, di_flags, "0x%.8X");
245 pv(di, di_payload_format, "%u");
246 pv(di, di_height, "%u"); 190 pv(di, di_height, "%u");
247 191
248 pv(di, di_depth, "%u"); 192 pv(di, di_depth, "%u");
@@ -251,7 +195,7 @@ void gfs2_dinode_print(const struct gfs2_dinode *di)
251 printk(KERN_INFO " di_eattr = %llu\n", (unsigned long long)di->di_eattr); 195 printk(KERN_INFO " di_eattr = %llu\n", (unsigned long long)di->di_eattr);
252} 196}
253 197
254void gfs2_log_header_in(struct gfs2_log_header *lh, const void *buf) 198void gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf)
255{ 199{
256 const struct gfs2_log_header *str = buf; 200 const struct gfs2_log_header *str = buf;
257 201
@@ -263,7 +207,7 @@ void gfs2_log_header_in(struct gfs2_log_header *lh, const void *buf)
263 lh->lh_hash = be32_to_cpu(str->lh_hash); 207 lh->lh_hash = be32_to_cpu(str->lh_hash);
264} 208}
265 209
266void gfs2_inum_range_in(struct gfs2_inum_range *ir, const void *buf) 210void gfs2_inum_range_in(struct gfs2_inum_range_host *ir, const void *buf)
267{ 211{
268 const struct gfs2_inum_range *str = buf; 212 const struct gfs2_inum_range *str = buf;
269 213
@@ -271,7 +215,7 @@ void gfs2_inum_range_in(struct gfs2_inum_range *ir, const void *buf)
271 ir->ir_length = be64_to_cpu(str->ir_length); 215 ir->ir_length = be64_to_cpu(str->ir_length);
272} 216}
273 217
274void gfs2_inum_range_out(const struct gfs2_inum_range *ir, void *buf) 218void gfs2_inum_range_out(const struct gfs2_inum_range_host *ir, void *buf)
275{ 219{
276 struct gfs2_inum_range *str = buf; 220 struct gfs2_inum_range *str = buf;
277 221
@@ -279,7 +223,7 @@ void gfs2_inum_range_out(const struct gfs2_inum_range *ir, void *buf)
279 str->ir_length = cpu_to_be64(ir->ir_length); 223 str->ir_length = cpu_to_be64(ir->ir_length);
280} 224}
281 225
282void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, const void *buf) 226void gfs2_statfs_change_in(struct gfs2_statfs_change_host *sc, const void *buf)
283{ 227{
284 const struct gfs2_statfs_change *str = buf; 228 const struct gfs2_statfs_change *str = buf;
285 229
@@ -288,7 +232,7 @@ void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, const void *buf)
288 sc->sc_dinodes = be64_to_cpu(str->sc_dinodes); 232 sc->sc_dinodes = be64_to_cpu(str->sc_dinodes);
289} 233}
290 234
291void gfs2_statfs_change_out(const struct gfs2_statfs_change *sc, void *buf) 235void gfs2_statfs_change_out(const struct gfs2_statfs_change_host *sc, void *buf)
292{ 236{
293 struct gfs2_statfs_change *str = buf; 237 struct gfs2_statfs_change *str = buf;
294 238
@@ -297,7 +241,7 @@ void gfs2_statfs_change_out(const struct gfs2_statfs_change *sc, void *buf)
297 str->sc_dinodes = cpu_to_be64(sc->sc_dinodes); 241 str->sc_dinodes = cpu_to_be64(sc->sc_dinodes);
298} 242}
299 243
300void gfs2_quota_change_in(struct gfs2_quota_change *qc, const void *buf) 244void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *buf)
301{ 245{
302 const struct gfs2_quota_change *str = buf; 246 const struct gfs2_quota_change *str = buf;
303 247