Skip to contentSkip to conversation

mdadm "hang", 100% CPU usage when trying to create RAID-1 array with external bitmap

DISCUSSION Tomasz Chmielewski 3 participants 6 messages Jul 14, 2010 – Jul 20, 2010 MD RAID

lore
Share & tools
lore
#0 lore raw

I'm trying to create RAID-1 with external bitmap with this command:

mdadm --create /dev/md11 --level=1 --bitmap=/mnt/src/bitmap --raid-devices 2 /dev/storage/origin missing

/dev/storage/origin is 1.2 TB; is placed on "stacked" block devices like this:

RAID-5 -> dm-crypt -> LVM-2 -> /dev/storage/origin

/mnt/src/bitmap is technically the same stacked device, except the last LVM volume:

RAID-5 -> dm-crypt -> LVM-2 -> /dev/storage/src -> /mnt/src/bitmap

(although I tried to keep bitmap outside of this RAID-5 device, and it was still hanging).

When started with "strace", mdadm hangs with 100% CPU usage after opening /mnt/src/bitmap:

(...)
rename("/var/run/map.new", "/var/run/map") = 0

flock(3, LOCK_UN)                       = 0
close(3)                                = 0
munmap(0x6ff40000, 4096)                = 0
unlink("/var/run/map.lock")             = 0
ioctl(4, 0x800c0910, 0x77f5f89c)        = 0
fstat64(4, {st_mode=S_IFBLK|0600, st_rdev=makedev(9, 1), ...}) = 0
fstat64(4, {st_mode=S_IFBLK|0600, st_rdev=makedev(9, 1), ...}) = 0
ioctl(4, 0x800c0910, 0x77f5f7cc)        = 0
ioctl(4, 0x40480923, 0x77f5f854)        = 0
access("/mnt/src/bitmap", F_OK)         = -1 ENOENT (No such file or directory)
open("/mnt/src/bitmap", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3

I see no disk activity when this happens.

# mdadm -V
mdadm - v3.1.2 - 10th March 2010

Kernel is 2.6.34.1 (tried also 2.6.28.7), 32 bit x86 system.

Or, I didn't wait long enough? So far, it takes about an hour to create this array...

Creating smaller arrays (i.e. 8 GB) in a similar configuration works fine.

Signature · 2 lines
Tomasz Chmielewski
http://wpkg.org
#1 lore raw
Quoted 21 lines · On Wed, 14 Jul 2010 12:53:45 +0200 Tomasz Chmielewski <[email protected]> wrote:

I'm trying to create RAID-1 with external bitmap with this command:

mdadm --create /dev/md11 --level=1 --bitmap=/mnt/src/bitmap --raid-devices 2 /dev/storage/origin missing

/dev/storage/origin is 1.2 TB; is placed on "stacked" block devices like this:

RAID-5 -> dm-crypt -> LVM-2 -> /dev/storage/origin

/mnt/src/bitmap is technically the same stacked device, except the last LVM volume:

RAID-5 -> dm-crypt -> LVM-2 -> /dev/storage/src -> /mnt/src/bitmap

(although I tried to keep bitmap outside of this RAID-5 device, and it was still hanging).

When started with "strace", mdadm hangs with 100% CPU usage after opening /mnt/src/bitmap:

(...)
rename("/var/run/map.new", "/var/run/map") = 0

Quoted 13 lines
flock(3, LOCK_UN)                       = 0
close(3)                                = 0
munmap(0x6ff40000, 4096)                = 0
unlink("/var/run/map.lock")             = 0
ioctl(4, 0x800c0910, 0x77f5f89c)        = 0
fstat64(4, {st_mode=S_IFBLK|0600, st_rdev=makedev(9, 1), ...}) = 0
fstat64(4, {st_mode=S_IFBLK|0600, st_rdev=makedev(9, 1), ...}) = 0
ioctl(4, 0x800c0910, 0x77f5f7cc)        = 0
ioctl(4, 0x40480923, 0x77f5f854)        = 0
access("/mnt/src/bitmap", F_OK)         = -1 ENOENT (No such file or directory)
open("/mnt/src/bitmap", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3

Hmm... that's rather embarrassing.
This patch should fit it. Or you can explicitly set a bitmap chunk size - aim for several megabyte.

Thanks for the report,
NeilBrown

bitmap.c +1 -1
index beef2dc..44a8677 100644
@@ -373,7 +373,7 @@ int CreateBitmap(char *filename, int force, char uuid[16],
 		 */
 		chunksize = DEFAULT_BITMAP_CHUNK;
 		/* <<20 for 2^20 chunks, >>9 to convert bytes to sectors */
-		while (array_size > (chunksize << (20-9)))
+		while (array_size > ((unsigned long long)chunksize << (20-9)))
 			chunksize <<= 1;
 	}
 
Quoted 13 lines

I see no disk activity when this happens.

# mdadm -V
mdadm - v3.1.2 - 10th March 2010

Kernel is 2.6.34.1 (tried also 2.6.28.7), 32 bit x86 system.

Or, I didn't wait long enough? So far, it takes about an hour to create this array...

Creating smaller arrays (i.e. 8 GB) in a similar configuration works fine.

#2 lore raw

On 15.07.2010 07:45, Neil Brown wrote:

(...)

Quoted 17 lines
Quoted 4 lines

access("/mnt/src/bitmap", F_OK) = -1 ENOENT (No such file or directory)
open("/mnt/src/bitmap", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3

Hmm... that's rather embarrassing.
This patch should fit it. Or you can explicitly set a bitmap chunk size - aim for several megabyte.

Thanks for the report,
NeilBrown

bitmap.c +0 -0
index beef2dc..44a8677 100644

bitmap.c int CreateBitmap(char *filename, int force, char uuid[16], · line 376

Quoted 5 lines
bitmap.c +1 -1
@@ -373,7 +373,7 @@ int CreateBitmap(char *filename, int force, char uuid[16],
  		 */
  		chunksize = DEFAULT_BITMAP_CHUNK;
  		/*<<20 for 2^20 chunks,>>9 to convert bytes to sectors */
-		while (array_size>  (chunksize<<  (20-9)))
+		while (array_size>  ((unsigned long long)chunksize<<  (20-9)))

It works fine with that patch applied, thanks a lot!

Signature · 2 lines
Tomasz Chmielewski
http://syneticon.net
#3 lore raw
In reply to Neil Brown
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Neil" == Neil Brown <[email protected]> writes:

Neil> On Wed, 14 Jul 2010 12:53:45 +0200

Quoted 19 lines · Neil> Tomasz Chmielewski <[email protected]> wrote:
Quoted 19 lines

I'm trying to create RAID-1 with external bitmap with this command:

mdadm --create /dev/md11 --level=1 --bitmap=/mnt/src/bitmap --raid-devices 2 /dev/storage/origin missing

/dev/storage/origin is 1.2 TB; is placed on "stacked" block devices like this:

RAID-5 -> dm-crypt -> LVM-2 -> /dev/storage/origin

/mnt/src/bitmap is technically the same stacked device, except the last LVM volume:

RAID-5 -> dm-crypt -> LVM-2 -> /dev/storage/src -> /mnt/src/bitmap

(although I tried to keep bitmap outside of this RAID-5 device, and it was still hanging).

When started with "strace", mdadm hangs with 100% CPU usage after opening /mnt/src/bitmap:

Quoted 15 lines
Quoted 15 lines

(...)
rename("/var/run/map.new", "/var/run/map") = 0

flock(3, LOCK_UN)                       = 0
close(3)                                = 0
munmap(0x6ff40000, 4096)                = 0
unlink("/var/run/map.lock")             = 0
ioctl(4, 0x800c0910, 0x77f5f89c)        = 0
fstat64(4, {st_mode=S_IFBLK|0600, st_rdev=makedev(9, 1), ...}) = 0
fstat64(4, {st_mode=S_IFBLK|0600, st_rdev=makedev(9, 1), ...}) = 0
ioctl(4, 0x800c0910, 0x77f5f7cc)        = 0
ioctl(4, 0x40480923, 0x77f5f854)        = 0
access("/mnt/src/bitmap", F_OK)         = -1 ENOENT (No such file or directory)
open("/mnt/src/bitmap", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3

Neil> Hmm... that's rather embarrassing.
Neil> This patch should fit it. Or you can explicitly set a bitmap chunk size - Neil> aim for several megabyte.

Neil> diff --git a/bitmap.c b/bitmap.c
Neil> index beef2dc..44a8677 100644
Neil> --- a/bitmap.c
Neil> +++ b/bitmap.c
Neil> @@ -373,7 +373,7 @@ int CreateBitmap(char *filename, int force, char uuid[16],

Neil>  		 */
Neil>  		chunksize = DEFAULT_BITMAP_CHUNK;
Neil>  		/* <<20 for 2^20 chunks, >>9 to convert bytes to sectors */

Neil> - while (array_size > (chunksize << (20-9)))
Neil> + while (array_size > ((unsigned long long)chunksize << (20-9)))
Neil> chunksize <<= 1;
Neil> }

How about also replacing the magic numbers 20 and 9 with usefully
named constants as well? I realize the comment tells you what's
going on here, but I just boggle a bit when I see 20-9 in the source. :-)

John

#4 lore raw
Quoted 57 lines · On Sun, 18 Jul 2010 15:09:38 -0400 "John Stoffel" <[email protected]> wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Neil" == Neil Brown <[email protected]> writes:

Neil> On Wed, 14 Jul 2010 12:53:45 +0200

Quoted 19 lines · Neil> Tomasz Chmielewski <[email protected]> wrote:
Quoted 19 lines

I'm trying to create RAID-1 with external bitmap with this command:

mdadm --create /dev/md11 --level=1 --bitmap=/mnt/src/bitmap --raid-devices 2 /dev/storage/origin missing

/dev/storage/origin is 1.2 TB; is placed on "stacked" block devices like this:

RAID-5 -> dm-crypt -> LVM-2 -> /dev/storage/origin

/mnt/src/bitmap is technically the same stacked device, except the last LVM volume:

RAID-5 -> dm-crypt -> LVM-2 -> /dev/storage/src -> /mnt/src/bitmap

(although I tried to keep bitmap outside of this RAID-5 device, and it was still hanging).

When started with "strace", mdadm hangs with 100% CPU usage after opening /mnt/src/bitmap:

Quoted 15 lines
Quoted 15 lines

(...)
rename("/var/run/map.new", "/var/run/map") = 0

flock(3, LOCK_UN)                       = 0
close(3)                                = 0
munmap(0x6ff40000, 4096)                = 0
unlink("/var/run/map.lock")             = 0
ioctl(4, 0x800c0910, 0x77f5f89c)        = 0
fstat64(4, {st_mode=S_IFBLK|0600, st_rdev=makedev(9, 1), ...}) = 0
fstat64(4, {st_mode=S_IFBLK|0600, st_rdev=makedev(9, 1), ...}) = 0
ioctl(4, 0x800c0910, 0x77f5f7cc)        = 0
ioctl(4, 0x40480923, 0x77f5f854)        = 0
access("/mnt/src/bitmap", F_OK)         = -1 ENOENT (No such file or directory)
open("/mnt/src/bitmap", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3

Neil> Hmm... that's rather embarrassing.
Neil> This patch should fit it. Or you can explicitly set a bitmap chunk size - Neil> aim for several megabyte.

Neil> diff --git a/bitmap.c b/bitmap.c
Neil> index beef2dc..44a8677 100644
Neil> --- a/bitmap.c
Neil> +++ b/bitmap.c
Neil> @@ -373,7 +373,7 @@ int CreateBitmap(char *filename, int force, char uuid[16],

Neil>  		 */
Neil>  		chunksize = DEFAULT_BITMAP_CHUNK;
Neil>  		/* <<20 for 2^20 chunks, >>9 to convert bytes to sectors */

Neil> - while (array_size > (chunksize << (20-9)))
Neil> + while (array_size > ((unsigned long long)chunksize << (20-9)))
Neil> chunksize <<= 1;
Neil> }

Quoted 4 lines

How about also replacing the magic numbers 20 and 9 with usefully
named constants as well? I realize the comment tells you what's
going on here, but I just boggle a bit when I see 20-9 in the source. :-)

If you sent that suggestion as a patch it would be much more likely to be applied (it might anyway, but still...)
:-)

NeilBrown

#5 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Neil" == Neil Brown <[email protected]> writes:

Neil> If you sent that suggestion as a patch it would be much more likely to be Neil> applied (it might anyway, but still...)
Neil> :-)

touche! I'll see about whipping up a patch today/tonight. Thanks for taking my nit-picking so well....

John