Commit Graph

3553 Commits

Author SHA1 Message Date
Mariusz Tkaczyk 802961a239 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>
2017-08-16 08:25:07 -04:00
NeilBrown dcd24efcfa 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>
2017-08-16 08:25:07 -04:00
NeilBrown 6438c249c4 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>
2017-08-16 08:25:07 -04:00
NeilBrown ceb5f8ef92 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>
2017-08-16 08:25:07 -04:00
NeilBrown 8e5b52cdda 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>
2017-08-16 08:25:07 -04:00
Tomasz Majchrzak fb12a74540 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>
2017-08-16 08:24:45 -04:00
Mariusz Tkaczyk a822017f30 Detail: correct output for active arrays
The check for inactive array is incorrect as it compares it against
active array. Introduce a new function md_is_array_active so the check
is consistent across the code.

As the output contains list of disks in the array include this
information in sysfs read.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-08-16 08:19:38 +00:00
Guoqing Jiang 0e23c59718 udev rules: introduce rules for cluster-md to confirm device
For cluster scenario, add device is different with native raid.
When a node issues adds a device, then the node will broadcast
a message with UUID to other nodes in the cluster. If receiving
node can find the device with the specific UUID, it must confirm
the device, otherwise reports it is missing.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-08-02 09:30:51 -04:00
Song Liu 3373d49f32 mdadm/r5cache: allow adding journal to array without journal
Currently, --add-journal can be only used to recreate broken journal
for arrays with journal since  creation. As the kernel code getting
more mature, this constraint is no longer necessary.

This patch allows --add-journal to add journal to array without
journal.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-08-02 09:22:51 -04:00
Pawel Baldysiak 795bd44ed1 super1: Always round data offset to 1M
Currently if metadata requires more then 1M,
data offset will be rounded down to closest MB.
This is not correct, since less then required space is reserved.
Always round data offset up to multiple of 1M.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-07-27 05:32:32 -04:00
Tomasz Majchrzak cb91230c87 Monitor: don't assume mdadm parameter is a block device
If symlink (e.g. /dev/md/raid) is passed as a parameter to mdadm --wait,
it fails as it's not able to find a corresponding entry in /proc/mdstat
output. Get parameter file major:minor and look for block device name in
sysfs. This commit is partial revert of commit 9e04ac1c43
("mdadm/util: unify stat checking blkdev into function").

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-07-10 13:40:05 -04:00
Zhilong Liu 25357919d2 mdadm/test: Add '--disks=' to support testing phsical devices
If test mode has set as '--dev=disk', then users can specify
the argument of "--disks" to test a bunch of physical devices.
For example: ./test --dev=disk --disks=/dev/sda{2..15}
could execute all test cases on physical devices.

Currently, the --dev=disk mode would confilct with testdev()
in current test cases, thus ignore testing testdev() if has
set --dev=disk mode.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-07-10 13:37:54 -04:00
Zhilong Liu 8403b202ca mdadm/test: Add '--raidtype=' to run different raidlevel cases
It supports to specify the argument of "--raidtype"
to run the different raid level cases. Details refer
to the do_help() usage.
For example: ./test --raidtype=raid1
could execute all the raid1 test cases under tests/.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-07-10 13:33:19 -04:00
Zhilong Liu 20d10b4be8 mdadm/test: Refactor and revamp 'test' script
Adding functions:
die()
  uniform the abnormal situations that have to abort.
check_env()
  do various basic checking before running test suite.
save_log()
  collect array infos, include of dmesg, superblock,
  bitmap and /proc/mdstat.
main()
  the core function of this script.

Improve functions:
cleanup()
  clear dmesg and remove the /var/tmp/mdtest* files.
mdadm()
  clear superblock once creating or building arrays
  every time, because it's always creating arrays
  many times in a test case.
check()
  just tidy up with die(), didn't change code meanings.
testdev()
  add checking $1 must be a block device, add 'return 0'
  in final because this function exists in last line of
  test case, such as tests/05r6tor0.
do_test()
  add checking abnormal dmesg and changing log management.
do_help()
  just recommend a better way to print Usage.
parse_args()
  revamp and improve.

Delete function:
fast_sync()
  It's no longer used, so get rid of it.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-07-10 13:30:10 -04:00
