]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix remaining problems with hot-add bitmap to version-1 superblock
authorNeil Brown <neilb@suse.de>
Mon, 12 Sep 2005 05:24:10 +0000 (05:24 +0000)
committerNeil Brown <neilb@suse.de>
Mon, 12 Sep 2005 05:24:10 +0000 (05:24 +0000)
Also some more tests - r5 and r6 bitmaps

Signed-off-by: Neil Brown <neilb@suse.de>
14 files changed:
ChangeLog
bitmap.c
mdadm.h
super0.c
super1.c
tests/00linear
tests/00raid0
tests/00raid1
tests/00raid4
tests/00raid5
tests/00raid6
tests/05r5-bitmapfile [new file with mode: 0644]
tests/05r5-internalbitmap [new file with mode: 0644]
tests/05r6-bitmapfile [new file with mode: 0644]

index b67e2a91c6c1962f430d2d598480006c03c88544..cb66fc48a1459bf000d4f0b2410cece3b481c5f7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,8 @@ Changes Prior to this release
     -   Fix assembling of arrays that use the version-1 superblock and
          have spares.  Previously the spares would be ignored.
     -   Fix bug so that multiple drives can be re-added at once.
+    -   Fix problem with hot-adding a bitmap to version-1-superblock
+         arrays.
 
 Changes Prior to 2.0
     -   Support assembling from byte-swapped superblocks
index 5252069b09c4ac10f269e9700aed0a07852f3e95..82da00a195c3c26dd0b59d5f7271c5c55aac9726 100644 (file)
--- a/bitmap.c
+++ b/bitmap.c
@@ -198,7 +198,7 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
                        /* just look at device... */
                        lseek(fd, 0, 0);
                } else {        
-                       st->ss->locate_bitmap(st, fd);
+                       st->ss->locate_bitmap(st, fd, NULL);
                }
                ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
                *stp = st;
diff --git a/mdadm.h b/mdadm.h
index 65fa824032d31b353eb6268f4c695ec2d6d9d423..3557c02706a36dda24301da37cc8615dd9ea9311 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -191,7 +191,7 @@ extern struct superswitch {
        struct supertype * (*match_metadata_desc)(char *arg);
        __u64 (*avail_size)(struct supertype *st, __u64 size);
        int (*add_internal_bitmap)(struct supertype *st, void *sbv, int chunk, int delay, int write_behind, int *sizep, int may_change);
-       void (*locate_bitmap)(struct supertype *st, int fd);
+       void (*locate_bitmap)(struct supertype *st, int fd, void *sbv);
        int (*write_bitmap)(struct supertype *st, int fd, void *sbv);
        int major;
        int swapuuid; /* true if uuid is bigending rather than hostendian */
index 916db5425b6ebfe63405c8fd57dcf098a90df14b..95968d302498ff9950e2684ab78878a5ea93a64a 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -701,7 +701,7 @@ static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int
 }
                
 
