]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: Make add_internal_bitmap() return 0 on success
authorJes Sorensen <Jes.Sorensen@redhat.com>
Thu, 12 May 2016 19:19:16 +0000 (15:19 -0400)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Thu, 12 May 2016 19:19:16 +0000 (15:19 -0400)
add_internal_bitmap() returned 1 on success and 0 on error which is
inconsistent. This changes it to return 0 on success and use more
reasonable error codes on error.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Create.c
Grow.c
mdadm.h
super0.c
super1.c

index 717086b080fef60f435b52a0ac15e0d31529256e..1594a39191396c315c036c4adaec5de72ac18bf1 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -774,9 +774,9 @@ int Create(struct supertype *st, char *mddev,
                                st->ss->name);
                        goto abort_locked;
                }
-               if (!st->ss->add_internal_bitmap(st, &s->bitmap_chunk,
-                                                c->delay, s->write_behind,
-                                                bitmapsize, 1, major_num)) {
+               if (st->ss->add_internal_bitmap(st, &s->bitmap_chunk,
+                                               c->delay, s->write_behind,
+                                               bitmapsize, 1, major_num)) {
                        pr_err("Given bitmap chunk size not supported.\n");
                        goto abort_locked;
                }
diff --git a/Grow.c b/Grow.c
index 580c13e1caff55bbc48d6ea44a18ba9632d657f7..cdd9d05b74eed849bcb9a016218af8a6ceab094f 100755 (executable)
--- a/Grow.c
+++ b/Grow.c
@@ -423,7 +423,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
                                continue;
                        rv = st->ss->load_super(st, fd2, NULL);
                        if (!rv) {
-                               if (st->ss->add_internal_bitmap(
+                               if (!st->ss->add_internal_bitmap(
                                            st, &s->bitmap_chunk, c->delay,
                                            s->write_behind, bitmapsize,
                                            offset_setable, major))
diff --git a/mdadm.h b/mdadm.h
index d209488b6539fcf2b6eb938c631fd3fe0ce2be08..b8705854aba32b3b1a62e934e4385a57f006187e 100755 (executable)
--- a/mdadm.h
+++ b/mdadm.h
@@ -896,6 +896,8 @@ extern struct superswitch {
         * created, in which case data_size may be updated, or it might
         * already exist.  Metadata handler can know if init_super
         * has been called, but not write_init_super.
+        *  0:     Success
+        * -Exxxx: On error
         */
        int (*add_internal_bitmap)(struct supertype *st, int *chunkp,
                                   int delay, int write_behind,
index 6fc1ac4f27c5e9cb0e4957cb38b0f6d9747a8086..467a37373d83dda63fd46297a9b7e066c3e26b94 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -1139,7 +1139,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
                if (chunk < 64*1024*1024)
                        chunk = 64*1024*1024;
        } else if ((unsigned long long)chunk < min_chunk)
-               return 0; /* chunk size too small */
+               return -EINVAL; /* chunk size too small */
 
        sb->state |= (1<<MD_SB_BITMAP_PRESENT);
 
@@ -1153,7 +1153,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
        bms->sync_size = __cpu_to_le64(size);
        bms->write_behind = __cpu_to_le32(write_behind);
        *chunkp = chunk;
-       return 1;
+       return 0;
 }
 
 static int locate_bitmap0(struct supertype *st, int fd, int node_num)
index fa933676621f6431398192b1c0b26f3ce53deac3..6bf9523451f3fd1f57c0d5c6c7f1a59ad38000c7 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -2270,7 +2270,7 @@ add_internal_bitmap1(struct supertype *st,
                }
                break;
        default:
-               return 0;
+               return -ENOSPC;
        }
 
        room -= bbl_size;
@@ -2280,7 +2280,7 @@ add_internal_bitmap1(struct supertype *st,
 
        if (room <= 1)
                /* No room for a bitmap */
-               return 0;
+               return -ENOSPC;
 
        max_bits = (room * 512 - sizeof(bitmap_super_t)) * 8;
 
@@ -2298,9 +2298,9 @@ add_internal_bitmap1(struct supertype *st,
                if (chunk < 64*1024*1024)
                        chunk = 64*1024*1024;
        } else if (chunk < min_chunk)
-               return 0; /* chunk size too small */
+               return -EINVAL; /* chunk size too small */
        if (chunk == 0) /* rounding problem */
-               return 0;
+               return -EINVAL;
 
        if (offset == 0) {
                /* start bitmap on a 4K boundary with enough space for
@@ -2336,7 +2336,7 @@ add_internal_bitmap1(struct supertype *st,
        }
 
        *chunkp = chunk;
-       return 1;
+       return 0;
 }
 
 static int locate_bitmap1(struct supertype *st, int fd, int node_num)