]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
6 years agoclustermd_tests: add test case to test switch-recovery against cluster-raid10
Zhilong Liu [Fri, 2 Feb 2018 06:11:03 +0000 (14:11 +0800)] 
clustermd_tests: add test case to test switch-recovery against cluster-raid10

03r10_switch-recovery:
Create new array with 2 active and 1 spare disk, set 1 active disk as 'fail',
it triggers recovery and the spare disk would replace the failure disk, then
stop the array in doing recovery node, the other node would take it over and
continue to complete the recovery.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test switch-recovery against cluster-raid1
Zhilong Liu [Fri, 2 Feb 2018 06:11:02 +0000 (14:11 +0800)] 
clustermd_tests: add test case to test switch-recovery against cluster-raid1

03r1_switch-recovery:
Create new array with 2 active and 1 spare disk, set 1 active disk as 'fail',
it triggers recovery and the spare disk would replace the failure disk, then
stop the array in doing recovery node, the other node would take it over and
continue to complete the recovery.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test switch-resync against cluster-raid10
Zhilong Liu [Fri, 2 Feb 2018 06:11:01 +0000 (14:11 +0800)] 
clustermd_tests: add test case to test switch-resync against cluster-raid10

03r10_switch-resync:
Create new array, 1 node is doing resync and other node would keep PENDING,
stop the array in resync node, other node would take it over and continue
to complete the resync.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test switch-resync against cluster-raid1
Zhilong Liu [Fri, 2 Feb 2018 06:11:00 +0000 (14:11 +0800)] 
clustermd_tests: add test case to test switch-resync against cluster-raid1

03r1_switch-resync:
Create new array, 1 node is doing resync and other node would keep PENDING,
stop the array in resync node, other node would take it over and continue
to complete the resync.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test manage_re-add against cluster-raid10
Zhilong Liu [Fri, 2 Feb 2018 06:10:59 +0000 (14:10 +0800)] 
clustermd_tests: add test case to test manage_re-add against cluster-raid10

02r10_Manage_re-add:
2 active disk in array, set 1 disk 'fail' and 'remove' it from array,
then re-add the disk back to array and triggers recovery.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test manage_re-add against cluster-raid1
Zhilong Liu [Fri, 2 Feb 2018 06:10:58 +0000 (14:10 +0800)] 
clustermd_tests: add test case to test manage_re-add against cluster-raid1

02r1_Manage_re-add:
2 active disk in array, set 1 disk 'fail' and 'remove' it from array,
then re-add the disk back to array and triggers recovery.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test manage_add-spare against cluster-raid10
Zhilong Liu [Fri, 2 Feb 2018 06:10:57 +0000 (14:10 +0800)] 
clustermd_tests: add test case to test manage_add-spare against cluster-raid10

02r10_Manage_add-spare: it has 2 scenarios against manage_add-spare.
1. 2 active disks in md array, using add-spare to add spare disk.
2. 2 active disks and 1 spare in array, add-spare 1 new disk into array,
   then check spares.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test manage_add-spare against cluster-raid1
Zhilong Liu [Fri, 2 Feb 2018 06:10:56 +0000 (14:10 +0800)] 
clustermd_tests: add test case to test manage_add-spare against cluster-raid1

02r1_Manage_add-spare: it has 2 scenarios against manage_add-spare.
1. 2 active disks in md array, using add-spare to add spare disk.
2. 2 active disks and 1 spare in array, add-spare 1 new disk into array,
   then check spares.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test manage_add against cluster-raid10
Zhilong Liu [Fri, 2 Feb 2018 06:10:55 +0000 (14:10 +0800)] 
clustermd_tests: add test case to test manage_add against cluster-raid10

02r10_Manage_add: it covers testing 2 scenarios against manage_add.
1. 2 active disks in md array, set 1 disk 'fail' and 'remove' it
   from array, then add 1 pure disk into array.
2. 2 active disks in array, add 1 new disk into array directly, now
   the 'add' in equal to 'add-spare'.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test manage_add against cluster-raid1
Zhilong Liu [Fri, 2 Feb 2018 06:10:54 +0000 (14:10 +0800)] 
clustermd_tests: add test case to test manage_add against cluster-raid1

02r1_Manage_add: it covers testing 2 scenarios against manage_add.
1. 2 active disks in md array, set 1 disk 'fail' and 'remove' it
   from array, then add 1 pure disk into array.
2. 2 active disks in array, add 1 new disk into array directly, now
   the 'add' in equal to 'add-spare'.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test grow_add against cluster-raid1
Zhilong Liu [Fri, 2 Feb 2018 06:10:53 +0000 (14:10 +0800)] 
clustermd_tests: add test case to test grow_add against cluster-raid1

01r1_Grow_add: It contains 3 kinds of growing array.
1. 2 active disk in md array, grow and add new disk into array.
2. 2 active and 1 spare disk in md array, grow and add new disk
   into array.
3. 2 active and 1 spare disk in md array, grow the device-number
   and make spare disk as active disk in array.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test switching bitmap against cluster-raid10
Zhilong Liu [Fri, 2 Feb 2018 06:10:52 +0000 (14:10 +0800)] 
clustermd_tests: add test case to test switching bitmap against cluster-raid10

01r10_Grow_bitmap-switch:
It tests switching bitmap during three modes include of
clustered, none and internal, this case is testing the
clustered raid10.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoclustermd_tests: add test case to test switching bitmap against cluster-raid1
Zhilong Liu [Fri, 2 Feb 2018 06:10:51 +0000 (14:10 +0800)] 
clustermd_tests: add test case to test switching bitmap against cluster-raid1

01r1_Grow_bitmap-switch:
It tests switching bitmap during three modes include of
clustered, none and internal, this case is testing the
clustered raid1.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomanpage: add prompt in --zero-superblock against clustered raid
Zhilong Liu [Fri, 2 Feb 2018 06:10:50 +0000 (14:10 +0800)] 
manpage: add prompt in --zero-superblock against clustered raid

