]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
11 years agosuper1: reserve at least 2 chunks for reshape headroom. r10-reshape
NeilBrown [Wed, 9 May 2012 10:49:32 +0000 (20:49 +1000)] 
super1: reserve  at least 2 chunks for reshape headroom.

sometimes 0.1% isn't enough, though mostly only in testing.

We need one chunk for a successful reshape, so reserve 2.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoNew RESHAPE_NO_BACKUP flag to track when backup action is needed.
NeilBrown [Wed, 9 May 2012 10:49:32 +0000 (20:49 +1000)] 
New RESHAPE_NO_BACKUP flag to track when backup action is needed.

Some arrays (raid10) never need a backup file, so during assembly
we can avoid the whole Grow_continue check in the case.
Achieve this using a flag set by the metadata handler.

Also get "mdadm -I" to fail if a backup process would be
needed.  It currently does fail as the kernel rejects things,
but it is nicer to have this explicit.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: add raid10 reshape.
NeilBrown [Wed, 9 May 2012 10:49:32 +0000 (20:49 +1000)] 
Grow: add raid10 reshape.

RAID10 reshape requires that data_offset be changed.
So we only allow it if the new_data_offset attribute is available,
and we compute a suitable change in data offset.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: set new_data_offset if appropriate
NeilBrown [Wed, 9 May 2012 10:49:31 +0000 (20:49 +1000)] 
Grow: set new_data_offset if appropriate

11 years agoAdd space_before/space_after fields to mdinfo
NeilBrown [Wed, 9 May 2012 10:49:31 +0000 (20:49 +1000)] 
Add space_before/space_after fields to mdinfo

These will be needed to guide changes to data_offset during reshape.
Only set them for super1 for now.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1: add new_offset field.
NeilBrown [Wed, 9 May 2012 10:49:31 +0000 (20:49 +1000)] 
super1: add new_offset field.

The 'new_offset' is used for reshaping to avoid the need
for a backup file.

For now we only report the value when it is set.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd --data-offset flag for Create and Grow
NeilBrown [Wed, 9 May 2012 10:49:31 +0000 (20:49 +1000)] 
Add --data-offset flag for Create and Grow

This can be used to over-ride the automatic assignment of
data offset.
For --create, it is useful to re-create old arrays where different
   defaults applied.
For --grow it may be able to force a reshape in the reverse direction.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd data_offset arg to ->init_super and use it in super1.c
NeilBrown [Wed, 9 May 2012 10:49:31 +0000 (20:49 +1000)] 
Add data_offset arg to ->init_super and use it in super1.c

So if ->data_offset is already set, use that rather than
computing one.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd data_offset arg to ->validate_geometry.
NeilBrown [Wed, 9 May 2012 10:49:31 +0000 (20:49 +1000)] 
Add data_offset arg to ->validate_geometry.

This is needed to return correct available size.  It isn't
really used yet.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd data_offset arg to ->avail_size
NeilBrown [Wed, 9 May 2012 10:49:31 +0000 (20:49 +1000)] 
Add data_offset arg to ->avail_size

This is currently only useful for 1.x metadata and will allow an
explicit --data-offset request on command line.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate new release: 3.2.4 mdadm-3.2.4
NeilBrown [Tue, 8 May 2012 23:42:57 +0000 (09:42 +1000)] 
Create new release: 3.2.4

Bugfix release

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper-intel.c: Fix resource leak from opendir()
Jes Sorensen [Fri, 4 May 2012 11:41:22 +0000 (13:41 +0200)] 
super-intel.c: Fix resource leak from opendir()

Use closedir() on dirp from opendir() to avoid resource leaking.

Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper-intel.c: Don't try to close negative fd
Jes Sorensen [Fri, 4 May 2012 11:41:21 +0000 (13:41 +0200)] 
super-intel.c: Don't try to close negative fd

This should be harmless, but lets be consistent and not try to close a
negative file descripter.

Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: failing the set the per-device size is not an error.
NeilBrown [Thu, 3 May 2012 06:18:22 +0000 (16:18 +1000)] 
Grow: failing the set the per-device size is not an error.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agotest: don't worry too much about array size.
NeilBrown [Thu, 3 May 2012 05:29:04 +0000 (15:29 +1000)] 
test: don't worry too much about array size.

With different amounts of space being reserved for metadata
it is hard for the script to know how big the array should be.
So allow a bit of slack.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdjust to new standard of /run
NeilBrown [Thu, 3 May 2012 04:16:56 +0000 (14:16 +1000)] 
Adjust to new standard of /run

Now that /run seems to be a good standard, make that
the default for storing various run-time files, rather than
/var/run or /dev/.mdadm.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUpdate test for "is udev active".
NeilBrown [Thu, 3 May 2012 04:16:51 +0000 (14:16 +1000)] 
Update test for "is udev active".

