From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Price Date: Mon, 5 Mar 2018 18:25:43 +0000 Subject: [Cluster-devel] [PATCH 14/20] libgfs2: Don't use buffer_heads in gfs2_leaf_{in, out} In-Reply-To: <20180305182549.17817-1-anprice@redhat.com> References: <20180305182549.17817-1-anprice@redhat.com> Message-ID: <20180305182549.17817-15-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Signed-off-by: Andrew Price --- gfs2/convert/gfs2_convert.c | 2 +- gfs2/edit/gfs2hex.c | 8 +++----- gfs2/edit/savemeta.c | 2 +- gfs2/fsck/metawalk.c | 10 ++++++---- gfs2/fsck/pass2.c | 6 +++--- gfs2/libgfs2/libgfs2.h | 4 ++-- gfs2/libgfs2/ondisk.c | 13 ++++++------- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index d2b29f34..eac907cd 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -1303,7 +1303,7 @@ 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); /* buffer to structure */ + gfs2_leaf_in(&leaf, bh_leaf->b_data); error = process_dirent_info(dip, sbp, bh_leaf, leaf.lf_entries, dentmod); bmodified(bh_leaf); brelse(bh_leaf); diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c index 1a12e05e..c1aa81a8 100644 --- a/gfs2/edit/gfs2hex.c +++ b/gfs2/edit/gfs2hex.c @@ -298,7 +298,7 @@ void do_dinode_extended(struct gfs2_dinode *dine, struct gfs2_buffer_head *lbh) if (last >= max_block) break; tmp_bh = bread(&sbd, last); - gfs2_leaf_in(&leaf, tmp_bh); + gfs2_leaf_in(&leaf, tmp_bh->b_data); indirect->ii[indirect_blocks].dirents = 0; for (direntcount = 0, bufoffset = sizeof(struct gfs2_leaf); bufoffset < sbd.bsize; @@ -325,12 +325,10 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir) { int x, i; struct gfs2_dirent de; - struct gfs2_buffer_head tbh; /* kludge */ x = 0; memset(indir, 0, sizeof(*indir)); - tbh.b_data = dlebuf; - gfs2_leaf_in(&indir->ii[0].lf, &tbh); + gfs2_leaf_in(&indir->ii[0].lf, dlebuf); /* Directory Entries: */ for (i = sizeof(struct gfs2_leaf); i < sbd.bsize; i += de.de_rec_len) { @@ -519,7 +517,7 @@ int display_gfs2(struct gfs2_buffer_head *dbh) break; case GFS2_METATYPE_LF: - gfs2_leaf_in(&lf, dbh); + gfs2_leaf_in(&lf, dbh->b_data); gfs2_leaf_print(&lf); break; diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 6d87f33d..25fd7bc1 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -574,7 +574,7 @@ static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, uint64_t bl return ret; } } - gfs2_leaf_in(&leaf, bh); + gfs2_leaf_in(&leaf, bh->b_data); brelse(bh); blk = leaf.lf_next; } while (leaf.lf_next != 0); diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 78c5b8aa..127edaa2 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -583,12 +583,13 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass, to use cpu_to_be32(), but we should check for incorrect values and replace them with the correct value. */ - gfs2_leaf_in(leaf, lbh); + gfs2_leaf_in(leaf, lbh->b_data); if (leaf->lf_dirent_format == (GFS2_FORMAT_DE << 16)) { log_debug( _("incorrect lf_dirent_format@leaf #%" PRIu64 "\n"), *leaf_no); leaf->lf_dirent_format = GFS2_FORMAT_DE; - gfs2_leaf_out(leaf, lbh); + gfs2_leaf_out(leaf, lbh->b_data); + bmodified(lbh); log_debug( _("Fixing lf_dirent_format.\n")); } @@ -623,7 +624,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass, changed it. */ brelse(lbh); lbh = bread(sdp, *leaf_no); - gfs2_leaf_in(leaf, lbh); + gfs2_leaf_in(leaf, lbh->b_data); if (count != leaf->lf_entries) { log_err( _("Leaf %llu (0x%llx) entry count in " "directory %llu (0x%llx) does not match " @@ -635,7 +636,8 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass, leaf->lf_entries, count); if (query( _("Update leaf entry count? (y/n) "))) { leaf->lf_entries = count; - gfs2_leaf_out(leaf, lbh); + gfs2_leaf_out(leaf, lbh->b_data); + bmodified(lbh); log_warn( _("Leaf entry count updated\n")); } else log_err( _("Leaf entry count left in " diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c index abc2b960..763e39a9 100644 --- a/gfs2/fsck/pass2.c +++ b/gfs2/fsck/pass2.c @@ -1496,7 +1496,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize, new_leaf_blk = find_free_blk(ip->i_sbd); dir_split_leaf(ip, lindex, leafblk, lbh); /* re-read the leaf to pick up dir_split_leaf's changes */ - gfs2_leaf_in(&leaf, lbh); + gfs2_leaf_in(&leaf, lbh->b_data); *proper_len = 1 << (ip->i_di.di_depth - leaf.lf_depth); log_err(_("Leaf block %llu (0x%llx) was split from length " "%d to %d\n"), (unsigned long long)leafblk, @@ -1793,7 +1793,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl, (unsigned long long)leafblk, proper_len, proper_len); lbh = bread(ip->i_sbd, leafblk); - gfs2_leaf_in(&leaf, lbh); + gfs2_leaf_in(&leaf, lbh->b_data); if (gfs2_check_meta(lbh, GFS2_METATYPE_LF) || leaf.lf_depth > ip->i_di.di_depth) leaf.lf_depth = factor; @@ -1833,7 +1833,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl, /* Now we have to determine if the hash table is corrupt, or if the leaf has the wrong depth. */ lbh = bread(ip->i_sbd, leafblk); - gfs2_leaf_in(&leaf, lbh); + gfs2_leaf_in(&leaf, lbh->b_data); brelse(lbh); /* Calculate the expected pointer count based on the leaf depth. */ diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 7b2671b5..71b4e5e8 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -735,8 +735,8 @@ extern void gfs2_dinode_in(struct gfs2_dinode *di, char *buf); extern void gfs2_dinode_out(struct gfs2_dinode *di, char *buf); extern void gfs2_dirent_in(struct gfs2_dirent *de, char *buf); extern void gfs2_dirent_out(struct gfs2_dirent *de, char *buf); -extern void gfs2_leaf_in(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh); -extern void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh); +extern void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf); +extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf); extern void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf); extern void gfs2_log_header_v1_in(struct gfs2_log_header *lh, struct gfs2_buffer_head *bh); extern void gfs2_log_header_in(struct gfs2_log_header *lh, struct gfs2_buffer_head *bh); diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c index 51dc004f..04f3ce2c 100644 --- a/gfs2/libgfs2/ondisk.c +++ b/gfs2/libgfs2/ondisk.c @@ -452,11 +452,11 @@ void gfs2_dirent_out(struct gfs2_dirent *de, char *buf) #endif /* GFS2_HAS_DE_RAHEAD */ } -void gfs2_leaf_in(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh) +void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf) { - struct gfs2_leaf *str = (struct gfs2_leaf *)bh->b_data; + struct gfs2_leaf *str = (struct gfs2_leaf *)buf; - gfs2_meta_header_in(&lf->lf_header, bh->b_data); + gfs2_meta_header_in(&lf->lf_header, buf); CPIN_16(lf, str, lf_depth); CPIN_16(lf, str, lf_entries); CPIN_32(lf, str, lf_dirent_format); @@ -472,11 +472,11 @@ void gfs2_leaf_in(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh) #endif } -void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh) +void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf) { - struct gfs2_leaf *str = (struct gfs2_leaf *)bh->b_data; + struct gfs2_leaf *str = (struct gfs2_leaf *)buf; - gfs2_meta_header_out(&lf->lf_header, bh->b_data); + gfs2_meta_header_out(&lf->lf_header, buf); CPOUT_16(lf, str, lf_depth); CPOUT_16(lf, str, lf_entries); CPOUT_32(lf, str, lf_dirent_format); @@ -490,7 +490,6 @@ void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh) #else CPOUT_08(lf, str, lf_reserved, 64); #endif - bmodified(bh); } void gfs2_leaf_print(const struct gfs2_leaf *lf) -- 2.14.3