Clustered raid would be damaged if calls --zero-superblock
incorrectly, so add prompt in --zero-superblock chapter of
manpage. Such as: cluster node1 has assembled cluster-md,
but calls --zero-superblock in other cluster node.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/clustermd_tests: delete meaningless commands in check
Zhilong Liu [Fri, 2 Feb 2018 06:10:49 +0000 (14:10 +0800)] 
mdadm/clustermd_tests: delete meaningless commands in check

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/clustermd_tests: add nobitmap in check
Zhilong Liu [Fri, 2 Feb 2018 06:10:48 +0000 (14:10 +0800)] 
mdadm/clustermd_tests: add nobitmap in check

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: add do_clean to ensure each case only catch its own testlog
Zhilong Liu [Fri, 2 Feb 2018 06:10:47 +0000 (14:10 +0800)] 
mdadm/test: add do_clean to ensure each case only catch its own testlog

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: add disk metadata infos in save_log
Zhilong Liu [Fri, 2 Feb 2018 06:10:46 +0000 (14:10 +0800)] 
mdadm/test: add disk metadata infos in save_log

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: improve filtering r10 from raid1 in raidtype
Zhilong Liu [Fri, 2 Feb 2018 06:10:45 +0000 (14:10 +0800)] 
mdadm/test: improve filtering r10 from raid1 in raidtype

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoAssemble: cleanup the failure path
Guoqing Jiang [Mon, 22 Jan 2018 09:12:10 +0000 (17:12 +0800)] 
Assemble: cleanup the failure path

There are some failure paths which share common codes
before return, so simplify them by move common codes
to the end of function, and just goto out in case
failure happened.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoAssemble: provide protection when clustered raid do assemble
Guoqing Jiang [Mon, 22 Jan 2018 09:12:09 +0000 (17:12 +0800)] 
Assemble: provide protection when clustered raid do assemble

The previous patch provides protection for other modes
such as CREATE, MANAGE, GROW and INCREMENTAL. And for
ASSEMBLE mode, we also need to protect during the process
of assemble clustered raid.

However, we can only know the array is clustered or not
when the metadata is ready, so the lock_cluster is called
after select_devices(). And we could re-read the metadata
when doing auto-assembly, so refresh the locking.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: improve the dlm locking mechanism for clustered raid
Guoqing Jiang [Mon, 22 Jan 2018 09:12:08 +0000 (17:12 +0800)] 
mdadm: improve the dlm locking mechanism for clustered raid

Previously, the dlm locking only protects several
functions which writes to superblock (update_super,
add_to_super and store_super), and we missed other
funcs such as add_internal_bitmap. We also need to
call the funcs which read superblock under the
locking protection to avoid consistent issue.

So let's remove the dlm stuffs from super1.c, and
provide the locking mechanism to the main() except
assemble mode which will be handled in next commit.
And since we can identify it is a clustered raid or
not based on check the different conditions of each
mode, so the change should not have effect on native
array.

And we improve the existed locking stuffs as follows:

1. replace ls_unlock with ls_unlock_wait since we
should return when unlock operation is complete.

2. inspired by lvm, let's also try to use the existed
lockspace first before creat a lockspace blindly if
the lockspace not released for some reason.

3. try more times before quit if EAGAIN happened for
locking.

Note: for MANAGE mode, we do not need to get lock if
node just want to confirm device change, otherwise we
can't add a disk to cluster since all nodes are compete
for the lock.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoAdd one sanity check for missing device
Xiao Ni [Wed, 21 Feb 2018 05:04:45 +0000 (13:04 +0800)] 
Add one sanity check for missing device

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: prevent out-of-date reshaping devices from force assemble
BingJing Chang [Thu, 22 Feb 2018 07:00:28 +0000 (15:00 +0800)] 
mdadm: prevent out-of-date reshaping devices from force assemble

With "--force", we can assemble the array even if some superblocks
appear out-of-date. But their data layout is regarded to make sense.
In reshape cases, if two devices claims different reshape progresses,
we cannot forcely assemble them back to array. Kernel will treat only
one of them as reshape progress. However, their data is still laid on
different layouts. It may lead to disaster if reshape goes on.

Reproducible Steps:
mdadm -C /dev/md0 --assume-clean -l5 -n3 /dev/loop[012]
mdadm -a /dev/md0 /dev/loop3
mdadm -G /dev/md0 -n4
mdadm -f /dev/md0 /dev/loop0 # after a period
mdadm -S /dev/md0 # after another period
mdadm -E /dev/loop[01] # make sure that they claims different ones

mdadm -Af -R /dev/md0 /dev/loop[023] # give no enough devices for
force_array() to pick non-fresh devices
cat /sys/block/md0/md/reshape_position # You can see that Kernel resume
reshape the from any progress of them.

Note: The unit of mdadm -E is KB, but reshape_position's is sector.

In order to prevent disaster, we add logics to prevent devices with
different reshape progress from being added into the array.

Reported-by: Allen Peng <allenpeng@synology.com>
Reviewed-by: Alex Wu <alexwu@synology.com>
Signed-off-by: BingJing Chang <bingjingc@synology.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: update product name in error message
Michal Zylowski [Fri, 16 Feb 2018 14:51:33 +0000 (15:51 +0100)] 
imsm: update product name in error message

This commit extends ab0c6bb ("imsm: update name in --detail-platform").
Refer user to RSTe/VROC manual when needed.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoAdd udev-md-raid-safe-timeouts.rules
Jonathan Underwood [Fri, 26 Jan 2018 23:54:26 +0000 (23:54 +0000)] 
Add udev-md-raid-safe-timeouts.rules

These udev rules attempt to set a safe kernel controller
timeout for disks containing RAID level 1 or higher
partitions for commodity disks which do not have SCTERC
capability, or do have it but it is disabled.

No attempt is made to change the STCERC settings on devices
which support it.

This attempts to mitigate the problem described here:

    https://raid.wiki.kernel.org/index.php/Timeout_Mismatch
    http://strugglers.net/~andy/blog/2015/11/09/linux-software-raid-and-drive-timeouts/

where the kernel controller may timeout on a read from a
disk after the default timeout of 30 seconds and consequently
cause mdraid to regard the disk as dead and eject it from the
RAID array.

The mitigation is to set the timeout to 180 seconds for disks
which contain a RAID level 1 or higher partition.

Signed-off-by: Jonathan G. Underwood <jonathan.underwood@gmail.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoSubdevs can't be all missing when create raid device
Xiao Ni [Fri, 26 Jan 2018 08:42:16 +0000 (16:42 +0800)] 
Subdevs can't be all missing when create raid device

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoGrow.c: Block any level migration with chunk size change
Mariusz Tkaczyk [Thu, 25 Jan 2018 14:12:50 +0000 (15:12 +0100)] 
Grow.c: Block any level migration with chunk size change

Mixing level and chunk changes in one grow operation is not supported.
Mdadm performs level migration correctly and ignores new chunk, but
after migration it tries to write this chunk to sysfs properties.
This is dangerous and can cause unexpected behaviours.