Zhilong Liu 662c349a5a mdadm/test: Convert code format to use Tab
In case to make codes neat, this commit didn't change
any codes, just tidy up and use Tab as code format.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-06-09 11:04:10 -04:00
Tomasz Majchrzak 922a58292f Grow: don't allow to enable PPL when reshape is in progress
Don't allow to enable PPL consistency policy when reshape is in progress.
Current PPL implementation doesn't work when reshape is taking place.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-06-09 10:58:36 -04:00
Tomasz Majchrzak b208f817ec Grow: don't allow array geometry change with ppl enabled
Don't allow array geometry change (size expand, disk adding) when PPL
consistency policy is enabled. Current PPL implementation doesn't work when
reshape is taking place.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-06-09 10:56:22 -04:00
Tomasz Majchrzak b13b52c80f Get failed disk count from array state
Recent commit has changed the way failed disks are counted. It breaks
recovery for external metadata arrays as failed disks are not part of
the array and have no corresponding entries is sysfs (they are only
reported for containers) so degraded arrays show no failed disks.

Recent commit overwrites GET_DEGRADED result prior to GET_STATE and it
is not set again if GET_STATE has not been requested. As GET_STATE
provides the same information as GET_DEGRADED, the latter is not needed
anymore. Remove GET_DEGRADED option and replace it with GET_STATE
option.