Newer udev doesn't use /dev/.udev any more. it used
/run/udev instead.
So test for that as well.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: fix: thunderdome may drop 2tb attribute
Czarnowska, Anna [Mon, 2 Apr 2012 20:59:03 +0000 (20:59 +0000)] 
imsm: fix: thunderdome may drop 2tb attribute

Spare superblock doesn't depend on other spares in container.
When loading container metadata thunderdome
may pick a small disk for the champion. This will result in incorrect
interpretation of sizes of other disks in container when joint superblock
is returned. If any disk in container has the 2TB attribute set, the result
must have it set too.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoIntroduce sysfs_set_num_signed() and use it to set bitmap/offset
Jes Sorensen [Thu, 26 Apr 2012 15:12:57 +0000 (17:12 +0200)] 
Introduce sysfs_set_num_signed() and use it to set bitmap/offset

mdinfo->bitmap_offset is a signed long and needs to be treated as
such when passed to the kernel.

This resolves the problem with adding internal bitmaps to a 1.0 array.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix sign extension of bitmap_offset in super1.c
Jes Sorensen [Thu, 26 Apr 2012 15:12:56 +0000 (17:12 +0200)] 
Fix sign extension of bitmap_offset in super1.c

fbdef49811c9e2b54e2064d9af68cfffa77c6e77 incorrectly tried to fix sign
extension of the bitmap offset. However mdinfo->bitmap_offset is a u32
and needs to be converted to a 32 bit signed integer before the sign
extension.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agofix: correct extending size of raid0 array
Lukasz Dorau [Fri, 20 Apr 2012 09:00:25 +0000 (11:00 +0200)] 
fix: correct extending size of raid0 array

Setting "sync_action" to "idle" while extending size of raid0 array
is racy and sometimes fails.
"sync_action" should be set to "frozen" instead.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: fix: rebuild does not continue after reboot
Lukasz Dorau [Fri, 20 Apr 2012 11:45:02 +0000 (13:45 +0200)] 
imsm: fix: rebuild does not continue after reboot

If system is rebooted during rebuild, md driver changes sync_action
from 'recover' to 'idle' (during stopping all md devices).
If mdmon is still running then, it detects the change of sync_action state,
finishes rebuild and writes metadata to disks. After computer's restart
the RAID volume is in Normal state in OROM and rebuild seems to be finished.
After system's start-up RAID volume is in auto-read-only state
and metadata is in Dirty state. Rebuild seems to be finished but it is not.
Data is inconsistent (out-of-sync).

When mdmon detects the change of sync_action from 'recover' to 'idle',
it has to check if rebuild is really finished. Appropriate test was added.
Now mdmon examines each volume's member if it is being rebuilt.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRelax restrictions on when --add is permitted.
NeilBrown [Wed, 18 Apr 2012 04:19:49 +0000 (14:19 +1000)] 
Relax restrictions on when --add is permitted.

The restriction that --add was not allowed on a device which
looked like a recent member of an array was overly harsh.

The real requirement was to avoid using --add when the array had
failed, and the device being added might contain necessary
information which can only be incorporated by stopping and
re-assembling with --force.

So change the test to reflect the need.

Reported-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAdd --prefer option for --detail and --monitor
NeilBrown [Wed, 18 Apr 2012 01:00:07 +0000 (11:00 +1000)] 
Add --prefer option for --detail and --monitor

Both --detail and --monitor can report the names of member
devices on an array, and do so by searching /dev and finding
the shortest name that matches.

If
   --prefer=foo
is given, they will instead prefer a name that contain /foo/.
So
   mdadm --detail /dev/md0 --prefer=by-path

will list the component devices via their /dev/disk/by-path/xxx
names.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRaid limit of 1024 when scanning for devices.
NeilBrown [Tue, 17 Apr 2012 23:06:02 +0000 (09:06 +1000)] 
Raid limit of 1024 when scanning for devices.

When we can for devices using GET_DISK_INFO we currently
limit to 1024.  But some arrays can have more than this.
So raise it to 4096 and make the constant a #define.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: resolve make everything compilation error
Lukasz Dorau [Mon, 16 Apr 2012 14:12:55 +0000 (16:12 +0200)] 
FIX: resolve make everything compilation error

When mdadm is compiled using e.g. 'everything' option, mdassemble
compilation is broken.

Change code to enable mdassemble compilation.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Assembled second array is in read only state during reshape
Adam Kwolek [Fri, 13 Apr 2012 14:52:08 +0000 (16:52 +0200)] 
FIX: Assembled second array is in read only state during reshape

