[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>
This commit is contained in:
Steven Whitehouse 2006-03-30 15:46:23 -05:00
parent cd45697f0d
commit e3167ded1f
6 changed files with 22 additions and 23 deletions

View File

@ -462,7 +462,7 @@ static int gfs2_dirent_offset(const void *buf)
BUG_ON(buf == NULL);
switch(be16_to_cpu(h->mh_type)) {
switch(be32_to_cpu(h->mh_type)) {
case GFS2_METATYPE_LF:
offset = sizeof(struct gfs2_leaf);
break;
@ -475,7 +475,7 @@ static int gfs2_dirent_offset(const void *buf)
return offset;
wrong_type:
printk(KERN_WARNING "gfs2_scan_dirent: wrong block type %u\n",
be16_to_cpu(h->mh_type));
be32_to_cpu(h->mh_type));
return -1;
}
@ -548,7 +548,7 @@ static int dirent_first(struct gfs2_inode *dip, struct buffer_head *bh,
{
struct gfs2_meta_header *h = (struct gfs2_meta_header *)bh->b_data;
if (be16_to_cpu(h->mh_type) == GFS2_METATYPE_LF) {
if (be32_to_cpu(h->mh_type) == GFS2_METATYPE_LF) {
if (gfs2_meta_check(dip->i_sbd, bh))
return -EIO;
*dent = (struct gfs2_dirent *)(bh->b_data +

View File

@ -377,8 +377,8 @@ static void log_write_header(struct gfs2_sbd *sdp, uint32_t flags, int pull)
lh = (struct gfs2_log_header *)bh->b_data;
memset(lh, 0, sizeof(struct gfs2_log_header));
lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
lh->lh_header.mh_type = cpu_to_be16(GFS2_METATYPE_LH);
lh->lh_header.mh_format = cpu_to_be16(GFS2_FORMAT_LH);
lh->lh_header.mh_type = cpu_to_be32(GFS2_METATYPE_LH);
lh->lh_header.mh_format = cpu_to_be32(GFS2_FORMAT_LH);
lh->lh_sequence = be64_to_cpu(sdp->sd_log_sequence++);
lh->lh_flags = be32_to_cpu(flags);
lh->lh_tail = be32_to_cpu(tail);

View File

@ -133,8 +133,8 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
ld = (struct gfs2_log_descriptor *)bh->b_data;
ptr = (__be64 *)(bh->b_data + offset);
ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD);
ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD);
ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD);
ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD);
ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_METADATA);
ld->ld_length = cpu_to_be32(num + 1);
ld->ld_data1 = cpu_to_be32(num);
@ -291,8 +291,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
bh = gfs2_log_get_buf(sdp);
ld = (struct gfs2_log_descriptor *)bh->b_data;
ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD);
ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD);
ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD);
ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD);
ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_REVOKE);
ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke,
sizeof(uint64_t)));
@ -313,8 +313,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
bh = gfs2_log_get_buf(sdp);
mh = (struct gfs2_meta_header *)bh->b_data;
mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
mh->mh_type = cpu_to_be16(GFS2_METATYPE_LB);
mh->mh_format = cpu_to_be16(GFS2_FORMAT_LB);
mh->mh_type = cpu_to_be32(GFS2_METATYPE_LB);
mh->mh_format = cpu_to_be32(GFS2_FORMAT_LB);
offset = sizeof(struct gfs2_meta_header);
}
@ -576,9 +576,9 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
ld->ld_header.mh_magic =
cpu_to_be32(GFS2_MAGIC);
ld->ld_header.mh_type =
cpu_to_be16(GFS2_METATYPE_LD);
cpu_to_be32(GFS2_METATYPE_LD);
ld->ld_header.mh_format =
cpu_to_be16(GFS2_FORMAT_LD);
cpu_to_be32(GFS2_FORMAT_LD);
ld->ld_type =
cpu_to_be32(GFS2_LOG_DESC_JDATA);
ld->ld_length = cpu_to_be32(num + 1);

View File

@ -83,8 +83,8 @@ static void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf)
struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
mh->mh_magic = be32_to_cpu(str->mh_magic);
mh->mh_type = be16_to_cpu(str->mh_type);
mh->mh_format = be16_to_cpu(str->mh_format);
mh->mh_type = be32_to_cpu(str->mh_type);
mh->mh_format = be32_to_cpu(str->mh_format);
}
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)
struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
str->mh_magic = cpu_to_be32(mh->mh_magic);
str->mh_type = cpu_to_be16(mh->mh_type);
str->mh_format = cpu_to_be16(mh->mh_format);
str->mh_type = cpu_to_be32(mh->mh_type);
str->mh_format = cpu_to_be32(mh->mh_format);
}
void gfs2_meta_header_print(struct gfs2_meta_header *mh)

View File

@ -324,7 +324,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
ld = (struct gfs2_log_descriptor *)bh->b_data;
length = be32_to_cpu(ld->ld_length);
if (be16_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) {
if (be32_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) {
struct gfs2_log_header lh;
error = get_log_header(jd, start, &lh);
if (!error) {
@ -400,7 +400,7 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
memset(lh, 0, sizeof(struct gfs2_log_header));
lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
lh->lh_header.mh_type = cpu_to_be16(GFS2_METATYPE_LH);
lh->lh_header.mh_format = cpu_to_be16(GFS2_FORMAT_LH);
lh->lh_header.mh_format = cpu_to_be32(GFS2_FORMAT_LH);
lh->lh_sequence = cpu_to_be64(head->lh_sequence + 1);
lh->lh_flags = cpu_to_be32(GFS2_LOG_HEAD_UNMOUNT);
lh->lh_blkno = cpu_to_be32(lblock);

View File

@ -107,12 +107,11 @@ static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
{
struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
uint32_t magic = mh->mh_magic;
uint16_t t = mh->mh_type;
uint16_t t = be32_to_cpu(mh->mh_type);
magic = be32_to_cpu(magic);
if (unlikely(magic != GFS2_MAGIC))
return gfs2_meta_check_ii(sdp, bh, "magic number", function,
file, line);
t = be16_to_cpu(t);
if (unlikely(t != type))
return gfs2_metatype_check_ii(sdp, bh, type, t, function,
file, line);
@ -127,8 +126,8 @@ static inline void gfs2_metatype_set(struct buffer_head *bh, uint16_t type,
{
struct gfs2_meta_header *mh;
mh = (struct gfs2_meta_header *)bh->b_data;
mh->mh_type = cpu_to_be16(type);
mh->mh_format = cpu_to_be16(format);
mh->mh_type = cpu_to_be32(type);
mh->mh_format = cpu_to_be32(format);
}