Re: [Cluster-devel] [PATCH 4/4] fs: remove obsolete simple_strto

2012-12-17 Thread Dave Chinner
On Fri, Dec 07, 2012 at 05:25:19PM +0530, Abhijit Pawar wrote:
> This patch replace the obsolete simple_strto with kstrto

The XFS changes look fine. Consider those:

Acked-by: Dave Chinner 

-- 
Dave Chinner
da...@fromorbit.com



[Cluster-devel] [PATCH 09/15] dlm: use new hashtable implementation

2012-12-17 Thread Sasha Levin
Switch dlm to use the new hashtable implementation. This reduces the amount of
generic unrelated code in the dlm.

This patch depends on d9b482c ("hashtable: introduce a small and naive
hashtable") which was merged in v3.6.

Signed-off-by: Sasha Levin 
---
 fs/dlm/lowcomms.c | 53 ++---
 1 file changed, 18 insertions(+), 35 deletions(-)

diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index dd87a31..822887c 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "dlm_internal.h"
 #include "lowcomms.h"
@@ -62,7 +63,7 @@
 #include "config.h"
 
 #define NEEDED_RMEM (4*1024*1024)
-#define CONN_HASH_SIZE 32
+#define CONN_HASH_BITS 5
 
 /* Number of messages to send before rescheduling */
 #define MAX_SEND_MSG_COUNT 25
@@ -158,34 +159,27 @@ static int dlm_allow_conn;
 static struct workqueue_struct *recv_workqueue;
 static struct workqueue_struct *send_workqueue;
 
-static struct hlist_head connection_hash[CONN_HASH_SIZE];
+/*
+ * On a sidenote, hash function could be very simple because most clusters
+ * have simple sequential nodeids, so we should be able to go straight to
+ * a connection struct in the array. We don't utilize it at the moment,
+ * but it's something work to keep in mind.
+ */
+static DEFINE_HASHTABLE(connection_hash, CONN_HASH_BITS);
 static DEFINE_MUTEX(connections_lock);
 static struct kmem_cache *con_cache;
 
 static void process_recv_sockets(struct work_struct *work);
 static void process_send_sockets(struct work_struct *work);
 
-
-/* This is deliberately very simple because most clusters have simple
-   sequential nodeids, so we should be able to go straight to a connection
-   struct in the array */
-static inline int nodeid_hash(int nodeid)
-{
-   return nodeid & (CONN_HASH_SIZE-1);
-}
-
 static struct connection *__find_con(int nodeid)
 {
-   int r;
struct hlist_node *h;
struct connection *con;
 
-   r = nodeid_hash(nodeid);
-
-   hlist_for_each_entry(con, h, &connection_hash[r], list) {
+   hash_for_each_possible(connection_hash, con, h, list, nodeid)
if (con->nodeid == nodeid)
return con;
-   }
return NULL;
 }
 
@@ -196,7 +190,6 @@ static struct connection *__find_con(int nodeid)
 static struct connection *__nodeid2con(int nodeid, gfp_t alloc)
 {
struct connection *con = NULL;
-   int r;
 
con = __find_con(nodeid);
if (con || !alloc)
@@ -206,8 +199,7 @@ static struct connection *__nodeid2con(int nodeid, gfp_t 
alloc)
if (!con)
return NULL;
 
-   r = nodeid_hash(nodeid);
-   hlist_add_head(&con->list, &connection_hash[r]);
+   hash_add(connection_hash, &con->list, nodeid);
 
con->nodeid = nodeid;
mutex_init(&con->sock_mutex);
@@ -235,11 +227,8 @@ static void foreach_conn(void (*conn_func)(struct 
connection *c))
struct hlist_node *h, *n;
struct connection *con;
 
-   for (i = 0; i < CONN_HASH_SIZE; i++) {
-   hlist_for_each_entry_safe(con, h, n, &connection_hash[i], list){
-   conn_func(con);
-   }
-   }
+   hash_for_each_safe(connection_hash, i, h, n, con, list)
+   conn_func(con);
 }
 
 static struct connection *nodeid2con(int nodeid, gfp_t allocation)
@@ -262,12 +251,10 @@ static struct connection *assoc2con(int assoc_id)
 
mutex_lock(&connections_lock);
 
-   for (i = 0 ; i < CONN_HASH_SIZE; i++) {
-   hlist_for_each_entry(con, h, &connection_hash[i], list) {
-   if (con->sctp_assoc == assoc_id) {
-   mutex_unlock(&connections_lock);
-   return con;
-   }
+   hash_for_each(connection_hash, i, h, con, list) {
+   if (con->sctp_assoc == assoc_id) {
+   mutex_unlock(&connections_lock);
+   return con;
}
}
mutex_unlock(&connections_lock);
@@ -1637,7 +1624,7 @@ static void free_conn(struct connection *con)
close_connection(con, true);
if (con->othercon)
kmem_cache_free(con_cache, con->othercon);
-   hlist_del(&con->list);
+   hash_del(&con->list);
kmem_cache_free(con_cache, con);
 }
 
@@ -1666,10 +1653,6 @@ int dlm_lowcomms_start(void)
 {
int error = -EINVAL;
struct connection *con;
-   int i;
-
-   for (i = 0; i < CONN_HASH_SIZE; i++)
-   INIT_HLIST_HEAD(&connection_hash[i]);
 
init_local();
if (!dlm_local_count) {
-- 
1.8.0



[Cluster-devel] [PATCH] Fix clang --analyze warning.

2012-12-17 Thread Sitsofe Wheeler
- Return before a possible NULL pointer dereference.
---
 gfs2/libgfs2/fs_bits.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c
index 94a612b..e4b5505 100644
--- a/gfs2/libgfs2/fs_bits.c
+++ b/gfs2/libgfs2/fs_bits.c
@@ -149,6 +149,8 @@ int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, 
int state)
break;
}
 
+   if (bits == NULL)
+   return -1;
byte = (unsigned char *)(rgd->bh[buf]->b_data + bits->bi_offset) +
(rgrp_block/GFS2_NBBY - bits->bi_start);
bit = (rgrp_block % GFS2_NBBY) * GFS2_BIT_SIZE;
-- 
1.7.2.5



[Cluster-devel] [PATCH] GFS2: Initialize hex string to '0'

2012-12-17 Thread Nathan Straz
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.
---
 fs/gfs2/lock_dlm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
index 0fb6539..a924b6a 100644
--- a/fs/gfs2/lock_dlm.c
+++ b/fs/gfs2/lock_dlm.c
@@ -239,6 +239,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.11.7



[Cluster-devel] GFS2: Use mpage_writepages() for both ordered and writeback modes

2012-12-17 Thread Steven Whitehouse
>From 211d733fa0219d0f032f6ef7b48eb5513ffea39e Mon Sep 17 00:00:00 2001
From: Steven Whitehouse 
Date: Fri, 14 Dec 2012 17:57:34 +
Subject: GFS2: Use mpage_writepages() for both ordered and writeback modes

For some reason the ordered mode was still using generic_writepages()
rather than mpage_writepages(). This patch fixes that oversight.

Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 92340dd..24f414f 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -230,16 +230,14 @@ out_ignore:
 }
 
 /**
- * gfs2_writeback_writepages - Write a bunch of dirty pages back to disk
+ * gfs2_writepages - Write a bunch of dirty pages back to disk
  * @mapping: The mapping to write
  * @wbc: Write-back control
  *
- * For the data=writeback case we can already ignore buffer heads
- * and write whole extents at once. This is a big reduction in the
- * number of I/O requests we send and the bmap calls we make in this case.
+ * Used for both ordered and writeback modes.
  */
-static int gfs2_writeback_writepages(struct address_space *mapping,
-struct writeback_control *wbc)
+static int gfs2_writepages(struct address_space *mapping,
+  struct writeback_control *wbc)
 {
return mpage_writepages(mapping, wbc, gfs2_get_block_noalloc);
 }
@@ -1102,7 +1100,7 @@ cannot_release:
 
 static const struct address_space_operations gfs2_writeback_aops = {
.writepage = gfs2_writeback_writepage,
-   .writepages = gfs2_writeback_writepages,
+   .writepages = gfs2_writepages,
.readpage = gfs2_readpage,
.readpages = gfs2_readpages,
.write_begin = gfs2_write_begin,
@@ -1118,6 +1116,7 @@ static const struct address_space_operations 
gfs2_writeback_aops = {
 
 static const struct address_space_operations gfs2_ordered_aops = {
.writepage = gfs2_ordered_writepage,
+   .writepages = gfs2_writepages,
.readpage = gfs2_readpage,
.readpages = gfs2_readpages,
.write_begin = gfs2_write_begin,
-- 
1.7.4





[Cluster-devel] GFS2: Merge gfs2_attach_bufdata() into trans.c

2012-12-17 Thread Steven Whitehouse
>From 426fe9003bc6c0410ece220294bed9f293697d6b Mon Sep 17 00:00:00 2001
From: Steven Whitehouse 
Date: Fri, 14 Dec 2012 17:54:21 +
Subject: GFS2: Merge gfs2_attach_bufdata() into trans.c

The locking in gfs2_attach_bufdata() was type specific (data/meta)
which made the function rather confusing. This patch moves the core
of gfs2_attach_bufdata() into trans.c renaming it gfs2_alloc_bufdata()
and moving the locking into gfs2_trans_add_data()/gfs2_trans_add_meta()

As a result all of the locking related to adding data and metadata to
the journal is now in these two functions. This should help to clarify
what is going on, and give us some opportunities to simplify in
some cases.

Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/lops.h b/fs/gfs2/lops.h
index d85b376..ba77b7d 100644
--- a/fs/gfs2/lops.h
+++ b/fs/gfs2/lops.h
@@ -47,13 +47,6 @@ static inline unsigned int databuf_limit(struct gfs2_sbd 
*sdp)
return limit;
 }
 
-static inline void lops_init_le(struct gfs2_bufdata *bd,
-   const struct gfs2_log_operations *lops)
-{
-   INIT_LIST_HEAD(&bd->bd_list);
-   bd->bd_ops = lops;
-}
-
 static inline void lops_before_commit(struct gfs2_sbd *sdp)
 {
int x;
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 22255d9..b059bbb 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -271,41 +271,6 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct 
buffer_head *bh)
return 0;
 }
 
-/**
- * gfs2_attach_bufdata - attach a struct gfs2_bufdata structure to a buffer
- * @gl: the glock the buffer belongs to
- * @bh: The buffer to be attached to
- * @meta: Flag to indicate whether its metadata or not
- */
-
-void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
-int meta)
-{
-   struct gfs2_bufdata *bd;
-
-   if (meta)
-   lock_page(bh->b_page);
-
-   if (bh->b_private) {
-   if (meta)
-   unlock_page(bh->b_page);
-   return;
-   }
-
-   bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL);
-   bd->bd_bh = bh;
-   bd->bd_gl = gl;
-
-   if (meta)
-   lops_init_le(bd, &gfs2_buf_lops);
-   else
-   lops_init_le(bd, &gfs2_databuf_lops);
-   bh->b_private = bd;
-
-   if (meta)
-   unlock_page(bh->b_page);
-}
-
 void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr, 