When arrays using external metadata are assembled, and one of array
in container is under reshape, second array will remain in read only
state (not auto read only). It is caused by array fact that array
is frozen and mdmon doesn't has opportunity to switch array in r/w mode.

Freezing not reshaped array just after it is being assembled allows mdmon
to enable it for writing.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Size change is possible as standalone change only
Adam Kwolek [Fri, 13 Apr 2012 14:52:07 +0000 (16:52 +0200)] 
FIX: Size change is possible as standalone change only

Size change is possible as standalone change only. To make sure size change
is not requested pass '-1' as size parameter.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Component size alignment check
Adam Kwolek [Fri, 13 Apr 2012 14:52:06 +0000 (16:52 +0200)] 
imsm: FIX: Component size alignment check

Put currently existing code for alignment correction in to function
imsm_component_size_aligment_check() and use it for align component size
to chunk size during volume size expansion operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Support setting max size for size change operation
Adam Kwolek [Fri, 13 Apr 2012 14:52:05 +0000 (16:52 +0200)] 
imsm: Support setting max size for size change operation

Add support for setting max size for size change operation using
imsm_get_free_size() function for computing maximum available space.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Add function imsm_get_free_size()
Adam Kwolek [Fri, 13 Apr 2012 14:52:04 +0000 (16:52 +0200)] 
imsm: Add function imsm_get_free_size()

Add function imsm_imsm_get_free_size() using part of code from function
reserve_space().

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Detect error and rollback metadata
Adam Kwolek [Fri, 13 Apr 2012 14:52:03 +0000 (16:52 +0200)] 
FIX: Detect error and rollback metadata

Some setting size error cases were not detected.
When error occurs, stop setting new size action and rollback metadata
changes.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Respect metadata size limitations
Adam Kwolek [Fri, 13 Apr 2012 14:52:02 +0000 (16:52 +0200)] 
FIX: Respect metadata size limitations

When reshape_super() updates metadata with new size, due to some metadata
limitations saved value can be different than requested value by user.
Update size (read it from metadata) for setting it in md.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Extend size of raid0 array
Adam Kwolek [Fri, 13 Apr 2012 14:52:01 +0000 (16:52 +0200)] 
FIX: Extend size of raid0 array

For raid0, takeover operation is required for size change.
Add takeover to degraded raid4 before size change and back to raid0 after.
Array information has to be read again from md after takeover.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Support metadata changes rollback
Adam Kwolek [Fri, 13 Apr 2012 14:52:00 +0000 (16:52 +0200)] 
imsm: FIX: Support metadata changes rollback

Add metadata rollback specific code for imsm.
Let reshape_super() ability to differentiate metadata apply and rollback
actions.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Support metadata changes rollback
Adam Kwolek [Fri, 13 Apr 2012 14:51:59 +0000 (16:51 +0200)] 
FIX: Support metadata changes rollback

Function reshape_super() guards metadata changes.
It is used to apply changes rollback in error case also.
As change (apply and rollback) can be not bi-directional reshape_super()
has to know if current action is metadata change that should be guarded
using metadata restrictions, or this is metadata rollback change
executed due to error occurrence.

In second case change has to be unconditional.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Execute size change for external metatdata
Adam Kwolek [Fri, 13 Apr 2012 14:51:58 +0000 (16:51 +0200)] 
imsm: Execute size change for external metatdata

For external metatdata ioctl doesn't set new size. Set new size using sysfs.
Put code for size change in to function to re-use the same code as during
On-line Capacity Expansion

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: Add new metadata update for volume size expansion
Adam Kwolek [Fri, 13 Apr 2012 14:51:57 +0000 (16:51 +0200)] 
imsm: Add new metadata update for volume size expansion

Add new meatdata update type imsm_update_size_change, and update metadata
for volume size expansion operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Add volume size expand support to imsm_analyze_change()
Adam Kwolek [Fri, 13 Apr 2012 14:51:56 +0000 (16:51 +0200)] 
imsm: FIX: Add volume size expand support to imsm_analyze_change()

Patch adds ability to function imsm_analyze_change() for:
1. Detect size change request for volume operation.
2. Check and correct size for change.
3. Set new change kind to CH_ARRAY_SIZE

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Update function imsm_num_data_members() for Raid1/10
Adam Kwolek [Fri, 13 Apr 2012 14:51:55 +0000 (16:51 +0200)] 
imsm: FIX: Update function imsm_num_data_members() for Raid1/10

Function imsm_num_data_members() returns wrong value for raid 1 and 10.
It returns all data member but it should return number of unique data
members (excluding mirror devices)

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: display maximum volumes per controller and array
Labun, Marcin [Tue, 17 Apr 2012 02:30:50 +0000 (12:30 +1000)] 
imsm: display maximum volumes per controller and array

