[Cluster-devel] [PATCH 2/8] libgfs2: Remove sdp and j arguments from write_journal

Andrew Price anprice at redhat.com
Mon Jan 27 14:17:16 UTC 2014


write_journal accepts an sdp argument which it only used to look up the
current journal (using j as the index) and the bsize. Replace these
arguments with the journal inode itself and the block size.

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/convert/gfs2_convert.c |  2 +-
 gfs2/fsck/fs_recovery.c     |  2 +-
 gfs2/libgfs2/libgfs2.h      |  3 +--
 gfs2/libgfs2/structures.c   | 21 +++++++--------------
 4 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index e9dd0da..8ab3981 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2006,7 +2006,7 @@ static int conv_build_jindex(struct gfs2_sbd *sdp)
 		sprintf(name, "journal%u", j);
 		sdp->md.journal[j] = createi(sdp->md.jiinode, name, S_IFREG |
 					     0600, GFS2_DIF_SYSTEM);
-		write_journal(sdp, j,
+		write_journal(sdp->md.journal[j], sdp->bsize,
 			      sdp->jsize << 20 >> sdp->sd_sb.sb_bsize_shift);
 		inode_put(&sdp->md.journal[j]);
 		printf(_("done.\n"));
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 41d575a..54a8c5f 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -552,7 +552,7 @@ out:
 	log_info( _("jid=%u: Failed\n"), j);
 reinit:
 	if (query( _("Do you want to clear the journal instead? (y/n)")))
-		error = write_journal(sdp, j,
+		error = write_journal(sdp->md.journal[j], sdp->bsize,
 				      sdp->md.journal[j]->i_di.di_size /
 				      sdp->sd_sb.sb_bsize);
 	else
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 3119f39..42f9d44 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -496,8 +496,7 @@ extern int gfs2_dirent_next(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
 extern void build_height(struct gfs2_inode *ip, int height);
 extern void unstuff_dinode(struct gfs2_inode *ip);
 extern unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size);
-extern int write_journal(struct gfs2_sbd *sdp, unsigned int j,
-			 unsigned int blocks);
+extern int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned blocks);
 
 /* gfs1.c - GFS1 backward compatibility structures and functions */
 
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index e888f1e..030974b 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -80,7 +80,7 @@ void build_sb(struct gfs2_sbd *sdp, const unsigned char *uuid)
 	}
 }
 
-int write_journal(struct gfs2_sbd *sdp, unsigned int j, unsigned int blocks)
+int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)
 {
 	struct gfs2_log_header lh;
 	unsigned int x;
@@ -90,9 +90,8 @@ int write_journal(struct gfs2_sbd *sdp, unsigned int j, unsigned int blocks)
 
 	/* Build the height up so our journal blocks will be contiguous and */
 	/* not broken up by indirect block pages.                           */
-	height = calc_tree_height(sdp->md.journal[j],
-				  (blocks + 1) * sdp->bsize);
-	build_height(sdp->md.journal[j], height);
+	height = calc_tree_height(jnl, (blocks + 1) * bsize);
+	build_height(jnl, height);
 
 	memset(&lh, 0, sizeof(struct gfs2_log_header));
 	lh.lh_header.mh_magic = GFS2_MAGIC;
@@ -101,20 +100,18 @@ int write_journal(struct gfs2_sbd *sdp, unsigned int j, unsigned int blocks)
 	lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
 
 	for (x = 0; x < blocks; x++) {
-		struct gfs2_buffer_head *bh = get_file_buf(sdp->md.journal[j],
-							   x, TRUE);
+		struct gfs2_buffer_head *bh = get_file_buf(jnl, x, TRUE);
 		if (!bh)
 			return -1;
 		bmodified(bh);
 		brelse(bh);
 	}
 	for (x = 0; x < blocks; x++) {
-		struct gfs2_buffer_head *bh = get_file_buf(sdp->md.journal[j],
-							   x, FALSE);
+		struct gfs2_buffer_head *bh = get_file_buf(jnl, x, FALSE);
 		if (!bh)
 			return -1;
 
-		memset(bh->b_data, 0, sdp->bsize);
+		memset(bh->b_data, 0, bsize);
 		lh.lh_sequence = seq;
 		lh.lh_blkno = x;
 		gfs2_log_header_out(&lh, bh);
@@ -128,10 +125,6 @@ int write_journal(struct gfs2_sbd *sdp, unsigned int j, unsigned int blocks)
 			seq = 0;
 	}
 
-	if (sdp->debug) {
-		printf("\nJournal %u:\n", j);
-		gfs2_dinode_print(&sdp->md.journal[j]->i_di);
-	}
 	return 0;
 }
 
@@ -146,7 +139,7 @@ int build_journal(struct gfs2_sbd *sdp, int j, struct gfs2_inode *jindex)
 	if (sdp->md.journal[j] == NULL) {
 		return errno;
 	}
-	ret = write_journal(sdp, j,
+	ret = write_journal(sdp->md.journal[j], sdp->bsize,
 			    sdp->jsize << 20 >> sdp->sd_sb.sb_bsize_shift);
 	return ret;
 }
-- 
1.8.3.1




More information about the Cluster-devel mailing list