]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
7 years agoAdd failfast support.
NeilBrown [Thu, 24 Nov 2016 23:55:49 +0000 (10:55 +1100)] 
Add failfast support.

Allow per-device "failfast" flag to be set when creating an
array or adding devices to an array.

When re-adding a device which had the failfast flag, it can be removed
using --nofailfast.

failfast status is printed in --detail and --examine output.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoIncrease buffer for sysfs disk state
Tomasz Majchrzak [Thu, 27 Oct 2016 09:34:16 +0000 (11:34 +0200)] 
Increase buffer for sysfs disk state

Bad block support has incremented sysfs disk state reported by kernel
("external_bbl") so it became longer than 20 bytes. It causes reshape to
fail as it reads truncated entry from sysfs.

Increase buffer so it can accommodate the string including all state
values currently implemented in kernel at the same time.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoIncrease buffer for sysfs path
Tomasz Majchrzak [Fri, 28 Oct 2016 08:35:50 +0000 (10:35 +0200)] 
Increase buffer for sysfs path

'unacknowledged_bad_blocks' is a long name for sysfs property and it
makes sysfs path over 50 characters long. Increase buffer to the double
length of the longest path available in sysfs at the moment.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoIMSM: 4Kn drives support - adapt general migration record
Pawel Baldysiak [Thu, 17 Nov 2016 13:58:38 +0000 (14:58 +0100)] 
IMSM: 4Kn drives support - adapt general migration record

Convert general migration record for 4Kn drives prior to write and post
read. Calculate record location based on sector size, don't just assume
it's 512. Assure buffer address is aligned to 4096 so write operation
avoids caching.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoIMSM: Add support for 4Kn sector size drives
Pawel Baldysiak [Thu, 17 Nov 2016 13:58:37 +0000 (14:58 +0100)] 
IMSM: Add support for 4Kn sector size drives

This patch adds support for drives with 4Kn sector size
for IMSM metadata. Mixing member drives with 4kn and 512
is not allowed. Some offsets were aligned with sector size.
Internal metadata representation and all calculations
are still based on 512-byte sector sizes. This
implementation converts only sector based values
when reading/writing to drive, because they needs to be
stored in metadata according to accual member drive sector size.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoIMSM: Read and store device sector size
Pawel Baldysiak [Thu, 17 Nov 2016 13:58:36 +0000 (14:58 +0100)] 
IMSM: Read and store device sector size

This patch adds retriving device sector size at startup
and set it in intel_super, so it can be used in other places.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoAdd function for getting member drive sector size
Pawel Baldysiak [Thu, 17 Nov 2016 13:58:35 +0000 (14:58 +0100)] 
Add function for getting member drive sector size

This patch introduces the function for getting sector size of
given device (fd).

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agosuper1: fix setting bad block log offset in write_init_super1()
Artur Paszkiewicz [Thu, 10 Nov 2016 10:50:54 +0000 (11:50 +0100)] 
super1: fix setting bad block log offset in write_init_super1()