Display maximum volumes per array and per controller
in --detail-platform command.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomdadm man page: fix typo
CoolCold [Thu, 12 Apr 2012 02:11:19 +0000 (06:11 +0400)] 
mdadm man page: fix typo

manpage for mdadm(8) contains typo - missing "d" at the end of "describe" word.

Signed-off-by: Roman Ovchinnikov <coolthecold@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix two typos in fprintf messages
Lukasz Dorau [Thu, 5 Apr 2012 10:26:41 +0000 (12:26 +0200)] 
Fix two typos in fprintf messages

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper1: leave more space in front of data by default.
NeilBrown [Wed, 4 Apr 2012 04:00:40 +0000 (14:00 +1000)] 
super1: leave more space in front of data by default.

The kernel is growing the ability to avoid the need for a
backup file during reshape by being able to change the data offset.

For this to be useful we need plenty of free space before the
data so the data offset can be reduced.

So for v1.1 and v1.2 metadata make the default data_offset much
larger.  Aim for 128Meg, but keep a power of 2 and don't use more
than 0.1% of each device.

Don't change v1.0 as that is used when the data_offset is required to
be zero.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoBitmap_offset is a signed number
NeilBrown [Wed, 4 Apr 2012 04:00:42 +0000 (14:00 +1000)] 
Bitmap_offset is a signed number

As the bitmap can be before the superblock, bitmap_offset is signed.
But some of the code didn't honour that :-(

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoparse_size: distinguish between 0 and error.
NeilBrown [Tue, 3 Apr 2012 18:00:42 +0000 (04:00 +1000)] 
parse_size: distinguish between 0 and error.

It isn't sufficient to use '0' for 'error' as well will
later have fields that can validly be '0'.

So return "-1" on error.

Also fix parsing of --bitmap_check so that '0' is treated
as an error: we don't support 512B anyway.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix typo: wan -> want
NeilBrown [Tue, 3 Apr 2012 18:00:41 +0000 (04:00 +1000)] 
Fix typo: wan -> want

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: set 2tb disk attribute for spare
Czarnowska, Anna [Mon, 2 Apr 2012 00:19:04 +0000 (10:19 +1000)] 
imsm: set 2tb disk attribute for spare

This patch ensures metadata attribute is set correctly also for spares.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agocheck that no disk over 2TB is used to create container when no support
Czarnowska, Anna [Mon, 2 Apr 2012 00:18:37 +0000 (10:18 +1000)] 
check that no disk over 2TB is used to create container when no support

Creation of a container using disks over 2TB should be allowed only when orom supports large disks

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agocheck volume size in validate_geometry_imsm_orom
Czarnowska, Anna [Mon, 2 Apr 2012 00:17:55 +0000 (10:17 +1000)] 
check volume size in validate_geometry_imsm_orom

When orom does not support volumes over 2TB the creation should be disallowed

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoshow 2TB volumes/disks support in --detail-platform
Czarnowska, Anna [Mon, 2 Apr 2012 00:17:25 +0000 (10:17 +1000)] 
show 2TB volumes/disks support in --detail-platform

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosimplify calculating array_blocks
Czarnowska, Anna [Mon, 2 Apr 2012 00:16:04 +0000 (10:16 +1000)] 
simplify calculating array_blocks

no point calling info_to_blocks_per_member when it just returns size*2 for level==1
calc_array_size can be used for all levels

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoclear hi bits if not used after loading metadata from disk
Czarnowska, Anna [Mon, 2 Apr 2012 00:15:08 +0000 (10:15 +1000)] 
clear hi bits if not used after loading metadata from disk

Functions retrieving sizes from metadata do not need to check
2TB attribute only when we can guarantee the hi bits are always
clear when the MPB_ATTR_2TB_DISK attribute is not set.

Therefore the following fields are cleared on metadata load
when not in use according to attribute:
struct imsm_disk.total_blocks_hi
struct imsm_map.pba_of_lba0_hi
struct imsm_map.blocks_per_member_hi
struct imsm_map.num_data_stripes_hi

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: avoid overflows for disks over 1TB
Czarnowska, Anna [Mon, 2 Apr 2012 00:15:03 +0000 (10:15 +1000)] 
imsm: avoid overflows for disks over 1TB

Calculating array_blocks using info->size causes error on activation of
volume using disks over 1 TB. unsigned long long size parameter
is used instead.

total_blocks, pba_of_lba0, blocks_per_member and num_data_stripes overflow
when using disks over 2TB.

