thirdparty/mdadm.git
4 years agosysfs: Avoid if and return on the same line
Jes Sorensen [Thu, 11 Aug 2016 19:52:48 +0000 (15:52 -0400)] 
sysfs: Avoid if and return on the same line

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper1: Avoid if and return on the same line
Jes Sorensen [Thu, 11 Aug 2016 19:52:02 +0000 (15:52 -0400)] 
super1: Avoid if and return on the same line

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agorestripe: Avoid if and return on the same line
Jes Sorensen [Thu, 11 Aug 2016 19:51:00 +0000 (15:51 -0400)] 
restripe: Avoid if and return on the same line

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoutil: Never have if and return on the same line
Jes Sorensen [Thu, 11 Aug 2016 19:48:47 +0000 (15:48 -0400)] 
util: Never have if and return on the same line

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoconfig: Various stylistic cleanups
Jes Sorensen [Thu, 11 Aug 2016 19:48:09 +0000 (15:48 -0400)] 
config: Various stylistic cleanups

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoconfig: Use xcalloc() rather than xmalloc()+memset()
Jes Sorensen [Thu, 11 Aug 2016 19:32:34 +0000 (15:32 -0400)] 
config: Use xcalloc() rather than xmalloc()+memset()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoIncremental: don't try to load_container() for a subarray
Artur Paszkiewicz [Tue, 9 Aug 2016 08:05:51 +0000 (10:05 +0200)] 
Incremental: don't try to load_container() for a subarray

mdadm -IRs would exit with a non-zero status because of this.

Reported-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agomdadm:add 'clustered' in typo prompt when specify wrong param for bitmap
Zhilong Liu [Tue, 2 Aug 2016 09:18:40 +0000 (05:18 -0400)] 
mdadm:add 'clustered' in typo prompt when specify wrong param for bitmap

  mdadm: 'clustered' bitmap has already supported, thus add the
         prompt if users specify wrong value for bitmap param.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoMonitor: release /proc/mdstat fd when no arrays present
Tomasz Majchrzak [Tue, 5 Jul 2016 07:12:51 +0000 (09:12 +0200)] 
Monitor: release /proc/mdstat fd when no arrays present