Block it before level migration starts.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoAssemble: prevent segfault with faulty "best" devices
Andrea Righi [Tue, 8 Aug 2017 17:48:07 +0000 (19:48 +0200)] 
Assemble: prevent segfault with faulty "best" devices

I was able to trigger this curious problem that seems to happen only on
one of our server:

Segmentation fault

This md volume is a raid1 volume made of 2 device mapper (dm-multipath)
devices and the underlying LUNs are imported via iSCSI.

Applying the following patch (see below) seems to fix the problem:

mdadm: /dev/md/10.4.237.12-volume has been started with 2 drives.

But I'm not sure if it's the right fix or if there're some other
problems that I'm missing.

More details about the md superblocks that might help to better
understand the nature of the problem:

dev: 36001405a04ed0c104881100000000000p2
/dev/mapper/36001405a04ed0c104881100000000000p2:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x1
     Array UUID : 5f3e8283:7f831b85:bc1958b9:6f2787a4
           Name : 10.4.237.12-volume
  Creation Time : Thu Jul 27 14:43:16 2017
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 1073729503 (511.99 GiB 549.75 GB)
     Array Size : 536864704 (511.99 GiB 549.75 GB)
  Used Dev Size : 1073729408 (511.99 GiB 549.75 GB)
    Data Offset : 8192 sectors
   Super Offset : 8 sectors
   Unused Space : before=8104 sectors, after=95 sectors
          State : clean
    Device UUID : 16dae7e3:42f3487f:fbeac43a:71cf1f63

Internal Bitmap : 8 sectors from superblock
    Update Time : Tue Aug  8 11:12:22 2017
  Bad Block Log : 512 entries available at offset 72 sectors
       Checksum : 518c443e - correct
         Events : 167

   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
dev: 36001405a04ed0c104881200000000000p2
/dev/mapper/36001405a04ed0c104881200000000000p2:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x1
     Array UUID : 5f3e8283:7f831b85:bc1958b9:6f2787a4
           Name : 10.4.237.12-volume
  Creation Time : Thu Jul 27 14:43:16 2017
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 1073729503 (511.99 GiB 549.75 GB)
     Array Size : 536864704 (511.99 GiB 549.75 GB)
  Used Dev Size : 1073729408 (511.99 GiB 549.75 GB)
    Data Offset : 8192 sectors
   Super Offset : 8 sectors
   Unused Space : before=8104 sectors, after=95 sectors
          State : clean
    Device UUID : ef612bdd:e475fe02:5d3fc55e:53612f34

Internal Bitmap : 8 sectors from superblock
    Update Time : Tue Aug  8 11:12:22 2017
  Bad Block Log : 512 entries available at offset 72 sectors
       Checksum : c39534fd - correct
         Events : 167

   Device Role : Active device 1
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)

