[Cluster-devel] GFS2: Pre-pull patch posting (fixes)

2012-09-13 Thread Steven Whitehouse
Hi,

Here are three GFS2 fixes for the current kernel tree. These are all
related to the block reservation code which was added at the merge
window. That code will be getting an update at the forthcoming merge
window too. In the mean time though there are a few smaller issues
which should be fixed.

The first patch resolves an issue with write sizes of greater than
32 bits with the size hinting code. The second ensures that the
allocation data structure is initialised when using xattrs and the
third takes into account allocations which may have been made by
other nodes which affect a reservation on the local node,

Steve.



[Cluster-devel] [PATCH 3/3] GFS2: Take account of blockages when using reserved blocks

2012-09-13 Thread Steven Whitehouse
The claim_reserved_blks() function was not taking account of
the possibility of blockages while performing allocation.
This can be caused by another node allocating something in
the same extent which has been reserved locally.

This patch tests for this condition and then skips the remainder
of the reservation in this case. This is a relatively rare event,
so that it should not affect the general performance improvement
which the block reservations provide.

The claim_reserved_blks() function also appears not to be able
to deal with reservations which cross bitmap boundaries, but
that can be dealt with in a future patch since we don't generate
boundary crossing reservations currently.

Signed-off-by: Steven Whitehouse swhit...@redhat.com
Reported-by: David Teigland teigl...@redhat.com
Cc: Bob Peterson rpete...@redhat.com

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 4d34887..c9ed814 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1961,7 +1961,7 @@ static void gfs2_rgrp_error(struct gfs2_rgrpd *rgd)
  * @dinode: 1 if this block is a dinode block, otherwise data block
  * @nblocks: desired extent length
  *
- * Lay claim to previously allocated block reservation blocks.
+ * Lay claim to previously reserved blocks.
  * Returns: Starting block number of the blocks claimed.
  * Sets *nblocks to the actual extent length allocated.
  */
