cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] GFS2: Pre-pull patch posting
@ 2013-01-03 11:50 Steven Whitehouse
  2013-01-03 11:50 ` [Cluster-devel] [PATCH 1/4] GFS2: Initialize hex string to '0' Steven Whitehouse
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Steven Whitehouse @ 2013-01-03 11:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

Here are four small bug fixes for GFS2. There is no common theme here
really, just a few items that were fixed recently. The first fixes
lock name generation when the glock number is 0. The second fixes a
race allocating reservation structures and the final two fix a performance
issue by making small changes in the allocation code,

Steve.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH 1/4] GFS2: Initialize hex string to '0'
  2013-01-03 11:50 [Cluster-devel] GFS2: Pre-pull patch posting Steven Whitehouse
@ 2013-01-03 11:50 ` Steven Whitehouse
  2013-01-03 11:50 ` [Cluster-devel] [PATCH 2/4] GFS2: Fix race in gfs2_rs_alloc Steven Whitehouse
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Steven Whitehouse @ 2013-01-03 11:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

From: Nathan Straz <nstraz@redhat.com>

When generating the DLM lock name, a value of 0 would skip
the loop and leave the string unchanged.  This left locks with
a value of 0 unlabeled.  Initializing the string to '0' fixes this.

Signed-off-by: Nathan Straz <nstraz@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
index 8dad6b0..b906ed1 100644
--- a/fs/gfs2/lock_dlm.c
+++ b/fs/gfs2/lock_dlm.c
@@ -241,6 +241,7 @@ static u32 make_flags(struct gfs2_glock *gl, const unsigned int gfs_flags,
 
 static void gfs2_reverse_hex(char *c, u64 value)
 {
+	*c = '0';
 	while (value) {
 		*c-- = hex_asc[value & 0x0f];
 		value >>= 4;
-- 
1.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH 2/4] GFS2: Fix race in gfs2_rs_alloc
  2013-01-03 11:50 [Cluster-devel] GFS2: Pre-pull patch posting Steven Whitehouse
  2013-01-03 11:50 ` [Cluster-devel] [PATCH 1/4] GFS2: Initialize hex string to '0' Steven Whitehouse
