]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
6 years agoudev rules: introduce rules for cluster-md to confirm device
Guoqing Jiang [Wed, 2 Aug 2017 02:05:41 +0000 (10:05 +0800)] 
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>
6 years agomdadm/r5cache: allow adding journal to array without journal
Song Liu [Tue, 28 Mar 2017 18:04:44 +0000 (11:04 -0700)] 
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>
6 years agosuper1: Always round data offset to 1M
Pawel Baldysiak [Wed, 26 Jul 2017 14:41:54 +0000 (16:41 +0200)] 
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>
6 years agoMonitor: don't assume mdadm parameter is a block device
Tomasz Majchrzak [Mon, 19 Jun 2017 09:19:53 +0000 (11:19 +0200)] 
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 9e04ac1c43e6
("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>
6 years agomdadm/test: Add '--disks=' to support testing phsical devices
Zhilong Liu [Wed, 14 Jun 2017 13:02:53 +0000 (21:02 +0800)] 
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>
6 years agomdadm/test: Add '--raidtype=' to run different raidlevel cases
Zhilong Liu [Wed, 14 Jun 2017 13:02:52 +0000 (21:02 +0800)] 
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>
6 years agomdadm/test: Refactor and revamp 'test' script
Zhilong Liu [Wed, 14 Jun 2017 13:02:51 +0000 (21:02 +0800)] 
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>
6 years agomdadm/test: Convert code format to use Tab
Zhilong Liu [Wed, 7 Jun 2017 09:31:26 +0000 (17:31 +0800)] 
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>
6 years agoGrow: don't allow to enable PPL when reshape is in progress
Tomasz Majchrzak [Fri, 9 Jun 2017 14:20:19 +0000 (16:20 +0200)] 
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>
6 years agoGrow: don't allow array geometry change with ppl enabled
Tomasz Majchrzak [Thu, 8 Jun 2017 14:05:51 +0000 (16:05 +0200)] 
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>
6 years agoGet failed disk count from array state
Tomasz Majchrzak [Wed, 31 May 2017 10:46:57 +0000 (12:46 +0200)] 
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>
6 years agoGrow: set component size prior to array size
Tomasz Majchrzak [Mon, 5 Jun 2017 14:09:44 +0000 (16:09 +0200)] 
Grow: set component size prior to array size

It is a partial revert of commit 758b327cf5a7 ("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>
6 years agomd_u: Remove unused ioctl declaration of START_ARRAY
Zhilong Liu [Wed, 31 May 2017 11:38:36 +0000 (19:38 +0800)] 
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>
6 years agosuper1: fix sb->max_dev when adding a new disk in linear array
Lidong Zhong [Thu, 25 May 2017 09:28:11 +0000 (17:28 +0800)] 
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>
6 years agoDetail: don't exit if ioctl has been successful
Tomasz Majchrzak [Wed, 24 May 2017 09:34:22 +0000 (11:34 +0200)] 
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>
6 years agomanpage: bad block support for IMSM
Tomasz Majchrzak [Thu, 18 May 2017 13:14:49 +0000 (15:14 +0200)] 
manpage: bad block support for IMSM

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: Fixup != broken formatting
Jes Sorensen [Tue, 16 May 2017 18:09:57 +0000 (14:09 -0400)] 
mdadm: Fixup != broken formatting

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: Fix '==' broken formatting
Jes Sorensen [Tue, 16 May 2017 18:04:22 +0000 (14:04 -0400)] 
mdadm: Fix '==' broken formatting

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: Fixup more broken logical operator formatting
Jes Sorensen [Tue, 16 May 2017 17:59:43 +0000 (13:59 -0400)] 
mdadm: Fixup more broken logical operator formatting

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: Fixup a large number of bad formatting of logical operators
Jes Sorensen [Tue, 16 May 2017 17:52:15 +0000 (13:52 -0400)] 
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>
6 years agosuper-ddf: sysfs_read() takes a pointer as device name argument
Jes Sorensen [Tue, 16 May 2017 17:29:46 +0000 (13:29 -0400)] 
super-ddf: sysfs_read() takes a pointer as device name argument

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm: Uninitialized variable rdev
James Puthukattukaran [Tue, 16 May 2017 15:57:00 +0000 (11:57 -0400)] 
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>
6 years agoMonitor: Fixup a pile of whitespace issues
Jes Sorensen [Thu, 11 May 2017 20:56:55 +0000 (16:56 -0400)] 
Monitor: Fixup a pile of whitespace issues

No code was hurt in this event

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor: mailfrom is initialized correctly
Jes Sorensen [Thu, 11 May 2017 20:44:19 +0000 (16:44 -0400)] 
Monitor: mailfrom is initialized correctly

Remove gratituous variable initialization.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor: Not much point declaring mdlist in both forks of the if() statement
Jes Sorensen [Thu, 11 May 2017 20:40:16 +0000 (16:40 -0400)] 
Monitor: Not much point declaring mdlist in both forks of the if() statement

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoretire the APIs that driver no longer supports
Zhilong Liu [Thu, 11 May 2017 08:52:41 +0000 (16:52 +0800)] 
retire the APIs that driver no longer supports

refer to commit: e6e5f8f1267d ("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>
6 years agoIMSM: Correct --examine output for 4k disks
Maksymilian Kunt [Tue, 9 May 2017 12:03:27 +0000 (14:03 +0200)] 
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>
6 years agoMonitor/check_array: Use working_disks from sysfs
Jes Sorensen [Tue, 9 May 2017 21:15:14 +0000 (17:15 -0400)] 
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>
6 years agosysfs/sysfs_read: Count working_disks
Jes Sorensen [Tue, 9 May 2017 21:09:40 +0000 (17:09 -0400)] 
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>
6 years agoMonitor/check_array: Get nr_disks, active_disks and spare_disks from sysfs
Jes Sorensen [Tue, 9 May 2017 21:03:03 +0000 (17:03 -0400)] 
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>
6 years agoMonitor/check_array: Get array_disks from sysfs
Jes Sorensen [Tue, 9 May 2017 20:58:55 +0000 (16:58 -0400)] 
Monitor/check_array: Get array_disks from sysfs

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor/check_array: Get 'failed_disks' from sysfs
Jes Sorensen [Tue, 9 May 2017 20:54:19 +0000 (16:54 -0400)] 
Monitor/check_array: Get 'failed_disks' from sysfs

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor/check_array: Obtain RAID level from syfs
Jes Sorensen [Tue, 9 May 2017 20:52:44 +0000 (16:52 -0400)] 
Monitor/check_array: Obtain RAID level from syfs

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor/check_array: Read sysfs entry earlier
Jes Sorensen [Tue, 9 May 2017 20:49:33 +0000 (16:49 -0400)] 
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>
6 years agoMonitor/check_array: Declate mdinfo instance globally
Jes Sorensen [Tue, 9 May 2017 20:41:06 +0000 (16:41 -0400)] 
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>
6 years agoMonitor/check_array: Reduce duplicated error handling
Jes Sorensen [Tue, 9 May 2017 20:38:06 +0000 (16:38 -0400)] 
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>
6 years agoMonitor/check_array: Centralize exit path
Jes Sorensen [Tue, 9 May 2017 20:25:23 +0000 (16:25 -0400)] 
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>
6 years agoAdd sector size as spare selection criterion
Alexey Obitotskiy [Tue, 9 May 2017 10:25:47 +0000 (12:25 +0200)] 
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>
6 years agoAllow more spare selection criteria
Alexey Obitotskiy [Tue, 9 May 2017 10:25:46 +0000 (12:25 +0200)] 
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>
6 years agoimsm: don't allow disks with different sector size in one array
Alexey Obitotskiy [Tue, 9 May 2017 10:25:45 +0000 (12:25 +0200)] 
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>
6 years agoimsm: allocate buffer to support maximum sector size
Alexey Obitotskiy [Tue, 9 May 2017 10:25:44 +0000 (12:25 +0200)] 
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>
6 years agoimsm: allow drives in a container regardless of sector size
Alexey Obitotskiy [Tue, 9 May 2017 10:25:43 +0000 (12:25 +0200)] 
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>
6 years agomdadm/md.4: set page-length as 1000 to avoid warnings from grotty
Zhilong Liu [Tue, 9 May 2017 06:25:17 +0000 (14:25 +0800)] 
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>
6 years agoMonitor: Code is 80 characters per line
Jes Sorensen [Mon, 8 May 2017 21:52:10 +0000 (17:52 -0400)] 
Monitor: Code is 80 characters per line

Fix up some lines that are too long for no reason, and some that have
silly line breaks.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMonitor: Use md_array_active() instead of manually fiddling in sysfs
Jes Sorensen [Mon, 8 May 2017 21:34:08 +0000 (17:34 -0400)] 
Monitor: Use md_array_active() instead of manually fiddling in sysfs

This removes a pile of clutter that can easily behandled with a simple
check of array_state.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoMention "endian" in documentation for --update=byte-order
NeilBrown [Sun, 7 May 2017 23:40:09 +0000 (09:40 +1000)] 
Mention "endian" in documentation for --update=byte-order

This makes it easier to find as "endian" is a commonly used term.

Reported-by: Trevor Cordes <trevor@tecnopolis.ca>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoIncrementalScan: Use md_array_active() instead of md_get_array_info()
Jes Sorensen [Fri, 5 May 2017 16:18:29 +0000 (12:18 -0400)] 
IncrementalScan: Use md_array_active() instead of md_get_array_info()

This eliminates yet another case where GET_ARRAY_INFO was used to
indicate whether the array was active.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agocontainer_members_max_degradation: Switch to using syfs for disk info
Jes Sorensen [Fri, 5 May 2017 16:06:57 +0000 (12:06 -0400)] 
container_members_max_degradation: Switch to using syfs for disk info

With sysfs now providing the necessary active_disks info, switch to
sysfs and eliminate one more use of md_get_array_info(). We can do
this unconditionally since we wouldn't get here witout sysfs being
available.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agosysfs/sysfs_read: Count active_disks and failed_disks
Jes Sorensen [Fri, 5 May 2017 15:51:43 +0000 (11:51 -0400)] 
sysfs/sysfs_read: Count active_disks and failed_disks

Cound active_disks as drives mark 'in_sync' and failed_disks as
disks marked 'faulty', in the same way ioctl(GET_ARRAY_INFO) does.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoIncremental: return is not a function
Jes Sorensen [Fri, 5 May 2017 15:39:58 +0000 (11:39 -0400)] 
Incremental: return is not a function

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoFix typo in new udev rule.
NeilBrown [Fri, 5 May 2017 05:16:15 +0000 (15:16 +1000)] 
Fix typo in new udev rule.

As pointed out by Peter Rajnoha, the correct usage in udev is
TEST=="file", not TEST="file".

Also improve a related comment which was a bit informal.

Reported-by: Peter Rajnoha <prajnoha@redhat.com>
Fixes: cd6cbb08c458 ("Create: tell udev md device is not ready when first created.")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/util: unify stat checking blkdev into function
Zhilong Liu [Fri, 5 May 2017 03:09:41 +0000 (11:09 +0800)] 
mdadm/util: unify stat checking blkdev into function

declare function stat_is_blkdev() to integrate repeated stat
checking blkdev operations, it returns 'true/1' when it is a
block device, and returns 'false/0' when it isn't.
The devname is necessary parameter, *rdev is optional, parse
the pointer of dev_t *rdev, if valid, assigned device number
to dev_t *rdev, if NULL, ignores.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdadm/util: unify fstat checking blkdev into function
Zhilong Liu [Thu, 4 May 2017 12:16:21 +0000 (20:16 +0800)] 
mdadm/util: unify fstat checking blkdev into function

declare function fstat_is_blkdev() to integrate repeated fstat
checking block device operations, it returns true/1 when it is
a block device, and returns false/0 when it isn't.
The fd and devname are necessary parameters, *rdev is optional,
parse the pointer of dev_t *rdev, if valid, assigned the device
number to dev_t *rdev, if NULL, ignores.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agomdassemble: Kill off the last remains
Jes Sorensen [Thu, 4 May 2017 15:57:41 +0000 (11:57 -0400)] 
mdassemble: Kill off the last remains

Having gotten rid of mdassemble, lets get rid of the man page too

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agokernel-patch: Remove obsolete kernel patches against 2.6
Jes Sorensen [Thu, 4 May 2017 15:39:05 +0000 (11:39 -0400)] 
kernel-patch: Remove obsolete kernel patches against 2.6

While we still support some of these kernels, I do not think it makes
sense to carry this patches around at this point.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoutil: md_array_valid(): Introduce md_array_valid() helper
Jes Sorensen [Wed, 3 May 2017 18:25:57 +0000 (14:25 -0400)] 
util: md_array_valid(): Introduce md_array_valid() helper

Using md_get_array_info() to determine if an array is valid is broken
during creation, since the ioctl() returns -ENODEV if the device is
valid but not active.

Where did I leave my stash of brown paper bags?

Fixes: ("40b054e mdopen/open_mddev: Use md_get_array_info() to determine valid array")
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agochange back 0644 permission for Grow.c
Zhilong Liu [Tue, 2 May 2017 09:27:13 +0000 (17:27 +0800)] 
change back 0644 permission for Grow.c

Fixes commit:
26714713cd2b ("mdadm: Change timestamps to unsigned data type.")

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoGrow: Grow_continue_command: Avoid aliasing array variable
Jes Sorensen [Tue, 2 May 2017 15:46:49 +0000 (11:46 -0400)] 
Grow: Grow_continue_command: Avoid aliasing array variable

While this would cause a warning since the two are different types,
lets avoid aliasing an existing variable.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoIMSM: Initialize my_vol_raid_dev_num during vol creation
Pawel Baldysiak [Wed, 26 Apr 2017 09:08:07 +0000 (11:08 +0200)] 
IMSM: Initialize my_vol_raid_dev_num during vol creation

This field was not initialized so far. This ID needs to be unique
for every newly created array in container.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoManage: Manage_ro(): Use md_array_active()
Jes Sorensen [Tue, 2 May 2017 14:40:07 +0000 (10:40 -0400)] 
Manage: Manage_ro(): Use md_array_active()

One call less to md_get_array_info() for determining whether an array
is active or not.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoIncremental: Use md_array_active() to determine state of array
Jes Sorensen [Tue, 2 May 2017 14:36:51 +0000 (10:36 -0400)] 
Incremental: Use md_array_active() to determine state of array

One less call to md_get_array_info()

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoCreate: tell udev md device is not ready when first created.
NeilBrown [Fri, 28 Apr 2017 05:05:50 +0000 (15:05 +1000)] 
Create: tell udev md device is not ready when first created.

When an array is created the content is not initialized,
so it could have remnants of an old filesystem or md array
etc on it.
udev will see this and might try to activate it, which is almost
certainly not what is wanted.

So create a mechanism for mdadm to communicate with udev to tell
it that the device isn't ready.  This mechanism is the existance
of a file /run/mdadm/created-mdXXX where mdXXX is the md device name.

When creating an array, mdadm will create the file.
A new udev rule file, 01-md-raid-creating.rules, will detect the
precense of thst file and set ENV{SYSTEMD_READY}="0".
This is fairly uniformly used to suppress actions based on the
contents of the device.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoIncremental: Cleanup some if() statement spaghetti
Jes Sorensen [Tue, 25 Apr 2017 19:01:43 +0000 (15:01 -0400)] 
Incremental: Cleanup some if() statement spaghetti

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoIncremental: Use md_array_active() where applicable
Jes Sorensen [Tue, 25 Apr 2017 18:57:46 +0000 (14:57 -0400)] 
Incremental: Use md_array_active() where applicable

md_get_array_info() == 0 implies an array is active, however this is more
correct.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoDetail: Reinstate support for not having sysfs
Jes Sorensen [Tue, 25 Apr 2017 18:34:31 +0000 (14:34 -0400)] 
Detail: Reinstate support for not having sysfs

While sysfs support will hopefully go away eventually, lets not break
it unnecessarily for now.

Fixes: 901d5ee ("Detail: Stop bothering about md drivers older than 0.90.00")
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoDetail: Respect code lines are 80 character wide
Jes Sorensen [Tue, 25 Apr 2017 16:21:39 +0000 (12:21 -0400)] 
Detail: Respect code lines are 80 character wide

In addition apply spaces and don'f do 'if () action()' on the same line.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoDetail: determine array state from sysfs
Jes Sorensen [Tue, 25 Apr 2017 15:40:27 +0000 (11:40 -0400)] 
Detail: determine array state from sysfs

This is easily obtained from sysfs as part of the existing call to
sysfs_read() and it simplifies the code a little too.

Another small step in the process of getting rid of the GET_ARRAY_STATE
ioctl.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
6 years agoDon't use UnSet with consistency_policy
Artur Paszkiewicz [Mon, 24 Apr 2017 14:03:26 +0000 (16:03 +0200)] 
Don't use UnSet with consistency_policy

Use CONSISTENCY_POLICY_UNKNOWN instead. Simplify some checks because
since 5e8e35fb7e17 ("maps: Use keyvalue for null terminator to indicate
'unset' value") map_name() can return this default directly.

Suggested-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
7 years agomaps: Simplify implementation of map_name()
Jes Sorensen [Fri, 21 Apr 2017 16:11:21 +0000 (12:11 -0400)] 
maps: Simplify implementation of map_name()

Reported-By: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agomaps: Remove incorrect comment about strcmp()
Jes Sorensen [Fri, 21 Apr 2017 16:09:12 +0000 (12:09 -0400)] 
maps: Remove incorrect comment about strcmp()

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoMakefile: Default to -O2 optimization
Jes Sorensen [Fri, 21 Apr 2017 16:06:35 +0000 (12:06 -0400)] 
Makefile: Default to -O2 optimization

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoQuery: Quiet gcc since it cannot know errno != 0 in this case
Jes Sorensen [Fri, 21 Apr 2017 16:04:05 +0000 (12:04 -0400)] 
Query: Quiet gcc since it cannot know errno != 0 in this case

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoDetail: ensure --export names are acceptable as shell variables.
NeilBrown [Thu, 20 Apr 2017 02:40:06 +0000 (12:40 +1000)] 
Detail: ensure --export names are acceptable as shell variables.

If an array contains a device which has a name that
contains something other than alphnumerics and underscores,
then some values reported by "mdadm --detail --export" will
not be valid as variable assignment of the shell.
This particularly affects dm devices.
e.g.
   MD_DEVICE_dm-4_ROLE=1
   MD_DEVICE_dm-4_DEV=/dev/dm-4

As it is particularly useful to be able to work with these
in a shell script, and as the precise name is not important,
change all non-alphanumerics to '_'.

   MD_DEVICE_dm_4_ROLE=1
   MD_DEVICE_dm_4_DEV=/dev/dm-4

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agosystemd/mdadm-last-resort: use ConditionPathExists instead of Conflicts
NeilBrown [Thu, 20 Apr 2017 02:40:05 +0000 (12:40 +1000)] 
systemd/mdadm-last-resort: use ConditionPathExists instead of Conflicts

Commit cec72c071bbe ("systemd/mdadm-last-resort: add Conflicts to .service file.")

added a 'Conflicts' directive to the mdadm-last-resort@.service file in
the hope that this would make sure the service didn't run after the device
was active, even if the timer managed to get started, which is possible in
race conditions.

This seemed to work is testing, but it isn't clear why, and it is known
to cause problems.
If systemd happens to know that the mentioned device is a dependency of a
mount point, the Conflicts can unmount that mountpoint, which is certainly
not wanted.

So remove the "Conflicts" and instead use
 ConditionPathExists=!/sys/devices/virtual/block/%i/md/sync_action

The "sync_action" file exists for any array which requires last-resort
handling, and only appears when the array is activated.  So it is safe
to rely on it to determine if the last-resort is really needed.

Fixes: cec72c071bbe ("systemd/mdadm-last-resort: add Conflicts to .service file.")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoGrow_continue_command: ensure 'content' is properly initialised.
NeilBrown [Thu, 20 Apr 2017 02:40:05 +0000 (12:40 +1000)] 
Grow_continue_command: ensure 'content' is properly initialised.

Grow_continue_command() call verify_reshape_position(), which assumes
that info->sys_name is initialised.
'info' in verify_reshape_position() is 'content' in Grow_continue_command().

In the st->ss->external != 0 branch of that function, sysfs_init() is called
to initialize content->sys_name.
In the st->ss->external == 0 branch, ->sys_name is not initialized so
verify_reshape_position() will not do the right thing.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agomdadm: retire mdassemble in make everything
Coly Li [Sun, 16 Apr 2017 07:01:29 +0000 (15:01 +0800)] 
mdadm: retire mdassemble in make everything

make everything reports no rule to make mdassemble, because mdassemble
is removed from mdadm. This patch removes mdassemble from "everything"
in Makefile, now there is no failure when compiling a static mdadm binary.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoutil: Get rid of unused enough_fd()
Jes Sorensen [Thu, 20 Apr 2017 15:53:30 +0000 (11:53 -0400)] 
util: Get rid of unused enough_fd()

enough_fd() is no longer used, so lets get rid of it.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agomaps: Use keyvalue for null terminator to indicate 'unset' value
Jes Sorensen [Thu, 20 Apr 2017 04:19:44 +0000 (00:19 -0400)] 
maps: Use keyvalue for null terminator to indicate 'unset' value

This simplifies the code calling map_name() so it no longer has to
manually check for UnSet and convert the value manually.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agomaps: Terminate 'modes' map correctly.
Jes Sorensen [Thu, 20 Apr 2017 04:13:31 +0000 (00:13 -0400)] 
maps: Terminate 'modes' map correctly.

While we are unlikely to fail here, terminate the modes map correctly
to ensure we don't start running over undefined data.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoutil: Introduce md_array_active() helper
Jes Sorensen [Thu, 13 Apr 2017 17:30:17 +0000 (13:30 -0400)] 
util: Introduce md_array_active() helper

Rather than querying md_get_array_info() to determine whether an array
is valid, do the work in md_array_active() using sysfs, and fall back
on md_get_array_info() if sysfs fails.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agosysfs: Parse array_state in sysfs_read()
Jes Sorensen [Thu, 20 Apr 2017 03:27:58 +0000 (23:27 -0400)] 
sysfs: Parse array_state in sysfs_read()

Rather than copying in the array_state string, parse it and use an
enum to indicate the state.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoQuery: Use sysfs to obtain data if possible
Jes Sorensen [Thu, 13 Apr 2017 16:20:46 +0000 (12:20 -0400)] 
Query: Use sysfs to obtain data if possible

Use sysfs to obtain leve, raid_disks, and spare_disks. If sysfs fails,
fall back to calling the ioctl via md_get_array_info().

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoQuery: Handle error returned by fstat()
Jes Sorensen [Thu, 13 Apr 2017 15:53:21 +0000 (11:53 -0400)] 
Query: Handle error returned by fstat()

We shouldn't ignore any error returned by fstat() even if open() didn't
fail.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoDetail: Fixup ugly if () foo() abuse
Jes Sorensen [Wed, 12 Apr 2017 21:05:55 +0000 (17:05 -0400)] 
Detail: Fixup ugly if () foo() abuse

Cosmetic change only

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoAssemble: Remove obsolete test for kernels older than 2.4
Jes Sorensen [Wed, 12 Apr 2017 18:50:02 +0000 (14:50 -0400)] 
Assemble: Remove obsolete test for kernels older than 2.4

We only support 2.6.15+ at this point

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoDetail: Remove pre-2.6 code for printing info on rebuilding
Jes Sorensen [Wed, 12 Apr 2017 18:48:10 +0000 (14:48 -0400)] 
Detail: Remove pre-2.6 code for printing info on rebuilding

Since we no longer support anything pre-2.6.15, there is no point in
keeping this around.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoAssemble: Clean up start_array()
Jes Sorensen [Wed, 12 Apr 2017 18:23:45 +0000 (14:23 -0400)] 
Assemble: Clean up start_array()

This is purely cosmetic, no codeflow changes.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agomdadm/manpage:clustered arrays don't support array-size yet
Zhilong Liu [Wed, 12 Apr 2017 08:37:27 +0000 (16:37 +0800)] 
mdadm/manpage:clustered arrays don't support array-size yet

Update manpage for array-size section:
Clustered arrays don't support the --array-size yet.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agomdadm/manpage:update manpage for readonly parameter
Zhilong Liu [Wed, 12 Apr 2017 08:36:38 +0000 (16:36 +0800)] 
mdadm/manpage:update manpage for readonly parameter

update readonly in manpage:
Currently both the readwrite and readonly are worked well,
update the readonly section.
One commit in linux/driver/md. Cleared "MD_CLOSING bit" to
Fixes: af8d8e6f0315 ("md: changes for MD_STILL_CLOSED flag")
Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agomdopen: use parameters/new_array to create arrays whenever possible.
NeilBrown [Wed, 12 Apr 2017 06:29:04 +0000 (16:29 +1000)] 
mdopen: use parameters/new_array to create arrays whenever possible.

In a sufficiently recent kernel, an md%d array can be
created by writing to .../parameters/new_array.
If mdadm does this consistently, then another new
feature, disabling create_on_open, can be enabled.
This avoids races on shutdown.

An added benefit of using new_array (where available)
is that it allows md arrays with numbers larger than 511
(e.g. md999) to be created.  The old create_on_open
mechanism doesn't support such devices since
Commit: af5628f05db6 ("md: disable probing for md devices 512 and over.")
in Linux 3.17.

After a few more mdadm releases it would be good to
have mdadm disable create_on_open automatically.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agosuper1: Clean up various style abuses
Jes Sorensen [Tue, 11 Apr 2017 18:25:24 +0000 (14:25 -0400)] 
super1: Clean up various style abuses

Code is 80 characters wide, so lets try to respect that. In addition, we
should never have one-line 'if () action()' statements. Fixup various
whitespace abuse.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoRetire mdassemble
Jes Sorensen [Tue, 11 Apr 2017 16:54:26 +0000 (12:54 -0400)] 
Retire mdassemble

mdassemble doesn't handle container based arrays, no support for sysfs,
etc. It has not been actively maintained for years, so time to send it
off to retirement.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
7 years agoRevert "mdadm/grow: reshape would be stuck from raid1 to raid5"
Jes Sorensen [Tue, 11 Apr 2017 15:30:23 +0000 (11:30 -0400)] 
Revert "mdadm/grow: reshape would be stuck from raid1 to raid5"

This reverts commit 5b2846684ef5172eccc432e3520b79efbc2abba5.

This was a red herring and shouldn't have been applied in the first
place.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
7 years agomdadm.c:fix compile warning "mdfd is uninitialized"
Zhilong Liu [Mon, 10 Apr 2017 04:49:52 +0000 (12:49 +0800)] 
mdadm.c:fix compile warning "mdfd is uninitialized"

Initialized the mdfd as -1 to prevent compile error
of some compilers.
For example, gcc version 4.8.5(SUSE Linux).

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
7 years agomdadm: Fail for kernels older than 2.6.15
Jes Sorensen [Thu, 6 Apr 2017 19:46:31 +0000 (15:46 -0400)] 
mdadm: Fail for kernels older than 2.6.15

With the removal of old kernel API support, mdadm will no longer run
on kernels older than 2.6.15.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
7 years agoutil: Finally kill off md_get_version()
Jes Sorensen [Wed, 5 Apr 2017 19:49:18 +0000 (15:49 -0400)] 
util: Finally kill off md_get_version()

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
7 years agoAssemble/Assemble: Get rid of last use of md_get_version()
Jes Sorensen [Wed, 5 Apr 2017 19:47:37 +0000 (15:47 -0400)] 
Assemble/Assemble: Get rid of last use of md_get_version()

At this point in the code, we know we have a valid array, and any
recent kernel will return 9003, so no point in querying the kernel for
this.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
7 years agomdassemble: Use md_get_array_info() to check for valid array
Jes Sorensen [Wed, 5 Apr 2017 19:46:35 +0000 (15:46 -0400)] 
mdassemble: Use md_get_array_info() to check for valid array

Get rid of another use of md_get_version()

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
7 years agomdopen/open_mddev: Use md_get_array_info() to determine valid array
Jes Sorensen [Wed, 5 Apr 2017 19:44:20 +0000 (15:44 -0400)] 
mdopen/open_mddev: Use md_get_array_info() to determine valid array

md_get_array_info() can be used instead of md_get_version() to
determine this is in fact a valid array.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
7 years agomdmon: Stop bothering about md_get_version()
Jes Sorensen [Wed, 5 Apr 2017 19:39:51 +0000 (15:39 -0400)] 
mdmon: Stop bothering about md_get_version()

If anyone has a kernel with md driver older than 0.90.03 they will
also know where to find older versions of mdadm.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>