Part of fillers in metadata is used to contain hi bits of the numbers
that are likely to go over 32 bit limit.
Functions are added to get and set such fields as the hi bits are not
adjacent with low bits in the structures.

Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosysfs: fixed sysfs_freeze_array array to work properly with Manage_subdevs.
NeilBrown [Wed, 28 Mar 2012 06:29:37 +0000 (17:29 +1100)] 
sysfs: fixed sysfs_freeze_array array to work properly with Manage_subdevs.

If the array is already frozen when Manage_subdevs is called we don't
want it to unfreeze the array.
This is because Grow calls Manage_subdevs to add devices to an array
being reshaped, and the array must stay frozen over this call.

So if sysfs_freeze_array find the array to be frozen it returns '0',
meaning that it didn't and cannot freeze it.  Then the caller will not
try to unfreeze, which is good.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix the new ROUND_UP macro.
NeilBrown [Thu, 22 Mar 2012 08:40:38 +0000 (19:40 +1100)] 
Fix the new ROUND_UP macro.

It was missing a "- 1".

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix tests/05r1-re-add-nosupper
NeilBrown [Thu, 22 Mar 2012 06:30:07 +0000 (17:30 +1100)] 
Fix tests/05r1-re-add-nosupper

This shouldn't have been changed when we size of RAID1
arrays was changed, as this uses 'build', not 'create'

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGrow: print useful error when converting RAID1->RAID5 will fail.
NeilBrown [Thu, 22 Mar 2012 06:00:57 +0000 (17:00 +1100)] 
Grow: print useful error when converting RAID1->RAID5 will fail.

RAID1 can only be converted to RAID0 or RAID5 if the size is
a multiple of 4K as we cannot have chunks smaller than 4K.

If this might happen, report a useful error message.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoCreate: round off size for RAID1 arrays.
NeilBrown [Thu, 22 Mar 2012 05:53:51 +0000 (16:53 +1100)] 
Create: round off size for RAID1 arrays.

RAID1 arrays don't have a chunk size, but if you ever convert
one to RAID5 you will need at least a small one >= 4K.
So round of size to a multiple of 64K.

This only affect Create, not "--grow --size=max".  The latter
is too hard and with smaller returns.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManage: freeze recovery while adding multiple devices.
NeilBrown [Thu, 22 Mar 2012 05:15:03 +0000 (16:15 +1100)] 
Manage: freeze recovery while adding multiple devices.

If the kernel supports it, freeze recovery over multiple adds,
so that they can all be added to the array at the same time and
be recovered in parallel.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManage: replace 'return 1' with 'goto abort'.
NeilBrown [Thu, 22 Mar 2012 05:07:02 +0000 (16:07 +1100)] 
Manage: replace 'return 1' with 'goto abort'.

This will allow exit processing in next patch

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoIncremental: fix adding devices with --incremental
NeilBrown [Thu, 22 Mar 2012 04:53:53 +0000 (15:53 +1100)] 
Incremental: fix adding devices with --incremental

We should use 'info' here, not 'info2'.
info2 refers to some other device (There may not even be one).l
info is *this* disk.

This is particularly important for getting info.disk.state
correct, which the kernel depends on to get 're-add' functionality
correct.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoRemove possible crash during RAID6 -> RAID5 reshape.
NeilBrown [Thu, 22 Mar 2012 04:34:17 +0000 (15:34 +1100)] 
Remove possible crash during RAID6 -> RAID5 reshape.

If a RAID6 array is in a state which doesn't have a
RAID5 equivalent, the code currently dereferences a NULL.

If it does have an equivalent - use that.
If it doesn't but it already in the RAID5-compatible layout
with the Q block last, handle that case,
else require the new layout to be explicitly requested.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAssemble: improve verbose logging when including old devices.
NeilBrown [Thu, 22 Mar 2012 03:52:21 +0000 (14:52 +1100)] 
Assemble: improve verbose logging when including old devices.

Reporting:

mdadm: added /dev/loop1 to /dev/md0 as 1
mdadm: added /dev/loop2 to /dev/md0 as 2
mdadm: added /dev/loop0 to /dev/md0 as 0
mdadm: /dev/md0 has been started with 2 drives (out of 3).

is confusing - why only 2?  Code now reports:

mdadm: added /dev/loop1 to /dev/md0 as 1
mdadm: added /dev/loop2 to /dev/md0 as 2 (possibly out of date)
mdadm: added /dev/loop0 to /dev/md0 as 0
mdadm: /dev/md0 has been started with 2 drives (out of 3).

which is somewhat clearer.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoExamine: fix array size calculation for RAID10.
NeilBrown [Thu, 22 Mar 2012 03:43:09 +0000 (14:43 +1100)] 
Examine: fix array size calculation for RAID10.