int meta)
 {
struct address_space *mapping = bh->b_page->mapping;
diff --git a/fs/gfs2/meta_io.h b/fs/gfs2/meta_io.h
index c30973b..0d4c843 100644
--- a/fs/gfs2/meta_io.h
+++ b/fs/gfs2/meta_io.h
@@ -56,9 +56,6 @@ int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno,
 int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh);
 struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno, int create);
 
-void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
-int meta);
-
 void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr,
  int meta);
 
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index 1fbd57e..14dbf6d 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -143,6 +143,21 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)
sb_end_intwrite(sdp->sd_vfs);
 }
 
+static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl,
+  struct buffer_head *bh,
+  const struct gfs2_log_operations 
*lops)
+{
+   struct gfs2_bufdata *bd;
+
+   bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL);
+   bd->bd_bh = bh;
+   bd->bd_gl = gl;
+   bd->bd_ops = lops;
+   INIT_LIST_HEAD(&bd->bd_list);
+   bh->b_private = bd;
+   return bd;
+}
+
 /**
  * databuf_lo_add - Add a databuf to the transaction.
  *
@@ -190,16 +205,15 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct 
buffer_head *bh)
lock_buffer(bh);
gfs2_log_lock(sdp);
bd = bh->b_private;
-   if (bd)
-   gfs2_assert(sdp, bd->bd_gl == gl);
-   else {
+   if (bd == NULL) {
gfs2_log_unlock(sdp);
unlock_buffer(bh);
-   gfs2_attach_bufdata(gl, bh, 0);
-   bd = bh->b_private;
+   if (bh->b_private == NULL)
+   bd = gfs2_alloc_bufdata(gl, bh, &gfs2_databuf_lops);
lock_buffer(bh);
gfs2_log_lock(sdp);
}
+   gfs2_assert(sdp, bd->bd_gl == gl);
databuf_lo_add(sdp, bd);
gfs2_log_unlock(sdp);
unlock_buffer(bh);
@@ -240,16 +254,17 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct 
buffer_head *bh)
lock_buffer(bh);
gfs2_log_lock(sdp);
bd = bh->b_private;
-   if (bd)
-   gfs2_assert(sdp, bd->bd_gl == gl);
-   else {
+   if (bd == NULL) {

[Cluster-devel] GFS2: Copy gfs2_trans_add_bh into new data/meta functions

2012-12-17 Thread Steven Whitehouse
>From eea05378c24bfb30bd2e07d48d96a1e6265bd1a2 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse 
Date: Fri, 14 Dec 2012 12:52:14 +
Subject: GFS2: Copy gfs2_trans_add_bh into new data/meta functions

This patch copies the body of gfs2_trans_add_bh into the two newly
added gfs2_trans_add_data and gfs2_trans_add_meta functions. We can
then move the .lo_add functions from lops.c into trans.c and call
them directly.

As a result of this, we no longer need to use the .lo_add functions
at all, so that is removed from the log operations structure.

Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index c373a24..5d129ab 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -52,7 +52,6 @@ struct gfs2_log_header_host {
  */
 
 struct gfs2_log_operations {
-   void (*lo_add) (struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
void (*lo_before_commit) (struct gfs2_sbd *sdp);
void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_ail *ai);
void (*lo_before_scan) (struct gfs2_jdesc *jd,
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 9c80742..a505597 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -37,7 +37,7 @@
  *
  * The log lock must be held when calling this function
  */
-static void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
+void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
 {
struct gfs2_bufdata *bd;
 
@@ -388,32 +388,6 @@ static struct page *gfs2_get_log_desc(struct gfs2_sbd 
*sdp, u32 ld_type,
return page;
 }
 
-static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
-{
-   struct gfs2_meta_header *mh;
-   struct gfs2_trans *tr;
-
-   tr = current->journal_info;
-   tr->tr_touched = 1;
-   if (!list_empty(&bd->bd_list))
-   return;
-   set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
-   set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
-   mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
-   if (unlikely(mh->mh_magic != cpu_to_be32(GFS2_MAGIC))) {
-   printk(KERN_ERR
-  "Attempting to add uninitialised block to journal 
(inplace block=%lld)\n",
-  (unsigned long long)bd->bd_bh->b_blocknr);
-   BUG();
-   }
-   gfs2_pin(sdp, bd->bd_bh);
-   mh->__pad0 = cpu_to_be64(0);
-   mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
-   sdp->sd_log_num_buf++;
-   list_add(&bd->bd_list, &sdp->sd_log_le_buf);
-   tr->tr_num_buf_new++;
-}
-
 static void gfs2_check_magic(struct buffer_head *bh)
 {
void *kaddr;
@@ -735,44 +709,6 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, 
int error, int pass)
 }
 
 /**
- * databuf_lo_add - Add a databuf to the transaction.
- *
- * This is used in two distinct cases:
- * i) In ordered write mode
- *We put the data buffer on a list so that we can ensure that its
- *synced to disk at the right time
- * ii) In journaled data mode
- *We need to journal the data block in the same way as metadata in
- *the functions above. The difference is that here we have a tag
- *which is two __be64's being the block number (as per meta data)
- *and a flag which says whether the data block needs escaping or
- *not. This means we need a new log entry for each 251 or so data
- *blocks, which isn't an enormous overhead but twice as much as
- *for normal metadata blocks.
- */
-static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
-{
-   struct gfs2_trans *tr = current->journal_info;
-   struct address_space *mapping = bd->bd_bh->b_page->mapping;
-   struct gfs2_inode *ip = GFS2_I(mapping->host);
-
-   if (tr)
-   tr->tr_touched = 1;
-   if (!list_empty(&bd->bd_list))
-   return;
-   set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
-   set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
-   if (gfs2_is_jdata(ip)) {
-   gfs2_pin(sdp, bd->bd_bh);
-   tr->tr_num_databuf_new++;
-   sdp->sd_log_num_databuf++;
-   list_add_tail(&bd->bd_list, &sdp->sd_log_le_databuf);
-   } else {
-   list_add_tail(&bd->bd_list, &sdp->sd_log_le_ordered);
-   }
-}
-
-/**
  * databuf_lo_before_commit - Scan the data buffers, writing as we go
  *
  */
@@ -871,7 +807,6 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, 
struct gfs2_ail *ai)
 
 
 const struct gfs2_log_operations gfs2_buf_lops = {
-   .lo_add = buf_lo_add,
.lo_before_commit = buf_lo_before_commit,
.lo_after_commit = buf_lo_after_commit,
.lo_before_scan = buf_lo_before_scan,
@@ -894,7 +829,6 @@ const struct gfs2_log_operations gfs2_rg_lops = {
 };
 
 const struct gfs2_log_operations gfs2_databuf_lops = {
-   .lo_add = databuf_lo_add,
.lo_before_commit = databuf_lo_before_commit,
.lo_after_commit = databuf_lo_after_commit,
.lo_scan_elements = databuf_lo_scan_elements,
diff --git a/

[Cluster-devel] GFS2: Split gfs2_trans_add_bh() into two

2012-12-17 Thread Steven Whitehouse
>From 162f03301aacd89188c9aa51da3039f7e26ec524 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse 
Date: Fri, 14 Dec 2012 12:36:02 +
Subject: GFS2: Split gfs2_trans_add_bh() into two

There is little common content in gfs2_trans_add_bh() between the data
and meta classes by the time that the functions which it calls are
taken into account. The intent here is to split this into two
separate functions. Stage one is to introduce gfs2_trans_add_data()
and gfs2_trans_add_meta() and update the callers accordingly.

Later patches will then pull in the content of gfs2_trans_add_bh()
and its dependent functions in order to clean up the code in this
area.

Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 30de4f2..92340dd 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -51,7 +51,7 @@ static void gfs2_page_add_databufs(struct gfs2_inode *ip, 
struct page *page,
continue;
if (gfs2_is_jdata(ip))
set_buffer_uptodate(bh);
-   gfs2_trans_add_bh(ip->i_gl, bh, 0);
+   gfs2_trans_add_data(ip->i_gl, bh);
}
 }
 
@@ -852,7 +852,7 @@ static int gfs2_write_end(struct file *file, struct 
address_space *mapping,
goto failed;
}
 
-   gfs2_trans_add_bh(ip->i_gl, dibh, 1);
+   gfs2_trans_add_meta(ip->i_gl, dibh);
 
if (gfs2_is_stuffed(ip))
return gfs2_stuffed_write_end(inode, dibh, pos, len, copied, 
page);
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index a68e91b..7a86275 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -93,7 +93,7 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct 
buffer_head *dibh,
if (!gfs2_is_jdata(ip))
mark_buffer_dirty(bh);
if (!gfs2_is_writeback(ip))
-   gfs2_trans_add_bh(ip->i_gl, bh, 0);
+   gfs2_trans_add_data(ip->i_gl, bh);
 
if (release) {
unlock_page(page);
@@ -153,7 +153,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page 
*page)
 
/*  Set up the pointer to the new block  */
 
-   gfs2_trans_add_bh(ip->i_gl, dibh, 1);
+   gfs2_trans_add_meta(ip->i_gl, dibh);
di = (struct gfs2_dinode *)dibh->b_data;
gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
 
@@ -405,7 +405,7 @@ static inline __be64 *gfs2_indirect_init(struct metapath 
*mp,
BUG_ON(i < 1);
BUG_ON(mp->mp_bh[i] != NULL);
mp->mp_bh[i] = gfs2_meta_new(gl, bn);
-   gfs2_trans_add_bh(gl, mp->mp_bh[i], 1);
+   gfs2_trans_add_meta(gl, mp->mp_bh[i]);
gfs2_metatype_set(mp->mp_bh[i], GFS2_METATYPE_IN, GFS2_FORMAT_IN);
gfs2_buffer_clear_tail(mp->mp_bh[i], sizeof(struct gfs2_meta_header));
ptr += offset;
@@ -468,7 +468,7 @@ static int gfs2_bmap_alloc(struct inode *inode, const 
sector_t lblock,
BUG_ON(sheight < 1);
BUG_ON(dibh == NULL);
 
-   gfs2_trans_add_bh(ip->i_gl, dibh, 1);
+   gfs2_trans_add_meta(ip->i_gl, dibh);
 
if (height == sheight) {
struct buffer_head *bh;
@@ -544,7 +544,7 @@ static int gfs2_bmap_alloc(struct inode *inode, const 
sector_t lblock,
/* Branching from existing tree */
case ALLOC_GROW_DEPTH:
if (i > 1 && i < height)
-   gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[i-1], 1);
+   gfs2_trans_add_meta(ip->i_gl, mp->mp_bh[i-1]);
for (; i < height && n > 0; i++, n--)
gfs2_indirect_init(mp, ip->i_gl, i,
   mp->mp_list[i-1], bn++);
@@ -556,7 +556,7 @@ static int gfs2_bmap_alloc(struct inode *inode, const 
sector_t lblock,
case ALLOC_DATA:
BUG_ON(n > dblks);
BUG_ON(mp->mp_bh[end_of_metadata] == NULL);
-   gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[end_of_metadata], 
1);
+   gfs2_trans_add_meta(ip->i_gl, 
mp->mp_bh[end_of_metadata]);
dblks = n;
ptr = metapointer(end_of_metadata, mp);
dblock = bn;
@@ -796,8 +796,8 @@ static int do_strip(struct gfs2_inode *ip, struct 
buffer_head *dibh,
 
down_write(&ip->i_rw_mutex);
 
-   gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-   gfs2_trans_add_bh(ip->i_gl, bh, 1);
+   gfs2_trans_add_meta(ip->i_gl, dibh);
+   gfs2_trans_add_meta(ip->i_gl, bh);
 
bstart = 0;
blen = 0;
@@ -981,7 +981,7 @@ static int gfs2_block_truncate_page(struct address_space 
*mapping, loff_t from)
}
 
if (!gfs2_is_writeback(ip))
-   gfs2_trans_add_bh(ip->i_gl, bh, 0);
+   gfs2_trans_add_data(ip->i_gl, bh);
 
zero_user(page, offset, length);
mark_buffer_dirty(bh);
@@ -1046,7 +1046,7 @@ static int trunc_start(struct inode *inode, u64 oldsi

[Cluster-devel] GFS2: Merge revoke adding functions

2012-12-17 Thread Steven Whitehouse
>From c2a6c93707cc26cd03acc0aa7d0a66fea7a73ab2 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse 
Date: Fri, 14 Dec 2012 12:29:56 +
Subject: GFS2: Merge revoke adding functions

This moves the lo_add function for revokes into trans.c, removing
a function call and making the code easier to read.

Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 9ceccb1..9c80742 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -600,20 +600,6 @@ static void buf_lo_after_scan(struct gfs2_jdesc *jd, int 
error, int pass)
jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
 }
 
-static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
-{
-   struct gfs2_glock *gl = bd->bd_gl;
-   struct gfs2_trans *tr;
-
-   tr = current->journal_info;
-   tr->tr_touched = 1;
-   tr->tr_num_revoke++;
-   sdp->sd_log_num_revoke++;
-   atomic_inc(&gl->gl_revokes);
-   set_bit(GLF_LFLUSH, &gl->gl_flags);
-   list_add(&bd->bd_list, &sdp->sd_log_le_revoke);
-}
-
 static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
 {
struct gfs2_meta_header *mh;
@@ -895,7 +881,6 @@ const struct gfs2_log_operations gfs2_buf_lops = {
 };
 
 const struct gfs2_log_operations gfs2_revoke_lops = {
-   .lo_add = revoke_lo_add,
.lo_before_commit = revoke_lo_before_commit,
.lo_after_commit = revoke_lo_after_commit,
.lo_before_scan = revoke_lo_before_scan,
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index 4136270..6f3ddbc 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -175,11 +175,19 @@ void gfs2_trans_add_bh(struct gfs2_glock *gl, struct 
buffer_head *bh, int meta)
 
 void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
 {
+   struct gfs2_glock *gl = bd->bd_gl;
+   struct gfs2_trans *tr = current->journal_info;
+
BUG_ON(!list_empty(&bd->bd_list));
BUG_ON(!list_empty(&bd->bd_ail_st_list));
BUG_ON(!list_empty(&bd->bd_ail_gl_list));
lops_init_le(bd, &gfs2_revoke_lops);
-   lops_add(sdp, bd);
+   tr->tr_touched = 1;
+   tr->tr_num_revoke++;
+   sdp->sd_log_num_revoke++;
+   atomic_inc(&gl->gl_revokes);
+   set_bit(GLF_LFLUSH, &gl->gl_flags);
+   list_add(&bd->bd_list, &sdp->sd_log_le_revoke);
 }
 
 void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno, unsigned int len)
-- 
1.7.4





[Cluster-devel] GFS2: Separate LRU scanning from shrinker

2012-12-17 Thread Steven Whitehouse
>From 99acf9a28b92fcdc33e8e1a7d7c46db3aa7f8e83 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse 
Date: Fri, 14 Dec 2012 12:28:30 +
Subject: GFS2: Separate LRU scanning from shrinker

This breaks out the LRU scanning function from the shrinker in
preparation for adding other callers to the LRU scanner.

Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 992c5c0..3ad8fd3 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1376,23 +1376,19 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
gfs2_glock_put(gl);
 }
 
+/**
+ * gfs2_scan_glock_lru - Scan the LRU looking for locks to demote
+ * @nr: The number of entries to scan
+ *
+ */
 
-static int gfs2_shrink_glock_memory(struct shrinker *shrink,
-   struct shrink_control *sc)
+static void gfs2_scan_glock_lru(int nr)
 {
struct gfs2_glock *gl;
int may_demote;
int nr_skipped = 0;
-   int nr = sc->nr_to_scan;
-   gfp_t gfp_mask = sc->gfp_mask;
LIST_HEAD(skipped);
 
-   if (nr == 0)
-   goto out;
-
-   if (!(gfp_mask & __GFP_FS))
-   return -1;
-
spin_lock(&lru_lock);
while(nr && !list_empty(&lru_list)) {
gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru);
@@ -1425,7 +1421,17 @@ static int gfs2_shrink_glock_memory(struct shrinker 
*shrink,
list_splice(&skipped, &lru_list);
atomic_add(nr_skipped, &lru_count);
spin_unlock(&lru_lock);
-out:
+}
+
+static int gfs2_shrink_glock_memory(struct shrinker *shrink,
+   struct shrink_control *sc)
+{
+   if (sc->nr_to_scan) {
+   if (!(sc->gfp_mask & __GFP_FS))
+   return -1;
+   gfs2_scan_glock_lru(sc->nr_to_scan);
+   }
+
return (atomic_read(&lru_count) / 100) * sysctl_vfs_cache_pressure;
 }
 
-- 
1.7.4





Re: [Cluster-devel] [PATCH] gfs2-utils: Fix build warnings in Fedora 18

2012-12-17 Thread Andrew Price

Hi Callum,

On 14/12/12 22:30, Callum Massey wrote:

Dropped the * from gzFile *gzin_fd because gzFile is no longer defined
as a void pointer.

Rearranged incldes in libgfs2/lang.c so parser.h gets passed struct
lgfs2_lang_state correctly.

Signed-off-by: Callum Massey 


This is now in gfs2-utils.git master.


---
  gfs2/edit/savemeta.c | 2 +-
  gfs2/libgfs2/lang.c  | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index f35c35d..cfe18eb 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -831,7 +831,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
exit(0);
  }

-static int restore_data(int fd, gzFile *gzin_fd, int printblocksonly,
+static int restore_data(int fd, gzFile gzin_fd, int printblocksonly,
int find_highblk)


Nice catch!

Thanks,

Andy


  {
size_t rs;
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index ad9382f..40a4355 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -7,8 +7,8 @@
  #include 
  #include 

-#include "parser.h"
  #include "lang.h"
+#include "parser.h"

  const char* ast_type_string[] = {
[AST_NONE] = "NONE",





[Cluster-devel] GFS2 git tree

2012-12-17 Thread Steven Whitehouse
Hi,

Linus has pulled the git tree, so it is now empty again. As usual I'll
start adding the pending patches just as soon as -rc1 is out,

Steve.




Re: [Cluster-devel] [PATCH] cman: Prevent libcman from causing SIGPIPE

2012-12-17 Thread Fabio M. Di Nitto
ACK

On 12/17/2012 10:23 AM, Christine Caulfield wrote:
> If corosync goes down/is shut down cman will return 0 from cman_dispatch
> and close the socket. However, if a cman write operation is issued
> before this happens then SIGPIPE can result from the writev() call to an
> open, but disconnected, FD.
> 
> This patch changes writev() to sendmg() so it can pass MSG_NOSIGNAL to
> the system call and prevent SIGPIPEs from occurring.
> 
> Signed-Off-By: Christine Caulfield 



[Cluster-devel] [PATCH] cman: Prevent libcman from causing SIGPIPE

2012-12-17 Thread Christine Caulfield
If corosync goes down/is shut down cman will return 0 from cman_dispatch 
and close the socket. However, if a cman write operation is issued 
before this happens then SIGPIPE can result from the writev() call to an 
open, but disconnected, FD.


This patch changes writev() to sendmg() so it can pass MSG_NOSIGNAL to 
the system call and prevent SIGPIPEs from occurring.


Signed-Off-By: Christine Caulfield 
diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c
index a89c731..a99f5a0 100644
--- a/cman/lib/libcman.c
+++ b/cman/lib/libcman.c
@@ -204,10 +204,19 @@ static int loopy_writev(int fd, struct iovec *iovptr, size_t iovlen)
 {
 	size_t byte_cnt=0;
 	int len;
+	struct msghdr msg;
+
+	msg.msg_name = NULL;
+	msg.msg_namelen = 0;
+	msg.msg_control = NULL;
+	msg.msg_controllen = 0;
 
 	while (iovlen > 0)
 	{
-		len = writev(fd, iovptr, iovlen);
+	  msg.msg_iov = iovptr;
+	  msg.msg_iovlen = iovlen;
+
+	  len = sendmsg(fd, &msg, MSG_NOSIGNAL);
 		if (len <= 0)
 			return len;