From: Andrew Price Date: Thu, 6 Aug 2020 14:37:42 +0100 Subject: [Cluster-devel] [PATCH 07/32] libgfs2: Remove gfs2_buffer_head from lgfs2_gfs_inode_get() In-Reply-To: <20200806133807.111280-1-anprice@redhat.com> References: <20200806133807.111280-1-anprice@redhat.com> Message-ID: <20200806133807.111280-8-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 Give lgfs2_gfs_inode_read() its own reading code for now. Removing bh's from that will involve removing the i_bh field from gfs2_inode, which has a lot of users. Signed-off-by: Andrew Price --- gfs2/convert/gfs2_convert.c | 2 +- gfs2/edit/savemeta.c | 4 ++-- gfs2/fsck/metawalk.c | 2 +- gfs2/libgfs2/gfs1.c | 33 ++++++++++++++++++--------------- gfs2/libgfs2/libgfs2.h | 6 ++---- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c index 7de0f924..54a6ec1b 100644 --- a/gfs2/convert/gfs2_convert.c +++ b/gfs2/convert/gfs2_convert.c @@ -867,7 +867,7 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh) struct inode_block *fixdir; int inode_was_gfs1; - inode = lgfs2_gfs_inode_get(sbp, bh); + inode = lgfs2_gfs_inode_get(sbp, bh->b_data); if (inode == NULL) { log_crit(_("Error reading inode: %s\n"), strerror(errno)); return -1; diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 10e3bcce..cbecf281 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -303,7 +303,7 @@ static size_t di_save_len(struct gfs2_buffer_head *bh, uint64_t owner) size_t len; if (sbd.gfs1) - inode = lgfs2_gfs_inode_get(&sbd, bh); + inode = lgfs2_gfs_inode_get(&sbd, bh->b_data); else inode = lgfs2_inode_get(&sbd, bh); @@ -724,7 +724,7 @@ static void save_inode_data(struct metafd *mfd, uint64_t iblk) osi_list_init(&metalist[i]); metabh = bread(&sbd, iblk); if (sbd.gfs1) { - inode = lgfs2_gfs_inode_get(&sbd, metabh); + inode = lgfs2_gfs_inode_get(&sbd, metabh->b_data); } else { inode = lgfs2_inode_get(&sbd, metabh); } diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 265fa760..a425e884 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -292,7 +292,7 @@ struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, return sysip; if (sdp->gfs1) - ip = lgfs2_gfs_inode_get(sdp, bh); + ip = lgfs2_gfs_inode_get(sdp, bh->b_data); else ip = lgfs2_inode_get(sdp, bh); if (ip) diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c index 7da23168..29e4f12d 100644 --- a/gfs2/libgfs2/gfs1.c +++ b/gfs2/libgfs2/gfs1.c @@ -277,9 +277,7 @@ static void gfs_dinode_in(struct gfs_dinode *di, char *buf) di->di_eattr = be64_to_cpu(str->di_eattr); } -static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, - struct gfs2_buffer_head *bh, - uint64_t di_addr) +static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, char *buf, uint64_t di_addr) { struct gfs_dinode gfs1_dinode; struct gfs2_inode *ip; @@ -288,13 +286,7 @@ static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, if (ip == NULL) { return NULL; } - - ip->bh_owned = 0; - if (!bh) { - bh = bread(sdp, di_addr); - ip->bh_owned = 1; - } - gfs_dinode_in(&gfs1_dinode, bh->b_data); + gfs_dinode_in(&gfs1_dinode, buf); memcpy(&ip->i_di.di_header, &gfs1_dinode.di_header, sizeof(struct gfs2_meta_header)); memcpy(&ip->i_di.di_num, &gfs1_dinode.di_num, @@ -319,20 +311,31 @@ static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, ip->i_di.di_depth = gfs1_dinode.di_depth; ip->i_di.di_entries = gfs1_dinode.di_entries; ip->i_di.di_eattr = gfs1_dinode.di_eattr; - ip->i_bh = bh; ip->i_sbd = sdp; return ip; } -struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, - struct gfs2_buffer_head *bh) +struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, char *buf) { - return __gfs_inode_get(sdp, bh, 0); + return __gfs_inode_get(sdp, buf, 0); } struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr) { - return __gfs_inode_get(sdp, NULL, di_addr); + struct gfs2_buffer_head *bh; + struct gfs2_inode *ip; + + bh = bget(sdp, di_addr); + if (bh == NULL) + return NULL; + if (pread(sdp->device_fd, bh->b_data, sdp->bsize, di_addr * sdp->bsize) != sdp->bsize) { + brelse(bh); + return NULL; + } + ip = __gfs_inode_get(sdp, bh->b_data, di_addr); + ip->i_bh = bh; + ip->bh_owned = 1; + return ip; } /* ------------------------------------------------------------------------ */ diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 59fb18e8..a34e77a7 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -639,10 +639,8 @@ extern void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, extern int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset, unsigned int size); extern int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet); -extern struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, - struct gfs2_buffer_head *bh); -extern struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, - uint64_t di_addr); +extern struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, char *buf); +extern struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr); extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf); extern void gfs_rgrp_in(struct gfs_rgrp *rg, const char *buf); extern void gfs_rgrp_out(const struct gfs_rgrp *rg, char *buf); -- 2.26.2