Commit Graph

3576 Commits

Author SHA1 Message Date
Jes Sorensen 28156667e5 gcc-8 coverity hack
Coverity still has issues with gcc-7, not to mention gcc-8. Hack around
it, until they fix it.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-06-04 14:49:59 -04:00
Zhilong Liu 7d4815f84c mdadm/test: correct tests/testdev as testdev in 02r5grow
Fixes: a6994ccc23 ("mdadm/test: get rid of the tests/testdev")

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-06-01 12:49:42 -04:00
Zhilong Liu 38e955cbf0 mdadm/test: mdadm needn't make install on the system
Fixes: beb71de04d ("mdadm/test: enable clustermd testing under clustermd_tests/")
clustermd_tests/func.sh:
remove unnecessary 'make install', just ensure 'make everything' has done.
the original idea is to make the /sbin/mdadm version same as ./mdadm, and
this breakage has pointed out by commit:
59416da78f ("tests/func.sh: Fix some total breakage in the test scripts")

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-06-01 12:46:13 -04:00
Xiao Ni 27e39ad31c Check major number of block device when querying md device
It give error message when query a non md device.
mdadm /dev/null
/dev/null: is an md device, but gives "Inappropriate ioctl for device" when queried

It's introduced by commit 5cb8599 and 8d0cd09
At first it checks whether a block is md device by function md_get_version.
In this function it does mainly two jobs:
1. send request by ioctl. (now it can be replace by argument ioctlerr)
2. check the block device major number which we don't do this.

We add the second judgement in this patch.

Fixes: 5cb8599 and 8d0cd09
Reported-by: Karsten Weiss <karsten.weiss@atos.net>
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-06-01 12:45:10 -04:00
Jes Sorensen 002a5978f0 super-ddf: Fix gcc-8.1 overflow warnings
Cast to types that are big enough to hold the values, but also guarantee
no overflow of the buffer keepts gcc happy.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-31 16:07:33 -04:00
Jes Sorensen 4d061b02b6 super1: Fix cases triggering gcc-8.1 strncpy truncate warning
Find the string length, copy it, and zero out the rest, instead of
relying on strncpy cleaning up for us.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-31 13:49:46 -04:00
Jes Sorensen 2dcd649271 super0: Use memmove() when adjusting sparc2.2 superblock data
memcpy() does not allow overlapping copies, switch to memmove()

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-31 13:19:57 -04:00
Jes Sorensen c1b78589cf mdopen: fix gcc 8.1 string overflow error
We already cut symlinks longer than 1000, so rely on this calling
readlink and error out if we are able to read more than 1000 bytes.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-31 13:11:21 -04:00
Jes Sorensen 9758983959 Monitor: Increase size of percentalert to avoid gcc warning
gcc-8.1 complains about truncated string operations. While we know
percent will never grow larger than 100, it doesn't cost us anything
to increase the size of 'percentalert' on the stack like this.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-31 11:45:21 -04:00
Michal Zylowski 5a5b3a6725 imsm: Do not require MDADM_EXPERIMENTAL flag anymore
Grow feature for IMSM metadata is currently fully supported and tested.
Reshape operation is not in experimental state anymore, so usage of this
flag is unnecessary.

Do not require MDADM_EXPERIMENTAL flag and remove obsolete information
from manual.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Acked-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Acked-by: Roman Sobanski <roman.sobanski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-31 11:30:36 -04:00
Michal Zylowski 59632db96b imsm: Do not block volume creation when container has disks with mixed sector size
Currently when created container keeps disks with mixed sector size (few
4K disks and some 512 disks) there is no possibility to create volume from
disks with one sector size.
Allow volume creation when given disks are related with mixed container.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-31 11:29:04 -04:00
Jes Sorensen ebad3af29b super-intel: Do not truncate last character of volume name
Clear up strncpy abuse to avoid gcc-8.1 complaining about truncating
the string.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-30 12:10:13 -04:00
Jes Sorensen 40659392ff super-intel: Avoid gcc-8.1 complaining about truncating snprintf()
We know the max size of the volume name, so no need to play the
snprintf() game.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-30 11:56:37 -04:00
Jes Sorensen 1cdc06dfda super-intel: Get rid of unnused string
No need to snprintf() into the string when we don't use it afterards

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-29 16:55:41 -04:00
Jes Sorensen 167d8bb830 super-intel: Use memcpy() to avoid confusing gcc
When added :0 to serial number and copying it back, use memcpy()
instead of strncpy() as we know the actual length. This stops gcc
from complaining with -Werror=stringop-truncation enabled

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-29 16:09:47 -04:00
Jes Sorensen 760365f944 Do not confuse gcc
gcc-8.1's -Werror=stringop-truncation is easily confused. Rather than
disabling the check, make it explicit we are OK truncating here.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-29 15:52:48 -04:00
Michal Zylowski 3e684231eb Fix misspelling of 'alignment' and 'geometry'
Set gemetry to geometry in error message about geometry validation failed.
Fix misspelled 'alignment' word in imsm_component_size_alignment_check
function.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-05-29 14:14:48 -04:00
Roman Sobanski 5d518de84e mdadm/grow: correct size and chunk_size casting
With commit 4b74a905a6
("mdadm/grow: Component size must be larger than chunk size") mdadm returns
incorrect message if size given to grow was greater than 2 147 483 647 K.
Cast chunk_size to "unsigned long long" instead of casting size to "int".

Signed-off-by: Roman Sobanski <roman.sobanski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-04-27 09:30:32 -04:00
Roman Sobanski 54865c30d5 Prevent create IMSM volume with size smaller than 1M or chunk
Block creation of the imsm volume when given size is smaller than 1M and
print appropriate message.