dev: 36001405a04ed0c104881100000000000p2
00001000  fc 4e 2b a9 01 00 00 00  01 00 00 00 00 00 00 00  |.N+.............|
00001010  5f 3e 82 83 7f 83 1b 85  bc 19 58 b9 6f 27 87 a4  |_>........X.o'..|
00001020  31 30 2e 34 2e 32 33 37  2e 31 32 2d 76 6f 6c 75  |10.4.237.12-volu|
00001030  6d 65 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |me..............|
00001040  64 50 7a 59 00 00 00 00  01 00 00 00 00 00 00 00  |dPzY............|
00001050  80 cf ff 3f 00 00 00 00  00 00 00 00 02 00 00 00  |...?............|
00001060  08 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00001070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00001080  00 20 00 00 00 00 00 00  df cf ff 3f 00 00 00 00  |. .........?....|
00001090  08 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000010a0  00 00 00 00 00 00 00 00  16 da e7 e3 42 f3 48 7f  |............B.H.|
000010b0  fb ea c4 3a 71 cf 1f 63  00 00 08 00 48 00 00 00  |...:q..c....H...|
000010c0  54 f0 89 59 00 00 00 00  a7 00 00 00 00 00 00 00  |T..Y............|
000010d0  ff ff ff ff ff ff ff ff  9c 43 8c 51 80 00 00 00  |.........C.Q....|
000010e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001100  00 00 01 00 fe ff fe ff  fe ff fe ff fe ff fe ff  |................|
00001110  fe ff fe ff fe ff fe ff  fe ff fe ff fe ff fe ff  |................|
*
00001200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002000  62 69 74 6d 04 00 00 00  5f 3e 82 83 7f 83 1b 85  |bitm...._>......|
00002010  bc 19 58 b9 6f 27 87 a4  a7 00 00 00 00 00 00 00  |..X.o'..........|
00002020  a7 00 00 00 00 00 00 00  80 cf ff 3f 00 00 00 00  |...........?....|
00002030  00 00 00 00 00 00 00 01  05 00 00 00 00 00 00 00  |................|
00002040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00003100  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
00004000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
003ffe00
dev: 36001405a04ed0c104881200000000000p2
00001000  fc 4e 2b a9 01 00 00 00  01 00 00 00 00 00 00 00  |.N+.............|
00001010  5f 3e 82 83 7f 83 1b 85  bc 19 58 b9 6f 27 87 a4  |_>........X.o'..|
00001020  31 30 2e 34 2e 32 33 37  2e 31 32 2d 76 6f 6c 75  |10.4.237.12-volu|
00001030  6d 65 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |me..............|
00001040  64 50 7a 59 00 00 00 00  01 00 00 00 00 00 00 00  |dPzY............|
00001050  80 cf ff 3f 00 00 00 00  00 00 00 00 02 00 00 00  |...?............|
00001060  08 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00001070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00001080  00 20 00 00 00 00 00 00  df cf ff 3f 00 00 00 00  |. .........?....|
00001090  08 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000010a0  01 00 00 00 00 00 00 00  ef 61 2b dd e4 75 fe 02  |.........a+..u..|
000010b0  5d 3f c5 5e 53 61 2f 34  00 00 08 00 48 00 00 00  |]?.^Sa/4....H...|
000010c0  54 f0 89 59 00 00 00 00  a7 00 00 00 00 00 00 00  |T..Y............|
000010d0  ff ff ff ff ff ff ff ff  5b 34 95 c3 80 00 00 00  |........[4......|
000010e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001100  00 00 01 00 fe ff fe ff  fe ff fe ff fe ff fe ff  |................|
00001110  fe ff fe ff fe ff fe ff  fe ff fe ff fe ff fe ff  |................|
*
00001200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002000  62 69 74 6d 04 00 00 00  5f 3e 82 83 7f 83 1b 85  |bitm...._>......|
00002010  bc 19 58 b9 6f 27 87 a4  a7 00 00 00 00 00 00 00  |..X.o'..........|
00002020  a7 00 00 00 00 00 00 00  80 cf ff 3f 00 00 00 00  |...........?....|
00002030  00 00 00 00 00 00 00 01  05 00 00 00 00 00 00 00  |................|
00002040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00003100  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
00004000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
003ffe00

Assemble: prevent segfault with faulty "best" devices

In Assemble(), after context reload, best[i] can be -1 in some cases,
and before checking if this value is negative we use it to access
devices[j].i.disk.raid_disk, potentially causing a segfault.

Check if best[i] is negative before using it to prevent this potential
segfault.

Signed-off-by: Andrea Righi <andrea@betterlinux.com>
Fixes: 69a481166be6 ("Assemble array with write journal")
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Robert LeBlanc <robert@leblancnet.us>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/clustermd_tests: add test case to test grow_resize cluster-raid10
Zhilong Liu [Tue, 16 Jan 2018 09:45:09 +0000 (17:45 +0800)] 
mdadm/clustermd_tests: add test case to test grow_resize cluster-raid10

01r10_Grow_resize:
1. Create clustered raid10 with smaller size, then resize the
mddev to max size, finally change back to smaller size.
2. Create clustered raid10 with smaller chunk-size, then resize
it to larger, and trigger reshape.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/clustermd_tests: add test case to test creating cluster-raid10
Zhilong Liu [Tue, 16 Jan 2018 09:45:08 +0000 (17:45 +0800)] 
mdadm/clustermd_tests: add test case to test creating cluster-raid10

00r10_Create: It contains 4 scenarios of creating clustered raid10.
1. General creating, master node does resync and slave node does
   Pending.
2. Creating clustered raid10 with --assume-clean.
3. Creating clustered raid10 with spare disk.
4. Creating clustered raid10 with --name.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/clustermd_tests: add test case to test grow_resize cluster-raid1
Zhilong Liu [Tue, 16 Jan 2018 09:45:07 +0000 (17:45 +0800)] 
mdadm/clustermd_tests: add test case to test grow_resize cluster-raid1

01r1_Grow_resize: Create clustered raid1 with smaller size, then
resize the mddev to max size, finally change back to smaller size.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/clustermd_tests: add test case to test creating cluster-raid1
Zhilong Liu [Tue, 16 Jan 2018 09:45:06 +0000 (17:45 +0800)] 
mdadm/clustermd_tests: add test case to test creating cluster-raid1

00r1_Create: It contains 4 scenarios of creating clustered raid1.
1. General creating, master node does resync and slave node does
   Pending.
2. Creating clustered raid1 with --assume-clean parameter.
3. Creating clustered raid1 with spare disk.
4. Creating clustered raid1 with --name.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: add '--testdir=' to switch choosing test suite
Zhilong Liu [Tue, 16 Jan 2018 09:45:05 +0000 (17:45 +0800)] 
mdadm/test: add '--testdir=' to switch choosing test suite

By now, mdadm has two test suites to cover traditional sofr-raid
testing and clustermd testing, the '--testdir=' option supports
to switch which suite to test, tests/ or clustermd_tests/.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: enable clustermd testing under clustermd_tests/
Zhilong Liu [Tue, 16 Jan 2018 09:45:04 +0000 (17:45 +0800)] 
mdadm/test: enable clustermd testing under clustermd_tests/

For clustermd testing, it needs user deploys the basic cluster
manually, test scripts don't cover auto-deploy cluster due to
different linux distributions have lots of difference.
Then complete the configuration in cluster_conf, please refer to
the detail comments in 'cluster_conf'.

1. 'func.sh' source file, it achieves feature functions for
   clustermd testing.
2. 'cluster_conf' configure file, it contains two parts as
   the input of testing.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: move some functions to new source file
Zhilong Liu [Tue, 16 Jan 2018 09:45:03 +0000 (17:45 +0800)] 
mdadm/test: move some functions to new source file

To make 'test' file concise, move some functions to new file
tests/func.sh, and leave core functions in 'test' file.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: correct the logic operation in save_log
Zhilong Liu [Tue, 16 Jan 2018 09:45:02 +0000 (17:45 +0800)] 
mdadm/test: correct the logic operation in save_log

1. delete the mdadm -As, keep the original testing scene intact.
2. move some actions into 'array' test, 'mdadm -D $array' would
   complain errors if $array is null.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agopolicy.c: Avoid to take spare without defined domain by imsm
Mariusz Tkaczyk [Thu, 11 Jan 2018 11:39:49 +0000 (12:39 +0100)] 
policy.c: Avoid to take spare without defined domain by imsm

Only Imsm get_disk_controller_domain returns disk controller domain for
each disk. It causes that mdadm automatically creates disk controller
domain policy for imsm metadata, and imsm containers in the same disk
controller domain can take spare for recovery.

Ignore spares if only one imsm domain is matched.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: update name in --detail-platform
Artur Paszkiewicz [Tue, 16 Jan 2018 11:23:09 +0000 (12:23 +0100)] 
imsm: update name in --detail-platform

For IMSM enterprise firmware starting with major version 6, present the
platform name as Intel VROC.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: allow clustered raid10 to be created with default layout
Guoqing Jiang [Wed, 3 Jan 2018 07:01:22 +0000 (15:01 +0800)] 
mdadm: allow clustered raid10 to be created with default layout

Since the default layout of raid10 is n2, so we
should allow the behavior.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomanagemon: Don't add disk to the array after it has started
Tomasz Majchrzak [Thu, 7 Dec 2017 09:23:54 +0000 (10:23 +0100)] 
managemon: Don't add disk to the array after it has started

If disk has disappeared from the system and appears again, it is added to the
corresponding container as long the metadata matches and disk number is set.
This code had no effect on imsm until commit 20dc76d15b40 ("imsm: Set disk slot
number"). Now the disk is added to container but not to the array - it is
correct as the disk is out-of-sync. Rebuild should start for the disk but it
doesn't. There is the same behaviour for both imsm and ddf metadata.

There is no point to handle out-of-sync disk as "good member of array" so
remove that part of code. There are no scenarios when monitor is already
running and disk can be safely added to the array. Just write initial metadata
to the disk so it's taken for rebuild.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/grow: correct the s->size > 1 to make 'max' work
Zhilong Liu [Thu, 23 Nov 2017 03:10:44 +0000 (11:10 +0800)] 
mdadm/grow: correct the s->size > 1 to make 'max' work

s->size > 1 : s->size is '1' when '--grow --size max'
parameter is specified, so correct this test here.

Fixes: 1b21c449e6f2 ("mdadm/grow: adding a test to ensure resize was required")
Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: continue resync on 3-disk RAID10
Maksymilian Kunt [Mon, 13 Nov 2017 11:30:49 +0000 (12:30 +0100)] 
imsm: continue resync on 3-disk RAID10

If RAID10 gets degraded during resync and is stopped, it doesn't continue
resync after automatic assemble and it is reported to be in sync. Resync
is blocked because the disk is missing. It should not happen for RAID10 as
it can still continue with 3 disks.

Count missing disks. Block resync only if number of missing disks exceeds
limit for given RAID level (only different for RAID10). Check if the
disk under recovery is present. If not, resync should be allowed to run.

Signed-off-by: Maksymilian Kunt <maksymilian.kunt@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor/msg: Don't print error message if mdmon doesn't run
Mariusz Tkaczyk [Tue, 21 Nov 2017 10:30:20 +0000 (11:30 +0100)] 
Monitor/msg: Don't print error message if mdmon doesn't run

Commit 4515fb28a53a ("Add detail information when can not connect
monitor") was added to warn about failed connection to monitor in
WaitClean function (see link below).

Mdmon runs for IMSM containers when they have array with redundancy so
if mdmon doesn't run, mdadm prints this error. This is misleading and
unnecessary. Just print it in WaitClean function.

The sock in WaitClean is deprecated so it is removed.

Link: https://bugzilla.redhat.com/show_bug.cgi?id=1375002
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agosysfs: include faulty drive in disk count
Mariusz Tkaczyk [Tue, 7 Nov 2017 15:49:56 +0000 (16:49 +0100)] 
sysfs: include faulty drive in disk count

When the disk fails, it goes into faulty state first and it is removed
from the array in a while. It gives mdadm monitor a chance to see the disk
has failed and notify an event (e.g. FailSpare). It doesn't work when
sysfs is used to get a number of disks in the array as it skips faulty
disk. ioctl implementation doesn't differentiate between active and
faulty disk. Do the same for sysfs then. It should not matter that number
of disks reported is greater than list of disk structures returned by the
call because the same approach already takes place for offline disks.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: More precise message when spanned raid is created
Michal Zylowski [Wed, 8 Nov 2017 14:43:41 +0000 (15:43 +0100)] 
imsm: More precise message when spanned raid is created

When RAID is created between VMD and SATA disks, printed message is
"Mixing devices attached to different VMD domains is not allowed". This message
is unclear and misleading because creating spanned containers between different
VMD domains is allowed. Set error message to more precise text.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoTo support clustered raid10
Guoqing Jiang [Mon, 30 Oct 2017 09:09:51 +0000 (17:09 +0800)] 
To support clustered raid10

We are now considering to extend clustered raid to
support raid10. But only near layout is supported,
so make the check when create the array or switch
the bitmap from internal to clustered.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: fix reading scsi serial
Artur Paszkiewicz [Thu, 2 Nov 2017 15:10:57 +0000 (16:10 +0100)] 
imsm: fix reading scsi serial

Improve error detection after SG_IO ioctl. Checking only the return
value and response length is insufficient and leads to anomalies if a
drive does not have a serial number.

Reported-by: NeilBrown <neilb@suse.com>
Tested-by: NeilBrown <neilb@suse.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoIncremental: Use ->validate_geometry instead of ->avail_size
NeilBrown [Mon, 30 Oct 2017 04:43:41 +0000 (15:43 +1100)] 
Incremental: Use ->validate_geometry instead of ->avail_size

Since mdadm 3.3 is has not been correct to call ->avail_size if
metadata hasn't been read from the device.  ->validate_geometry
should be used instead.

Unfortunately array_try_spare() didn't get the memo, and it can crash
when adding a spare with no metdata.

So change it to use ->validate_geometry().

Only one place remains that uses ->avail_size(), and that is safe.

Also fix a comment with a typo.

Reported-and-tested-by: Bjørnar Ness <bjornar.ness@gmail.com>
Fixes: 641da7459192 ("super1: separate to version of _avail_space1().")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agosystemd: add %I to description of mdadm-last-resort services.
NeilBrown [Mon, 30 Oct 2017 00:42:15 +0000 (11:42 +1100)] 
systemd: add %I to description of mdadm-last-resort services.

Just like the other template services, include the instance
name (I%) in the description of
 mdadm-last-resort@.service
 mdadm-last-resort@.timer

so that it is clear from the logs which array is affected.

Reported-by: Andrei Borzenkov <arvidjaar@gmail.com>
Link: http://bugzilla.opensuse.org/show_bug.cgi?id=1064915
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/mdopen: create new function create_named_array for writing to new_array
Zhilong Liu [Mon, 16 Oct 2017 07:54:18 +0000 (15:54 +0800)] 
mdadm/mdopen: create new function create_named_array for writing to new_array

Split 'write to new_array' out into a function named create_named_array.
And fixed a trivial compiling warning 'warn_unused_result' against commit:
fdbf7aaa1956 (mdopen: call "modprobe md_mod" if it might be needed.)

Suggested-by: NeilBrown <neilb@suse.com>
Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/grow: adding a test to ensure resize was required
Zhilong Liu [Wed, 11 Oct 2017 08:53:12 +0000 (16:53 +0800)] 
mdadm/grow: adding a test to ensure resize was required

To fix the commit: 4b74a905a67e
(mdadm/grow: Component size must be larger than chunk size)

array.level > 1 : against the raids which chunk_size is meaningful.
s->size > 0 : ensure that changing component size has required.
array.chunk_size / 1024 > s->size : ensure component size should
be always >= current chunk_size when requires resize, otherwise,
mddev->pers->resize would be set mddev->dev_sectors as '0'.

Reported-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Suggested-by: NeilBrown <neilb@suse.com>
Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMove mdadm_env.sh out of /usr/lib/systemd
NeilBrown [Thu, 5 Oct 2017 06:13:17 +0000 (17:13 +1100)] 
Move mdadm_env.sh out of /usr/lib/systemd

The systemd developers like to keep control of the
lib/systemd namespace, and haven't approved of the use
of lib/systemd/scripts.  So we should stop using it.

Move the mdadm_env.sh script, optionally sourced by
mdmonitor.service, to a new directory /usr/lib/mdadm.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdcheck: improve cleanup
NeilBrown [Fri, 6 Oct 2017 01:34:40 +0000 (12:34 +1100)] 
mdcheck: improve cleanup

We should remove the tmp file on signals as well as on exit.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdcheck: add some logging.
NeilBrown [Fri, 6 Oct 2017 01:33:36 +0000 (12:33 +1100)] 
mdcheck: add some logging.

Use 'logger' to report when mdcheck starts, stops, or continues
the check on an array.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/mdstat: correct the strncmp number 4 as 6
Zhilong Liu [Mon, 9 Oct 2017 08:21:14 +0000 (16:21 +0800)] 
mdadm/mdstat: correct the strncmp number 4 as 6

mdstat: it should be corrected as 6 when strncmp 'resync'.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/mdstat: fixup a number of '==' broken formatting
Zhilong Liu [Mon, 9 Oct 2017 08:21:13 +0000 (16:21 +0800)] 
mdadm/mdstat: fixup a number of '==' broken formatting

This commit doesn't change any codes, just tidy up the
code formatting.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: Add one test case for raid5 reshape
Xiao Ni [Tue, 10 Oct 2017 11:32:52 +0000 (19:32 +0800)] 
mdadm/test: Add one test case for raid5 reshape

This case tries to allow raid5 reshape to use backwards direction.
It changes chunksize after reshape and stops the raid. Then starts
the raid again.

Signed-off-by: Xiao Ni <xni@redhat.com>
Suggested-by: Jes Sorensen <jes.sorensen@gmail.com>
Suggested-by: Zhilong Liu <zlliu@suse.com>
Suggested-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdmon: get safe mode delay file descriptor early
Tomasz Majchrzak [Wed, 4 Oct 2017 08:18:21 +0000 (10:18 +0200)] 
mdmon: get safe mode delay file descriptor early

After switch root new mdmon is started. It sends initrd mdmon a signal
to terminate. initrd mdmon receives it and switches the safe mode delay
to 1 ms in order to get array to clean state and flush last version of
metadata. The problem is sysfs filesystem is not available to initrd mdmon
after switch root so the original safe mode delay is unchanged. The delay
is set to few seconds - if there is a lot of traffic on the filesystem,
initrd mdmon doesn't terminate for a long time (no clean state). There
are 2 instances of mdmon. initrd mdmon flushes metadata when array goes
to clean state but this metadata might be already outdated.

Use file descriptor obtained on mdmon start to change safe mode delay.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: Set disk slot number
Mariusz Tkaczyk [Tue, 3 Oct 2017 12:49:49 +0000 (14:49 +0200)] 
imsm: Set disk slot number

If first disk of IMSM RAID1 is failed but still present in the system,
the array is not auto-assembled. Auto-assemble uses raid disk slot from
metadata to index disks. As it's not set, the valid disk is seen as a
replacement disk and its metadata is ignored. The problem is not
observed for other RAID levels as they have more than 2 disks -
replacement disks are only stored under uneven indexes so third disk
metadata is used in such scenario.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Reviewed-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoGrow: Use all 80 characters
Jes Sorensen [Mon, 2 Oct 2017 21:21:40 +0000 (17:21 -0400)] 
Grow: Use all 80 characters

Try to use the full line length and avoid breaking up lines excessively.
Equally break up lines that are too long for no reason.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: write initial ppl on a disk added for rebuild
Artur Paszkiewicz [Thu, 28 Sep 2017 12:41:18 +0000 (14:41 +0200)] 
imsm: write initial ppl on a disk added for rebuild

When rebuild is initiated by the UEFI driver it is possible that the new
disk will not contain a valid ppl header. Just write the initial ppl
and don't abort assembly.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: use correct map when validating ppl
Artur Paszkiewicz [Thu, 28 Sep 2017 12:41:17 +0000 (14:41 +0200)] 
imsm: use correct map when validating ppl

Use the first map to get the correct disk when rebuilding and not the
failed disk from the second map.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: always do ppl recovery when starting a rebuilding array
Artur Paszkiewicz [Thu, 28 Sep 2017 12:41:16 +0000 (14:41 +0200)] 
imsm: always do ppl recovery when starting a rebuilding array

Set resync_start to 0 when starting a rebuilding array to make the
kernel perform ppl recovery before the rebuild.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: Write empty PPL header if assembling regular clean array.
Pawel Baldysiak [Thu, 28 Sep 2017 12:41:15 +0000 (14:41 +0200)] 
imsm: Write empty PPL header if assembling regular clean array.

If array was initially assembled with kernel without PPL support -
initial header was never written to the drive.
If initial resync was completed and system is rebooted to kernel with
PPL support - mdadm prevents from assembling normal clean array
due to lack of valid PPL.
Write empty header when assemble normal clean array, so the
its assamble is no longer blocked.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: don't skip resync when an invalid ppl header is found
Artur Paszkiewicz [Thu, 28 Sep 2017 12:41:14 +0000 (14:41 +0200)] 
imsm: don't skip resync when an invalid ppl header is found

If validate_ppl_imsm() detects an invalid ppl header it will be
overwritten with a valid, empty ppl header. But if we are assembling an
array after unclean shutdown this will cause the kernel to skip resync
after ppl recovery. We don't want that because if there was an invalid
ppl it's best to assume that the ppl recovery is not enough to make the
array consistent and a full resync should be performed. So when
overwriting the invalid ppl add one ppl_header_entry with a wrong
checksum. This will prevent the kernel from skipping resync after ppl
recovery.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoGrow: fix switching on PPL during recovery
Pawel Baldysiak [Thu, 28 Sep 2017 12:41:13 +0000 (14:41 +0200)] 
Grow: fix switching on PPL during recovery

If raid memeber is not in sync - it is skipped during
enablement of PPL. This is not correct, since the drive that
we are currently recovering to does not have ppl_size and ppl_sector
properly set in sysfs.
Remove this skipping, so all drives are updated during turning on the PPL.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: switch to multiple ppls automatically during assemble
Pawel Baldysiak [Thu, 28 Sep 2017 12:41:12 +0000 (14:41 +0200)] 
imsm: switch to multiple ppls automatically during assemble

If user has array with single ppl -
update the metadata to use multiple ppls.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoZeroout whole ppl space during creation/force assemble
Pawel Baldysiak [Thu, 28 Sep 2017 12:41:11 +0000 (14:41 +0200)] 
Zeroout whole ppl space during creation/force assemble

PPL area should be cleared before creation/force assemble.
If the drive was used in other RAID array, it might contains PPL from it.
There is a risk that mdadm recognizes those PPLs and
refuses to assemble the RAID due to PPL conflict with created
array.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: validate multiple ppls during assemble
Pawel Baldysiak [Thu, 28 Sep 2017 12:41:10 +0000 (14:41 +0200)] 
imsm: validate multiple ppls during assemble

Change validation algorithm to check validity of multiple ppls that
are stored in PPL area.

If read error occurs during - treat the all PPLs as invalid -
there is no guarantee that this one was not latest. If the header CRC is
incorrect - assume that there are no further PPLs in PPL area.

If whole PPL area was written at least once - there is a possibility that
old PPL (with lower generation number) will follow the recent one
(with higest generation number). Compare those generation numbers to check
which PPL is latest.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: Add support for multiple ppls
Pawel Baldysiak [Thu, 28 Sep 2017 12:41:09 +0000 (14:41 +0200)] 
imsm: Add support for multiple ppls

Add interpreting new rwh_policy bits. Set PPL size as 1MB.
If new array with ppl is created - use new implementation of ppl by
default.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agosuper1: Add support for multiple-ppls
Pawel Baldysiak [Thu, 28 Sep 2017 12:41:08 +0000 (14:41 +0200)] 
super1: Add support for multiple-ppls

Add support for super1 with multiple ppls. Extend ppl area size to 1MB.
Use 1MB as default during creation. Always start array as single ppl -
if kernel is capable of multiple ppls and there is enough space reserved -
it will switch the policy during first metadata update.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoDon't abort starting the array if kernel does not support ppl
Artur Paszkiewicz [Thu, 28 Sep 2017 12:41:07 +0000 (14:41 +0200)] 
Don't abort starting the array if kernel does not support ppl

Change the behavior of assemble and create for consistency-policy=ppl
for external metadata arrays. If the kernel does not support ppl, don't
abort but print a warning and start the array without ppl
(consistency-policy=resync). No change for native md arrays because the
kernel will not allow starting the array if it finds an unsupported
feature bit in the superblock.

In sysfs_add_disk() check consistency_policy in the mdinfo structure
that represents the array, not the disk and read the current consistency
policy from sysfs in mdmon's manage_member(). This is necessary to make
sysfs_add_disk() honor the actual consistency policy and not what is in
the metadata. Also remove all the places where consistency_policy is set
for a disk's mdinfo - it is a property of the array, not the disk.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: fixes some trivial typos in comments
Zhilong Liu [Tue, 5 Sep 2017 09:41:38 +0000 (17:41 +0800)] 
mdadm: fixes some trivial typos in comments

fix some trivial typos in comments.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/manpage: disable bitmap_resize for external file bitmap
Zhilong Liu [Tue, 5 Sep 2017 09:41:37 +0000 (17:41 +0800)] 
mdadm/manpage: disable bitmap_resize for external file bitmap

Update the manpage in "SIZE CHANGES" against the md commit.
Commit: e8a27f836f165c26f867ece7f31eb5c811692319
(md/bitmap: disable bitmap_resize for file-backed bitmaps.)

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/grow: Component size must be larger than chunk size
Zhilong Liu [Tue, 5 Sep 2017 09:41:36 +0000 (17:41 +0800)] 
mdadm/grow: Component size must be larger than chunk size

Grow: Changing component size must be larger than current
chunk size against stripe raids, otherwise Grow_reshape()
would set s->size to '0'.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor: Check redundancy for arrays
Mariusz Tkaczyk [Mon, 4 Sep 2017 10:52:46 +0000 (12:52 +0200)] 
Monitor: Check redundancy for arrays

GET_MISMATCH option doesn't exist for RAID arrays without redundancy
so sysfs_read fails if this information is requested. Set options
according to the device using information from /proc/mdstat.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: New disk controller domains
Mariusz Tkaczyk [Thu, 7 Sep 2017 14:05:09 +0000 (16:05 +0200)] 
imsm: New disk controller domains

Add disk controller domain for nvme and vmd devices to prevent moving
spares between different domains.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoGrow: stop previous reshape process first
Tomasz Majchrzak [Thu, 7 Sep 2017 11:01:16 +0000 (13:01 +0200)] 
Grow: stop previous reshape process first

If array is stopped during reshape and assembled again straight away,
reshape process in a background might still be running. systemd doesn't
start a new service if one already exists. If there is a race, previous
process might terminate and new one is not created. Reshape doesn't
continue after assemble.

Tell systemd to restart the service rather than just start it. It will
assure previous service is stopped first. If it's not running, stopping
has no effect and only new process is started.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoClose mdfd before returning main function
Xiao Ni [Tue, 19 Sep 2017 06:06:46 +0000 (14:06 +0800)] 
Close mdfd before returning main function

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoutil: Code is 80 characters wide
Jes Sorensen [Fri, 29 Sep 2017 22:15:23 +0000 (18:15 -0400)] 
util: Code is 80 characters wide

Lets not make things uglier than they need to be.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoManage_subdevs(): Use a dev_t
Jes Sorensen [Fri, 29 Sep 2017 22:08:01 +0000 (18:08 -0400)] 
Manage_subdevs(): Use a dev_t

Use the correct type for rdev

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agosysfs_init_dev - take a dev_t argument
Jes Sorensen [Fri, 29 Sep 2017 22:04:06 +0000 (18:04 -0400)] 
sysfs_init_dev - take a dev_t argument

Be consistent and use the correct type.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agolib: devid2kname() should take a dev_t
Jes Sorensen [Fri, 29 Sep 2017 21:54:12 +0000 (17:54 -0400)] 
lib: devid2kname() should take a dev_t

Make devid2kname() and devid2devnm() consistent in their APIs

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdopen: call "modprobe md_mod" if it might be needed.
NeilBrown [Mon, 25 Sep 2017 05:52:19 +0000 (15:52 +1000)] 
mdopen: call "modprobe md_mod" if it might be needed.

Creating an array by opening a block-device with major number of 9
will transparently load the md module if needed.
Creating an array by opening
   /sys/module/md_mod/parameters/new_array
and writing to it won't, it will just fail if md_mod isn't loaded.

So when opening that file fails with ENOENT, run "modprobe md_mod" and
try again.

This fixes a bug whereby if you have "CREATE names=yes" in mdadm.conf,
and the md modules isn't loaded, then creating or assembling an
array will not honor the "names=yes" configuration.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: add new testcase for testing readonly/readwrite
Zhilong Liu [Mon, 28 Aug 2017 09:24:31 +0000 (17:24 +0800)] 
mdadm/test: add new testcase for testing readonly/readwrite

This is a test case for testing --readonly and
--readwrite feature, it covers common metadata
versions and raid levels.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: get rid of tests/check
Zhilong Liu [Mon, 28 Aug 2017 09:24:30 +0000 (17:24 +0800)] 
mdadm/test: get rid of tests/check

The tests/check can be removed due to check()
in new 'test' has covered various checking.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: get rid of the tests/testdev
Zhilong Liu [Mon, 28 Aug 2017 09:24:29 +0000 (17:24 +0800)] 
mdadm/test: get rid of the tests/testdev

It's time to get rid of the tests/testdev due
to it has covered by testdev() in new 'test'.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/test: use the first element of array as parsing condition
Zhilong Liu [Mon, 28 Aug 2017 09:24:28 +0000 (17:24 +0800)] 
mdadm/test: use the first element of array as parsing condition

it would complain "too many arguments" when array[] has
few members, it's proper to check whether or not array[0]
is null.

Reported-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/bitmap: examine-bitmap failed when bitmap is external mode
Zhilong Liu [Mon, 28 Aug 2017 09:24:27 +0000 (17:24 +0800)] 
mdadm/bitmap: examine-bitmap failed when bitmap is external mode

--examine-bitmap: the bitmap_file_open() shouldn't omit the
regular file descriptor when the bitmap is external mode.
Such as: ./mdadm -X /mnt/3

This commit is partial revert of commit 0a6bff09d416
(mdadm/util: unify fstat checking blkdev into function)

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: set journal_clean after scanning all disks
Song Liu [Tue, 29 Aug 2017 16:53:02 +0000 (09:53 -0700)] 
mdadm: set journal_clean after scanning all disks

Summary:
In Incremental.c:count_active(), max_events is tracked to show to
which devices are up to date. If a device has events==max_events+1,
getinfo_super() is called to reload the superblock from this
device. getinfo_super1() blindly set journal_clean to 0, which is
wrong.

This patch fixes this by tracking max_journal_events for all the
disks. After scanning all disks, journal_clean is set if
max_journal_events >= max_events-1.

Signed-off-by: Song Liu <songliubraving@fb.com>
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: install two more udev rules in mdadm.spec
Song Liu [Mon, 28 Aug 2017 22:20:35 +0000 (15:20 -0700)] 
mdadm: install two more udev rules in mdadm.spec

To avoid rpmbuild error.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoDetail: differentiate between container and inactive arrays
Mariusz Tkaczyk [Fri, 18 Aug 2017 10:00:23 +0000 (12:00 +0200)] 
Detail: differentiate between container and inactive arrays

Containers used to be handled as active arrays because GET_ARRAY_INFO
ioctl returns valid structure for them. As containers appear as inactive
in sysfs, the output for detail command has changed.

Stop relying on inactive state for containers. Make the output look the
same as in mdadm 4.0.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor: Include containers in spare migration
Mariusz Tkaczyk [Wed, 16 Aug 2017 12:59:46 +0000 (14:59 +0200)] 
Monitor: Include containers in spare migration

Spare migration doesn't work for external metadata. mdadm skips
a container with spare device because it is inactive. It used to work
because GET_ARRAY_INFO ioctl returned valid structure for a container
and mdadm treated such response as active container. Current
implementation checks it in sysfs where container is shown as inactive.

Adapt sysfs implementation to work the same way as ioctl.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor: containers don't have the same sysfs properties as arrays
Mariusz Tkaczyk [Wed, 16 Aug 2017 12:22:32 +0000 (14:22 +0200)] 
Monitor: containers don't have the same sysfs properties as arrays

GET_MISMATCH option doesn't exist for containers so sysfs_read fails if
this information is requested. Set options according to the device using
information from /proc/mdstat.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoDon't use exit(ERANGE)
NeilBrown [Fri, 4 Aug 2017 05:30:02 +0000 (15:30 +1000)] 
Don't use exit(ERANGE)

mdadm uses smaller exit codes like 0,1,2,3,4.
Using ERANGE is inconsistent and not helpful.
So change it to a more consistent number.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agosuper1: only set clustered flag when bitmap is present
NeilBrown [Fri, 4 Aug 2017 05:30:02 +0000 (15:30 +1000)] 
super1: only set clustered flag when bitmap is present

If no bitmap is present, then the test

if (__le32_to_cpu(bsb->nodes) > 1)

accesses uninitialised memory.  So move that test inside
a test for a bitmap being present.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoUse correct syntax for passing DEVLINKS to mdadm from udev
NeilBrown [Fri, 4 Aug 2017 05:30:02 +0000 (15:30 +1000)] 
Use correct syntax for passing DEVLINKS to mdadm from udev

 ${DEVLINKS}
is not valid udev syntax, and is passed through uninterpreted.
 $env{DEVLINKS}
or
  %e{DEVLINKS}
is correct.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoError messages should end with a newline character.
NeilBrown [Fri, 4 Aug 2017 05:30:02 +0000 (15:30 +1000)] 
Error messages should end with a newline character.

Add "\n" to the end of error messages which don't already
have one.  Also spell "opened" correctly.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoimsm: rebuild from 2-disk RAID10
Tomasz Majchrzak [Thu, 10 Aug 2017 13:47:22 +0000 (15:47 +0200)] 
imsm: rebuild from 2-disk RAID10

When RAID10 loses 2 disks and it is still operational, it cannot be
rebuilt. The rebuild process starts for the first disk and completes,
however completion is not recorded in metadata. There is an assumption
that rebuild completion corresponds to transition from degraded to
normal state. It's not the case for 2-disk RAID10 as it's still degraded
after rebuild to first disk completes.

Check if disk rebuild flag is set in the second map and clear it. So far it
has been checked only in the first map (where it was not set). The flag in
the second map has not been cleared but rebuild completion dropped second
map so the problem was not visible.

If rebuild completion is notified and array still has failed disks and is in
degraded state, check first if rebuild position is really unset (the same
check as for array in normal state). If so, mark migration as done but don't
change array state (it should remain degraded). Update failed disk number.

On rebuild start don't clear the rebuild flag in the destination map for all
the drives because failed state is lost for one of them. Just do a copy of
a map and clear the flag in the destination map for the disk that goes into
rebuild. Similarily preserve the rebuild flag in the map during disk removal.

If the disk is missing on array start and migration has been in progress,
don't just cancel it. Check first if maybe one of the disks was not under
rebuild (rebuild flag present both in source and destination map). If so,
rebuild was running despite of failed disk so there is no need to cancel
migration.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>