RAID10 arrays with an odd number of devices had the arraysize
reported wrongly by --examine due to a rounding error.

Reported-by: Chris Francy <zoredache@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years ago__write_init_super_ddf(): Use posix_memalign() instead of static aligned buffer
Jes Sorensen [Tue, 20 Mar 2012 21:07:12 +0000 (08:07 +1100)] 
__write_init_super_ddf(): Use posix_memalign() instead of static aligned buffer

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper-intel.c: Use ROUND_UP() instead of manually coding it
Jes Sorensen [Tue, 20 Mar 2012 21:07:02 +0000 (08:07 +1100)] 
super-intel.c: Use ROUND_UP() instead of manually coding it

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper1.c: use ROUND_UP/ROUND_UP_PTR
Jes Sorensen [Tue, 20 Mar 2012 21:06:35 +0000 (08:06 +1100)] 
super1.c: use ROUND_UP/ROUND_UP_PTR

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoGeneralize ROUND_UP() macro and introduce matching ROUND_UP_PTR()
Jes Sorensen [Tue, 20 Mar 2012 21:04:24 +0000 (08:04 +1100)] 
Generalize ROUND_UP() macro and introduce matching ROUND_UP_PTR()

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomatch_metadata_desc0(): Use calloc instead of malloc+memset
Jes Sorensen [Tue, 20 Mar 2012 21:04:14 +0000 (08:04 +1100)] 
match_metadata_desc0(): Use calloc instead of malloc+memset

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoUse struct align_fd to cache fd's block size for aligned reads/writes
Jes Sorensen [Tue, 20 Mar 2012 21:01:20 +0000 (08:01 +1100)] 
Use struct align_fd to cache fd's block size for aligned reads/writes

This uses a struct to cache the block size for aligned reads/writes,
to avoid repeated ioctl(BLKSSZGET) calls.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoUse 4K buffer alignment for superblock allocations
Jes Sorensen [Tue, 20 Mar 2012 21:01:04 +0000 (08:01 +1100)] 
Use 4K buffer alignment for superblock allocations

To better accommodate 4K sector drives, use 4K buffer alignment for
superblock buffers.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agomatch_metadata_desc1(): Use calloc instead of malloc+memset
Jes Sorensen [Tue, 20 Mar 2012 21:00:50 +0000 (08:00 +1100)] 
match_metadata_desc1(): Use calloc instead of malloc+memset

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoinit_super1() memset full buffer allocated for superblock
Jes Sorensen [Tue, 20 Mar 2012 21:00:26 +0000 (08:00 +1100)] 
init_super1() memset full buffer allocated for superblock

Avoid possibly using stale data in bitmap and misc area of superblock.
In addition, remove superfluous memsets already covered by memset of
full superblock.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoDefine and use SUPER1_SIZE for allocations
Jes Sorensen [Tue, 20 Mar 2012 21:00:07 +0000 (08:00 +1100)] 
Define and use SUPER1_SIZE for allocations

Use a #define rather than calculate the size of the superblock buffer
on every allocation.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper1.c don't keep recalculating bitmap pointer
Jes Sorensen [Tue, 20 Mar 2012 16:54:06 +0000 (17:54 +0100)] 
super1.c don't keep recalculating bitmap pointer

We just calculated the pointer to the bitmap, so use it instead of
recalculating.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoCreate: reduce the verbosity of 'default_layout'.
NeilBrown [Thu, 8 Mar 2012 04:40:54 +0000 (15:40 +1100)] 
Create: reduce the verbosity of 'default_layout'.

We only need this the first couple of times.  Reporting it for
every device is not necessary.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agosuper1: support superblocks up to 4K.
NeilBrown [Thu, 8 Mar 2012 04:40:52 +0000 (15:40 +1100)] 
super1: support superblocks up to 4K.

The current 1024 byte limit on 1.x superblocks limits us to
384 devices.  Sometimes people want more.

The kernel is already prepared for superblocks up to 4K,
so enable that in mdadm  allowing up to
   (4096-256)/2 == 1920
devices (active plus spare).

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoReset bad flag on map update
Czarnowska, Anna [Wed, 7 Mar 2012 12:51:30 +0000 (12:51 +0000)] 
Reset bad flag on map update

Map file may miss an entry if bad flag is not cleared on update.

This happens for example when an old entry exists in map that
has no mdstat counterpart and we create a new array with the same devnum.
Newly created array will not appear in map if update doesnt clear bad flag.

Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoManage: allow --re-add to failed array.
NeilBrown [Wed, 7 Mar 2012 04:25:57 +0000 (15:25 +1100)] 
Manage: allow --re-add to failed array.

