From: Andrew Price Date: Thu, 6 Aug 2020 14:37:44 +0100 Subject: [Cluster-devel] [PATCH 09/32] libgfs2: Move get_file_buf() into structures.c In-Reply-To: <20200806133807.111280-1-anprice@redhat.com> References: <20200806133807.111280-1-anprice@redhat.com> Message-ID: <20200806133807.111280-10-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 It's only called from there. Open code inode_is_stuffed() as it's simple enough. Signed-off-by: Andrew Price --- gfs2/libgfs2/fs_ops.c | 27 --------------------------- gfs2/libgfs2/libgfs2.h | 2 -- gfs2/libgfs2/structures.c | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c index b5363c05..ee512f67 100644 --- a/gfs2/libgfs2/fs_ops.c +++ b/gfs2/libgfs2/fs_ops.c @@ -744,33 +744,6 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf, return copied; } -struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn, - int prealloc) -{ - struct gfs2_sbd *sdp = ip->i_sbd; - uint64_t dbn; - int new = TRUE; - - if (inode_is_stuffed(ip)) - unstuff_dinode(ip); - - block_map(ip, lbn, &new, &dbn, NULL, prealloc); - if (!dbn) { - fprintf(stderr, "get_file_buf\n"); - exit(1); - } - - if (!prealloc && new && - ip->i_di.di_size < (lbn + 1) << sdp->sd_sb.sb_bsize_shift) { - bmodified(ip->i_bh); - ip->i_di.di_size = (lbn + 1) << sdp->sd_sb.sb_bsize_shift; - } - if (dbn == ip->i_di.di_num.no_addr) - return ip->i_bh; - else - return bread(sdp, dbn); -} - int gfs2_dirent_first(struct gfs2_inode *dip, struct gfs2_buffer_head *bh, struct gfs2_dirent **dent) { diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index a34e77a7..aa500dfd 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -432,8 +432,6 @@ extern int gfs2_readi(struct gfs2_inode *ip, void *buf, uint64_t offset, __gfs2_writei(ip, buf, offset, size, 1) extern int __gfs2_writei(struct gfs2_inode *ip, void *buf, uint64_t offset, unsigned int size, int resize); -extern struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, - uint64_t lbn, int prealloc); extern int init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct gfs2_inum *inum, unsigned int mode, uint32_t flags, struct gfs2_inum *parent); extern struct gfs2_inode *createi(struct gfs2_inode *dip, const char *filename, diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c index 0aca7cd0..1e275bca 100644 --- a/gfs2/libgfs2/structures.c +++ b/gfs2/libgfs2/structures.c @@ -194,6 +194,30 @@ int lgfs2_write_journal_data(struct gfs2_inode *ip) return 0; } +static struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn, int prealloc) +{ + struct gfs2_sbd *sdp = ip->i_sbd; + uint64_t dbn; + int new = TRUE; + + if (ip->i_di.di_height == 0) + unstuff_dinode(ip); + + block_map(ip, lbn, &new, &dbn, NULL, prealloc); + if (!dbn) + return NULL; + + if (!prealloc && new && + ip->i_di.di_size < (lbn + 1) << sdp->sd_sb.sb_bsize_shift) { + bmodified(ip->i_bh); + ip->i_di.di_size = (lbn + 1) << sdp->sd_sb.sb_bsize_shift; + } + if (dbn == ip->i_di.di_num.no_addr) + return ip->i_bh; + else + return bread(sdp, dbn); +} + int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks) { struct gfs2_log_header lh; -- 2.26.2