]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
super1: add more checks for NodeNumUpdate option
authorGuoqing Jiang <gqjiang@suse.com>
Wed, 11 May 2016 09:31:36 +0000 (17:31 +0800)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Thu, 12 May 2016 19:44:51 +0000 (15:44 -0400)
There are some cases which didn't need to check the space
is enough or not for NodeNumUpdate option.

1. for array which does not have clustered bitmap.
2. "--nodes" parameter is 0 (eg, add a disk to clustered raid).
3. if "--nodes" parameter is set to a smaller num than
   current bms->nodes.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
super1.c

index 6bf9523451f3fd1f57c0d5c6c7f1a59ad38000c7..879e0d5a678a84c122f4875cbb3b13cee070c314 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -2394,9 +2394,25 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update
                        return -EINVAL;
                }
 
-               if (bms->version == BITMAP_MAJOR_CLUSTERED && st->nodes <= 1) {
-                       pr_err("Warning: cluster-md at least needs two nodes\n");
-                       return -EINVAL;
+               if (bms->version == BITMAP_MAJOR_CLUSTERED) {
+                       if (st->nodes == 1) {
+                               /* the parameter for nodes is not valid */
+                               pr_err("Warning: cluster-md at least needs two nodes\n");
+                               return -EINVAL;
+                       } else if (st->nodes == 0)
+                               /* --nodes is not specified */
+                               break;
+                       else if (__cpu_to_le32(st->nodes) < bms->nodes) {
+                               /* Since the nodes num is not increased, no need to check the space
+                                * is enough or not, just update bms->nodes */
+                               bms->nodes = __cpu_to_le32(st->nodes);
+                               break;
+                       }
+               } else {
+                       /* no need to change bms->nodes for other bitmap types */
+                       if (st->nodes)
+                               pr_err("Warning: --nodes option is only suitable for clustered bitmap\n");
+                       break;
                }
 
                /* Each node has an independent bitmap, it is necessary to calculate the