Don't count number of failed disks looking at sysfs entries but
calculate it at the end. Do it only for arrays as containers report
no disks, just spares.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-06-05 11:11:36 -04:00
Tomasz Majchrzak 07c45a1871 Grow: set component size prior to array size
It is a partial revert of commit 758b327cf5 ("Grow: Remove unnecessary
optimization"). For native metadata component size is set in kernel for
entire disk space. As external metadata supports multiple arrays within
one disk, the component size is set to array size. If component size is
not updated prior to array size update, the grow operation fails.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-06-05 11:06:35 -04:00
Zhilong Liu ea1c4a8722 md_u: Remove unused ioctl declaration of START_ARRAY
START_ARRAY is no longer used in the code, so get rid of it.
MD commit: fbedac04fa11 ("[PATCH] md: the scheduled removal
of the START_ARRAY ioctl for md") merged in the year 2006.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-06-02 13:49:53 -04:00
Lidong Zhong 68fee4af17 super1: fix sb->max_dev when adding a new disk in linear array
The value of sb->max_dev will always be increased by 1 when adding
a new disk in linear array. It causes an inconsistence between each
disk in the array and the "Array State" value of "mdadm --examine DISK"
is wrong. For example, when adding the first new disk into linear array
it will be:

Array State : RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
('A' == active, '.' == missing, 'R' == replacing)

Adding the second disk into linear array it will be

Array State : .AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
('A' == active, '.' == missing, 'R' == replacing)

Signed-off-by: Lidong Zhong <lzhong@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-26 14:35:35 -04:00
Tomasz Majchrzak 9b8fea914f Detail: don't exit if ioctl has been successful
When GET_ARRAY_INFO ioctl is successful, mdadm exits with an error.
It breaks udev and no links in /dev/md are created.

Also change debug print to error print in the message indicating lack
of the link to facilitate debugging similar issues in the future.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-24 13:28:33 -04:00
Tomasz Majchrzak 8fac4a54cb manpage: bad block support for IMSM
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-19 15:43:44 -04:00
Jes Sorensen d16a749444 mdadm: Fixup != broken formatting
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-16 14:09:57 -04:00
Jes Sorensen b831b299e8 mdadm: Fix '==' broken formatting
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-16 14:04:22 -04:00
Jes Sorensen d7be7d8736 mdadm: Fixup more broken logical operator formatting
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-16 13:59:43 -04:00
Jes Sorensen fc54fe7a7e mdadm: Fixup a large number of bad formatting of logical operators
Logical oprators never belong at the beginning of a line.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-16 13:52:15 -04:00
Jes Sorensen a0628abf2b super-ddf: sysfs_read() takes a pointer as device name argument
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-16 13:29:46 -04:00
James Puthukattukaran a3476c9223 mdadm: Uninitialized variable rdev
rdev is not initialized properly causing compiler complaint.

Signed-off-by: James Puthukattukaran <joejames70@gmail.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-16 11:58:31 -04:00
Jes Sorensen f566ef45d3 Monitor: Fixup a pile of whitespace issues
No code was hurt in this event

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-11 16:56:55 -04:00
Jes Sorensen 72362f18ae Monitor: mailfrom is initialized correctly
Remove gratituous variable initialization.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-11 16:44:19 -04:00
Jes Sorensen 9f3dd4549b Monitor: Not much point declaring mdlist in both forks of the if() statement
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-11 16:40:16 -04:00
Zhilong Liu e644902ddb retire the APIs that driver no longer supports
refer to commit: e6e5f8f126 ("Build: Stop
bothering about supporting md driver ...")
continue to retire the APIs that md driver
wasn't supported for very long period of time.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-11 11:45:44 -04:00
Maksymilian Kunt 84918897ee IMSM: Correct --examine output for 4k disks
"Array Size" and "Per Dev Size" are incorrect for disks with sector size
different than 512B.

Calculate "Array Size" and "Per Dev Size" based on sector size. Additionally
print "Sector Size".

Signed-off-by: Maksymilian Kunt <maksymilian.kunt@intel.com>
Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-11 11:44:44 -04:00
Jes Sorensen e5eb6857cd Monitor/check_array: Use working_disks from sysfs
sysfs now provides working_disks information, so lets use it too.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 17:15:14 -04:00
Jes Sorensen 8b0ebd6452 sysfs/sysfs_read: Count working_disks
This counts working_disks the same way as get_array_info counts it in
the kernel.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 17:09:40 -04:00
Jes Sorensen b98943a4f8 Monitor/check_array: Get nr_disks, active_disks and spare_disks from sysfs
This leaves working_disks and utime missing before we can eliminate
check_array()'s call to md_get_array_info()

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 17:06:09 -04:00
Jes Sorensen 12a9d21f4e Monitor/check_array: Get array_disks from sysfs
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 16:58:55 -04:00
Jes Sorensen b8e5713c74 Monitor/check_array: Get 'failed_disks' from sysfs
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 16:54:19 -04:00
Jes Sorensen 48bc2ade86 Monitor/check_array: Obtain RAID level from syfs
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 16:52:44 -04:00
Jes Sorensen aed5f5c34c Monitor/check_array: Read sysfs entry earlier
This will allow us to pull additional info from sysfs, such as level
and device info.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 16:51:41 -04:00
Jes Sorensen 826522f0dc Monitor/check_array: Declate mdinfo instance globally
We can pull in more information from sysfs earlier, so move sra to the top.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 16:41:06 -04:00
Jes Sorensen 13e5d8455c Monitor/check_array: Reduce duplicated error handling
Avoid closing fd in multiple places, and duplicating the error message
for when a device disappeared.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 16:38:06 -04:00
Jes Sorensen 1830e74b4c Monitor/check_array: Centralize exit path
Improve exit handling to make it easier to share error handling and free
sysfs entries later.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 16:25:23 -04:00
Alexey Obitotskiy 4b57ecf6ce Add sector size as spare selection criterion
Add sector size as new spare selection criterion. Assume that 0 means
there is no requirement for the sector size in the array. Skip disks
with unsuitable sector size when looking for a spare to move across
containers.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 14:18:38 -04:00
Alexey Obitotskiy fbfdcb06dc Allow more spare selection criteria
Disks can be moved across containers in order to be used as a spare
drive for reubild. At the moment the only requirement checked for such
disk is its size (if it matches donor expectations). In order to
introduce more criteria rename corresponding superswitch method to more
generic name and move function parameter to a structure. This change is
a big edit but it doesn't introduce any changes in code logic, it just
updates function naming and parameters.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 14:18:36 -04:00
Alexey Obitotskiy f2cc4f7d82 imsm: don't allow disks with different sector size in one array
As there is no support in IMSM for arrays including disks with different
sector sizes, don't allow to create such configuration. Also skip the
disk with unsuitable sector size when looking for spares in the same
container.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 14:18:35 -04:00
Alexey Obitotskiy 853375734e imsm: allocate buffer to support maximum sector size
Allocate migration record buffer to support maximum sector size. Disk with
non-matching sector size is not going to be included in the array, however
some preparation/cleanup actions still take place on it and they would
cause a crash. Clear migration record using sector size of the disk (not
array) as they might not match.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 14:18:33 -04:00
Alexey Obitotskiy 5c5ea85b4d imsm: allow drives in a container regardless of sector size
IMSM doesn't allow to create arrays including drives with different
sector sizes. The initial idea was not to permit to combine drives
with different sector size in the same container. The problem is it
only worked for array creation. On array assemble there are no
calls to metadata handlers to see if drive is suitable for a container
(e.g. as a spare) and it leads to wrong configuration.

Revert the change and allow adding drives with different sector size
to the container.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 14:17:50 -04:00
Zhilong Liu 17645275ca mdadm/md.4: set page-length as 1000 to avoid warnings from grotty
"nroff" ("man") or ("tbl") needs a long page to avoid warnings
from "grotty", set 'pl' as 1000 to fix the following issue.

This command invokes by Makefile rule.
linux-tjrh:~/mdadm # man -l md.4 > test
grotty:<standard input> (<standard input>):5967:
character above first line discarded
... ...

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-09 10:52:38 -04:00