-void locate_bitmap0(struct supertype *st, int fd)
+void locate_bitmap0(struct supertype *st, int fd, void *sbv)
 {
        unsigned long long dsize;
        unsigned long size;
index 00da49755820fc1ccd7ff2c3602837e40d45a2fc..43607ba6d692e8d810bf1ac06bdf60f7b2340d59 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -892,16 +892,21 @@ add_internal_bitmap1(struct supertype *st, void *sbv,
 }
 
 
-void locate_bitmap1(struct supertype *st, int fd)
+void locate_bitmap1(struct supertype *st, int fd, void *sbv)
 {
        unsigned long long offset;
        struct mdp_superblock_1 *sb;
 
-       if (st->ss->load_super(st, fd, (void**)&sb, NULL))
-               return; /* no error I hope... */
+       if (sbv)
+               sb = sbv;
+       else {
+               if (st->ss->load_super(st, fd, (void**)&sb, NULL))
+                       return; /* no error I hope... */
+       }
        offset = __le64_to_cpu(sb->super_offset);
        offset += (long) __le32_to_cpu(sb->bitmap_offset);
-
+       if (!sbv)
+               free(sb);
        lseek64(fd, offset<<9, 0);
 }
 
@@ -914,7 +919,7 @@ int write_bitmap1(struct supertype *st, int fd, void *sbv)
        int towrite, n;
        char buf[4096];
 
-       locate_bitmap1(st, fd);
+       locate_bitmap1(st, fd, sbv);
 
        write(fd, ((char*)sb)+1024, sizeof(bitmap_super_t));
        towrite = __le64_to_cpu(bms->sync_size) / (__le32_to_cpu(bms->chunksize)>>9);
index 6f08ba0cd88914a30dc704cced9a0991bda4ef45..ec6a16675081f6b8133bd02f5e1eb5cb6402d775 100644 (file)
@@ -6,7 +6,7 @@ check linear
 testdev $md0 3 $mdsize0 64 
 mdadm -S $md0
 
-# now with verion-1 superblock
+# now with version-1 superblock
 mdadm -CR $md0 -e1 --level=linear -n4 $dev0 $dev1 $dev2 $dev3
 check linear
 testdev $md0 4 $mdsize1 64 
index 07437c0852e6d179a8409e016384fca1771d87da..f5122ec6edfd3b7c3ce73fd6de292d1f9566e9b9 100644 (file)
@@ -6,7 +6,7 @@ check raid0
 testdev $md0 3 $mdsize0 64 
 mdadm -S $md0
 
-# now with verion-1 superblock
+# now with version-1 superblock
 mdadm -CR $md0 -e1 -l0 -n4 $dev0 $dev1 $dev2 $dev3 
 check raid0
 testdev $md0 4 $mdsize1 64 
@@ -27,7 +27,7 @@ do
   testdev $md0 3 $mdsize0 $chunk
   mdadm -S $md0
 
-  # now with verion-1 superblock
+  # now with version-1 superblock
   mdadm -CR $md0 -e1 -l0 -c $chunk -n4 $dev0 $dev1 $dev2 $dev3 
   check raid0
   testdev $md0 4 $mdsize1 $chunk
index af40da4ce95fe5fad9a72e1e81fc568034eb51b6..b0dfa6a9151af62a70dcc0c1def42787dedf68e9 100644 (file)
@@ -9,7 +9,7 @@ check raid1
 testdev $md0 1 $mdsize0 1
 mdadm -S $md0
 
-# now with verion-1 superblock, spare
+# now with version-1 superblock, spare
 mdadm -CR $md0 -e1 --level=raid1 -n3 -x2 $dev0 missing missing $dev1 $dev2 
 check recovery
 check raid1
index a45668ab21a20c888645da27f61d165b6f9c4634..46383873624becc349e6a5a764e52770feedf18f 100644 (file)
@@ -6,7 +6,7 @@ check resync ; check raid5
 testdev $md0 2 $mdsize0 64
 mdadm -S $md0
 
-# now with verion-1 superblock
+# now with version-1 superblock
 mdadm -CR $md0 -e1 --level=raid4 -n4 $dev0 $dev1 $dev2 $dev3 
 check resync; check raid5
 testdev $md0 3 $mdsize1 64
index 7192ac53bc99ac297b9b5d02e1a0cbbddfb20950..71f365454bcf81265f4af2a6d695606beadcb382 100644 (file)
@@ -6,7 +6,7 @@ check resync
 testdev $md0 2 $mdsize0 64
 mdadm -S $md0
 
-# now with verion-1 superblock
+# now with version-1 superblock
 mdadm -CR $md0 -e1 --level=raid5 -n4 $dev0 $dev1 $dev2 $dev3 
 check recovery
 testdev $md0 3 $mdsize1 64
@@ -22,7 +22,7 @@ do
   testdev $md0 2 $mdsize0 64
   mdadm -S $md0
 
-  # now with verion-1 superblock
+  # now with version-1 superblock
   mdadm -CR $md0 -e1 --level=raid5 --layout $lo -n4 $dev0 $dev1 $dev2 $dev3 
   check recovery ; check raid5
   testdev $md0 3 $mdsize1 64
index ba8c61cf863d722017d700f6fc6a0dc27abbc330..81834aaef78dbeba7d8401135af316544d570847 100644 (file)
@@ -6,7 +6,7 @@ check resync ; check raid6
 testdev $md0 2 $mdsize0 64
 mdadm -S $md0
 
-# now with verion-1 superblock
+# now with version-1 superblock
 mdadm -CR $md0 -e1 --level=raid6 -n5 $dev0 $dev1 $dev2 $dev3 $dev4 
 check resync ; check raid6
 testdev $md0 3 $mdsize1 64
diff --git a/tests/05r5-bitmapfile b/tests/05r5-bitmapfile
new file mode 100644 (file)
index 0000000..25c1228
--- /dev/null
@@ -0,0 +1,48 @@
+
+#
+# create a raid1 with a bitmap file
+#
+bmf=$targetdir/bitmap
+rm -f $bmf
+mdadm --create --run $md0 --level=5 -n3 --delay=1  --bitmap $bmf $dev1 $dev2 $dev3
+check wait
+testdev $md0 2 $mdsize0 1
+mdadm -S $md0
+
+mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 $dev3
+testdev $md0 2 $mdsize0 1
+dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+sleep 4
+dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ]
+then  echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2"
+  exit 1
+fi
+mdadm $md0 -f $dev1
+testdev $md0 2 $mdsize0 1
+sleep 4
+dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+if [ $dirty3 -lt 400 ]
+then
+   echo >&2 "ERROR dirty count $dirty3 is too small"
+   exit 2
+fi
+
+mdadm -S $md0
+
+mdadm --assemble -R $md0 --bitmap=$bmf $dev2 $dev3
+mdadm $md0 --add $dev1
+check recovery
+
+dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+check wait
+sleep 4
+dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ]
+then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5"
+  exit 1
+fi
+
+mdadm -S $md0
diff --git a/tests/05r5-internalbitmap b/tests/05r5-internalbitmap
new file mode 100644 (file)
index 0000000..d79db90
--- /dev/null
@@ -0,0 +1,46 @@
+
+#
+# create a raid1 with an internal bitmap
+#
+mdadm --create --run $md0 --level=5 -n3 --delay=1  --bitmap internal $dev1 $dev2 $dev3
+check wait
+testdev $md0 2 $mdsize0 1
+mdadm -S $md0
+
+mdadm --assemble $md0 $dev1 $dev2 $dev3
+testdev $md0 2 $mdsize0 1
+dirty1=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+sleep 4
+dirty2=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ]
+then  echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2"
+  exit 1
+fi
+mdadm $md0 -f $dev1
+testdev $md0 2 $mdsize0 1
+sleep 4
+dirty3=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+if [ $dirty3 -lt 400 ]
+then
+   echo >&2 "ERROR dirty count $dirty3 is too small"
+   exit 2
+fi
+
+mdadm -S $md0
+
+mdadm --assemble -R $md0  $dev2 $dev3
+mdadm $md0 --add $dev1
+check recovery
+
+dirty4=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+check wait
+sleep 4
+dirty5=`mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ]
+then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5"
+  exit 1
+fi
+
+mdadm -S $md0
diff --git a/tests/05r6-bitmapfile b/tests/05r6-bitmapfile
new file mode 100644 (file)
index 0000000..865cedb
--- /dev/null
@@ -0,0 +1,48 @@
+
+#
+# create a raid1 with a bitmap file
+#
+bmf=$targetdir/bitmap
+rm -f $bmf
+mdadm --create --run $md0 --level=6 -n4 --delay=1  --bitmap $bmf $dev1 $dev2 $dev3 $dev4
+check wait
+testdev $md0 2 $mdsize0 1
+mdadm -S $md0
+
+mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 $dev3 $dev4
+testdev $md0 2 $mdsize0 1
+dirty1=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+sleep 4
+dirty2=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ]
+then  echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2"
+  exit 1
+fi
+mdadm $md0 -f $dev3
+testdev $md0 2 $mdsize0 1
+sleep 4
+dirty3=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+if [ $dirty3 -lt 400 ]
+then
+   echo >&2 "ERROR dirty count $dirty3 is too small"
+   exit 2
+fi
+
+mdadm -S $md0
+
+mdadm --assemble -R $md0 --bitmap=$bmf $dev1 $dev2 $dev4
+mdadm $md0 --add $dev3
+check recovery
+
+dirty4=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+check wait
+sleep 4
+dirty5=`mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ]
+then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5"
+  exit 1
+fi
+
+mdadm -S $md0