@ 2013-01-03 11:50 ` Steven Whitehouse
  2013-01-03 11:50 ` [Cluster-devel] [PATCH 3/4] GFS2: Stop looking for free blocks at end of rgrp Steven Whitehouse
  2013-01-03 11:50 ` [Cluster-devel] [PATCH 4/4] GFS2: Reset rd_last_alloc when it reaches the end of the rgrp Steven Whitehouse
  3 siblings, 0 replies; 5+ messages in thread
From: Steven Whitehouse @ 2013-01-03 11:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

From: Abhijith Das <adas@redhat.com>

QE aio tests uncovered a race condition in gfs2_rs_alloc where it's possible
to come out of the function with a valid ip->i_res allocation but it gets
freed before use resulting in a NULL ptr dereference.

This patch envelopes the initial short-circuit check for non-NULL ip->i_res
into the mutex lock. With this patch, I was able to successfully run the
reproducer test multiple times.

Resolves: rhbz#878476
Signed-off-by: Abhi Das <adas@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 37ee061..738b388 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -557,22 +557,20 @@ void gfs2_free_clones(struct gfs2_rgrpd *rgd)
  */
 int gfs2_rs_alloc(struct gfs2_inode *ip)
 {
-	struct gfs2_blkreserv *res;
+	int error = 0;
 
+	down_write(&ip->i_rw_mutex);
 	if (ip->i_res)
-		return 0;
-
-	res = kmem_cache_zalloc(gfs2_rsrv_cachep, GFP_NOFS);
-	if (!res)
-		return -ENOMEM;
+		goto out;
 
-	RB_CLEAR_NODE(&res->rs_node);
+	ip->i_res = kmem_cache_zalloc(gfs2_rsrv_cachep, GFP_NOFS);
+	if (!ip->i_res) {
+		error = -ENOMEM;
+		goto out;
+	}
 
-	down_write(&ip->i_rw_mutex);
-	if (ip->i_res)
-		kmem_cache_free(gfs2_rsrv_cachep, res);
-	else
-		ip->i_res = res;
+	RB_CLEAR_NODE(&ip->i_res->rs_node);
+out:
 	up_write(&ip->i_rw_mutex);
 	return 0;
 }
-- 
1.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH 3/4] GFS2: Stop looking for free blocks at end of rgrp
  2013-01-03 11:50 [Cluster-devel] GFS2: Pre-pull patch posting Steven Whitehouse
  2013-01-03 11:50 ` [Cluster-devel] [PATCH 1/4] GFS2: Initialize hex string to '0' Steven Whitehouse
  2013-01-03 11:50 ` [Cluster-devel] [PATCH 2/4] GFS2: Fix race in gfs2_rs_alloc Steven Whitehouse
@ 2013-01-03 11:50 ` Steven Whitehouse
  2013-01-03 11:50 ` [Cluster-devel] [PATCH 4/4] GFS2: Reset rd_last_alloc when it reaches the end of the rgrp Steven Whitehouse
  3 siblings, 0 replies; 5+ messages in thread
From: Steven Whitehouse @ 2013-01-03 11:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

From: Bob Peterson <rpeterso@redhat.com>

This patch adds a return code check after calling function
gfs2_rbm_from_block while determining the free extent size.
That way, when the end of an rgrp is reached, it won't try
to process unaligned blocks after the end.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 738b388..712dd4f 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -350,10 +350,14 @@ static u32 gfs2_free_extlen(const struct gfs2_rbm *rrbm, u32 len)
 		BUG_ON(len < chunk_size);
 		len -= chunk_size;
 		block = gfs2_rbm_to_block(&rbm);
-		gfs2_rbm_from_block(&rbm, block + chunk_size);
-		n_unaligned = 3;
-		if (ptr)
+		if (gfs2_rbm_from_block(&rbm, block + chunk_size)) {
+			n_unaligned = 0;
 			break;
+		}
+		if (ptr) {
+			n_unaligned = 3;
+			break;
+		}
 		n_unaligned = len & 3;
 	}
 
-- 
1.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH 4/4] GFS2: Reset rd_last_alloc when it reaches the end of the rgrp
  2013-01-03 11:50 [Cluster-devel] GFS2: Pre-pull patch posting Steven Whitehouse
                   ` (2 preceding siblings ...)
  2013-01-03 11:50 ` [Cluster-devel] [PATCH 3/4] GFS2: Stop looking for free blocks at end of rgrp Steven Whitehouse
@ 2013-01-03 11:50 ` Steven Whitehouse
  3 siblings, 0 replies; 5+ messages in thread
From: Steven Whitehouse @ 2013-01-03 11:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

From: Bob Peterson <rpeterso@redhat.com>

In function rg_mblk_search, it's searching for multiple blocks in
a given state (e.g. "free"). If there's an active block reservation
its goal is the next free block of that. If the resource group
contains the dinode's goal block, that's used for the search. But
if neither is the case, it uses the rgrp's last allocated block.
That way, consecutive allocations appear after one another on media.
The problem comes in when you hit the end of the rgrp; it would never
start over and search from the beginning. This became a problem,
since if you deleted all the files and data from the rgrp, it would
never start over and find free blocks. So it had to keep searching
further out on the media to allocate blocks. This patch resets the
rd_last_alloc after it does an unsuccessful search at the end of
the rgrp.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 712dd4f..b7eff07 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1426,6 +1426,9 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,
 		rs->rs_free = extlen;
 		rs->rs_inum = ip->i_no_addr;
 		rs_insert(ip);
+	} else {
+		if (goal == rgd->rd_last_alloc + rgd->rd_data0)
+			rgd->rd_last_alloc = 0;
 	}
 }
 
-- 
1.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-01-03 11:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-03 11:50 [Cluster-devel] GFS2: Pre-pull patch posting Steven Whitehouse
2013-01-03 11:50 ` [Cluster-devel] [PATCH 1/4] GFS2: Initialize hex string to '0' Steven Whitehouse
2013-01-03 11:50 ` [Cluster-devel] [PATCH 2/4] GFS2: Fix race in gfs2_rs_alloc Steven Whitehouse
2013-01-03 11:50 ` [Cluster-devel] [PATCH 3/4] GFS2: Stop looking for free blocks at end of rgrp Steven Whitehouse
2013-01-03 11:50 ` [Cluster-devel] [PATCH 4/4] GFS2: Reset rd_last_alloc when it reaches the end of the rgrp Steven Whitehouse

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).