linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix wrong bitmap output for cluster raid
@ 2016-03-07  9:31 Guoqing Jiang
  2016-03-07  9:31 ` [PATCH 2/2] Remove dead code about LKF_CONVERT flag Guoqing Jiang
  2016-03-07 20:53 ` [PATCH 1/2] Fix wrong bitmap output for cluster raid Jes Sorensen
  0 siblings, 2 replies; 5+ messages in thread
From: Guoqing Jiang @ 2016-03-07  9:31 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: linux-raid, rgoldwyn, neilb, Guoqing Jiang

For cluster raid, we need to displays bitmap related
contents from different bitmaps which are based on node
num. So bitmap_file_open and locate_bitmap are changed a
little bit for the purpose.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Fixes: b98043a2f8 ("Show all bitmaps while examining bitmap")
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
 bitmap.c | 18 +++++++++---------
 mdadm.h  |  2 +-
 super0.c |  2 +-
 super1.c | 12 ++++++------
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/bitmap.c b/bitmap.c
index dab674b..5ad7401 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -194,7 +194,7 @@ out:
 	return info;
 }
 
-int bitmap_file_open(char *filename, struct supertype **stp)
+int bitmap_file_open(char *filename, struct supertype **stp, int node_num)
 {
 	int fd;
 	struct stat stb;
@@ -222,7 +222,7 @@ int bitmap_file_open(char *filename, struct supertype **stp)
 				st->ss->name);
 			return -1;
 		} else {
-			if (st->ss->locate_bitmap(st, fd)) {
+			if (st->ss->locate_bitmap(st, fd, node_num)) {
 				pr_err("%s doesn't have bitmap\n", filename);
 				fd = -1;
 			}
@@ -267,7 +267,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
 	int fd, i;
 	__u32 uuid32[4];
 
-	fd = bitmap_file_open(filename, &st);
+	fd = bitmap_file_open(filename, &st, 0);
 	if (fd < 0)
 		return rv;
 
@@ -348,11 +348,11 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
 		printf("   Cluster nodes : %d\n", sb->nodes);
 		printf("    Cluster name : %-64s\n", sb->cluster_name);
 		for (i = 0; i < (int)sb->nodes; i++) {
-			if (i) {
-				free(info);
-				info = bitmap_fd_read(fd, brief);
-				sb = &info->sb;
-			}
+			st = NULL;
+			free(info);
+			fd = bitmap_file_open(filename, &st, i);
+			info = bitmap_fd_read(fd, brief);
+			sb = &info->sb;
 			if (sb->magic != BITMAP_MAGIC)
 				pr_err("invalid bitmap magic 0x%x, the bitmap file appears to be corrupted\n", sb->magic);
 
@@ -367,7 +367,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
 			printf("          Bitmap : %llu bits (chunks), %llu dirty (%2.1f%%)\n",
 			       info->total_bits, info->dirty_bits,
 			       100.0 * info->dirty_bits / (info->total_bits?:1));
-
+			 close(fd);
 		}
 	}
 
diff --git a/mdadm.h b/mdadm.h
index 72888e2..355c455 100755
--- a/mdadm.h
+++ b/mdadm.h
@@ -904,7 +904,7 @@ extern struct superswitch {
 	/* Seek 'fd' to start of write-intent-bitmap.  Must be an
 	 * md-native format bitmap
 	 */
-	int (*locate_bitmap)(struct supertype *st, int fd);
+	int (*locate_bitmap)(struct supertype *st, int fd, int node_num);
 	/* if add_internal_bitmap succeeded for existing array, this
 	 * writes it out.
 	 */
diff --git a/super0.c b/super0.c
index 59a6a03..6fc1ac4 100644
--- a/super0.c
+++ b/super0.c
@@ -1156,7 +1156,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
 	return 1;
 }
 
-static int locate_bitmap0(struct supertype *st, int fd)
+static int locate_bitmap0(struct supertype *st, int fd, int node_num)
 {
 	unsigned long long dsize;
 	unsigned long long offset;
diff --git a/super1.c b/super1.c
index 9b877e5..f8a35ac 100644
--- a/super1.c
+++ b/super1.c
@@ -1548,7 +1548,7 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
 }
 #endif
 
-static int locate_bitmap1(struct supertype *st, int fd);
+static int locate_bitmap1(struct supertype *st, int fd, int node_num);
 
 static int store_super1(struct supertype *st, int fd)
 {
@@ -1622,7 +1622,7 @@ static int store_super1(struct supertype *st, int fd)
 		struct bitmap_super_s *bm = (struct bitmap_super_s*)
 			(((char*)sb)+MAX_SB_SIZE);
 		if (__le32_to_cpu(bm->magic) == BITMAP_MAGIC) {
-			locate_bitmap1(st, fd);
+			locate_bitmap1(st, fd, 0);
 			if (awrite(&afd, bm, sizeof(*bm)) != sizeof(*bm))
 				return 5;
 		}
@@ -2062,7 +2062,7 @@ static int load_super1(struct supertype *st, int fd, char *devname)
 	 * valid.  If it doesn't clear the bit.  An --assemble --force
 	 * should get that written out.
 	 */
-	locate_bitmap1(st, fd);
+	locate_bitmap1(st, fd, 0);
 	if (aread(&afd, bsb, 512) != 512)
 		goto no_bitmap;
 
@@ -2334,7 +2334,7 @@ add_internal_bitmap1(struct supertype *st,
 	return 1;
 }
 
-static int locate_bitmap1(struct supertype *st, int fd)
+static int locate_bitmap1(struct supertype *st, int fd, int node_num)
 {
 	unsigned long long offset;
 	struct mdp_superblock_1 *sb;
@@ -2353,7 +2353,7 @@ static int locate_bitmap1(struct supertype *st, int fd)
 	else
 		ret = -1;
 	offset = __le64_to_cpu(sb->super_offset);
-	offset += (int32_t) __le32_to_cpu(sb->bitmap_offset);
+	offset += (int32_t) __le32_to_cpu(sb->bitmap_offset) * (node_num + 1);
 	if (mustfree)
 		free(sb);
 	lseek64(fd, offset<<9, 0);
@@ -2408,7 +2408,7 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update
 
 	init_afd(&afd, fd);
 
-	locate_bitmap1(st, fd);
+	locate_bitmap1(st, fd, 0);
 
 	if (posix_memalign(&buf, 4096, 4096))
 		return -ENOMEM;
-- 
2.6.2


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

* [PATCH 2/2] Remove dead code about LKF_CONVERT flag
  2016-03-07  9:31 [PATCH 1/2] Fix wrong bitmap output for cluster raid Guoqing Jiang
@ 2016-03-07  9:31 ` Guoqing Jiang
  2016-03-07 20:54   ` Jes Sorensen
  2016-03-07 20:53 ` [PATCH 1/2] Fix wrong bitmap output for cluster raid Jes Sorensen
  1 sibling, 1 reply; 5+ messages in thread
From: Guoqing Jiang @ 2016-03-07  9:31 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: linux-raid, rgoldwyn, neilb, Guoqing Jiang

Since flags is only set as LKF_NOQUEUE, the code
with LKF_CONVERT flag should be delete.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
 mdadm.h | 1 -
 util.c  | 8 --------
 2 files changed, 9 deletions(-)

diff --git a/mdadm.h b/mdadm.h
index 355c455..97aac52 100755
--- a/mdadm.h
+++ b/mdadm.h
@@ -64,7 +64,6 @@ typedef uint64_t cmap_handle_t;
 #include	<errno.h>
 #else
 #define LKF_NOQUEUE	0x00000001
-#define LKF_CONVERT	0x00000004
 #define LKM_PWMODE	4
 #define EUNLOCK		0x10002
 
diff --git a/util.c b/util.c
index 96a806d..09c2f6f 100644
--- a/util.c
+++ b/util.c
@@ -147,13 +147,7 @@ int cluster_get_dlmlock(int *lockid)
 		return -ENOMEM;
 	}
 
-	/* Conversions need the lockid in the LKSB */
-	if (flags & LKF_CONVERT)
-		dlm_lock_res->lksb.sb_lkid = *lockid;
-
 	snprintf(str, 64, "bitmap%s", cluster_name);
-	/* if flags with LKF_CONVERT causes below return ENOENT which means
-	 * "No such file or directory" */
 	ret = dlm_hooks->ls_lock(dlm_lock_res->ls, LKM_PWMODE, &dlm_lock_res->lksb,
 			  flags, str, strlen(str), 0, dlm_ast,
 			  dlm_lock_res, NULL, NULL);
@@ -177,8 +171,6 @@ int cluster_release_dlmlock(int lockid)
 	if (!cluster_name)
 		return -1;
 
-	/* if flags with LKF_CONVERT causes below return EINVAL which means
-	 * "Invalid argument" */
 	ret = dlm_hooks->ls_unlock(dlm_lock_res->ls, lockid, 0,
 				     &dlm_lock_res->lksb, dlm_lock_res);
 	if (ret) {
-- 
2.6.2


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

* Re: [PATCH 1/2] Fix wrong bitmap output for cluster raid
  2016-03-07  9:31 [PATCH 1/2] Fix wrong bitmap output for cluster raid Guoqing Jiang
  2016-03-07  9:31 ` [PATCH 2/2] Remove dead code about LKF_CONVERT flag Guoqing Jiang
@ 2016-03-07 20:53 ` Jes Sorensen
  1 sibling, 0 replies; 5+ messages in thread
From: Jes Sorensen @ 2016-03-07 20:53 UTC (permalink / raw)
  To: Guoqing Jiang; +Cc: linux-raid, rgoldwyn, neilb

Guoqing Jiang <gqjiang@suse.com> writes:
> For cluster raid, we need to displays bitmap related
> contents from different bitmaps which are based on node
> num. So bitmap_file_open and locate_bitmap are changed a
> little bit for the purpose.
>
> Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> Fixes: b98043a2f8 ("Show all bitmaps while examining bitmap")
> Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
> ---
>  bitmap.c | 18 +++++++++---------
>  mdadm.h  |  2 +-
>  super0.c |  2 +-
>  super1.c | 12 ++++++------
>  4 files changed, 17 insertions(+), 17 deletions(-)

Applied!

Thanks,
Jes

>
> diff --git a/bitmap.c b/bitmap.c
> index dab674b..5ad7401 100644
> --- a/bitmap.c
> +++ b/bitmap.c
> @@ -194,7 +194,7 @@ out:
>  	return info;
>  }
>  
> -int bitmap_file_open(char *filename, struct supertype **stp)
> +int bitmap_file_open(char *filename, struct supertype **stp, int node_num)
>  {
>  	int fd;
>  	struct stat stb;
> @@ -222,7 +222,7 @@ int bitmap_file_open(char *filename, struct supertype **stp)
>  				st->ss->name);
>  			return -1;
>  		} else {
> -			if (st->ss->locate_bitmap(st, fd)) {
> +			if (st->ss->locate_bitmap(st, fd, node_num)) {
>  				pr_err("%s doesn't have bitmap\n", filename);
>  				fd = -1;
>  			}
> @@ -267,7 +267,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
>  	int fd, i;
>  	__u32 uuid32[4];
>  
> -	fd = bitmap_file_open(filename, &st);
> +	fd = bitmap_file_open(filename, &st, 0);
>  	if (fd < 0)
>  		return rv;
>  
> @@ -348,11 +348,11 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
>  		printf("   Cluster nodes : %d\n", sb->nodes);
>  		printf("    Cluster name : %-64s\n", sb->cluster_name);
>  		for (i = 0; i < (int)sb->nodes; i++) {
> -			if (i) {
> -				free(info);
> -				info = bitmap_fd_read(fd, brief);
> -				sb = &info->sb;
> -			}
> +			st = NULL;
> +			free(info);
> +			fd = bitmap_file_open(filename, &st, i);
> +			info = bitmap_fd_read(fd, brief);
> +			sb = &info->sb;
>  			if (sb->magic != BITMAP_MAGIC)
>  				pr_err("invalid bitmap magic 0x%x, the bitmap file appears to be corrupted\n", sb->magic);
>  
> @@ -367,7 +367,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
>  			printf("          Bitmap : %llu bits (chunks), %llu dirty (%2.1f%%)\n",
>  			       info->total_bits, info->dirty_bits,
>  			       100.0 * info->dirty_bits / (info->total_bits?:1));
> -
> +			 close(fd);
>  		}
>  	}
>  
> diff --git a/mdadm.h b/mdadm.h
> index 72888e2..355c455 100755
> --- a/mdadm.h
> +++ b/mdadm.h
> @@ -904,7 +904,7 @@ extern struct superswitch {
>  	/* Seek 'fd' to start of write-intent-bitmap.  Must be an
>  	 * md-native format bitmap
>  	 */
> -	int (*locate_bitmap)(struct supertype *st, int fd);
> +	int (*locate_bitmap)(struct supertype *st, int fd, int node_num);
>  	/* if add_internal_bitmap succeeded for existing array, this
>  	 * writes it out.
>  	 */
> diff --git a/super0.c b/super0.c
> index 59a6a03..6fc1ac4 100644
> --- a/super0.c
> +++ b/super0.c
> @@ -1156,7 +1156,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
>  	return 1;
>  }
>  
> -static int locate_bitmap0(struct supertype *st, int fd)
> +static int locate_bitmap0(struct supertype *st, int fd, int node_num)
>  {
>  	unsigned long long dsize;
>  	unsigned long long offset;
> diff --git a/super1.c b/super1.c
> index 9b877e5..f8a35ac 100644
> --- a/super1.c
> +++ b/super1.c
> @@ -1548,7 +1548,7 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
>  }
>  #endif
>  
> -static int locate_bitmap1(struct supertype *st, int fd);
> +static int locate_bitmap1(struct supertype *st, int fd, int node_num);
>  
>  static int store_super1(struct supertype *st, int fd)
>  {
> @@ -1622,7 +1622,7 @@ static int store_super1(struct supertype *st, int fd)
>  		struct bitmap_super_s *bm = (struct bitmap_super_s*)
>  			(((char*)sb)+MAX_SB_SIZE);
>  		if (__le32_to_cpu(bm->magic) == BITMAP_MAGIC) {
> -			locate_bitmap1(st, fd);
> +			locate_bitmap1(st, fd, 0);
>  			if (awrite(&afd, bm, sizeof(*bm)) != sizeof(*bm))
>  				return 5;
>  		}
> @@ -2062,7 +2062,7 @@ static int load_super1(struct supertype *st, int fd, char *devname)
>  	 * valid.  If it doesn't clear the bit.  An --assemble --force
>  	 * should get that written out.
>  	 */
> -	locate_bitmap1(st, fd);
> +	locate_bitmap1(st, fd, 0);
>  	if (aread(&afd, bsb, 512) != 512)
>  		goto no_bitmap;
>  
> @@ -2334,7 +2334,7 @@ add_internal_bitmap1(struct supertype *st,
>  	return 1;
>  }
>  
> -static int locate_bitmap1(struct supertype *st, int fd)
> +static int locate_bitmap1(struct supertype *st, int fd, int node_num)
>  {
>  	unsigned long long offset;
>  	struct mdp_superblock_1 *sb;
> @@ -2353,7 +2353,7 @@ static int locate_bitmap1(struct supertype *st, int fd)
>  	else
>  		ret = -1;
>  	offset = __le64_to_cpu(sb->super_offset);
> -	offset += (int32_t) __le32_to_cpu(sb->bitmap_offset);
> +	offset += (int32_t) __le32_to_cpu(sb->bitmap_offset) * (node_num + 1);
>  	if (mustfree)
>  		free(sb);
>  	lseek64(fd, offset<<9, 0);
> @@ -2408,7 +2408,7 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update
>  
>  	init_afd(&afd, fd);
>  
> -	locate_bitmap1(st, fd);
> +	locate_bitmap1(st, fd, 0);
>  
>  	if (posix_memalign(&buf, 4096, 4096))
>  		return -ENOMEM;

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

* Re: [PATCH 2/2] Remove dead code about LKF_CONVERT flag
  2016-03-07  9:31 ` [PATCH 2/2] Remove dead code about LKF_CONVERT flag Guoqing Jiang
@ 2016-03-07 20:54   ` Jes Sorensen
  2016-03-08  1:28     ` Guoqing Jiang
  0 siblings, 1 reply; 5+ messages in thread
From: Jes Sorensen @ 2016-03-07 20:54 UTC (permalink / raw)
  To: Guoqing Jiang; +Cc: linux-raid, rgoldwyn, neilb

Guoqing Jiang <gqjiang@suse.com> writes:
> Since flags is only set as LKF_NOQUEUE, the code
> with LKF_CONVERT flag should be delete.
>
> Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
> ---
>  mdadm.h | 1 -
>  util.c  | 8 --------
>  2 files changed, 9 deletions(-)

Applied!

For multi-patch series, would you mind adding a cover letter when you
post them? Then I can just respond to that if all patches are applied.

Thanks,
Jes

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

* Re: [PATCH 2/2] Remove dead code about LKF_CONVERT flag
  2016-03-07 20:54   ` Jes Sorensen
@ 2016-03-08  1:28     ` Guoqing Jiang
  0 siblings, 0 replies; 5+ messages in thread
From: Guoqing Jiang @ 2016-03-08  1:28 UTC (permalink / raw)
  To: Jes Sorensen, Guoqing Jiang; +Cc: linux-raid, rgoldwyn, neilb



On 03/08/2016 04:54 AM, Jes Sorensen wrote:
> Guoqing Jiang <gqjiang@suse.com> writes:
>> Since flags is only set as LKF_NOQUEUE, the code
>> with LKF_CONVERT flag should be delete.
>>
>> Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
>> Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
>> ---
>>   mdadm.h | 1 -
>>   util.c  | 8 --------
>>   2 files changed, 9 deletions(-)
> Applied!
>
> For multi-patch series, would you mind adding a cover letter when you
> post them? Then I can just respond to that if all patches are applied.

Sorry for inconvenience, I will do it in next time for similar case.

Thanks,
Guoqing


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

end of thread, other threads:[~2016-03-08  1:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-07  9:31 [PATCH 1/2] Fix wrong bitmap output for cluster raid Guoqing Jiang
2016-03-07  9:31 ` [PATCH 2/2] Remove dead code about LKF_CONVERT flag Guoqing Jiang
2016-03-07 20:54   ` Jes Sorensen
2016-03-08  1:28     ` Guoqing Jiang
2016-03-07 20:53 ` [PATCH 1/2] Fix wrong bitmap output for cluster raid Jes Sorensen

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