cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/2] gfs2: fix bitmap declaration
@ 2013-03-02 14:31 Akinobu Mita
  2013-03-02 14:31 ` [Cluster-devel] [PATCH 2/2] gfs2: use memchr_inv Akinobu Mita
  2013-03-04 14:46 ` [Cluster-devel] [PATCH 1/2] gfs2: fix bitmap declaration Steven Whitehouse
  0 siblings, 2 replies; 3+ messages in thread
From: Akinobu Mita @ 2013-03-02 14:31 UTC (permalink / raw)
  To: cluster-devel.redhat.com

The bitmap accessed by bitops like set_bit_le and clear_bit_le must
be aligned to the size of an "unsigned long".  But there are bitmaps
that are declared as char array.

This converts these bitmaps to properly declared ones.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: cluster-devel at redhat.com
---
 fs/gfs2/lock_dlm.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
index 9802de0..ead5b36 100644
--- a/fs/gfs2/lock_dlm.c
+++ b/fs/gfs2/lock_dlm.c
@@ -464,7 +464,7 @@ static void gdlm_cancel(struct gfs2_glock *gl)
 #define JID_BITMAP_OFFSET 8 /* 4 byte generation number + 4 byte unused */
 
 static void control_lvb_read(struct lm_lockstruct *ls, uint32_t *lvb_gen,
-			     char *lvb_bits)
+			     void *lvb_bits)
 {
 	uint32_t gen;
 	memcpy(lvb_bits, ls->ls_control_lvb, GDLM_LVB_SIZE);
@@ -473,7 +473,7 @@ static void control_lvb_read(struct lm_lockstruct *ls, uint32_t *lvb_gen,
 }
 
 static void control_lvb_write(struct lm_lockstruct *ls, uint32_t lvb_gen,
-			      char *lvb_bits)
+			      void *lvb_bits)
 {
 	uint32_t gen;
 	memcpy(ls->ls_control_lvb, lvb_bits, GDLM_LVB_SIZE);
@@ -481,11 +481,11 @@ static void control_lvb_write(struct lm_lockstruct *ls, uint32_t lvb_gen,
 	memcpy(ls->ls_control_lvb, &gen, sizeof(uint32_t));
 }
 
-static int all_jid_bits_clear(char *lvb)
+static int all_jid_bits_clear(void *lvb)
 {
 	int i;
 	for (i = JID_BITMAP_OFFSET; i < GDLM_LVB_SIZE; i++) {
-		if (lvb[i])
+		if (((char *)lvb)[i])
 			return 0;
 	}
 	return 1;
@@ -580,7 +580,7 @@ static void gfs2_control_func(struct work_struct *work)
 {
 	struct gfs2_sbd *sdp = container_of(work, struct gfs2_sbd, sd_control_work.work);
 	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
-	char lvb_bits[GDLM_LVB_SIZE];
+	DECLARE_BITMAP(lvb_bits, GDLM_LVB_SIZE * BITS_PER_BYTE);
 	uint32_t block_gen, start_gen, lvb_gen, flags;
 	int recover_set = 0;
 	int write_lvb = 0;
@@ -758,7 +758,7 @@ static void gfs2_control_func(struct work_struct *work)
 static int control_mount(struct gfs2_sbd *sdp)
 {
 	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
-	char lvb_bits[GDLM_LVB_SIZE];
+	DECLARE_BITMAP(lvb_bits, GDLM_LVB_SIZE * BITS_PER_BYTE);
 	uint32_t start_gen, block_gen, mount_gen, lvb_gen;
 	int mounted_mode;
 	int retries = 0;
@@ -949,7 +949,7 @@ static int dlm_recovery_wait(void *word)
 static int control_first_done(struct gfs2_sbd *sdp)
 {
 	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
-	char lvb_bits[GDLM_LVB_SIZE];
+	DECLARE_BITMAP(lvb_bits, GDLM_LVB_SIZE * BITS_PER_BYTE);
 	uint32_t start_gen, block_gen;
 	int error;
 
-- 
1.8.1.2



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

* [Cluster-devel] [PATCH 2/2] gfs2: use memchr_inv
  2013-03-02 14:31 [Cluster-devel] [PATCH 1/2] gfs2: fix bitmap declaration Akinobu Mita
@ 2013-03-02 14:31 ` Akinobu Mita
  2013-03-04 14:46 ` [Cluster-devel] [PATCH 1/2] gfs2: fix bitmap declaration Steven Whitehouse
  1 sibling, 0 replies; 3+ messages in thread
From: Akinobu Mita @ 2013-03-02 14:31 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Use memchr_inv to verify that the specified memory range is cleared.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: cluster-devel at redhat.com
---
 fs/gfs2/lock_dlm.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
index ead5b36..830ad2f 100644
--- a/fs/gfs2/lock_dlm.c
+++ b/fs/gfs2/lock_dlm.c
@@ -483,12 +483,8 @@ static void control_lvb_write(struct lm_lockstruct *ls, uint32_t lvb_gen,
 
 static int all_jid_bits_clear(void *lvb)
 {
-	int i;
-	for (i = JID_BITMAP_OFFSET; i < GDLM_LVB_SIZE; i++) {
-		if (((char *)lvb)[i])
-			return 0;
-	}
-	return 1;
+	return !memchr_inv(lvb + JID_BITMAP_OFFSET, 0,
+			GDLM_LVB_SIZE - JID_BITMAP_OFFSET);
 }
 
 static void sync_wait_cb(void *arg)
-- 
1.8.1.2



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

* [Cluster-devel] [PATCH 1/2] gfs2: fix bitmap declaration
  2013-03-02 14:31 [Cluster-devel] [PATCH 1/2] gfs2: fix bitmap declaration Akinobu Mita
  2013-03-02 14:31 ` [Cluster-devel] [PATCH 2/2] gfs2: use memchr_inv Akinobu Mita
@ 2013-03-04 14:46 ` Steven Whitehouse
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Whitehouse @ 2013-03-04 14:46 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

Both patches now in the GFS2 -nmw tree. Thanks,

Steve.

On Sat, 2013-03-02 at 23:31 +0900, Akinobu Mita wrote:
> The bitmap accessed by bitops like set_bit_le and clear_bit_le must
> be aligned to the size of an "unsigned long".  But there are bitmaps
> that are declared as char array.
> 
> This converts these bitmaps to properly declared ones.
> 
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Steven Whitehouse <swhiteho@redhat.com>
> Cc: cluster-devel at redhat.com
> ---
>  fs/gfs2/lock_dlm.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
> index 9802de0..ead5b36 100644
> --- a/fs/gfs2/lock_dlm.c
> +++ b/fs/gfs2/lock_dlm.c
> @@ -464,7 +464,7 @@ static void gdlm_cancel(struct gfs2_glock *gl)
>  #define JID_BITMAP_OFFSET 8 /* 4 byte generation number + 4 byte unused */
>  
>  static void control_lvb_read(struct lm_lockstruct *ls, uint32_t *lvb_gen,
> -			     char *lvb_bits)
> +			     void *lvb_bits)
>  {
>  	uint32_t gen;
>  	memcpy(lvb_bits, ls->ls_control_lvb, GDLM_LVB_SIZE);
> @@ -473,7 +473,7 @@ static void control_lvb_read(struct lm_lockstruct *ls, uint32_t *lvb_gen,
>  }
>  
>  static void control_lvb_write(struct lm_lockstruct *ls, uint32_t lvb_gen,
> -			      char *lvb_bits)
> +			      void *lvb_bits)
>  {
>  	uint32_t gen;
>  	memcpy(ls->ls_control_lvb, lvb_bits, GDLM_LVB_SIZE);
> @@ -481,11 +481,11 @@ static void control_lvb_write(struct lm_lockstruct *ls, uint32_t lvb_gen,
>  	memcpy(ls->ls_control_lvb, &gen, sizeof(uint32_t));
>  }
>  
> -static int all_jid_bits_clear(char *lvb)
> +static int all_jid_bits_clear(void *lvb)
>  {
>  	int i;
>  	for (i = JID_BITMAP_OFFSET; i < GDLM_LVB_SIZE; i++) {
> -		if (lvb[i])
> +		if (((char *)lvb)[i])
>  			return 0;
>  	}
>  	return 1;
> @@ -580,7 +580,7 @@ static void gfs2_control_func(struct work_struct *work)
>  {
>  	struct gfs2_sbd *sdp = container_of(work, struct gfs2_sbd, sd_control_work.work);
>  	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
> -	char lvb_bits[GDLM_LVB_SIZE];
> +	DECLARE_BITMAP(lvb_bits, GDLM_LVB_SIZE * BITS_PER_BYTE);
>  	uint32_t block_gen, start_gen, lvb_gen, flags;
>  	int recover_set = 0;
>  	int write_lvb = 0;
> @@ -758,7 +758,7 @@ static void gfs2_control_func(struct work_struct *work)
>  static int control_mount(struct gfs2_sbd *sdp)
>  {
>  	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
> -	char lvb_bits[GDLM_LVB_SIZE];
> +	DECLARE_BITMAP(lvb_bits, GDLM_LVB_SIZE * BITS_PER_BYTE);
>  	uint32_t start_gen, block_gen, mount_gen, lvb_gen;
>  	int mounted_mode;
>  	int retries = 0;
> @@ -949,7 +949,7 @@ static int dlm_recovery_wait(void *word)
>  static int control_first_done(struct gfs2_sbd *sdp)
>  {
>  	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
> -	char lvb_bits[GDLM_LVB_SIZE];
> +	DECLARE_BITMAP(lvb_bits, GDLM_LVB_SIZE * BITS_PER_BYTE);
>  	uint32_t start_gen, block_gen;
>  	int error;
>  




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

end of thread, other threads:[~2013-03-04 14:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-02 14:31 [Cluster-devel] [PATCH 1/2] gfs2: fix bitmap declaration Akinobu Mita
2013-03-02 14:31 ` [Cluster-devel] [PATCH 2/2] gfs2: use memchr_inv Akinobu Mita
2013-03-04 14:46 ` [Cluster-devel] [PATCH 1/2] gfs2: fix bitmap declaration 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).