Commit Graph

3788 Commits

Author SHA1 Message Date
Michal Zylowski cf42a1c707 tests, imsm: Calculate expected array_size in proper way
Tests should calucalte expected array_size accordingly to raid level. Also
tests should take care about runding to neares MB introduced from b53bfba6
"imsm: use rounded size for metadata initialization".

Expect proper size in tests. Simplify 09imsm-overlap test by creating array
with size which has not been rounded. Main purpose of this test is checking
something else.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-07-11 13:17:29 -04:00
Michal Zylowski f49f083e2c tests, imsm: Migration from RAID5 to RAID0 is not supported for IMSM metadata
When test tries to change RAID level from RAID5 to RAID0 mdadm respond with
error about unsporrted operation.

Make 16imsm-r5_3d-migrate-r0_3d and 16imsm-r5_5d-migrate-r0_5d test
negative.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-07-11 13:17:12 -04:00
Michal Zylowski 1a90fd8458 tests, imsm: Test shouldn't call grow with chunk and level in one command
Since a3b831c9 "Grow.c: Block any level migration with chunk size change"
there is no possibility to perform migration between level and chunk in
one operation. When any test tries to do this error message is printed
and tests finishes with fail.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-07-11 13:16:48 -04:00
Michal Zylowski 2b2ccdc04b tests, imsm: Set new_num_disks value corectly to perform expected size calculations
In some migration tests, variable new_num_disks should be set to expected
number of disks after migration. This is required for proper expected size
calculation.

Pass new_num_disks variable during test execution for:
- 16imsm-r0_3d-migrate-r5_4d
- 18imsm-r1_2d-takeover-r0_1d
- 16imsm-r0_5d-migrate-r5_6d

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-07-11 13:16:24 -04:00
Michal Zylowski b202e322c1 tests, imsm: Fix unit inconsistency in tests error messages
Chunk size copied from sysfs should be divied by 1024 to compare with
expected chunk size.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-07-11 13:16:02 -04:00
Michal Zylowski 6adfeaa7a2 tests, imsm: Set correct expected offset between volumes
Since 611d9529 (imsm: change reserved space to 4MB) gap between RAID
volumes has changed. Tests should expect correct offset in size
calulations.

Fix expected offset for tests.

Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-07-11 13:15:37 -04:00
Anthony Youngman d94eb07f82 Coverity: Resource leak: close fd before return
Anthony Youngman <anthony@youngman.org.uk>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-07-11 13:11:17 -04:00
Anthony Youngman 29446c962f Coverity: Resource leak: close fds and free array before return
Signed-off-by: Anthony Youngman <anthony@youngman.org.uk>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-07-11 13:08:25 -04:00
Anthony Youngman 4a670aabdc Coverity: Resource leak: fix return without free
Signed-off-by: Anthony Youngman <anthony@youngman.org.uk>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-07-11 13:08:17 -04:00
Guoqing Jiang 898bd1ecef Free map to avoid resource leak issues
1. There are some places which didn't free map as
discovered by coverity.

CID 289661 (#1 of 1): Resource leak (RESOURCE_LEAK)12. leaked_storage: Variable mapl going out of scope leaks the storage it points to.
CID 289619 (#3 of 3): Resource leak (RESOURCE_LEAK)63. leaked_storage: Variable map going out of scope leaks the storage it points to.
CID 289618 (#1 of 1): Resource leak (RESOURCE_LEAK)26. leaked_storage: Variable map going out of scope leaks the storage it points to.
CID 289607 (#1 of 1): Resource leak (RESOURCE_LEAK)41. leaked_storage: Variable map going out of scope leaks the storage it points to.

2. If we call map_by_* inside a loop, then map_free
should be called in the same loop, and it is better
to set map to NULL after free.

3. And map_unlock is always called with map_lock,
if we don't call map_remove before map_unlock,
then the memory (allocated by  map_lock -> map_read
-> map_add -> xmalloc) could be leaked. So we
need to free it in map_unlock as well.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-06-11 06:35:41 -04:00
Roman Sobanski 4a353e6ec4 imsm: correct num_data_stripes in metadata map for migration
When migrating an array from R0 to R10 num_data_stripes in metadata map
will not be updated. Update it to allow correct migration process.
Changes in R10 to R0 migration for clarity of code.

Signed-off-by: Roman Sobanski <roman.sobanski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-06-08 13:36:36 -04:00
Mariusz Tkaczyk 7298c9a6fa Assemble.c Don't ignore faulty disk when array is auto assembled.
Since commit 20dc76d15b ("imsm: Set disk slot number") mdadm
sets slot number for each disk in imsm array. Now auto-assemble determines
devices using slot number and ignores devices on the same slot that have
older generation number.
It causes infinit loop if failed device is still visible in system
(it has metadata, but it is not merged with exisiting array).

To avoid it, out-of-sync device should be added to the best[]. Later
mdadm adds it as spare to the container.

Imsm doesn't support disk replacement feature, so it can use rooms for
replacements.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-06-08 12:47:14 -04:00
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