Commit f79bbf4f6904 ("super1: don't put the bblog at the end of the free
space.") changed the location of the bad block log to be after the
write-intent bitmap, but a fixed offset was used and it can make bbl
overlap with the bitmap, especially when using a small bitmap chunk.
This patch changes it to use the actual offset and size of the bitmap.
It also joins the cases for v1.1 and v1.2 superblock because the code
was very similar.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agosuper1: make internal bitmap size calculations more consistent
Artur Paszkiewicz [Thu, 10 Nov 2016 10:50:53 +0000 (11:50 +0100)] 
super1: make internal bitmap size calculations more consistent

Determining internal bitmap size is performed using two different
functions (bitmap_sectors() and calc_bitmap_size()) and in
getinfo_super1() it is calculated in yet another way. Each of these
methods give slightly different results. The most accurate is
calc_bitmap_size() but it also has a rounding issue. So:

- fix the rounding issue in calc_bitmap_size() using bitmap_bits()
- replace usages of bitmap_sectors() and open-coded calculations with
  calc_bitmap_size()
- remove bitmap_sectors()
- move bitmap_bits() to mdadm.h as inline - otherwise mdassemble won't
  compile (it does not use bitmap.c)

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoLib.c: Fix geting devname for devices with long path
Pawel Baldysiak [Fri, 21 Oct 2016 09:37:51 +0000 (11:37 +0200)] 
Lib.c: Fix geting devname for devices with long path

In scenario where VMD is enabled, and "x8" type of NVMe drive is
plugged into PCIe switch - the path will be longer than 200 chars
(additional VMD domain + 2 level of PCIe switches).
This patch makes the buffer big enough to handle this kind of
configurations.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoIMSM: Enable spanning between VMD domains
Pawel Baldysiak [Fri, 21 Oct 2016 09:37:50 +0000 (11:37 +0200)] 
IMSM: Enable spanning between VMD domains

Each VMD domain adds additional PCI domain. This patch
enables RAID creation with NVMe drives from different
VMD domains.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoIMSM: Add warning message when x8-type device is used
Pawel Baldysiak [Mon, 24 Oct 2016 08:19:52 +0000 (10:19 +0200)] 
IMSM: Add warning message when x8-type device is used

This patch adds the warning message when x8-type device
is used with IMSM metadata. x8 device is a special
NVMe drive - two of them on a single PCIe card.
This card could be a single point of failure for
RAID levels different than RAID0. x8 devices have
serial number ending with "-A/-B" or "-1/-2".

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoimsm: load migration record from right disk
Tomasz Majchrzak [Mon, 24 Oct 2016 10:00:17 +0000 (12:00 +0200)] 
imsm: load migration record from right disk

Migration record is only stored on disks in first and second metadata
slot. The function to load the record incorrectly passes disk slot as
disk index. If rebuilt has taken place for a container, disk slot
doesn't match disk index so it causes migration record to be read from a
disk it has not been written to. As a result reshape operation fails.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoraid6check.c: fix "misleading-indentation" error
Yilong Ren [Wed, 26 Oct 2016 08:10:38 +0000 (16:10 +0800)] 
raid6check.c: fix "misleading-indentation" error

To fix the following error info:

root@vm-lkp-nex04-8G-7 /tmp/mdadm# make test
cc -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter -ggdb -DSendmail=\""/usr/sbin/sendmail -t"\" -DCONFFILE=\"/etc/mdadm.conf\" -DCONFFILE2=\"/etc/mdadm/mdadm.conf\" -DMAP_DIR=\"/run/mdadm\" -DMAP_FILE=\"map\" -DMDMON_DIR=\"/run/mdadm\" -DFAILED_SLOTS_DIR=\"/run/mdadm/failed-slots\" -DNO_COROSYNC -DNO_DLM -DVERSION=\"3.4-43-g1dcee1c\" -DVERS_DATE="\"06th April 2016\"" -DUSE_PTHREADS -DBINDIR=\"/sbin\"  -c -o raid6check.o raid6check.c
raid6check.c: In function 'manual_repair':
raid6check.c:267:4: error: this 'else' clause does not guard... [-Werror=misleading-indentation]
    else
    ^~~~
raid6check.c:269:5: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'else'
     printf("Repairing D(%d) and P\n", failed_data);
     ^~~~~~
cc1: all warnings being treated as errors
<builtin>: recipe for target 'raid6check.o' failed
make: *** [raid6check.o] Error 1
root@vm-lkp-nex04-8G-7 /tmp/mdadm#

Cc: NeilBrown <neilb@suse.com>
Cc: linux-raid <linux-raid@vger.kernel.org>
Cc: LKP <lkp@eclists.intel.com>
Reviewed-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Yilong Ren <yilongx.ren@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoFix bus error when accessing MBR partition records
James Clarke [Mon, 17 Oct 2016 20:16:01 +0000 (21:16 +0100)] 
Fix bus error when accessing MBR partition records

Since the MBR layout only has partition records as 2-byte aligned, the
32-bit fields in them are not aligned. Thus, they cannot be accessed on
some architectures (such as SPARC) by using a "struct MBR_part_record *"
pointer, as the compiler can assume that the pointer is properly aligned.
Instead, the records must be accessed by going through the MBR struct
itself every time.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agosuper-intel: Reduce excessive parenthesis abuse
Jes Sorensen [Wed, 19 Oct 2016 16:31:00 +0000 (12:31 -0400)] 
super-intel: Reduce excessive parenthesis abuse

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoAllow level migration only for single-array container
Mariusz Dabrowski [Wed, 12 Oct 2016 12:29:42 +0000 (14:29 +0200)] 
Allow level migration only for single-array container

IMSM doesn't allow to change RAID level of array in container with two
arrays but array count check is being done too late (after removing disks)
and in some cases (e. g. RAID 0 and RAID 1 migrated to RAID 0) both arrays
become degraded. This patch adds array count check before disks are being
removed.

Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoimsm: block chunk size change for RAID 10
Mariusz Dabrowski [Wed, 12 Oct 2016 12:28:42 +0000 (14:28 +0200)] 
imsm: block chunk size change for RAID 10

Chunk size change of RAID 10 array fails because it is not supported but
invalid values still are being written to metadata and array cannot be
assembled after stop. Operation should be blocked before metadata update.

Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agosuper1: make write_bitmap1 compatible with previous mdadm versions
Guoqing Jiang [Wed, 12 Oct 2016 06:24:07 +0000 (02:24 -0400)] 
super1: make write_bitmap1 compatible with previous mdadm versions

For older mdadm version, v1.x metadata has different bitmap_offset,
we can't ensure all the bitmaps are on a 4K boundary since writing
4K for bitmap could corrupt the superblock, and Anthony reported
the bug about it at below link.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837964

So let's check about the alignment for bitmap_offset before set
the boundary to 4096 unconditionally. Thanks for Neil's detailed
explanation.

Reported-by: Anthony DeRobertis <anthony@derobert.net>
Fixes: 95a05b37e8eb ("Create n bitmaps for clustered mode")
Cc: Neil Brown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoFix some issues found by clang
NeilBrown [Fri, 7 Oct 2016 03:55:20 +0000 (14:55 +1100)] 
Fix some issues found by clang

The clang compiler complained about each of these.

The mdmon.h error will only affect 'far' RAID10 arrays using intel or DDF
metadata, and there is no such thing.

The mdopen.c will cause a problem if there are no free md device
numbers in the first 512.  That is fairly unlikely.

The restripe.c error would only affect the 'test_stripe' command, and
probably doesn't change its behaviour.

The super-intel.c fix is purely cosmetic.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoimsm: retrieve nvme serial from sysfs
Artur Paszkiewicz [Thu, 6 Oct 2016 09:13:09 +0000 (11:13 +0200)] 
imsm: retrieve nvme serial from sysfs

Don't rely on SCSI ioctl for reading NVMe serials - SCSI emulation for
NVMe devices can be disabled in the kernel config. Instead, try to get a
serial from /sys/block/nvme*/device/serial. If that fails for whatever
reason (i.e. no such attribute in old kernels) - fall back to the SCSI
method.

This also moves some SCSI-specific code from imsm_read_serial() to
scsi_get_serial().

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Reviewed-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoFix RAID metadata check
Mariusz Dabrowski [Thu, 22 Sep 2016 07:02:11 +0000 (09:02 +0200)] 
Fix RAID metadata check

mdadm recognizes devices with partition table as part of an RAID array
and invalid warning message is displayed. After this fix proper warning
messages are being displayed for MBR/GPT disks and devices with RAID
metadata.

Signed-off-by: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoimsm: remove redundant characters from some error messages
Artur Paszkiewicz [Fri, 16 Sep 2016 13:25:14 +0000 (15:25 +0200)] 
imsm: remove redundant characters from some error messages

Fix the cases that produced messages like "mdadm: : The message".

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoimsm: do not activate spares for uninitialized member arrays
Artur Paszkiewicz [Thu, 15 Sep 2016 07:53:58 +0000 (09:53 +0200)] 
imsm: do not activate spares for uninitialized member arrays

This fixes some issues when a member array is created with "missing"
devices in a container that has more devices than used in the member
array.

Reported-by: Yi Zhang <yizhan@redhat.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agomdadm: fix a buffer overflow
Song Liu [Thu, 8 Sep 2016 18:21:07 +0000 (11:21 -0700)] 
mdadm: fix a buffer overflow

struct mdp_superblock_1.set_name is 32B long, but struct mdinfo.name
is 33B long. So we need strncpy instead strcpy to avoid buffer
overflow.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agomdopen: Prevent overrunning the devname buffer when copying devnm into it for long...
Robert LeBlanc [Wed, 24 Aug 2016 16:10:44 +0000 (10:10 -0600)] 
mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names.

Linux allows for 32 character device names. When using the maximum
size device name and also storing "/dev/", devname needs to be 37
character long to store the complete device name.
i.e. "/dev/md_abcdefghijklmnopqrstuvwxyz12\0"

Signed-off-by: Robert LeBlanc<robert@leblancnet.us>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agobitmap: Mark a number of local functions static
Jes Sorensen [Mon, 15 Aug 2016 20:35:28 +0000 (16:35 -0400)] 
bitmap: Mark a number of local functions static

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agobitmap: Handle errors when reading bitmap info for cluster nodes
Jes Sorensen [Mon, 15 Aug 2016 20:21:33 +0000 (16:21 -0400)] 
bitmap: Handle errors when reading bitmap info for cluster nodes

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agobitmap: Simplify code for bitmap_file_open()
Jes Sorensen [Mon, 15 Aug 2016 20:16:05 +0000 (16:16 -0400)] 
bitmap: Simplify code for bitmap_file_open()

By switching to open+fstat rather than stat+open the code can be
simplified and avoid duplicating the open handling.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agosuper0: Clean up formatting in examine_super0()
Jes Sorensen [Mon, 15 Aug 2016 19:56:23 +0000 (15:56 -0400)] 
super0: Clean up formatting in examine_super0()

No funcionality change - should be purely cosmetic

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agosuper0: Fix spelling of 'version' in comment and fix formatting
Jes Sorensen [Mon, 15 Aug 2016 19:49:59 +0000 (15:49 -0400)] 
super0: Fix spelling of 'version' in comment and fix formatting

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agosuper0: Use random_uuid() in init_super0()
Jes Sorensen [Mon, 15 Aug 2016 19:48:56 +0000 (15:48 -0400)] 
super0: Use random_uuid() in init_super0()

This shaves another 80 bytes off the mdadm binary.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agoIntroduce random_uuid() helper function
Jes Sorensen [Mon, 15 Aug 2016 19:41:34 +0000 (15:41 -0400)] 
Introduce random_uuid() helper function

This gets rid of 5 nearly identical copies of the same code, and
reduces the binary size of mdadm by over 700 bytes on x86_64.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agomdadm.h: Fix build problem against newer glibc
Jes Sorensen [Mon, 15 Aug 2016 15:30:39 +0000 (11:30 -0400)] 
mdadm.h: Fix build problem against newer glibc

Newer glibc requires direct include of sys/sysmacros.h in order to
access makedev().

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agomdadm: put journal device in right place of --detail
Song Liu [Fri, 12 Aug 2016 00:14:13 +0000 (17:14 -0700)] 
mdadm: put journal device in right place of --detail

When there is failed HDDs, journal device showed in wrong place
of --detail:

    Number   Major   Minor   RaidDevice State
       4       8       24        -      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

       0       8       17        -      faulty   /dev/sdb1

This patch fixed the output as:

    Number   Major   Minor   RaidDevice State
       -       0        0        0      removed
       1       8       18        1      active sync   /dev/sdb2
       2       8       19        2      active sync   /dev/sdb3
       3       8       21        3      active sync   /dev/sdb5

       0       8       17        -      faulty   /dev/sdb1
       4       8       24        -      journal   /dev/sdb8

Reported-by: Yi Zhang <yizhan@redhat.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agomdadm: add man page for --add-journal
Song Liu [Fri, 12 Aug 2016 00:10:04 +0000 (17:10 -0700)] 
mdadm: add man page for --add-journal

Add the following to man page:

--add-journal
      Recreate journal for RAID-4/5/6 array that lost a journal device.
      In the current implementation, this command cannot add a journal
      to an array that had a failed journal. To avoid interrupting
      on-going write opertion --add-journal only works for array in
      Read-Only state.

Reported-by: Yi Zhang <yizhan@redhat.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agolib: Various coding style cleanups
Jes Sorensen [Thu, 11 Aug 2016 20:01:00 +0000 (16:01 -0400)] 
lib: Various coding style cleanups

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 years agolib: Avoid if and return on the same line
Jes Sorensen [Thu, 11 Aug 2016 19:53:29 +0000 (15:53 -0400)] 
lib: Avoid if and return on the same line

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>