gfs2-utils: RHEL7 - libgfs2: Remove sdp and j arguments from write_journal

Andrew Price andyp at fedoraproject.org
Mon Sep 8 17:32:31 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=7c83804fa24110527704094ae99625702b5a594e
Commit:        7c83804fa24110527704094ae99625702b5a594e
Parent:        cdec90ab7cdce6077cba2f3ee015d18a61dff550
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Tue Jan 14 15:41:53 2014 +0000
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Thu Jul 24 16:08:54 2014 +0100

libgfs2: Remove sdp and j arguments from write_journal

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 eacc565..69b4b8b 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2024,7 +2024,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 813aa97..ce05491 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 2c1939a..2cc9a98 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -140,7 +140,7 @@ out_buf:
 	return err;
 }
 
-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;
@@ -150,9 +150,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;
@@ -161,20 +160,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);
@@ -188,10 +185,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;
 }
 
@@ -206,7 +199,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;
 }


More information about the cluster-commits mailing list