mdadm: write behind value does not have endian conversion
Neil,
The write behind value does not get converted to/from little endian which causes write behind not to work on big endian machines (RUN ARRAY fails with invalid argument error):
# mdadm -B /dev/md0 -l1 -n2 --write-behind=256 /dev/sdb10 --write-mostly /dev/nbd0 --bitmap=/bitmaps/test5 mdadm: RUN_ARRAY failed: Invalid argument
# tail /var/log/messages Oct 6 13:14:48 caspian kernel: daemon sleep: 5s Oct 6 13:14:48 caspian kernel: sync size: 1001456 KB Oct 6 13:14:48 caspian kernel: max write behind: 65536 Oct 6 13:14:48 caspian kernel: md0: failed to create bitmap (-22)
Attached patch for mdadm fixes this.
Thanks,
Paul
bitmap.c renamed from bitmap.c.orig +1 -0
@@ -33,6 +33,7 @@ inline void sb_le_to_cpu(bitmap_super_t sb->chunksize =__le32_to_cpu (sb->chunksize); sb->daemon_sleep =__le32_to_cpu (sb->daemon_sleep); sb->sync_size =__le64_to_cpu (sb->sync_size); + sb->write_behind =__le32_to_cpu (sb->sync_size); }inline void sb_cpu_to_le (bitmap_super_t *sb)
bitmap.c inline void sb_le_to_cpu(bitmap_super_t · line 37
Quoted 8 lines · Paul Clements
bitmap.c renamed from bitmap.c.orig +1
-0@@ -33,6 +33,7 @@ inline void sb_le_to_cpu(bitmap_super_t sb->chunksize =__le32_to_cpu (sb->chunksize); sb->daemon_sleep =__le32_to_cpu (sb->daemon_sleep); sb->sync_size =__le64_to_cpu (sb->sync_size); + sb->write_behind =__le32_to_cpu (sb->sync_size);
Obviously, sync_size should be write_behind in the above line.
Quoted 9 lines · On Friday October 6, [email protected] wrote:
Quoted 6 lines · Paul Clements
bitmap.c renamed from bitmap.c.orig +0
-0@@ -33,6 +33,7 @@ inline void sb_le_to_cpu(bitmap_super_t sb->chunksize =__le32_to_cpu (sb->chunksize); sb->daemon_sleep =__le32_to_cpu (sb->daemon_sleep); sb->sync_size =__le64_to_cpu (sb->sync_size);
Quoted 3 lines
bitmap.c inline void sb_le_to_cpu(bitmap_super_t · line 36
Quoted 1 line
bitmap.c renamed from bitmap.c.orig +1
-0+ sb->write_behind =__le32_to_cpu (sb->sync_size);Obviously,
sync_sizeshould bewrite_behindin the above line.
Thanks.
Applied and push out to git.
NeilBrown