If both "legs" of a RAID1 (or equivalent in RAID10) fail, then one
of the becomes available again it maybe appropriate to re-add the
failed device(s).
So remove the restriction that an array must has 'enough' devices
before being re-added, and if there is no-where to read a superblock
from for matching, then assume the kernel will do necessary checks.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAssemble: support assembling of a RAID0 being reshaped.
NeilBrown [Tue, 6 Mar 2012 23:47:34 +0000 (10:47 +1100)] 
Assemble: support assembling of a RAID0 being reshaped.

This is a bit of a hack and the code need to be made more
general.  But this adds the special case of a RAID0 being
reshaped which looks like a RAID4 but doesn't need as many
devices.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoAssemble: don't use O_EXCL until we have checked device content.
NeilBrown [Tue, 6 Mar 2012 23:41:24 +0000 (10:41 +1100)] 
Assemble: don't use O_EXCL until we have checked device content.

If we open with O_EXCL before checking that the device is one that
we really want, then that could cause some other process to think
the device is busy when it isn't really.

This particularly affects running "mdadm -A devname" in parallel for
different arrays.  One might be looking at a device that it won't
end up using while another trys and fails to look at a device that
it needs.

So delay the O_EXCL until after all identity checks.

Multiple "mdadm -As" will still have races, but that is fundamentally
racy anyway.

Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoUse MDMON_DIR for pid files created in Monitor.c
Jes Sorensen [Thu, 2 Feb 2012 11:45:02 +0000 (12:45 +0100)] 
Use MDMON_DIR for pid files created in Monitor.c

Other parts of mdadm/mdmon place .pid/.sock files in MDMON_DIR. This
makes Monitor.c consistent with the rest.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoPrint error message if failing to write super for 1.x metadata
Jes Sorensen [Wed, 22 Feb 2012 21:55:19 +0000 (08:55 +1100)] 
Print error message if failing to write super for 1.x metadata

In addition remove attempt to print an error message if
write_init_super() fails, as this is handled in the various
write_init_super() functions. This avoids a segfault on error.

Reported by Jim Meyering in
https://bugzilla.redhat.com/show_bug.cgi?id=795461

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoavoid double-free upon "old buggy kernel" sysfs_read failure
Jim Meyering [Tue, 21 Feb 2012 12:02:22 +0000 (13:02 +0100)] 
avoid double-free upon "old buggy kernel" sysfs_read failure

* Incremental.c (Incremental): On sysfs_read failure, don't call
sysfs_free(sra) just before "goto out_unlock", since that very
same "sra" is freed the same way by the clean-up code below.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Changes in '0' case for reshape position verification
Adam Kwolek [Thu, 16 Feb 2012 13:16:04 +0000 (14:16 +0100)] 
FIX: Changes in '0' case for reshape position verification

Reading sysfs entry that is '0' long should cause an error.
Reshape position cannot be empty.

Absence of reshape position should be ignored. It is possible
that we are about raid0 reshape continuation and it is before takeover.
This means that according metadata (changed by mdmon) it should be reshaped
but md knows nothing about it at this moment. Reshape continuation
in reshape_array() will change it to raid4 and reshape position appears
in sysfs.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoUse posix_memalign() for memory used to write bitmaps
Jes Sorensen [Tue, 14 Feb 2012 10:52:13 +0000 (11:52 +0100)] 
Use posix_memalign() for memory used to write bitmaps

This makes super[01].c properly align buffers used for the bitmap
using posix_memalign() to make sure the writes don't fail in case the
bitmap is opened using O_DIRECT.

This is based on https://bugzilla.redhat.com/show_bug.cgi?id=789898
and an initial patch by Alexander Murashkin.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoconfig: conf_match should ignore devname when not set.
NeilBrown [Thu, 16 Feb 2012 03:11:57 +0000 (14:11 +1100)] 
config: conf_match should ignore devname when not set.

mapfile:RebuildMap calls conf_match with no devname, so we must be
careful not to use it.

Reported-by: Arkadiusz Miƛkiewicz <arekm@maven.pl>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Do not try to (continue) reshape using inactive array
Adam Kwolek [Thu, 9 Feb 2012 01:38:15 +0000 (12:38 +1100)] 
FIX: Do not try to (continue) reshape using inactive array

When one of arrays is inactive, do not try to continue reshape
on this array. Just skip it.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: restart reshape when reshape process is stopped just between 2 reshapes
Adam Kwolek [Thu, 9 Feb 2012 01:37:40 +0000 (12:37 +1100)] 
FIX: restart reshape when reshape process is stopped just between 2 reshapes

