diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-03-30 15:46:23 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-03-30 15:46:23 -0500 |
commit | e3167ded1f1b16424bc14d5673cdc5414f179970 (patch) | |
tree | 1b995e6387b230b1f447aabe30b689d091ee0b52 /fs | |
parent | cd45697f0ddbb58f3f83c29fe164713ee7765e21 (diff) |
[GFS] Fix bug in endian conversion for metadata header
In some cases 16 bit functions were being used rather than 32 bit
functions.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/dir.c | 6 | ||||
-rw-r--r-- | fs/gfs2/log.c | 4 | ||||
-rw-r--r-- | fs/gfs2/lops.c | 16 | ||||
-rw-r--r-- | fs/gfs2/ondisk.c | 8 | ||||
-rw-r--r-- | fs/gfs2/recovery.c | 4 | ||||
-rw-r--r-- | fs/gfs2/util.h | 7 |
6 files changed, 22 insertions, 23 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 9f17e7d05af1..66917f2c64aa 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c | |||
@@ -462,7 +462,7 @@ static int gfs2_dirent_offset(const void *buf) | |||
462 | 462 | ||
463 | BUG_ON(buf == NULL); | 463 | BUG_ON(buf == NULL); |
464 | 464 | ||
465 | switch(be16_to_cpu(h->mh_type)) { | 465 | switch(be32_to_cpu(h->mh_type)) { |
466 | case GFS2_METATYPE_LF: | 466 | case GFS2_METATYPE_LF: |
467 | offset = sizeof(struct gfs2_leaf); | 467 | offset = sizeof(struct gfs2_leaf); |
468 | break; | 468 | break; |
@@ -475,7 +475,7 @@ static int gfs2_dirent_offset(const void *buf) | |||
475 | return offset; | 475 | return offset; |
476 | wrong_type: | 476 | wrong_type: |
477 | printk(KERN_WARNING "gfs2_scan_dirent: wrong block type %u\n", | 477 | printk(KERN_WARNING "gfs2_scan_dirent: wrong block type %u\n", |
478 | be16_to_cpu(h->mh_type)); | 478 | be32_to_cpu(h->mh_type)); |
479 | return -1; | 479 | return -1; |
480 | } | 480 | } |
481 | 481 | ||
@@ -548,7 +548,7 @@ static int dirent_first(struct gfs2_inode *dip, struct buffer_head *bh, | |||
548 | { | 548 | { |
549 | struct gfs2_meta_header *h = (struct gfs2_meta_header *)bh->b_data; | 549 | struct gfs2_meta_header *h = (struct gfs2_meta_header *)bh->b_data; |
550 | 550 | ||
551 | if (be16_to_cpu(h->mh_type) == GFS2_METATYPE_LF) { | 551 | if (be32_to_cpu(h->mh_type) == GFS2_METATYPE_LF) { |
552 | if (gfs2_meta_check(dip->i_sbd, bh)) | 552 | if (gfs2_meta_check(dip->i_sbd, bh)) |
553 | return -EIO; | 553 | return -EIO; |
554 | *dent = (struct gfs2_dirent *)(bh->b_data + | 554 | *dent = (struct gfs2_dirent *)(bh->b_data + |
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index b103d9acf40d..ea69376c00d8 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c | |||
@@ -377,8 +377,8 @@ static void log_write_header(struct gfs2_sbd *sdp, uint32_t flags, int pull) | |||
377 | lh = (struct gfs2_log_header *)bh->b_data; | 377 | lh = (struct gfs2_log_header *)bh->b_data; |
378 | memset(lh, 0, sizeof(struct gfs2_log_header)); | 378 | memset(lh, 0, sizeof(struct gfs2_log_header)); |
379 | lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC); | 379 | lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC); |
380 | lh->lh_header.mh_type = cpu_to_be16(GFS2_METATYPE_LH); | 380 | lh->lh_header.mh_type = cpu_to_be32(GFS2_METATYPE_LH); |
381 | lh->lh_header.mh_format = cpu_to_be16(GFS2_FORMAT_LH); | 381 | lh->lh_header.mh_format = cpu_to_be32(GFS2_FORMAT_LH); |
382 | lh->lh_sequence = be64_to_cpu(sdp->sd_log_sequence++); | 382 | lh->lh_sequence = be64_to_cpu(sdp->sd_log_sequence++); |
383 | lh->lh_flags = be32_to_cpu(flags); | 383 | lh->lh_flags = be32_to_cpu(flags); |
384 | lh->lh_tail = be32_to_cpu(tail); | 384 | lh->lh_tail = be32_to_cpu(tail); |
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 9d40e21f6ead..689c9101c0fb 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c | |||
@@ -133,8 +133,8 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp) | |||
133 | ld = (struct gfs2_log_descriptor *)bh->b_data; | 133 | ld = (struct gfs2_log_descriptor *)bh->b_data; |
134 | ptr = (__be64 *)(bh->b_data + offset); | 134 | ptr = (__be64 *)(bh->b_data + offset); |
135 | ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC); | 135 | ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC); |
136 | ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD); | 136 | ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD); |
137 | ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD); | 137 | ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD); |
138 | ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_METADATA); | 138 | ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_METADATA); |
139 | ld->ld_length = cpu_to_be32(num + 1); | 139 | ld->ld_length = cpu_to_be32(num + 1); |
140 | ld->ld_data1 = cpu_to_be32(num); | 140 | ld->ld_data1 = cpu_to_be32(num); |
@@ -291,8 +291,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) | |||
291 | bh = gfs2_log_get_buf(sdp); | 291 | bh = gfs2_log_get_buf(sdp); |
292 | ld = (struct gfs2_log_descriptor *)bh->b_data; | 292 | ld = (struct gfs2_log_descriptor *)bh->b_data; |
293 | ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC); | 293 | ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC); |
294 | ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD); | 294 | ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD); |
295 | ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD); | 295 | ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD); |
296 | ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_REVOKE); | 296 | ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_REVOKE); |
297 | ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, | 297 | ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, |
298 | sizeof(uint64_t))); | 298 | sizeof(uint64_t))); |
@@ -313,8 +313,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) | |||
313 | bh = gfs2_log_get_buf(sdp); | 313 | bh = gfs2_log_get_buf(sdp); |
314 | mh = (struct gfs2_meta_header *)bh->b_data; | 314 | mh = (struct gfs2_meta_header *)bh->b_data; |
315 | mh->mh_magic = cpu_to_be32(GFS2_MAGIC); | 315 | mh->mh_magic = cpu_to_be32(GFS2_MAGIC); |
316 | mh->mh_type = cpu_to_be16(GFS2_METATYPE_LB); | 316 | mh->mh_type = cpu_to_be32(GFS2_METATYPE_LB); |
317 | mh->mh_format = cpu_to_be16(GFS2_FORMAT_LB); | 317 | mh->mh_format = cpu_to_be32(GFS2_FORMAT_LB); |
318 | offset = sizeof(struct gfs2_meta_header); | 318 | offset = sizeof(struct gfs2_meta_header); |
319 | } | 319 | } |
320 | 320 | ||
@@ -576,9 +576,9 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
576 | ld->ld_header.mh_magic = | 576 | ld->ld_header.mh_magic = |
577 | cpu_to_be32(GFS2_MAGIC); | 577 | cpu_to_be32(GFS2_MAGIC); |
578 | ld->ld_header.mh_type = | 578 | ld->ld_header.mh_type = |
579 | cpu_to_be16(GFS2_METATYPE_LD); | 579 | cpu_to_be32(GFS2_METATYPE_LD); |
580 | ld->ld_header.mh_format = | 580 | ld->ld_header.mh_format = |
581 | cpu_to_be16(GFS2_FORMAT_LD); | 581 | cpu_to_be32(GFS2_FORMAT_LD); |
582 | ld->ld_type = | 582 | ld->ld_type = |
583 | cpu_to_be32(GFS2_LOG_DESC_JDATA); | 583 | cpu_to_be32(GFS2_LOG_DESC_JDATA); |
584 | ld->ld_length = cpu_to_be32(num + 1); | 584 | ld->ld_length = cpu_to_be32(num + 1); |
diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index 3be060f1cbe7..acfc944ce13e 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c | |||
@@ -83,8 +83,8 @@ static void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf) | |||
83 | struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf; | 83 | struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf; |
84 | 84 | ||
85 | mh->mh_magic = be32_to_cpu(str->mh_magic); | 85 | mh->mh_magic = be32_to_cpu(str->mh_magic); |
86 | mh->mh_type = be16_to_cpu(str->mh_type); | 86 | mh->mh_type = be32_to_cpu(str->mh_type); |
87 | mh->mh_format = be16_to_cpu(str->mh_format); | 87 | mh->mh_format = be32_to_cpu(str->mh_format); |
88 | } | 88 | } |
89 | 89 | ||
90 | static void gfs2_meta_header_out(struct gfs2_meta_header *mh, char *buf) | 90 | static void gfs2_meta_header_out(struct gfs2_meta_header *mh, char *buf) |
@@ -92,8 +92,8 @@ static void gfs2_meta_header_out(struct gfs2_meta_header *mh, char *buf) | |||
92 | struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf; | 92 | struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf; |
93 | 93 | ||
94 | str->mh_magic = cpu_to_be32(mh->mh_magic); | 94 | str->mh_magic = cpu_to_be32(mh->mh_magic); |
95 | str->mh_type = cpu_to_be16(mh->mh_type); | 95 | str->mh_type = cpu_to_be32(mh->mh_type); |
96 | str->mh_format = cpu_to_be16(mh->mh_format); | 96 | str->mh_format = cpu_to_be32(mh->mh_format); |
97 | } | 97 | } |
98 | 98 | ||
99 | void gfs2_meta_header_print(struct gfs2_meta_header *mh) | 99 | void gfs2_meta_header_print(struct gfs2_meta_header *mh) |
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 6c7e2e880e32..68c85610fb5b 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c | |||
@@ -324,7 +324,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start, | |||
324 | ld = (struct gfs2_log_descriptor *)bh->b_data; | 324 | ld = (struct gfs2_log_descriptor *)bh->b_data; |
325 | length = be32_to_cpu(ld->ld_length); | 325 | length = be32_to_cpu(ld->ld_length); |
326 | 326 | ||
327 | if (be16_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) { | 327 | if (be32_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) { |
328 | struct gfs2_log_header lh; | 328 | struct gfs2_log_header lh; |
329 | error = get_log_header(jd, start, &lh); | 329 | error = get_log_header(jd, start, &lh); |
330 | if (!error) { | 330 | if (!error) { |
@@ -400,7 +400,7 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) | |||
400 | memset(lh, 0, sizeof(struct gfs2_log_header)); | 400 | memset(lh, 0, sizeof(struct gfs2_log_header)); |
401 | lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC); | 401 | lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC); |
402 | lh->lh_header.mh_type = cpu_to_be16(GFS2_METATYPE_LH); | 402 | lh->lh_header.mh_type = cpu_to_be16(GFS2_METATYPE_LH); |
403 | lh->lh_header.mh_format = cpu_to_be16(GFS2_FORMAT_LH); | 403 | lh->lh_header.mh_format = cpu_to_be32(GFS2_FORMAT_LH); |
404 | lh->lh_sequence = cpu_to_be64(head->lh_sequence + 1); | 404 | lh->lh_sequence = cpu_to_be64(head->lh_sequence + 1); |
405 | lh->lh_flags = cpu_to_be32(GFS2_LOG_HEAD_UNMOUNT); | 405 | lh->lh_flags = cpu_to_be32(GFS2_LOG_HEAD_UNMOUNT); |
406 | lh->lh_blkno = cpu_to_be32(lblock); | 406 | lh->lh_blkno = cpu_to_be32(lblock); |
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h index addbe304993e..4532dbab0a2c 100644 --- a/fs/gfs2/util.h +++ b/fs/gfs2/util.h | |||
@@ -107,12 +107,11 @@ static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp, | |||
107 | { | 107 | { |
108 | struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; | 108 | struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; |
109 | uint32_t magic = mh->mh_magic; | 109 | uint32_t magic = mh->mh_magic; |
110 | uint16_t t = mh->mh_type; | 110 | uint16_t t = be32_to_cpu(mh->mh_type); |
111 | magic = be32_to_cpu(magic); | 111 | magic = be32_to_cpu(magic); |
112 | if (unlikely(magic != GFS2_MAGIC)) | 112 | if (unlikely(magic != GFS2_MAGIC)) |
113 | return gfs2_meta_check_ii(sdp, bh, "magic number", function, | 113 | return gfs2_meta_check_ii(sdp, bh, "magic number", function, |
114 | file, line); | 114 | file, line); |
115 | t = be16_to_cpu(t); | ||
116 | if (unlikely(t != type)) | 115 | if (unlikely(t != type)) |
117 | return gfs2_metatype_check_ii(sdp, bh, type, t, function, | 116 | return gfs2_metatype_check_ii(sdp, bh, type, t, function, |
118 | file, line); | 117 | file, line); |
@@ -127,8 +126,8 @@ static inline void gfs2_metatype_set(struct buffer_head *bh, uint16_t type, | |||
127 | { | 126 | { |
128 | struct gfs2_meta_header *mh; | 127 | struct gfs2_meta_header *mh; |
129 | mh = (struct gfs2_meta_header *)bh->b_data; | 128 | mh = (struct gfs2_meta_header *)bh->b_data; |
130 | mh->mh_type = cpu_to_be16(type); | 129 | mh->mh_type = cpu_to_be32(type); |
131 | mh->mh_format = cpu_to_be16(format); | 130 | mh->mh_format = cpu_to_be32(format); |
132 | } | 131 | } |
133 | 132 | ||
134 | 133 | ||