This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master in repository gfs2-utils.
commit 756aca78969a6ff78fa8b7d640b4fd074221d2fe Author: Andrew Price anprice@redhat.com AuthorDate: Wed Jun 9 17:18:40 2021 +0100
libgfs2: Remove gfs2_meta_header_{in,out}
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/convert/gfs2_convert.c | 30 ++++++++-------- gfs2/fsck/initialize.c | 11 +++--- gfs2/fsck/pass1.c | 16 +++++---- gfs2/fsck/rgrepair.c | 56 ++++++++++++++++------------- gfs2/libgfs2/fs_ops.c | 87 ++++++++++++++++++++++++--------------------- gfs2/libgfs2/gfs1.c | 24 ++++++------- gfs2/libgfs2/lang.c | 8 ++--- gfs2/libgfs2/libgfs2.h | 2 -- gfs2/libgfs2/ondisk.c | 36 ------------------- gfs2/libgfs2/structures.c | 8 ++--- gfs2/mkfs/main_jadd.c | 8 ++--- 11 files changed, 132 insertions(+), 154 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index 32f32064..4439b77a 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -278,12 +278,12 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip, struct gfs2_buffer_head *bh; unsigned int amount, ptramt; int hdrsize, h, copied = 0, new; - struct gfs2_meta_header mh; + struct gfs2_meta_header mh = {0}; char *srcptr = (char *)first_nonzero_ptr;
- mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_IN; - mh.mh_format = GFS2_FORMAT_IN; + mh.mh_magic = cpu_to_be32(GFS2_MAGIC); + mh.mh_type = cpu_to_be32(GFS2_METATYPE_IN); + mh.mh_format = cpu_to_be32(GFS2_FORMAT_IN); if (!ip->i_height) unstuff_dinode(ip);
@@ -304,7 +304,7 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip, bh = bread(sbp, block); if (new) memset(bh->b_data, 0, sbp->sd_bsize); - gfs2_meta_header_out(&mh, bh->b_data); + memcpy(bh->b_data, &mh, sizeof(mh)); bmodified(bh); }
@@ -436,11 +436,11 @@ static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip, struct gfs2_buffer_head *bh; unsigned int amount, ptramt; int h, copied = 0, new = 0; - struct gfs2_meta_header mh; + struct gfs2_meta_header mh = {0};
- mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_IN; - mh.mh_format = GFS2_FORMAT_IN; + mh.mh_magic = cpu_to_be32(GFS2_MAGIC); + mh.mh_type = cpu_to_be32(GFS2_METATYPE_IN); + mh.mh_format = cpu_to_be32(GFS2_FORMAT_IN);
if (!ip->i_height) unstuff_dinode(ip); @@ -463,7 +463,7 @@ static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip, if (new) memset(bh->b_data, 0, sbp->sd_bsize); if (h < (blk->height - 1)) { - gfs2_meta_header_out(&mh, bh->b_data); + memcpy(bh->b_data, &mh, sizeof(mh)); bmodified(bh); } } @@ -1835,12 +1835,12 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp) struct gfs_jindex *jndx; struct rgrp_tree *rgd, *rgdhigh; struct osi_node *n, *next = NULL; - struct gfs2_meta_header mh; + struct gfs2_meta_header mh = {0}; uint64_t ri_addr;
- mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_RB; - mh.mh_format = GFS2_FORMAT_RB; + mh.mh_magic = cpu_to_be32(GFS2_MAGIC); + mh.mh_type = cpu_to_be32(GFS2_METATYPE_RB); + mh.mh_format = cpu_to_be32(GFS2_FORMAT_RB); log_notice(_("Converting journal space to rg space.\n")); /* Go through each journal, converting them one by one */ for (j = 0; j < orig_journals; j++) { /* for each journal */ @@ -1907,7 +1907,7 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp) rgd->bits[0].bi_modified = 1;
for (unsigned i = 1; i < rgd->rt_length; i++) { - gfs2_meta_header_out(&mh, rgd->bits[i].bi_data); + memcpy(rgd->bits[i].bi_data, &mh, sizeof(mh)); rgd->bits[i].bi_modified = 1; } } /* for each journal */ diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index c2a8029d..9d661dce 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -1147,7 +1147,6 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock, uint32_t chk; char *p; int found_rg; - struct gfs2_meta_header mh;
sdp->sd_bsize = GFS2_DEFAULT_BSIZE; max_rg_size = 524288; @@ -1173,15 +1172,19 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock, /* Try all the block sizes in 512 byte multiples */ for (bsize2 = GFS2_BASIC_BLOCK; bsize2 <= GFS2_DEFAULT_BSIZE; bsize2 += GFS2_BASIC_BLOCK) { + struct gfs2_meta_header *mh; + int is_rb; + rb_addr = (bh->b_blocknr * (GFS2_DEFAULT_BSIZE / bsize2)) + (bsize / bsize2) + 1; sdp->sd_bsize = bsize2; /* temporarily */ rb_bh = bread(sdp, rb_addr); - gfs2_meta_header_in(&mh, rb_bh->b_data); + mh = (struct gfs2_meta_header *)rb_bh->b_data; + is_rb = (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC && + be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RB); brelse(rb_bh); - if (mh.mh_magic == GFS2_MAGIC && - mh.mh_type == GFS2_METATYPE_RB) { + if (is_rb) { log_debug(_("boff:%d bsize2:%d rg:0x%llx, " "rb:0x%llx\n"), bsize, bsize2, (unsigned long long)blk, diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index bd3c360a..9526aed2 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -522,7 +522,8 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock, q = block_type(bl, block); if (q != GFS2_BLKST_FREE) { struct gfs2_buffer_head *bh; - struct gfs2_meta_header mh; + struct gfs2_meta_header *mh; + uint32_t mh_type;
log_err(_("Found duplicate %s block %"PRIu64" (0x%"PRIx64") " "referenced as data by dinode %"PRIu64" (0x%"PRIx64") "), @@ -548,13 +549,14 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock, return 1; case GFS2_BLKST_USED: /* tough decision: May be data or meta */ bh = bread(ip->i_sbd, block); - gfs2_meta_header_in(&mh, bh->b_data); + mh = (struct gfs2_meta_header *)bh->b_data; + mh_type = be32_to_cpu(mh->mh_type); brelse(bh); - if (mh.mh_magic == GFS2_MAGIC && - mh.mh_type >= GFS2_METATYPE_RG && - mh.mh_type <= GFS2_METATYPE_QC && - mh.mh_type != GFS2_METATYPE_DI && - mh.mh_format % 100 == 0) { + if (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC && + mh_type >= GFS2_METATYPE_RG && + mh_type <= GFS2_METATYPE_QC && + mh_type != GFS2_METATYPE_DI && + be32_to_cpu(mh->mh_format) % 100 == 0) { log_info(_("The block was processed earlier " "as valid metadata, so it can't " "possibly be data.\n")); diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c index fbdc4f34..9d165083 100644 --- a/gfs2/fsck/rgrepair.c +++ b/gfs2/fsck/rgrepair.c @@ -319,7 +319,6 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk, uint64_t rgrp_dist = 0, used_blocks, block, next_block, twogigs; struct rgrp_tree *rgd = NULL, *next_rgd; struct gfs2_buffer_head *bh; - struct gfs2_meta_header mh; int first, length, b, found; uint64_t mega_in_blocks; uint32_t free_blocks; @@ -353,15 +352,17 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk, first = 1; found = 0; while (1) { + struct gfs2_meta_header *mh; + if (block >= sdp->device.length) break; if (block >= prevrgd->rt_addr + twogigs) break; bh = bread(sdp, block); - gfs2_meta_header_in(&mh, bh->b_data); - if ((mh.mh_magic != GFS2_MAGIC) || - (first && mh.mh_type != GFS2_METATYPE_RG) || - (!first && mh.mh_type != GFS2_METATYPE_RB)) { + mh = (struct gfs2_meta_header *)bh->b_data; + if ((be32_to_cpu(mh->mh_magic) != GFS2_MAGIC) || + (first && be32_to_cpu(mh->mh_type) != GFS2_METATYPE_RG) || + (!first && be32_to_cpu(mh->mh_type) != GFS2_METATYPE_RB)) { brelse(bh); break; } @@ -391,22 +392,21 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk, if (next_block + b >= sdp->device.length) break; bh = bread(sdp, next_block + b); - gfs2_meta_header_in(&mh, bh->b_data); - brelse(bh); - if (mh.mh_magic == GFS2_MAGIC) { - if (mh.mh_type == GFS2_METATYPE_RG) { + mh = (struct gfs2_meta_header *)bh->b_data; + if (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC) { + if (be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RG) found = 1; - break; - } /* if the first thing we find is a bitmap, there must be a damaged rgrp on the previous block. */ - if (mh.mh_type == GFS2_METATYPE_RB) { + if (be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RB) { found = 1; rgrp_dist--; - break; } } + brelse(bh); + if (found) + break; rgrp_dist++; } if (found) { @@ -429,7 +429,7 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk, { uint64_t rgrp_dist = 0, block, twogigs, last_block, last_meg; struct gfs2_buffer_head *bh; - struct gfs2_meta_header mh; + struct gfs2_meta_header *mh; int b, mega_in_blocks;
/* Skip ahead the previous amount: we might get lucky. @@ -438,14 +438,16 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk, return sdp->fssize - blk;
bh = bread(sdp, blk + last_bump); - gfs2_meta_header_in(&mh, bh->b_data); - brelse(bh); - if (mh.mh_magic == GFS2_MAGIC && mh.mh_type == GFS2_METATYPE_RG) { + mh = (struct gfs2_meta_header *)bh->b_data; + if (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC && + be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RG) { log_info( _("rgrp found at 0x%llx, length=%lld\n"), (unsigned long long)blk + last_bump, (unsigned long long)last_bump); + brelse(bh); return last_bump; } + brelse(bh);
rgrp_dist = AWAY_FROM_BITMAPS; /* Get away from any bitmaps associated with the previous rgrp */ @@ -464,15 +466,19 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk, last_meg = mega_in_blocks; } for (b = AWAY_FROM_BITMAPS; b < last_block; b++) { + uint32_t magic, type; + bh = bread(sdp, block + b); - gfs2_meta_header_in(&mh, bh->b_data); + mh = (struct gfs2_meta_header *)bh->b_data; + magic = be32_to_cpu(mh->mh_magic); + type = be32_to_cpu(mh->mh_type); brelse(bh); - if (mh.mh_magic == GFS2_MAGIC) { - if (mh.mh_type == GFS2_METATYPE_RG) + if (magic == GFS2_MAGIC) { + if (type == GFS2_METATYPE_RG) break; /* if the first thing we find is a bitmap, there must be a damaged rgrp on the previous block. */ - if (mh.mh_type == GFS2_METATYPE_RB) { + if (type == GFS2_METATYPE_RB) { rgrp_dist--; break; } @@ -923,11 +929,11 @@ static int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_tree *rg, } if (x) { struct gfs2_meta_header mh = { - .mh_magic = GFS2_MAGIC, - .mh_type = GFS2_METATYPE_RB, - .mh_format = GFS2_FORMAT_RB + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_RB), + .mh_format = cpu_to_be32(GFS2_FORMAT_RB) }; - gfs2_meta_header_out(&mh, buf); + memcpy(buf, &mh, sizeof(mh)); } else { rg->rt_free = rg->rt_data; if (sdp->gfs1) diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c index 4cc9b275..dae6d1b7 100644 --- a/gfs2/libgfs2/fs_ops.c +++ b/gfs2/libgfs2/fs_ops.c @@ -246,14 +246,14 @@ void unstuff_dinode(struct gfs2_inode *ip) if (lgfs2_meta_alloc(ip, &block)) exit(1); if (isdir) { - struct gfs2_meta_header mh; + struct gfs2_meta_header mh = { + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_JD), + .mh_format = cpu_to_be32(GFS2_FORMAT_JD) + };
bh = bget(sdp, block); - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_JD; - mh.mh_format = GFS2_FORMAT_JD; - gfs2_meta_header_out(&mh, bh->b_data); - + memcpy(bh->b_data, &mh, sizeof(mh)); buffer_copy_tail(sdp, bh, sizeof(struct gfs2_meta_header), ip->i_bh, sizeof(struct gfs2_dinode)); @@ -399,15 +399,16 @@ void build_height(struct gfs2_inode *ip, int height) }
if (new_block) { - struct gfs2_meta_header mh; + struct gfs2_meta_header mh = { + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_IN), + .mh_format = cpu_to_be32(GFS2_FORMAT_IN) + };
if (lgfs2_meta_alloc(ip, &block)) exit(1); bh = bget(sdp, block); - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_IN; - mh.mh_format = GFS2_FORMAT_IN; - gfs2_meta_header_out(&mh, bh->b_data); + memcpy(bh->b_data, &mh, sizeof(mh)); buffer_copy_tail(sdp, bh, sizeof(struct gfs2_meta_header), ip->i_bh, sizeof(struct gfs2_dinode)); @@ -514,12 +515,13 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, return;
if (*new) { - struct gfs2_meta_header mh; + struct gfs2_meta_header mh = { + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_IN), + .mh_format = cpu_to_be32(GFS2_FORMAT_IN) + }; bh = bget(sdp, *dblock); - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_IN; - mh.mh_format = GFS2_FORMAT_IN; - gfs2_meta_header_out(&mh, bh->b_data); + memcpy(bh->b_data, &mh, sizeof(mh)); bmodified(bh); } else { if (*dblock == ip->i_addr) @@ -707,11 +709,12 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf, if (new) { bh = bget(sdp, dblock); if (isdir) { - struct gfs2_meta_header mh; - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_JD; - mh.mh_format = GFS2_FORMAT_JD; - gfs2_meta_header_out(&mh, bh->b_data); + struct gfs2_meta_header mh = { + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_JD), + .mh_format = cpu_to_be32(GFS2_FORMAT_JD), + }; + memcpy(bh->b_data, &mh, sizeof(mh)); bmodified(bh); } } else { @@ -907,11 +910,12 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no, exit(1); nbh = bget(dip->i_sbd, bn); { - struct gfs2_meta_header mh; - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_LF; - mh.mh_format = GFS2_FORMAT_LF; - gfs2_meta_header_out(&mh, nbh->b_data); + struct gfs2_meta_header mh = { + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_LF), + .mh_format = cpu_to_be32(GFS2_FORMAT_LF) + }; + memcpy(nbh->b_data, &mh, sizeof(mh)); bmodified(nbh); buffer_clear_tail(dip->i_sbd, nbh, sizeof(struct gfs2_meta_header)); @@ -1182,15 +1186,15 @@ restart: continue;
} else { - struct gfs2_meta_header mh; - + struct gfs2_meta_header mh = { + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_LF), + .mh_format = cpu_to_be32(GFS2_FORMAT_LF) + }; if (lgfs2_meta_alloc(dip, &bn)) exit(1); nbh = bget(dip->i_sbd, bn); - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_LF; - mh.mh_format = GFS2_FORMAT_LF; - gfs2_meta_header_out(&mh, nbh->b_data); + memcpy(nbh->b_data, &mh, sizeof(mh)); bmodified(nbh);
leaf->lf_next = cpu_to_be64(bn); @@ -1239,11 +1243,12 @@ static void dir_make_exhash(struct gfs2_inode *dip) exit(1); bh = bget(sdp, bn); { - struct gfs2_meta_header mh; - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_LF; - mh.mh_format = GFS2_FORMAT_LF; - gfs2_meta_header_out(&mh, bh->b_data); + struct gfs2_meta_header mh = { + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_LF), + .mh_format = cpu_to_be32(GFS2_FORMAT_LF) + }; + memcpy(bh->b_data, &mh, sizeof(mh)); bmodified(bh); }
@@ -1434,9 +1439,9 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip) uint64_t ptr0 = ip->i_addr + 1; unsigned ptrs = 1; struct gfs2_meta_header mh = { - .mh_magic = GFS2_MAGIC, - .mh_type = GFS2_METATYPE_IN, - .mh_format = GFS2_FORMAT_IN, + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_IN), + .mh_format = cpu_to_be32(GFS2_FORMAT_IN) }; struct gfs2_buffer_head *bh = bget(sdp, ip->i_addr); if (bh == NULL) @@ -1462,7 +1467,7 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip) lgfs2_dinode_out(ip, bh->b_data); } else { start += sizeof(struct gfs2_meta_header); - gfs2_meta_header_out(&mh, bh->b_data); + memcpy(bh->b_data, &mh, sizeof(mh)); } lgfs2_fill_indir(start, bh->b_data + sdp->sd_bsize, ptr0, ptrs, &p); if (bwrite(bh)) { diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c index 97fa32a5..10a196df 100644 --- a/gfs2/libgfs2/gfs1.c +++ b/gfs2/libgfs2/gfs1.c @@ -116,13 +116,13 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, return;
if (*new) { - struct gfs2_meta_header mh; - + struct gfs2_meta_header mh = { + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_IN), + .mh_format = cpu_to_be32(GFS2_FORMAT_IN) + }; bh = bget(sdp, *dblock); - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_IN; - mh.mh_format = GFS2_FORMAT_IN; - gfs2_meta_header_out(&mh, bh->b_data); + memcpy(bh->b_data, &mh, sizeof(mh)); bmodified(bh); } else { if (*dblock == ip->i_addr) @@ -214,12 +214,12 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset, bh = bread(sdp, dblock);
if (journaled && dblock != ip->i_addr ) { - struct gfs2_meta_header mh; - - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_JD; - mh.mh_format = GFS2_FORMAT_JD; - gfs2_meta_header_out(&mh, bh->b_data); + struct gfs2_meta_header mh = { + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(GFS2_METATYPE_JD), + .mh_format = cpu_to_be32(GFS2_FORMAT_JD) + }; + memcpy(bh->b_data, &mh, sizeof(mh)); }
memcpy(bh->b_data + offset, buf + copied, amount); diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c index 3633c7a7..f0870457 100644 --- a/gfs2/libgfs2/lang.c +++ b/gfs2/libgfs2/lang.c @@ -551,11 +551,11 @@ static struct lgfs2_lang_result *ast_interp_set(struct lgfs2_lang_state *state,
if (lookup->ast_right->ast_type == AST_EX_TYPESPEC) { struct gfs2_meta_header mh = { - .mh_magic = GFS2_MAGIC, - .mh_type = result->lr_mtype->mh_type, - .mh_format = result->lr_mtype->mh_format, + .mh_magic = cpu_to_be32(GFS2_MAGIC), + .mh_type = cpu_to_be32(result->lr_mtype->mh_type), + .mh_format = cpu_to_be32(result->lr_mtype->mh_format), }; - gfs2_meta_header_out(&mh, result->lr_buf); + memcpy(result->lr_buf, &mh, sizeof(mh)); lookup = lookup->ast_right; }
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index ba22f3bb..7f6988f8 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -810,8 +810,6 @@ extern void print_it(const char *label, const char *fmt, const char *fmt2, ...)
extern void lgfs2_inum_in(struct lgfs2_inum *i, void *inp); extern void lgfs2_inum_out(struct lgfs2_inum *i, void *inp); -extern void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf); -extern void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf); extern void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf); extern void lgfs2_sb_out(const struct gfs2_sbd *sdp, void *buf); extern void lgfs2_rindex_in(lgfs2_rgrp_t rg, void *buf); diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c index c6d396f5..1b6679b5 100644 --- a/gfs2/libgfs2/ondisk.c +++ b/gfs2/libgfs2/ondisk.c @@ -9,13 +9,6 @@ #include <uuid.h> #include "libgfs2.h"
-#define pv(struct, member, fmt, fmt2) do { \ - print_it(" "#member, fmt, fmt2, struct->member); \ - } while (0); -#define pv2(struct, member, fmt, fmt2) do { \ - print_it(" ", fmt, fmt2, struct->member); \ - } while (0); - #define printbe16(struct, member) do { \ print_it(" "#member, "%"PRIu16, "0x%"PRIx16, be16_to_cpu(struct->member)); \ } while(0) @@ -29,15 +22,6 @@ print_it(" "#member, "%"PRIu8, "0x%"PRIx8, struct->member); \ } while(0)
-#define CPIN_08(s1, s2, member, count) {memcpy((s1->member), (s2->member), (count));} -#define CPOUT_08(s1, s2, member, count) {memcpy((s2->member), (s1->member), (count));} -#define CPIN_16(s1, s2, member) {(s1->member) = be16_to_cpu((s2->member));} -#define CPOUT_16(s1, s2, member) {(s2->member) = cpu_to_be16((s1->member));} -#define CPIN_32(s1, s2, member) {(s1->member) = be32_to_cpu((s2->member));} -#define CPOUT_32(s1, s2, member) {(s2->member) = cpu_to_be32((s1->member));} -#define CPIN_64(s1, s2, member) {(s1->member) = be64_to_cpu((s2->member));} -#define CPOUT_64(s1, s2, member) {(s2->member) = cpu_to_be64((s1->member));} - void lgfs2_inum_in(struct lgfs2_inum *i, void *inp) { struct gfs2_inum *in = inp; @@ -62,26 +46,6 @@ void lgfs2_inum_print(void *nop) printbe64(no, no_addr); }
-void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf) -{ - const struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf; - - CPIN_32(mh, str, mh_magic); - CPIN_32(mh, str, mh_type); - CPIN_32(mh, str, mh_format); -} - -void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf) -{ - struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf; - - CPOUT_32(mh, str, mh_magic); - CPOUT_32(mh, str, mh_type); - CPOUT_32(mh, str, mh_format); - str->__pad0 = 0; - str->__pad1 = 0; -} - void lgfs2_meta_header_print(void *mhp) { struct gfs2_meta_header *mh = mhp; diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c index f0eb8832..9dcf237f 100644 --- a/gfs2/libgfs2/structures.c +++ b/gfs2/libgfs2/structures.c @@ -377,9 +377,9 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j) struct gfs2_buffer_head *bh;
memset(&mh, 0, sizeof(struct gfs2_meta_header)); - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_QC; - mh.mh_format = GFS2_FORMAT_QC; + mh.mh_magic = cpu_to_be32(GFS2_MAGIC); + mh.mh_type = cpu_to_be32(GFS2_METATYPE_QC); + mh.mh_format = cpu_to_be32(GFS2_FORMAT_QC);
sprintf(name, "quota_change%u", j); ip = createi(per_node, name, S_IFREG | 0600, GFS2_DIF_SYSTEM); @@ -396,7 +396,7 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j) return -1;
memset(bh->b_data, 0, sdp->sd_bsize); - gfs2_meta_header_out(&mh, bh->b_data); + memcpy(bh->b_data, &mh, sizeof(mh)); bmodified(bh); brelse(bh); } diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c index 66d9e293..8feb201c 100644 --- a/gfs2/mkfs/main_jadd.c +++ b/gfs2/mkfs/main_jadd.c @@ -377,10 +377,10 @@ static int add_qc(struct gfs2_sbd *sdp, struct jadd_opts *opts) }
memset(&mh, 0, sizeof(struct gfs2_meta_header)); - mh.mh_magic = GFS2_MAGIC; - mh.mh_type = GFS2_METATYPE_QC; - mh.mh_format = GFS2_FORMAT_QC; - gfs2_meta_header_out(&mh, buf); + mh.mh_magic = cpu_to_be32(GFS2_MAGIC); + mh.mh_type = cpu_to_be32(GFS2_METATYPE_QC); + mh.mh_format = cpu_to_be32(GFS2_FORMAT_QC); + memcpy(buf, &mh, sizeof(mh));
for (x=0; x<blocks; x++) { if (write(fd, buf, sdp->sd_bsize) != sdp->sd_bsize) {
cluster-commits@lists.fedorahosted.org