When reshape is restarted from '0', very begin of array
it is possible that for external metadata reshape and array
configuration doesn't happen.
Check if md has the same opinion, and reshape is restarted
from 0. If so, this is regular reshape start after reshape
switch in metadata to next array only.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Clear migration record when migration switches to next volume.
Adam Kwolek [Thu, 9 Feb 2012 01:37:04 +0000 (12:37 +1100)] 
imsm: FIX: Clear migration record when migration switches to next volume.

When OLCE is in progress, checkpoint steps are getting bigger due to added space during process.
When mdadm fails after saving "max" to sync_max, mdmon will monitor process
and switch reshape to next array. At this moment we have got information
inconsistency between metadata and migration record.
To avoid this, clear migration record by mdmon /exception from the rule
that migration record is maintained by mdadm/ when reshape switches
to next array.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: use md position to reshape restart
Adam Kwolek [Thu, 9 Feb 2012 01:36:42 +0000 (12:36 +1100)] 
imsm: FIX: use md position to reshape restart

When reshape is broken it can occur that metadata is not saved properly.
This can cause that reshape process is farther in md than metadata states.

On restart save checkpoint to store current position /probably farther/
that can be read from md.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: use md position to reshape restart
Adam Kwolek [Thu, 9 Feb 2012 01:36:41 +0000 (12:36 +1100)] 
FIX: use md position to reshape restart

When reshape is broken, it can occur that metadata is not saved properly.
This can cause that reshape process is farther in md than metadata states.

On reshape restart use md position as start position, if it is farther than
position specified in metadata. Opposite situation treat as error.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: Chunk size migration problem
Adam Kwolek [Tue, 7 Feb 2012 14:03:51 +0000 (15:03 +0100)] 
imsm: FIX: Chunk size migration problem

When chunk size migration occurs (e.g. 128k->4k) first checkpoint cannot
be set in md due to too small step. Correct migration record initialization
to allow whole copy area usage and increase migration checkpoint step.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFlush mdmon before next reshape step during container operation
Adam Kwolek [Tue, 7 Feb 2012 14:03:43 +0000 (15:03 +0100)] 
Flush mdmon before next reshape step during container operation

Using takeover operation for grow purposes, mdadm has to be sure
that mdmon processes all updates, and if necessary it will be closed
at takeover to raid0 operation. If mdmon is late, next array in container
is processed and due to race condition mdmon closes itself instead to monitor
next reshape operation.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFix: Sometimes mdmon throws core dump during reshape
Adam Kwolek [Tue, 7 Feb 2012 14:03:35 +0000 (15:03 +0100)] 
Fix: Sometimes mdmon throws core dump during reshape

Problem was found during reshaping 2 volumes /raid0 and raid5/ in container.
Sometimes mdmon throws core dump due to NULL pointer exception.

Problem occurs in scenario:
- managemon: is about spare activation (degraded raid4 volume == raid0 under takeover)
- managemon: detect level change and signals monitor (manage_member() calls replace_array())
- monitor: detects transition raid4/5->raid0 and sets a->container to NULL
           to indicate array deactivation
- managemon : continues his work and tries to activate spare (a->check_degraded is set).
              NULL pointer is passed to metadata handler activate_spare()
              Core dump is generated.

To resolve this situation managemon (after monitor kick) checks again
a->container pointer to learn if current array is not to be deactivated.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: imsm_get_allowed_degradation() doesn't count degradation for raid1
Adam Kwolek [Tue, 7 Feb 2012 14:03:27 +0000 (15:03 +0100)] 
imsm: FIX: imsm_get_allowed_degradation() doesn't count degradation for raid1

Missing case raid1 added to function.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: Array is not run when expansion disks are added
Adam Kwolek [Tue, 7 Feb 2012 14:03:19 +0000 (15:03 +0100)] 
FIX: Array is not run when expansion disks are added

When added disk is disk added by expansion and this is last disk added
to array, assemble_container_content() will not even try to run such array.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoimsm: FIX: No new missing disks are allowed during general migration
Adam Kwolek [Tue, 7 Feb 2012 14:03:11 +0000 (15:03 +0100)] 
imsm: FIX: No new missing disks are allowed during general migration

When during incremental assembly general migration is in progress,
starting degraded array causes that no more disks (even present)
can be added later as array is already started.

Request all previously present disks during general migration for assembly.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
12 years agoFIX: NULL pointer to strdup() can be passed
Adam Kwolek [Tue, 7 Feb 2012 14:03:03 +0000 (15:03 +0100)] 
FIX: NULL pointer to strdup() can be passed

When result from strchr() is NULL and it is assigned to subarray,
NULL pointer can be passed to strdup() function and coredump file
is generated.

Subarray is checked for NULL pointer, so it is assumed that it can
be NULL at this moment.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>