This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master in repository gfs2-utils.
commit 012367e32bae205522ca5d4fe82759de1acdffc1 Author: Andrew Price anprice@redhat.com AuthorDate: Wed Jun 9 15:48:33 2021 +0100
Remove some users of gfs2_leaf_in()
Just interpret the data through a gfs2_leaf pointer instead.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/convert/gfs2_convert.c | 10 +++++----- gfs2/edit/extended.c | 14 ++++++-------- gfs2/edit/gfs2hex.c | 6 ++---- gfs2/edit/savemeta.c | 19 ++++++++----------- 4 files changed, 21 insertions(+), 28 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index 9c703e4c..32f32064 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -1266,7 +1266,7 @@ static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip /* for all the leafs, get the leaf block and process the dirents inside */ for (leaf_num = 0; ; leaf_num++) { uint64_t buf; - struct gfs2_leaf leaf; + struct gfs2_leaf *leaf;
error = gfs2_readi(dip, (char *)&buf, leaf_num * sizeof(uint64_t), sizeof(uint64_t)); @@ -1293,14 +1293,14 @@ static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip (unsigned long long)leaf_block); break; } - gfs2_leaf_in(&leaf, bh_leaf->b_data); - error = process_dirent_info(dip, sbp, bh_leaf, leaf.lf_entries, dentmod); + leaf = (struct gfs2_leaf *)bh_leaf->b_data; + error = process_dirent_info(dip, sbp, bh_leaf, be16_to_cpu(leaf->lf_entries), dentmod); bmodified(bh_leaf); brelse(bh_leaf); if (dentmod && error == -EISDIR) /* dentmod was marked DT_DIR, break out */ break; - if (leaf.lf_next) { /* leaf has a leaf chain, process leaves in chain */ - leaf_block = leaf.lf_next; + if (leaf->lf_next) { /* leaf has a leaf chain, process leaves in chain */ + leaf_block = be64_to_cpu(leaf->lf_next); error = 0; goto leaf_chain; } diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c index d2ac8507..58cc2134 100644 --- a/gfs2/edit/extended.c +++ b/gfs2/edit/extended.c @@ -295,10 +295,6 @@ static void print_inode_type(__be16 de_type) } }
-#define LEAF_HINT_FMTS "lf_inode: 0x%"PRIx64", lf_dist: %"PRIu32", " \ - "lf_nsec: %"PRIu32", lf_sec: %"PRIu64", " -#define LEAF_HINT_FIELDS(lp) lp->lf_inode, lp->lf_dist, lp->lf_nsec, lp->lf_sec, - static int display_leaf(struct iinfo *ind) { struct gfs2_leaf *leaf = &ind->ii[0].lf; @@ -309,11 +305,13 @@ static int display_leaf(struct iinfo *ind) if (gfs2_struct_type == GFS2_METATYPE_SB) print_gfs2("The superblock has 2 directories"); else - print_gfs2("Directory block: lf_depth:%"PRIu16", lf_entries:%"PRIu16", " - LEAF_HINT_FMTS + print_gfs2("Directory block: " + "lf_depth:%"PRIu16", lf_entries:%"PRIu16", lf_inode: 0x%"PRIx64", " + "lf_dist: %"PRIu32", lf_nsec: %"PRIu32", lf_sec: %"PRIu64", " "fmt:%"PRIu32" next=0x%"PRIx64" (%d dirents).", - leaf->lf_depth, leaf->lf_entries, - LEAF_HINT_FIELDS(leaf) + be16_to_cpu(leaf->lf_depth), be16_to_cpu(leaf->lf_entries), + be64_to_cpu(leaf->lf_inode), be32_to_cpu(leaf->lf_dist), + be32_to_cpu(leaf->lf_nsec), be64_to_cpu(leaf->lf_sec), leaf->lf_dirent_format, leaf->lf_next, ind->ii[0].dirents); diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c index 5a1f9b7f..a18df909 100644 --- a/gfs2/edit/gfs2hex.c +++ b/gfs2/edit/gfs2hex.c @@ -300,13 +300,11 @@ void do_dinode_extended(char *buf) if (p != last || ((y + 1) * sizeof(uint64_t) == be64_to_cpu(dip->di_size))) { struct gfs2_buffer_head *tmp_bh; int skip = 0, direntcount = 0; - struct gfs2_leaf leaf; unsigned int bufoffset;
if (last >= max_block) break; tmp_bh = bread(&sbd, last); - gfs2_leaf_in(&leaf, tmp_bh->b_data); indirect->ii[indirect_blocks].dirents = 0; for (direntcount = 0, bufoffset = sizeof(struct gfs2_leaf); bufoffset < sbd.sd_bsize; @@ -336,7 +334,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
x = 0; memset(indir, 0, sizeof(*indir)); - gfs2_leaf_in(&indir->ii[0].lf, dlebuf); + memcpy(&indir->ii[0].lf, dlebuf, sizeof(struct gfs2_leaf)); /* Directory Entries: */ for (i = sizeof(struct gfs2_leaf); i < sbd.sd_bsize; i += be16_to_cpu(de->de_rec_len)) { de = (struct gfs2_dirent *)(dlebuf + i); @@ -350,7 +348,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir) if (be16_to_cpu(de->de_rec_len) <= sizeof(struct gfs2_dirent)) break; } - return indir->ii[0].lf.lf_next; + return be64_to_cpu(indir->ii[0].lf.lf_next); }
static void do_eattr_extended(char *buf) diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 5d51ea1f..09761fe2 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -329,7 +329,7 @@ static size_t di_save_len(const char *buf, uint64_t owner) static int get_gfs_struct_info(const char *buf, uint64_t owner, unsigned *block_type, unsigned *gstruct_len) { - struct gfs2_meta_header mh; + struct gfs2_meta_header *mh = (struct gfs2_meta_header *)buf;
if (block_type != NULL) *block_type = 0; @@ -337,17 +337,16 @@ static int get_gfs_struct_info(const char *buf, uint64_t owner, unsigned *block_ if (gstruct_len != NULL) *gstruct_len = sbd.sd_bsize;
- gfs2_meta_header_in(&mh, buf); - if (mh.mh_magic != GFS2_MAGIC) + if (be32_to_cpu(mh->mh_magic) != GFS2_MAGIC) return -1;
if (block_type != NULL) - *block_type = mh.mh_type; + *block_type = be32_to_cpu(mh->mh_type);
if (gstruct_len == NULL) return 0;
- switch (mh.mh_type) { + switch (be32_to_cpu(mh->mh_type)) { case GFS2_METATYPE_SB: /* 1 (superblock) */ if (sbd.gfs1) *gstruct_len = sizeof(struct gfs_sb); @@ -791,12 +790,10 @@ new_range:
static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, char *buf) { - struct gfs2_leaf leaf; + struct gfs2_leaf *leaf = (struct gfs2_leaf *)buf;
- gfs2_leaf_in(&leaf, buf); - - while (leaf.lf_next != 0) { - uint64_t blk = leaf.lf_next; + while (leaf->lf_next != 0) { + uint64_t blk = be64_to_cpu(leaf->lf_next); ssize_t r;
if (gfs2_check_range(sdp, blk) != 0) @@ -817,7 +814,7 @@ static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, char *buf) return ret; } } - gfs2_leaf_in(&leaf, buf); + leaf = (struct gfs2_leaf *)buf; } return 0; }
cluster-commits@lists.fedorahosted.org