cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [GFS2 PATCH V2] GFS2: Combine func meta_prep_new with its only caller
       [not found] <2004376135.14896837.1495806824589.JavaMail.zimbra@redhat.com>
@ 2017-05-26 13:56 ` Bob Peterson
  0 siblings, 0 replies; only message in thread
From: Bob Peterson @ 2017-05-26 13:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

This patch is the same as the one I posted earlier, but I
moved the setting of mh_magic inside the protection of the
buffer lock, since Steve pointed out how flawed that was.

I like Steve's other idea of combining some of the other code
of the callers, for example, adding the new buffer to an existing
transaction, but I'll address that with a later patch.

Regards,

Bob Peterson
---
Before this patch function meta_prep_new was only called in one
place, function gfs2_meta_new which is only a couple lines long.
This patch combines them for readability.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 663ffc1..b1705a7 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -158,18 +158,6 @@ struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno, int create)
 	return bh;
 }
 
-static void meta_prep_new(struct buffer_head *bh)
-{
-	struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
-
-	lock_buffer(bh);
-	clear_buffer_dirty(bh);
-	set_buffer_uptodate(bh);
-	unlock_buffer(bh);
-
-	mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
-}
-
 /**
  * gfs2_meta_new - Get a block
  * @gl: The glock associated with this block
@@ -180,9 +168,15 @@ static void meta_prep_new(struct buffer_head *bh)
 
 struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno)
 {
-	struct buffer_head *bh;
-	bh = gfs2_getbuf(gl, blkno, CREATE);
-	meta_prep_new(bh);
+	struct buffer_head *bh = gfs2_getbuf(gl, blkno, CREATE);
+	struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
+
+	lock_buffer(bh);
+	clear_buffer_dirty(bh);
+	set_buffer_uptodate(bh);
+	mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
+	unlock_buffer(bh);
+
 	return bh;
 }
 



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-26 13:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <2004376135.14896837.1495806824589.JavaMail.zimbra@redhat.com>
2017-05-26 13:56 ` [Cluster-devel] [GFS2 PATCH V2] GFS2: Combine func meta_prep_new with its only caller Bob Peterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).