Commit b53bfba611
(imsm: use rounded size for metadata initialization) introduces issue with
rounding volume sizes smaller than 1M to 0. There is an inconsistency when
size smaller than 1M was given depends of what we give as target device:
1) When block devices was given created volume has maximum available size.
2) When container symlink was given created volume has size 0. Additionally
it causes below call trace:

[69587.891556] WARNING: CPU: 28 PID: 22485 at ../drivers/md/md.c:7582 md_seq_show+0x764/0x770 [md_mod]
[69588.066405] Call Trace:
[69588.066409]  seq_read+0x336/0x430
[69588.066411]  proc_reg_read+0x40/0x70
[69588.066412]  __vfs_read+0x26/0x140
[69588.066414]  vfs_read+0x89/0x130
[69588.066415]  SyS_read+0x42/0x90
[69588.066417]  do_syscall_64+0x74/0x140
[69588.066419]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2

Signed-off-by: Roman Sobanski <roman.sobanski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-04-25 09:30:05 -04:00
Mariusz Dabrowski 444909385f imsm: do not use blocks_per_member in array size calculations
mdadm assumes that blocks_per_member value is equal to num_data_stripes *
blocks_per_stripe but it is not true. For IMSM arrays created in OROM
NUM_BLOCKS_DIRTY_STRIPE_REGION sectors are added up to this value. Because
of this mdadm shows invalid size of arrays created in OROM and to fix this
we need to use array size calculation based on num data stripes and blocks
per stripe.

Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-04-12 11:34:44 -04:00
Mariusz Dabrowski 9529d34367 imsm: pass already existing map to imsm_num_data_members
In almost every place where imsm_num_data_members is called there is
already existing map so it can be used it to avoid mistake when specifying
map for imsm_num_data_members.

Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-04-12 11:34:17 -04:00
Mariusz Dabrowski fcc2c9daed imsm: add functions to get and set imsm dev size
Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-04-12 11:32:30 -04:00
Mariusz Dabrowski 611d95290d imsm: change reserved space to 4MB
Due to compatibility to the  newest OROM, imsm reserved space has to be
expanded to 4MB.

Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-04-12 11:31:45 -04:00
Jes Sorensen 59416da78f tests/func.sh: Fix some total breakage in the test scripts
We will never mandate an obsolete file system such as ext[2-4] for
running the test suite, nor should the test version of mdadm be
installed on the system for the tests to be run.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Fixes: 20d10b4be8 ("mdadm/test: Refactor and revamp 'test' script")
2018-04-11 17:27:28 -04:00
Michal Zylowski b91ad097d6 imsm: Allow create RAID volume with link to container
After 1db03765("Subdevs can't be all missing when create raid device")
raid volume can't be created with link to container. This feature should
not be blocked in Create function.  IMSM code forbids creation of
container with missing disk, so case like all dev's missing is already
handled.

Permit IMSM volume creation when devices are given as link to container.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-04-10 16:12:00 -04:00
Zhipeng Xie 1c7c65a3e5 mdadm: fix use-after-free after free_mdstat
e->percent access the mdstat_ent which was already freed in free_mdstat

Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-04-10 11:12:24 -04:00
Jes Sorensen 6a173ed317 mdadm: 4.1-rc1
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-03-22 13:06:56 -04:00
Jes Sorensen 94d7a6c361 makedist: Fix to handle rc releases
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-03-22 13:06:56 -04:00
Artur Paszkiewicz e397cefe13 imsm: fix assemble with ppl during rebuild
When assembling an array undergoing rebuild the kernel will switch to
resync if there are no ppl entries to recover. Prevent that by adding an
empty entry when validating the ppl header.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-03-22 13:06:56 -04:00
Zhilong Liu 548b2a3d2f 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>
2018-03-08 14:40:34 -05:00
Zhilong Liu 305a051bdf 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>
2018-03-08 14:40:17 -05:00
Zhilong Liu 2ec2fb76ad 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>
2018-03-08 14:40:03 -05:00
Zhilong Liu 9042a561b1 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>
2018-03-08 14:39:21 -05:00
Zhilong Liu 56928762ba 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>
2018-03-08 14:39:04 -05:00
Zhilong Liu 05f1959b19 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>
2018-03-08 14:38:32 -05:00
Zhilong Liu ffa22ea2f3 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>
2018-03-08 14:38:18 -05:00
Zhilong Liu bb76bc6825 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>
2018-03-08 14:38:03 -05:00
Zhilong Liu 1070b7f867 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>
2018-03-08 14:37:10 -05:00
Zhilong Liu db76b9b156 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>
2018-03-08 14:34:59 -05:00
Zhilong Liu 6374882f21 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>
2018-03-08 14:34:40 -05:00
Zhilong Liu b3d330436a 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>
2018-03-08 14:34:20 -05:00
Zhilong Liu 4a557d9d1d 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>
2018-03-08 14:32:33 -05:00
Zhilong Liu b2a613ddd5 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>
2018-03-08 14:30:53 -05:00
Zhilong Liu b3872c0284 mdadm/clustermd_tests: delete meaningless commands in check
Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-03-08 14:30:36 -05:00
Zhilong Liu f7331a1158 mdadm/clustermd_tests: add nobitmap in check
Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-03-08 14:30:15 -05:00
Zhilong Liu 064bd3f5ca 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>
2018-03-08 14:29:50 -05:00
Zhilong Liu 7d81135e8a 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>
2018-03-08 14:28:39 -05:00
Zhilong Liu 05e0e58f70 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>
2018-03-08 14:28:03 -05:00
Guoqing Jiang 57908e9eba 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>
2018-03-08 14:22:25 -05:00
Guoqing Jiang 76781701a4 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>
2018-03-08 14:18:41 -05:00