@@ -1970,19 +1970,17 @@ static u64 claim_reserved_blks(struct gfs2_inode *ip, 
bool dinode,
 {
struct gfs2_blkreserv *rs = ip-i_res;
struct gfs2_rgrpd *rgd = rs-rs_rgd;
-   struct gfs2_sbd *sdp = GFS2_SB(ip-i_inode);
struct gfs2_bitmap *bi;
u64 start_block = gfs2_rs_startblk(rs);
const unsigned int elen = *nblocks;
 
-   /*BUG_ON(!gfs2_glock_is_locked_by_me(ip-i_gl));*/
-   gfs2_assert_withdraw(sdp, rgd);
-   /*BUG_ON(!gfs2_glock_is_locked_by_me(rgd-rd_gl));*/
bi = rs-rs_bi;
gfs2_trans_add_bh(rgd-rd_gl, bi-bi_bh, 1);
 
for (*nblocks = 0; *nblocks  elen  rs-rs_free; (*nblocks)++) {
-   /* Make sure the bitmap hasn't changed */
+   if (gfs2_testbit(rgd, bi-bi_bh-b_data + bi-bi_offset,
+bi-bi_len, rs-rs_biblk) != GFS2_BLKST_FREE)
+   break;
gfs2_setbit(rgd, bi-bi_clone, bi, rs-rs_biblk,
dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED);
rs-rs_biblk++;
@@ -1991,20 +1989,12 @@ static u64 claim_reserved_blks(struct gfs2_inode *ip, 
bool dinode,
BUG_ON(!rgd-rd_reserved);
rgd-rd_reserved--;
dinode = false;
-   trace_gfs2_rs(ip, rs, TRACE_RS_CLAIM);
}
 
-   if (!rs-rs_free) {
-   struct gfs2_rgrpd *rgd = ip-i_res-rs_rgd;
-
+   trace_gfs2_rs(ip, rs, TRACE_RS_CLAIM);
+   if (!rs-rs_free || *nblocks != elen)
gfs2_rs_deltree(rs);
-   /* -nblocks because we haven't returned to do the math yet.
-  I'm doing the math backwards to prevent negative numbers,
-  but think of it as:
-  if (unclaimed_blocks(rgd) - *nblocks = RGRP_RSRV_MINBLKS */
-   if (unclaimed_blocks(rgd) = RGRP_RSRV_MINBLKS + *nblocks)
-   rg_mblk_search(rgd, ip);
-   }
+
return start_block;
 }
 
@@ -2037,34 +2027,34 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, 
unsigned int *nblocks,
if (ip-i_res-rs_requested == 0)
return -ECANCELED;
 
-   /* Check if we have a multi-block reservation, and if so, claim the
-  next free block from it. */
+   /* If we have a reservation, claim blocks from it. */
if (gfs2_rs_active(ip-i_res)) {
BUG_ON(!ip-i_res-rs_free);
rgd = ip-i_res-rs_rgd;
block = claim_reserved_blks(ip, dinode, nblocks);
-   } else {
-   rgd = ip-i_rgd;
+   if (*nblocks)
+   goto found_blocks;
+   }
 
-   if (!dinode  rgrp_contains_block(rgd, ip-i_goal))
-   goal = ip-i_goal - rgd-rd_data0;
-   else
-   goal = rgd-rd_last_alloc;
-
-   blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, bi);
-
-   /* Since all blocks are reserved in advance, this shouldn't
-  happen */
-   if (blk == BFITNOENT) {
-   printk(KERN_WARNING BFITNOENT, nblocks=%u\n,
-  *nblocks);
-   printk(KERN_WARNING FULL=%d\n,
-  test_bit(GBF_FULL, rgd-rd_bits-bi_flags));
-   goto rgrp_error;
-   }
+   rgd = ip-i_rgd;
 
-   block = gfs2_alloc_extent(rgd, bi, blk, dinode, nblocks);
+   if (!dinode  rgrp_contains_block(rgd, ip-i_goal))
+   goal = ip-i_goal - rgd-rd_data0;
+   else
+   goal = 

[Cluster-devel] [PATCH 1/3] GFS2: Make write size hinting code common

2012-09-13 Thread Steven Whitehouse
This collects up the write size hinting code which is used by the
block reservation subsystem into a single function. At the same
time this also corrects the rounding for this calculation.

Signed-off-by: Steven Whitehouse swhit...@redhat.com

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index d1d791e..382000f 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -323,6 +323,29 @@ static long gfs2_ioctl(struct file *filp, unsigned int 
cmd, unsigned long arg)
 }
 
 /**
+ * gfs2_size_hint - Give a hint to the size of a write request
+ * @file: The struct file
+ * @offset: The file offset of the write
+ * @size: The length of the write
+ *
+ * When we are about to do a write, this function records the total
+ * write size in order to provide a suitable hint to the lower layers
+ * about how many blocks will be required.
+ *
+ */
+
+static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size)
+{
+   struct inode *inode = filep-f_dentry-d_inode;
+   struct gfs2_sbd *sdp = GFS2_SB(inode);
+   struct gfs2_inode *ip = GFS2_I(inode);
+   size_t blks = (size + sdp-sd_sb.sb_bsize - 1)  
sdp-sd_sb.sb_bsize_shift;
+   int hint = min_t(size_t, INT_MAX, blks);
+
+   atomic_set(ip-i_res-rs_sizehint, hint);
+}
+
+/**
  * gfs2_allocate_page_backing - Use bmap to allocate blocks
  * @page: The (locked) page to allocate backing for
  *
@@ -382,8 +405,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, 
struct vm_fault *vmf)
if (ret)
return ret;
 
-   atomic_set(ip-i_res-rs_sizehint,
-  PAGE_CACHE_SIZE  sdp-sd_sb.sb_bsize_shift);
+   gfs2_size_hint(vma-vm_file, pos, PAGE_CACHE_SIZE);
 
gfs2_holder_init(ip-i_gl, LM_ST_EXCLUSIVE, 0, gh);
ret = gfs2_glock_nq(gh);
@@ -663,7 +685,8 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, 
const struct iovec *iov,
if (ret)
return ret;
 
-   atomic_set(ip-i_res-rs_sizehint, writesize  
sdp-sd_sb.sb_bsize_shift);
+   gfs2_size_hint(file, pos, writesize);
+
if (file-f_flags  O_APPEND) {
struct gfs2_holder gh;
 
@@ -789,7 +812,7 @@ static long gfs2_fallocate(struct file *file, int mode, 
loff_t offset,
if (unlikely(error))
goto out_uninit;
 
-   atomic_set(ip-i_res-rs_sizehint, len  sdp-sd_sb.sb_bsize_shift);
+   gfs2_size_hint(file, offset, len);
 
while (len  0) {
if (len  bytes)
-- 
1.7.4



[Cluster-devel] [PATCH] Fix misuse of cman FD in fenced

2012-09-13 Thread Christine Caulfield
This patch fixes a caching of the cman file descriptor in fenced, which 
the header file explicitly says you should not do.


I have seen symptoms that are consistent with this going wrong and while 
I can't prove that this is the cause it looks highly likely.


The patch is against the RHEL5 branch, but the bug also exists in RHEL6 
and upstream versions


There also is a chance that this mistake exists in other cluster 
daemons, I haven't checked as yet.
diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h
index c4204c8..584367c 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -197,5 +197,6 @@ int is_member(char *name);
 int is_fenced(char *name);
 fd_node_t *get_new_node(fd_t *fd, int nodeid, char *in_name);
 void update_cman(char *victim, char *agent);
+int get_member_fd(void);
 
 #endif/*  __FD_DOT_H__  */
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index 3d553b2..72961f5 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -531,6 +531,7 @@ static int setup_listen(void)
 static int loop(void)
 {
 	int rv, i, f, maxi = 0, listen_fd, member_fd, groupd_fd;
+	int cluster_fd_pos;
 
 	rv = listen_fd = setup_listen();
 	if (rv  0)
@@ -540,7 +541,7 @@ static int loop(void)
 	rv = member_fd = setup_member();
 	if (rv  0)
 		goto out;
-	client_add(member_fd, maxi);
+	cluster_fd_pos = client_add(member_fd, maxi);
 
 	rv = groupd_fd = setup_groupd();
 	if (rv  0)
@@ -551,6 +552,8 @@ static int loop(void)
 		  listen_fd, member_fd, groupd_fd);
 
 	for (;;) {
+/* We need to re-get the cluster FD eac time */
+		pollfd[cluster_fd_pos].fd = get_member_fd();
 		rv = poll(pollfd, maxi + 1, -1);
 		if (rv  0) {
 			if (errno == EINTR)
diff --git a/fence/fenced/member_cman.c b/fence/fenced/member_cman.c
index 6ef74c3..8086af4 100644
--- a/fence/fenced/member_cman.c
+++ b/fence/fenced/member_cman.c
@@ -241,6 +241,11 @@ void exit_member(void)
 	cman_finish(ch);
 }
 
+int get_member_fd()
+{
+	return cman_get_fd(ch);
+}
+
 int is_member(char *name)
 {
 	cman_node_t *cn;


[Cluster-devel] GFS2: Pull request (fixes)

2012-09-13 Thread Steven Whitehouse
Hi,

Please consider pulling the following GFS2 fixes

Steve.

--

Here are three GFS2 fixes for the current kernel tree. These are all
related to the block reservation code which was added at the merge
window. That code will be getting an update at the forthcoming merge
window too. In the mean time though there are a few smaller issues
which should be fixed.

The first patch resolves an issue with write sizes of greater than
32 bits with the size hinting code. The second ensures that the
allocation data structure is initialised when using xattrs and the
third takes into account allocations which may have been made by
other nodes which affect a reservation on the local node.

The following changes since commit 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee:

  Linux 3.6-rc1 (2012-08-02 16:38:10 -0700)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-fixes.git master

Steven Whitehouse (3):
  GFS2: Make write size hinting code common
  GFS2: Fix missing allocation data for set/remove xattr
  GFS2: Take account of blockages when using reserved blocks

 fs/gfs2/file.c  |   31 ++---
 fs/gfs2/inode.c |8 +-
 fs/gfs2/rgrp.c  |   66 +++---
 3 files changed, 61 insertions(+), 44 deletions(-)



signature.asc
Description: This is a digitally signed message part