If md kernel module is reloaded, /proc/mdstat cannot be accessed ("cat:
/proc/mdstat: No such file or directory"). The reason is mdadm monitor
still holds a file descriptor to previous /proc/mdstat instance. It
leads to really confusing outcome of the following operations - mdadm
seems to run without errors, however some udev rules don't get executed
and new array doesn't work.

Add a check if lseek was successful as it fails if md kernel module has
been unloaded - close a file descriptor then. The problem is mdadm
monitor doesn't always do it before next operation takes place. To
prevent it monitor always releases /proc/mdstat descriptor when there
are no arrays to be monitored, just in case driver unload happens in a
moment.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoRemove: container should wait for an array to release a drive
Tomasz Majchrzak [Thu, 21 Jul 2016 07:59:42 +0000 (09:59 +0200)] 
Remove: container should wait for an array to release a drive

A 'faulty' drive is being removed from a container after it has been
released by an array, however there is a race there. The drive is
released asynchronously by a monitor but sometimes it doesn't happen
before container checks it. It results in a container refusing to remove
a drive as it still seems to be a part of some array.

It seems 'ping_monitor' could be a solution here to assure monitor has
had a chance to process the events, however it doesn't resolve the
problem - sometimes an array has to request a release of the drive few
times (as the array is busy) and single 'ping_monitor' call is not
sufficient. As there is no way to query monitor progress, it forces us
to retry a check several times before an error is returned.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoimsm: properly handle values of sync_completed
Alexey Obitotskiy [Thu, 16 Jun 2016 09:31:37 +0000 (11:31 +0200)] 
imsm: properly handle values of sync_completed

The sync_completed can be set to such values:
- two numbers of processed sectors and total during synchronization,
separated with '/';
- 'none' if synchronization process is stopped;
- 'delayed' if synchronization process is delayed.
Handle value of sync_completed not only as numbers but
also check for 'none' and 'delayed'.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Reviewed-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoimsm: add handling of sync_action is equal to 'idle'
Alexey Obitotskiy [Thu, 16 Jun 2016 09:31:36 +0000 (11:31 +0200)] 
imsm: add handling of sync_action is equal to 'idle'

After resync is stopped sync_action value become 'idle'.
We treat this case as normal termination of waiting, not as error.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Reviewed-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agomonitor: Make sure that last_checkpoint is set to 0 after sync
Pawel Baldysiak [Thu, 16 Jun 2016 09:12:20 +0000 (11:12 +0200)] 
monitor: Make sure that last_checkpoint is set to 0 after sync

In a case of successful completion of a resync (in the last step)
- read_and_act sometimes still reads sync_action as "resync"
but sync_completed already is set to component_size.
When this race occurs, sync operation is
marked as finished, but last_checkpoint is
overwritten with sync_completed. It will cause next
sync operation (ie. reshape) to be reported as complete immediately
after start - mdmon will write successful completion of the reshape
to metadata. This patch sets last_checkpoint to 0 once the sync
is completed to stop it happening.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoMDADM:Check mdinfo->reshape_active more times before calling Grow_continue
Xiao Ni [Thu, 16 Jun 2016 01:41:02 +0000 (09:41 +0800)] 
MDADM:Check mdinfo->reshape_active more times before calling Grow_continue

When reshaping a 3 drives raid5 to 4 drives raid5, there is a chance that
it can't start the reshape. If the disks are not enough to have spaces for
relocating the data_offset, it needs to call start_reshape and then run
mdadm --grow --continue by systemd. But mdadm --grow --continue fails
because it checkes that info->reshape_active is 0.

The info->reshape_active is got from the superblock of underlying devices.
Function start_reshape write reshape to /sys/../sync_action. Before writing
latest superblock to underlying devices, mdadm --grow --continue is called.
There is a chance info->reshape_active is 0. We should wait for superblock
updating more time before calling Grow_continue.

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoThe sys_name array in the mdinfo structure is 20 bytes of storage.
Nikhil Kshirsagar [Fri, 10 Jun 2016 03:20:10 +0000 (08:50 +0530)] 
The sys_name array in the mdinfo structure is 20 bytes of storage.

Increasing the size of this array to 32 bytes to handle cases with
longer device names.

Signed-off-by: Nikhil Kshirsagar <nkshirsa@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoMonitor: Use sysfs_free() to free object returned by sysfs_read()
Jes Sorensen [Fri, 10 Jun 2016 18:54:53 +0000 (14:54 -0400)] 
Monitor: Use sysfs_free() to free object returned by sysfs_read()

We should always use sysfs_free() to release sysfs_* allocated
objects.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoChange behavior in find_free_devnm when wrapping around.
Mike Lovell [Wed, 18 May 2016 18:23:14 +0000 (12:23 -0600)] 
Change behavior in find_free_devnm when wrapping around.

Newer kernels don't allow for specifying an array larger than 511. This
makes it so find_free_devnm wraps to 511 instead of 2^20 - 1.

Signed-off-by: Mike Lovell <mlovell@bluehost.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoUse dev_t for devnm2devid and devid2devnm
Mike Lovell [Wed, 18 May 2016 18:23:13 +0000 (12:23 -0600)] 
Use dev_t for devnm2devid and devid2devnm

Commit 4dd2df0966ec added a trip through makedev(), major(), and minor() for
device major and minor numbers. This would cause mdadm to fail in operating
on a device with a minor number bigger than (2^19)-1 due to it changing
from dev_t to a signed int and back.

Where this was found as a problem was when a array was created with a device
specified as a name like /dev/md/raidname and there were already 128 arrays
on the system. In this case, mdadm would chose 1048575 ((2^20)-1) for the
array and minor number. This would cause the major and minor number to become
negative when generated from devnm2devid() and passed to major() and minor()
in open_dev_excl(). open_dev_excl() would then call dev_open() which would
detect the negative minor number and call open() on the *char containing the
major:minor pair which isn't a valid file.

Signed-off-by: Mike Lovell <mlovell@bluehost.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoIMSM: retry reading sync_completed during reshape
Pawel Baldysiak [Tue, 17 May 2016 11:24:41 +0000 (13:24 +0200)] 
IMSM: retry reading sync_completed during reshape

The sync_completed after restarting a reshape
(for example - after reboot) is set to "delayed" until
mdmon changes the state. Mdadm does not wait for that change with
old kernels. If this condition occurs - it exits and reshape
is not continuing. This patch adds retry of reading sync_complete
with a delay. It gives time for mdmon to change the "delayed" state.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper1: add more checks for NodeNumUpdate option
Guoqing Jiang [Wed, 11 May 2016 09:31:36 +0000 (17:31 +0800)] 
super1: add more checks for NodeNumUpdate option

There are some cases which didn't need to check the space
is enough or not for NodeNumUpdate option.

1. for array which does not have clustered bitmap.
2. "--nodes" parameter is 0 (eg, add a disk to clustered raid).
3. if "--nodes" parameter is set to a smaller num than
   current bms->nodes.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: Apply some more consistent formatting to Grow_addbitmap()
Jes Sorensen [Thu, 12 May 2016 18:42:12 +0000 (14:42 -0400)] 
Grow: Apply some more consistent formatting to Grow_addbitmap()

This should be purely cosmetic and cause no functional change
... famous last words!

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: Simplify error paths in Grow_addbitmap()
Jes Sorensen [Thu, 12 May 2016 18:37:44 +0000 (14:37 -0400)] 
Grow: Simplify error paths in Grow_addbitmap()

This gets rid of some repeated exit paths, making the code a little
cleaner.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agomdadm: Make add_internal_bitmap() return 0 on success
Jes Sorensen [Thu, 12 May 2016 19:19:16 +0000 (15:19 -0400)] 
mdadm: Make add_internal_bitmap() return 0 on success

add_internal_bitmap() returned 1 on success and 0 on error which is
inconsistent. This changes it to return 0 on success and use more
reasonable error codes on error.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: Handle failure to load superblock in Grow_addbitmap()
Jes Sorensen [Thu, 12 May 2016 18:30:10 +0000 (14:30 -0400)] 
Grow: Handle failure to load superblock in Grow_addbitmap()

Reported-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: Grow_addbitmap() reduce indentation
Jes Sorensen [Thu, 12 May 2016 18:27:11 +0000 (14:27 -0400)] 
Grow: Grow_addbitmap() reduce indentation

This makes the code a little more readable.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper1: make the check for NodeNumUpdate more accurate
Guoqing Jiang [Mon, 9 May 2016 02:22:58 +0000 (10:22 +0800)] 
super1: make the check for NodeNumUpdate more accurate

We missed to check the version is BITMAP_MAJOR_CLUSTERED
or not, otherwise mdadm can't create array with other 1.x
metadatas (1.0 and 1.1).

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper1: don't update node nums if it is not more than 1
Guoqing Jiang [Wed, 4 May 2016 08:33:44 +0000 (16:33 +0800)] 
super1: don't update node nums if it is not more than 1

We at least need two nodes for cluster raid so make the
check before update node nums.

Reported-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoCreate: check the node nums when create clustered raid
Guoqing Jiang [Wed, 4 May 2016 08:33:43 +0000 (16:33 +0800)] 
Create: check the node nums when create clustered raid

It doesn't make sense to create a clustered raid
with only 1 node.

Reported-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper1: Clear memory allocated for superblock + bitmap before use
Jes Sorensen [Wed, 6 Apr 2016 20:13:59 +0000 (16:13 -0400)] 
super1: Clear memory allocated for superblock + bitmap before use

load_super1() did not clear memory allocated for the superblock +
bitmap. This causes issues if the superblock does not contain a bitmap
as later checks of bitmap features would rely on the bits being
cleared.

This bug has been around for a long time, but was only exposed in
mdadm-3.4 with the introduction of the clustering code.

Reported-by: Jan Stodola <jstodola@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoConsistent use of metric prefix in manpage
Marko Hauptvogel [Thu, 31 Mar 2016 22:21:53 +0000 (00:21 +0200)] 
Consistent use of metric prefix in manpage

Added the optional K suffix for completeness, as it
is allowed by util.c's parse_size(char*).

Signed-off-by: Marko Hauptvogel <marko.hauptvogel@googlemail.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoIntroduce stat2kname() and fd2kname()
Artur Paszkiewicz [Tue, 29 Mar 2016 13:20:29 +0000 (15:20 +0200)] 
Introduce stat2kname() and fd2kname()

These are similar to stat2devnm() and fd2devnm() but not limited to md
devices. If the device is a partition they will return its kernel name,
not the whole device's name. For more information see commit:
8d83493 ("Introduce devid2kname - slightly different to devid2devnm.")

Also remove unsued declaration for fmt_devname().

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agomdadm:Add '--nodes' option in GROW mode
zhilong [Fri, 25 Mar 2016 02:22:03 +0000 (10:22 +0800)] 
mdadm:Add '--nodes' option in GROW mode

mdadm:add '--nodes' option in GROW mode, because
'Cluster nodes' is set 4 by default if the nodes
parameter is not specified when switch bitmap
from none to clustered.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoChange the option from NoUpdate to NodeNumUpdate
Guoqing Jiang [Thu, 24 Mar 2016 10:00:35 +0000 (18:00 +0800)] 
Change the option from NoUpdate to NodeNumUpdate

Actually, we need to use NodeNumUpdate here to
ensure there are enough spaces for those nodes.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoAssemble: No need for dummy NULL pointer when calling map_update()
Jes Sorensen [Wed, 9 Mar 2016 20:26:50 +0000 (15:26 -0500)] 
Assemble: No need for dummy NULL pointer when calling map_update()

assemble_container_content() doesn't need a dummy NULL pointer
variable for calling map_update. Passing NULL directly is sufficient.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoAssemble: assemble_container_content(): Avoid superfluous NULL initialization
Jes Sorensen [Wed, 9 Mar 2016 20:21:26 +0000 (15:21 -0500)] 
Assemble: assemble_container_content(): Avoid superfluous NULL initialization

No need to init avail to NULL since it will only be accessed after
assignment.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoManage: Manage_subdevs(): Remove unnecessary NULL initialization
Jes Sorensen [Wed, 9 Mar 2016 20:08:55 +0000 (15:08 -0500)] 
Manage: Manage_subdevs(): Remove unnecessary NULL initialization

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoManage: Manage_add(): Avoid NULL initialization of dev_st
Jes Sorensen [Wed, 9 Mar 2016 19:51:03 +0000 (14:51 -0500)] 
Manage: Manage_add(): Avoid NULL initialization of dev_st

dev_st is only ever assigned if array->not_persistent == 0, so move
the second use of it into the same scope where the assignment is
made.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agomdadm: Cleanup conditionals
Jes Sorensen [Wed, 9 Mar 2016 19:37:46 +0000 (14:37 -0500)] 
mdadm: Cleanup conditionals

Be more consistent in the formatting of conditionals. Don't split on
multiple lines if not needed, don't overflow the 80 character line
length, put the condition operator at the end of the line of
multi-line conditionals, etc.

This should be purely cosmetic.... famous last words!

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper_intel: imsm_manage_reshape(): Fix potential NULL pointer dereference
Jes Sorensen [Wed, 9 Mar 2016 19:11:02 +0000 (14:11 -0500)] 
super_intel: imsm_manage_reshape(): Fix potential NULL pointer dereference

If sra == NULL we cannot goto abort, as it would result in calls to
sysfs_set_num() which would dereference sra.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper-intel: Remove excessive NULL/0 variable initialization
Jes Sorensen [Wed, 9 Mar 2016 19:06:29 +0000 (14:06 -0500)] 
super-intel: Remove excessive NULL/0 variable initialization

This removes a pile of unnecessary NULL/0 initialization of variables.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoManage: Manage_add(): Fix memory leak
Jes Sorensen [Mon, 7 Mar 2016 16:51:24 +0000 (11:51 -0500)] 
Manage: Manage_add(): Fix memory leak

sysfs_read() allocates and populates a struct mdinfo, however the code
forgot to free it again, before dropping the reference to the pointer.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: goto release if Manage_subdevs failed
Guoqing Jiang [Tue, 22 Mar 2016 09:03:44 +0000 (17:03 +0800)] 
Grow: goto release if Manage_subdevs failed

If failure happened when add disk to array
by grow mode, need to goto release instead
of continue the reshape.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: analyse_change add notification about only 2-device can be convert from RAID1...
Yi Zhang [Fri, 11 Mar 2016 09:26:40 +0000 (17:26 +0800)] 
Grow: analyse_change add notification about only 2-device can be convert from RAID1 to RAID5

Notify "Can only convert a 2-device array to RAID5" instead of
"Impossibly level change request for RAID1" when convert from
RAID1 to RAID5 if the disk num is not equal two like RAID4/5->RAID1
did.

Signed-off-by: Yi Zhang <yizhan@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper-intel: Simplify for() loop in ahci_enumerate_ports
Pawel Baldysiak [Fri, 11 Mar 2016 15:47:16 +0000 (16:47 +0100)] 
super-intel: Simplify for() loop in ahci_enumerate_ports

This patch simplifies for() loop used in
ahci_enumerate_ports(). It makes it more readable.
Similar thing was done in b913501
({platform,super}-intel: Fix two resource leaks).

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper-intel: Make print_vmd_attached_devs() return int again
Pawel Baldysiak [Fri, 11 Mar 2016 15:47:15 +0000 (16:47 +0100)] 
super-intel: Make print_vmd_attached_devs() return int again

This patch reverts a0abe1e
(super-intel: Make print_found_intel_controllers() return void)
and make this function "return int" again.
Also, interpreting the return value is added.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: close fd earlier to avoid "cannot get excl access" when stopping
Pawel Baldysiak [Fri, 11 Mar 2016 12:49:07 +0000 (13:49 +0100)] 
Grow: close fd earlier to avoid "cannot get excl access" when stopping

If this file descriptor is not closed here, it remains open during
reshape process and stopping process will end up with
"cannot get exclusive access to container".
Once this file descriptor is no longer needed - it can be closed.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoFix regression during add devices
Hannes Reinecke [Wed, 9 Mar 2016 05:20:18 +0000 (13:20 +0800)] 
Fix regression during add devices

Commit d180d2aa2a17 ("Manage: fix test for 'is array failed'.")
introduced a regression which would not allow to re-add new
drivers to a failed array.

Fixes: d180d2aa2a17 ("Manage: fix test for 'is array failed'.")
Signed-off-by: Hannes Reinecke <hare@suse.de>
Cc: Coly Li <colyli@suse.de>
Cc: Neil Brown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoddf: use 64bit 'size', not 32bit 'info->size' for create.
NeilBrown [Thu, 10 Mar 2016 07:06:59 +0000 (18:06 +1100)] 
ddf: use 64bit 'size', not 32bit 'info->size' for create.

The 'size' field of mdu_disk_info_t is 32bit and should not be used
except for legacy ioctls.  super-ddf got this wrong :-(

This change makes it possible to create ddf arrays which used more than
2TB of each device.

Reported-by: Dan Russell <dpr@aol.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper-intel: Make print_found_intel_controllers() return void
Jes Sorensen [Wed, 9 Mar 2016 16:25:16 +0000 (11:25 -0500)] 
super-intel: Make print_found_intel_controllers() return void

The return value from print_found_intel_controllers() is never used,
so lets make it return void.

Reported-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper1: Fix potential buffer overflows when copying cluster_name
Jes Sorensen [Mon, 7 Mar 2016 19:50:06 +0000 (14:50 -0500)] 
super1: Fix potential buffer overflows when copying cluster_name

cmap_get_string() used to retrieve cluster_name does not restrict it's
size. To prevent buffer overflows use the size of the destination
buffer, not strlen() of the source, and null terminate the copied
string.

Fixes: 0aa2f15b ("mdadm: add the ability to change cluster name)"
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoManage: Manage_subdevs() fix file descriptor leak
Jes Sorensen [Mon, 7 Mar 2016 18:53:43 +0000 (13:53 -0500)] 
Manage: Manage_subdevs() fix file descriptor leak

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agobitmap: Fix resource leak in bitmap_file_open()
Jes Sorensen [Mon, 7 Mar 2016 18:48:19 +0000 (13:48 -0500)] 
bitmap: Fix resource leak in bitmap_file_open()

The code would leak 'fd' if locate_bitmap() failed.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years ago{platform,super}-intel: Fix two resource leaks
Jes Sorensen [Mon, 7 Mar 2016 17:33:49 +0000 (12:33 -0500)] 
{platform,super}-intel: Fix two resource leaks

The code did not free 'dir' allocated by opendir(). An additional
benefit is that this simplifies the for() loops.

Fixes: 60f0f54d ("IMSM: Add support for VMD")
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: Grow_addbitmap(): Add check to quiet down static code checkers
Jes Sorensen [Fri, 4 Mar 2016 21:49:38 +0000 (16:49 -0500)] 
Grow: Grow_addbitmap(): Add check to quiet down static code checkers

Grow_addbitmap() is only ever called with s->bitmap_file != NULL, but
not all static code checkers catch this. This adds a check to quiet
down the false positive warnings.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: Grow_continue_command() remove dead code
Jes Sorensen [Fri, 4 Mar 2016 21:30:22 +0000 (16:30 -0500)] 
Grow: Grow_continue_command() remove dead code

All cases where fd2 is used are completed with a close(fd2), so there
is no need to set fd2 = -1 or check for it before exiting.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoload_sys(): Add a buffer size argument
Jes Sorensen [Fri, 4 Mar 2016 21:00:21 +0000 (16:00 -0500)] 
load_sys(): Add a buffer size argument

This adds a buffer size argument to load_sys(), rather than relying on
a hard coded buffer size. The old behavior was safe because we knew
the kernel would never return strings overrunning the buffers, however
it was ugly, and would cause code checking tools to spit out warnings.

This caused a Coverity warning over the read into
sra->sysfs_array_state which is only 20 bytes.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoManage: Manage_add(): Fix potential NULL pointer dereference
Jes Sorensen [Mon, 7 Mar 2016 16:49:03 +0000 (11:49 -0500)] 
Manage: Manage_add(): Fix potential NULL pointer dereference

sysfs_read() may return NULL, so we should check the validity of the
pointer before dereferencing it.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoAssemble: Remove unnecesary NULL pointer checks when calling sysfs_free()
Jes Sorensen [Mon, 7 Mar 2016 17:09:12 +0000 (12:09 -0500)] 
Assemble: Remove unnecesary NULL pointer checks when calling sysfs_free()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoIncremental: Remove unnecesary NULL pointer checks when calling sysfs_free()
Jes Sorensen [Mon, 7 Mar 2016 17:07:45 +0000 (12:07 -0500)] 
Incremental: Remove unnecesary NULL pointer checks when calling sysfs_free()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoutil: Remove unnecesary NULL pointer checks when calling sysfs_free()
Jes Sorensen [Mon, 7 Mar 2016 17:04:58 +0000 (12:04 -0500)] 
util: Remove unnecesary NULL pointer checks when calling sysfs_free()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoManage: Remove unnecessary NULL pointer checks
Jes Sorensen [Mon, 7 Mar 2016 16:54:33 +0000 (11:54 -0500)] 
Manage: Remove unnecessary NULL pointer checks

sysfs_free() handles NULL pointers, so remove superfluous NULL pointer
checks before calling it.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoRemove dead code about LKF_CONVERT flag
Guoqing Jiang [Mon, 7 Mar 2016 09:31:03 +0000 (17:31 +0800)] 
Remove dead code about LKF_CONVERT flag

Since flags is only set as LKF_NOQUEUE, the code
with LKF_CONVERT flag should be delete.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoFix wrong bitmap output for cluster raid
Guoqing Jiang [Mon, 7 Mar 2016 09:31:02 +0000 (17:31 +0800)] 
Fix wrong bitmap output for cluster raid

For cluster raid, we need to displays bitmap related
contents from different bitmaps which are based on node
num. So bitmap_file_open and locate_bitmap are changed a
little bit for the purpose.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Fixes: b98043a2f8 ("Show all bitmaps while examining bitmap")
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper-intel: ensure suspended region is removed when reshape completes.
NeilBrown [Thu, 18 Feb 2016 04:53:32 +0000 (15:53 +1100)] 
super-intel: ensure suspended region is removed when reshape completes.

A recent commit removed a call to abort_reshape() when IMSM reshape
completed.  An unanticipated result of this is that the suspended
region is not cleared as it should be.
So after a reshape, a region of the array will cause all IO to block.

Re-instate the required updates to suspend_{lo,hi} coped from
abort_reshape().

This is caught (sometimes) by the test suite.

Also fix a couple of typos found while exploring the code.

Reported-by: Ken Moffat <zarniwhoop@ntlworld.com>
Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Fixes: 2139b03c2080 ("imsm: don't call abort_reshape() in imsm_manage_reshape()")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoGrow: Add documentation to abort_reshape() for suspend_{lo,hi} setting
Jes Sorensen [Mon, 22 Feb 2016 14:43:43 +0000 (09:43 -0500)] 
Grow: Add documentation to abort_reshape() for suspend_{lo,hi} setting

Add documentation for quirky reset procedure for resetting suspended
region range.

Suggested-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoManage.c: Only issue change events for kernels older than 2.6.28
Jes Sorensen [Tue, 16 Feb 2016 21:58:36 +0000 (16:58 -0500)] 
Manage.c: Only issue change events for kernels older than 2.6.28

2.6.28+ kernels handle this themselves and issuing the event here can
cause a race.

Reported-by: Sebastian Parschauer <sebastian.riemer@profitbricks.com>
Suggested-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agomdadm.h: rename bswap macros to avoid clash with uClibc definitions
Jes Sorensen [Wed, 10 Feb 2016 19:15:38 +0000 (14:15 -0500)] 
mdadm.h: rename bswap macros to avoid clash with uClibc definitions

uClibc exposes it's own version of bswap_<X> macros. Rather than
pulling in random macros by change, rename the mdadm ones to make sure
we know what we are getting.

Reported-by: "Maxin B. John" <maxin.john@gmail.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoutil.c: include poll.h instead of sys/poll.h
Maxin B. John [Fri, 5 Feb 2016 22:28:16 +0000 (00:28 +0200)] 
util.c: include poll.h instead of sys/poll.h

This fixes a compile warning when building with musl:

 In file included from util.c:27:0:
 |
 qemux86-64/usr/include/sys/poll.h:1:2:
 error: #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
 [-Werror=cpp]
 |  #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
 |   ^

Signed-off-by: Maxin B. John <maxin.john@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoMakefile: make the CC definition conditional
Maxin B. John [Mon, 8 Feb 2016 09:59:29 +0000 (11:59 +0200)] 
Makefile: make the CC definition conditional

By hardcoding CC's definition in the Makefile, all the external gcc
parameters set by tune settings are lost. This causes compile failure
with x32 toolchain

Signed-off-by: Maxin B. John <maxin.john@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoFix some type comparison problems
Xiao Ni [Sat, 6 Feb 2016 01:18:41 +0000 (09:18 +0800)] 
Fix some type comparison problems

As 26714713cd2bad9e0bf7f4669f6cc4659ceaab6c said, 32 bit signed
timestamps will overflow in the year 2038. It already changed the
utime and ctime in struct mdu_array_info_s from int to unsigned
int. So we need to change the values that compared with them to
unsigned int too.

Signed-off-by : Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agosuper1: Fix bblog_size accesses on big-ending machines.
NeilBrown [Fri, 29 Jan 2016 01:35:33 +0000 (12:35 +1100)] 
super1: Fix bblog_size accesses on big-ending machines.

bblog_size is 16bit so using le32_to_cpu on it is not wise
and leads to errors on big-endian machines.
Change all such calls to use le16.

Bug was introduced in mdadm-3.3

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
4 years agoRelease mdadm-3.4 mdadm-3.4
NeilBrown [Thu, 28 Jan 2016 02:34:13 +0000 (13:34 +1100)] 
Release mdadm-3.4

My last release!

Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoAssorted fixed for a "make everything" build
NeilBrown [Thu, 28 Jan 2016 02:28:58 +0000 (13:28 +1100)] 
Assorted fixed for a "make everything" build

Signed-off-by: NeilBrown <neilb@suse.com>
4 years agosuper1: allow reshape that hasn't really started to be reverted.
NeilBrown [Thu, 28 Jan 2016 01:57:08 +0000 (12:57 +1100)] 
super1: allow reshape that hasn't really started to be reverted.

A simple revert doesn't work here because the reshape_position is
in the critical section.
The best approach is to let the reshape progress a bit and then
go backwards.
If that isn't possible, assembling with --update=revert-reshape and
--invalid-backup should work.

Reported-by-tested-by: George Rapp <george.rapp@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agosuper0: Fix reporting of devices between 2GB and 4GB
NeilBrown [Thu, 28 Jan 2016 00:57:54 +0000 (11:57 +1100)] 
super0: Fix reporting of devices between 2GB and 4GB

v0.90 metadata can handle devices between 2GB and 4GB, but we need
to treat the 'size' and unsigned.  In a couple of places we don't.

URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809447
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agosystemd/mdadm-last-resort: add Conflicts to .service file.
NeilBrown [Thu, 28 Jan 2016 00:45:53 +0000 (11:45 +1100)] 
systemd/mdadm-last-resort: add Conflicts to .service file.

It seems that having the Conflicts in the .timer file is not sufficient.
Sometimes it works, but if the timer gets requested after the conflicting
block device appears (or was it "before" ...) the timer is not aborted.

Having the Conflicts in both files seems to work reliably.

URL: https://bugzilla.suse.com/show_bug.cgi?id=853944
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agosuper1: fix calculation of space_before
NeilBrown [Thu, 28 Jan 2016 00:44:27 +0000 (11:44 +1100)] 
super1: fix calculation of space_before

This code was meant to update 'earliest' but clearly never doesn't.

This bug would only affect an array with a very large bitmap so it is unlikely
to be significant.

Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoutil: fix wrong return value of cluster_get_dlmlock
Guoqing Jiang [Wed, 20 Jan 2016 08:21:25 +0000 (16:21 +0800)] 
util: fix wrong return value of cluster_get_dlmlock

Actually lksb.sb_status means that a node got the lock
or not instead of the return value of dlm_lock.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
4 years agoAdd casts for the addr arg of connect and bind
Khem Raj [Thu, 14 Jan 2016 06:32:39 +0000 (22:32 -0800)] 
Add casts for the addr arg of connect and bind

glibc allows the addr arg to connect and socket to be any of a number
of 'sockaddr_*' types, but musl requires 'const struct sockaddr *'
which is in line with open group specs.  So add casts to allow
compilation with musl.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoDefine _POSIX_C_SOURCE if undefined
Khem Raj [Thu, 14 Jan 2016 06:32:38 +0000 (22:32 -0800)] 
Define _POSIX_C_SOURCE if undefined

config.c uses _POSIX_C_SOURCE which is defined in features.h when
glibc/uclibc is used, but isn't defined when musl is used.
So provide a reasonable default.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoCreate: minor fix when adding a journal device
NeilBrown [Thu, 14 Jan 2016 03:09:57 +0000 (14:09 +1100)] 
Create: minor fix when adding a journal device

The check of "is there a filesystem here" is still appropriate for a
journal device.

Also set active_disks correctly - even though it is ignored.

Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoCreate: fix regression in setting raid_disk
NeilBrown [Thu, 14 Jan 2016 02:22:17 +0000 (13:22 +1100)] 
Create: fix regression in setting raid_disk

Recent commit caused 'missing' declarations to not be handled correctly.

Fixes: cc1799c3ddc9 ("Enable create array with write journal (--write-journal DEVICE).")
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agorestripe: fix compilation of "make test"
NeilBrown [Tue, 12 Jan 2016 23:01:02 +0000 (10:01 +1100)] 
restripe: fix compilation of "make test"

Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoFix wrong description in manpage
Guoqing Jiang [Tue, 12 Jan 2016 15:08:24 +0000 (18:08 +0300)] 
Fix wrong description in manpage

The careless change was introduce by 'commit 7e6e839a2651
(mdadm: change the num of cluster node)'. Which should be
revert to avoid misunderstanding.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoimsm: don't update migration record when reshape is interrupted
Artur Paszkiewicz [Tue, 5 Jan 2016 16:16:16 +0000 (17:16 +0100)] 
imsm: don't update migration record when reshape is interrupted

Abort imsm_manage_reshape() without updating the migration record if any
error occurs when checking progress. If reshape is interrupted and the
migration record is then updated, the checkpoint will be wrong and will
cause reshape to fail when the array is restarted.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoimsm: use timeout when waiting for reshape progress
Artur Paszkiewicz [Tue, 5 Jan 2016 16:16:15 +0000 (17:16 +0100)] 
imsm: use timeout when waiting for reshape progress

Waiting for reshape progress is done by using select() on sync_completed
to block until an exception condition is signalled on the
filedescriptor. This happens when the attribute's value is updated by
the kernel, but if the array is stopped when mdadm is blocked on
select() this will never happen, because this attribute is then removed
and apparently the kernel doesn't do sysfs_notify() when removing a
sysfs attribute. So set a 3 second timeout for the sysfs_wait() call.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoIMSM: Add support for VMD
Pawel Baldysiak [Tue, 5 Jan 2016 16:03:04 +0000 (17:03 +0100)] 
IMSM: Add support for VMD

The Intel Volume Management Device (VMD) is an integrated
endpoint on the platform's PCIe root complex that acts
as a host bridge to a secondary PCIe domain.

This patch adds proper handling of NVMe devices attached to VMD domain.
Each VMD domain is treated as a separate controller (HBA).
Spanning between domains is forbidden.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoimsm: abort reshape if sync_action is not "reshape"
Artur Paszkiewicz [Wed, 23 Dec 2015 11:57:11 +0000 (12:57 +0100)] 
imsm: abort reshape if sync_action is not "reshape"

When reshape was interrupted, an incorrect checkpoint would be saved in
the migration record. Change wait_for_reshape_imsm() to return -1 when
sync_action is not "reshape" to abort early in imsm_manage_reshape()
without writing the migration record.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoGrow: close file descriptor earlier to avoid "still in use" when stopping
Artur Paszkiewicz [Wed, 23 Dec 2015 11:57:10 +0000 (12:57 +0100)] 
Grow: close file descriptor earlier to avoid "still in use" when stopping

Close fd2 as soon as it is no longer needed, before calling
Grow_continue(). Otherwise, we won't be able to stop an array with
external metadata during reshape, because mdadm running in background
will be keeping it open.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoDetail: fix wrong condition in recent change.
NeilBrown [Wed, 23 Dec 2015 01:15:32 +0000 (12:15 +1100)] 
Detail: fix wrong condition in recent change.

Now that we can print device details with a specific raid_disk but not
disk.number, the condition for "print either disk.number or disk.raid_disk"
must be make more specific.

Reported-by: Coly Li <colyli@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoCheck and remove bitmap first when reshape to raid0
Xiao Ni [Tue, 22 Dec 2015 03:09:34 +0000 (11:09 +0800)] 
Check and remove bitmap first when reshape to raid0

If reshape one raid device with bitmap to raid0, the reshape progress will
start. But it'll fail and lose some components. So it should remove bitmap
first.

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoin --add assign raid_disk of 0 to journal
Song Liu [Mon, 21 Dec 2015 19:23:42 +0000 (11:23 -0800)] 
in --add assign raid_disk of 0 to journal

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agomove journal to end of --detail list
Song Liu [Mon, 21 Dec 2015 19:23:41 +0000 (11:23 -0800)] 
move journal to end of --detail list

As we give journal device raid_disk of 0, the output of --detail is:

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       5       8       24        0      journal   /dev/sdb8
       1       8       18        1      active sync   /dev/sdb2
       2       8       19        2      active sync   /dev/sdb3
       3       8       21        3      active sync   /dev/sdb5

       4       8       23        -      spare   /dev/sdb7

This patch makes it back to:
    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       18        1      active sync   /dev/sdb2
       2       8       19        2      active sync   /dev/sdb3
       3       8       21        3      active sync   /dev/sdb5

       4       8       23        -      spare   /dev/sdb7
       5       8       24        -      journal   /dev/sdb8

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoAdd --update=force-no-bbl.
NeilBrown [Mon, 21 Dec 2015 03:56:38 +0000 (14:56 +1100)] 
Add --update=force-no-bbl.

This forcibly removed the bad-block log.  There can be situations where it is hard to
remove bad blocks by writing to them - partiularly on RAID5.

Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoMerge branch 'fix-unlikely-potential-overflows' of https://github.com/sjvs/mdadm
NeilBrown [Mon, 21 Dec 2015 02:01:10 +0000 (13:01 +1100)] 
Merge branch 'fix-unlikely-potential-overflows' of https://github.com/sjvs/mdadm

4 years agoMerge https://github.com/makelinux/mdadm
NeilBrown [Mon, 21 Dec 2015 01:57:06 +0000 (12:57 +1100)] 
Merge https://github.com/makelinux/mdadm

Fixes https://github.com/neilbrown/mdadm/issues/17

4 years agoDetail: don't assume a particular 'disk' number of missing devices.
NeilBrown [Fri, 18 Dec 2015 02:51:54 +0000 (13:51 +1100)] 
Detail: don't assume a particular 'disk' number of missing devices.

When a particular raid-disk is missing, we don't know which disk number
it should have, and reporting a number could result in duplicate
numbers (with v1.x metadata - never with the old 0.90).

So set the default to -1 and recoginise that when printing.

Signed-off-by: NeilBrown <neilb@suse.com>
4 years agoDetail: report correct raid-disk for removed drives.
NeilBrown [Fri, 18 Dec 2015 02:49:30 +0000 (13:49 +1100)] 
Detail: report correct raid-disk for removed drives.

Back in
  Commit: 8057db46a15d ("Detail: fix handling of 'disks' array.")
when we doubled the size of the 'disks' array to handle primary and
replacement, we should have halved the setting of the default raid_disk
number.

Reported-by: Coly Li <colyli@suse.de>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agomdadm: improve the safeguard for change cluster raid's sb
Guoqing Jiang [Wed, 16 Dec 2015 17:54:26 +0000 (01:54 +0800)] 
mdadm: improve the safeguard for change cluster raid's sb

This commit does the following jobs:

1. rename is_clustered to dlm_funs_ready since it match the
   function better.
2. st->cluster_name can't be use to identify the raid is a
   clustered or not, we should check the bitmap's version to
   perform the identification.
3. for cluster_get_dlmlock/cluster_release_dlmlock funcs, both
   of them just need the lockid as parameter since the cluster
   name can get by get_cluster_name().

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>
4 years agomdadm: do not try to hold dlm lock in free_super1
Guoqing Jiang [Wed, 16 Dec 2015 17:54:25 +0000 (01:54 +0800)] 
mdadm: do not try to hold dlm lock in free_super1

Since free_super1 actually doesn't change the sb, it
just free the addr space of sb. Also free_super1 is
called in lots of place within mdadm, so remove dlm
lock code since the func doesn't need the protection
and also reduce latency.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>