Commit Graph

312 Commits

Author SHA1 Message Date
Artur Paszkiewicz 2432ce9b32 imsm: PPL support
Enable creating and assembling IMSM raid5 arrays with PPL. Update the
IMSM metadata format to include new fields used for PPL.

Add structures for PPL metadata. They are used also by super1 and shared
with the kernel, so put them in md_p.h.

Write the initial empty PPL header when creating an array. When
assembling an array with PPL, validate the PPL header and in case it is
not correct allow to overwrite it if --force was provided.

Write the PPL location and size for a device to the new rdev sysfs
attributes 'ppl_sector' and 'ppl_size'. Enable PPL in the kernel by
writing to 'consistency_policy' before the array is activated.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 11:32:49 -04:00
Jes Sorensen c5f71c2417 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>
2016-08-15 15:41:34 -04:00
Jes Sorensen 0c79d8ca10 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>
2016-03-22 14:07:36 -04:00
Jes Sorensen 0a8e239c18 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>
2016-03-22 14:06:28 -04:00
Jes Sorensen 30e19bf805 Assemble: Remove unnecesary NULL pointer checks when calling sysfs_free()
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2016-03-08 12:19:03 -05:00
NeilBrown c61b1c0bb5 Release mdadm-3.4
My last release!

Signed-off-by: NeilBrown <neilb@suse.com>
2016-01-28 17:14:56 +11:00
NeilBrown d5ff855d47 super1: allow reshape that hasn't really started to be reverted.
A simple revert doesn't work here because the reshape_position is
in the critical section.
The best approach is to let the reshape progress a bit and then
go backwards.
If that isn't possible, assembling with --update=revert-reshape and
--invalid-backup should work.

Reported-by-tested-by: George Rapp <george.rapp@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.com>
2016-01-28 12:57:08 +11:00
Song Liu dbfbca4300 fix bug in assemble
In Assemble, getinfo_super() over-writes journal_clean.  To
ensure correct journal_clean, keep it in a local variable
before getinfo_super().

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.com>
2015-12-09 07:35:50 +11:00
Song Liu 051f326550 mdadm: refactor write journal code in Assemble and Incremental
As discussed, standalone require_journal() in struct superswitch
is not a very good idea. Instead, journal related information
fits well in struct mdinfo.

This patch simplifies journal support code in Assemble and
Incremental as:

- Add journal_device_required and journal_clean to struct mdinfo;
- Remove function require_journal from struct superswitch;
- Update Assemble and Incremental to use journal_device_required
and journal_clean from struct mdinfo (instead of separate var).

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.com>
2015-10-22 12:19:09 +11:00
Song Liu 69a481166b Assemble array with write journal
Example output:

./mdadm --assemble /dev/md0 /dev/sd[c-f] /dev/sdb1
mdadm: /dev/md0 has been started with 4 drives and 1 journal.

mdadm checks superblock for journal devices. If the journal device
is missing or faulty, mdadm will show warning

./mdadm --assemble /dev/md0 /dev/sd[c-q] /dev/sdb1
mdadm: Not safe to assemble with missing or stale journal device, consider --force.

User can insist to start the array (read only) with --force

./mdadm --assemble /dev/md0 /dev/sd[c-q] /dev/sdb1 --force
mdadm: Journal is missing or stale, starting array read only.
mdadm: /dev/md0 has been started with 15 drives.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.com>
2015-10-19 13:06:15 +11:00
NeilBrown d80f7aa9a1 Assemble: correctly capture error from ->write_bitmap
else 'err' might be undefined.

Signed-off-by: NeilBrown <neilb@suse.com>
2015-08-05 14:55:31 +10:00
NeilBrown 5997585200 Merge branch 'mdadm-3.3.x' 2015-08-03 16:21:37 +10:00
NeilBrown 8360760457 Assemble: really don't assemble IMSM array without OROM.
Previous patch missed on case.

Also print more useful information when rejecting
a device with IMSM metadata.

Signed-off-by: NeilBrown <neilb@suse.com>
2015-08-03 16:06:51 +10:00
NeilBrown 7eee461e91 Assemble: don't assemble IMSM array without OROM.
If someone has an IMSM array, and disables RAID in the BIOS
and uses the devices for some other purpose, then they really don't
want mdadm to start syncing the array.

So don't assemble if OROM doesn't confirm it is OK.

There can still be problems for crash-dump not being able to find
the OROM.   Some explicit work-around might be needed for that
rather than a more general workaround that can corrupt data.

Signed-off-by: NeilBrown <neilb@suse.com>
2015-08-03 15:42:16 +10:00
NeilBrown 9f2e55a421 Assemble: don't assemble IMSM array without OROM.
If someone has an IMSM array, and disables RAID in the BIOS
and uses the devices for some other purpose, then they really don't
want mdadm to start syncing the array.

So don't assemble if OROM doesn't confirm it is OK.

There can still be problems for crash-dump not being able to find
the OROM.   Some explicit work-around might be needed for that
rather than a more general workaround that can corrupt data.

Signed-off-by: NeilBrown <neilb@suse.com>
2015-07-29 14:38:37 +10:00
NeilBrown 653299b699 Merge branch 'cluster'
Now that 3.3.3 is out, it is time to include the cluster-support code.

Signed-off-by: NeilBrown <neilb@suse.com>
2015-07-27 11:01:08 +10:00
NeilBrown 86b77ddf87 Assemble: extend --homehost='<ignore>' to allow --name= to ignore homehost
Also make --homehost='<ignore>' work properly.

Signed-off-by: NeilBrown <neilb@suse.com>
2015-07-24 12:50:54 +10:00
NeilBrown 00f23a8861 Assemble: improve tests for matching --name= request.
If the name in the array has a home-host, then
require that it matches, or is "any", or requested
homehost is "any".

Signed-off-by: NeilBrown <neilb@suse.com>
2015-07-22 09:24:36 +10:00
NeilBrown 29a312f2f3 Assemble: really ensure stripe_cache is bit enough to handle new chunk size
Earlier patch:
  56fcbcbb6f
calculated the proper chunk size - but didn't use it..

Let's actually use it this time.

Signed-off-by: NeilBrown <neilb@suse.com>
2015-07-17 13:10:25 +10:00
NeilBrown 56fcbcbb6f Assemble: ensure stripe_cache is big enough to handle new chunk size
If you reshape to a larger chunk size, and need to restart,
it can have problems.

Signed-off-by: NeilBrown <neilb@suse.de>
2015-06-18 15:49:52 +10:00
Guoqing Jiang 7e6e839a26 mdadm: change the num of cluster node
This extends nodes option for assemble mode, make the num of
cluster node could be change by user.

Before that, it is necessary to ensure there are enough space
for those nodes, calc_bitmap_size is introduced to calculate
the bitmap size of each node.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2015-06-17 09:43:31 +10:00
Guoqing Jiang 0aa2f15b20 mdadm: add the ability to change cluster name
To support change the cluster name, the commit do the followings:

1. extend original write_bitmap function for new scenario.
2. add the scenarion to handle the modification of cluster's name
   in write_bitmap1.
3. let the cluster name also show in examine_super1 and detail_super1

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2015-06-17 09:33:39 +10:00
NeilBrown ec6db5ba71 Assemble: don't check for pre-existing array when updating uuid.
This is a very corner-case, but the self-tests tripped on it,
and it makes sense not to trust the uuid when it is being changed.

Signed-off-by: NeilBrown <neilb@suse.de>
2015-05-13 12:41:48 +10:00
NeilBrown 87af7267bd Assemble/force: make it possible to "force" a new device in a reshape.
Normally we do not "force"-assemble devices which are in the
middle of recovery, as they are unlikely to have useful data.

However, when a reshape increases the number of devices,
the newly added devices appear to be recovering because they
do not have complete data on them yet, but then they aren't expected
to until the reshape completes.
So in this case, it can be appropriate to force-assemble them.

Reported-by: "Jonathan Harker (Jesusaurus)" <jesusaurus@gentlydownthe.net>
Signed-off-by: NeilBrown <neilb@suse.de>
2015-04-08 12:04:00 +10:00
NeilBrown c34fef774a Assemble: remove stray ':' from error message.
Signed-off-by: NeilBrown <neilb@suse.de>
2015-04-08 11:27:34 +10:00
NeilBrown d316dba7c9 Revert "Assemble: support assembling of a RAID0 being reshaped."
This reverts commit b720636a58.

As it said, this was a hack.  It causes problems when trying to
--force assemble a RAID4.  There is a better way.

Reported-by: "Jonathan Harker (Jesusaurus)" <jesusaurus@gentlydownthe.net>
Signed-off-by: NeilBrown <neilb@suse.de>
2015-04-08 09:31:32 +10:00
NeilBrown ee466574f2 Assemble: fix "no uptodate device" message.
Since we introduced replacement devices, the 'i' used in
start_array() is twice the slot number.

So we need to adjust when printing.

Signed-off-by: NeilBrown <neilb@suse.de>
2015-04-08 09:20:26 +10:00
NeilBrown e9e6894d4b Assemble: don't ignore the return value from stat.
static checkers complain about that.
So change the code to use 'fstat', as we really don't want
to see an error here..

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2015-03-04 15:56:52 +11:00
NeilBrown 7a862a020f Don't break long strings onto multiple lines.
It is best to keep strings all together so that they
are easier to search for in the source code.
If a string is so long that it looks ugly one line,
them maybe it should be broken into multiple lines
for display too.

Only strings which contain a newline can be broken
into multiple lines:

 "It is OK to\n"
 "break this string\n"


Signed-off-by: NeilBrown <neilb@suse.de>
2015-02-12 13:46:53 +11:00
NeilBrown 5141638c54 Assemble: Only fail auto-assemble in face of mdadm.conf conflicts.
We should never auto-assemble things that conflict with mdadm.conf
However explicit assembly requests should be allowed.

Reported-by: olovopb
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1070245
Signed-off-by: NeilBrown <neilb@suse.de>
2014-07-29 13:48:23 +10:00
Pawel Baldysiak 0c21b485e4 IMSM: Add warning message when assemble spanned container
Due to several changes in code assemble with disks
spanned between different controllers can be obtained
in some cases. After IMSM container will be assembled, check HBA of
disks, and print proper warning if mismatch is detected.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2014-07-08 11:39:23 +10:00
NeilBrown 02b70e83e6 Incremental: remove old devices when assembling in container.
When assembling a native array we just give all devices to the kernel
and leave it to discard the 'old' ones (based on sequence/event
number).

For external/container arrays, mdadm needs to do that.

So in assemble_container_content, get list of current devices in
array and discard any that aren't in the 'content' given.
They must have been rejected by metadata manager.

If we cannot discard old devices the array must already be active, so
just leave it alone, but with a message.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-06-05 15:58:31 +10:00
NeilBrown 06e293d097 Grow: fix resent grow_continue breakage.
Commit 5e76dce1ac changed
Grow_continue to assume a fork had already happened, so that
   mdadm --grow --continue

didn't fork.  This is good, but it means that if Grow_continue
is run from Assemble, then
  mdadm --assemble ....

can misbehave if the array was in the middle of a reshape.

So introduce finer control.  Grow_continue only assumes it has
already forked if run from "mdadm --grow --continue".

Signed-off-by: NeilBrown <neilb@suse.de>
2014-05-22 14:22:58 +10:00
NeilBrown 54ded86fbd Grow: store a link to current backup file in /run/mdadm or similar.
Subsequent patch will allow the background part of "mdadm --grow" to
be run from systemd.  This can require the passing of a backup file
name.
To do this, store that name as a symlink in /run/mdadm (or MAP_DIR)
and look for it when appropriate.

It might be useful to also store the name across reboot, but that
would be a different patch.  We would need to use the uuid to identify
it, and store it in stable storage.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-05-15 14:23:16 +10:00
NeilBrown 56bbc588f7 Assemble: change load_devices to return most_recent 'st' value.
This means that

	st->ss->getinfo_super(st, content, NULL);
	clean = content->array.state & 1;

will get an up-to-date value for 'clean'.  This fix allows
  tests/03r5assem-failed
to work.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-25 15:04:16 +11:00
NeilBrown 9ee314dab9 Assemble: re-arrange freeing of 'tst' in load_devices().
When we return in error, we need to free(tst), and ->free_super(tst);
Sometimes we didn't.

Also the final ->free_super(tst) should be followed by free(tst)
but wasn't.

Move that file free forward in the code a bit as we will want to use
the tst there in the next patch.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-25 14:59:12 +11:00
NeilBrown df842e69a3 Assemble: allow load_devices to change the 'st' which is passed in.
The given 'st' might not be best.  Making this interface change
will allow load_devices to return a better 'st'.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-25 14:54:34 +11:00
NeilBrown 284546ef89 Assemble: avoid infinite loop when auto-assembling partial container.
When auto-assembling we loop until we get no successes.

If a device is found that look like it is part of an already-existing
container, but we subsequently fail to add that device, then the fact
that the container is running looks like a success.  This can result
in infinite looping.
So if a container was already partially assemble, and is still only
partially assembled after we try to add devices, then don't treat that
as success.

Signed-off-by: NeilBrown  <neilb@suse.de>
2014-01-20 15:23:31 +11:00
NeilBrown 8832342d3a Assemble/Incremental: don't hold O_EXCL on mddev after assembly.
As soon as the array is assembled, udev or systemd might run
fsck and mount it.  So we need to drop O_EXCL promptly.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-05 10:35:16 +11:00
NeilBrown 9ca39acb3e Incremental: add --export handling.
If --export is given with --incremental, then
  MD_DEVNAME
is output which gives the name of the device (in /dev/md) that
is the array (or container) that the device would be added to.
Also
  MD_STARTED
is set to one of
  no
  unsafe
  yes
  nothing

to indicate if the array was started.  IF MD_STARTED=unsafe
then it may be appropriate to run
  mdadm -R /dev/md/$MD_DEVNAME
after a timeout to ensure newly degraded array are started.

If
  MD_FOREIGN=yes
it might be appropriate to suppress this as the array is
probably not critical.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-11-28 15:15:30 +11:00
NeilBrown c1736844ba Restructure assemble_container_content and improve messages.
We lose one level of indent, and now get told the difference between
'not assemble because not safe' and 'not assembled because not enough
devices'.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-11-28 14:47:41 +11:00
NeilBrown f81a2b56c4 Assembe: fix bug in force_array - it wasn't forcing properly.
Since 'best' was expanded to hold replacement devices, we might
need to go up to raid_disks*2 to find devices to force.

Also fix another place when considering replacement drives would
be wrong (the 'chosen' device should never be a replacement).

Reported-by: John Yates <jyates65@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-22 09:55:04 +11:00
NeilBrown d5a4041647 Make -IRs and --run work properly for containers.
We really need to make sure assemble_container_content()
gets called to finished the assembly of these.

Reported-by: Francis Moreau <francis.moro@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-13 10:51:20 +10:00
NeilBrown 6f02172d2e Release mdadm-3.3
(and  various cosmetic fixes)

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-03 14:47:47 +10:00
NeilBrown a792ece676 Assemble: don't ever consider a 'spare' to be the 'most recent'.
If all devices have the same event count and the first one is a spare,
then that spare will be the 'most_recent'.
However then other devices will think the 'most_recent' has failed
(for v0.90 metadata) and will be rejected from the array.

So never consider a 'spare' to be 'most recent'.

Reported-by: Andreas Baer <synthetic.gods@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-02 11:48:06 +10:00
NeilBrown b4924f46c0 Don't set 'hold' option for mdstat_read if not needed.
We only need 'hold' if we want to mdstat_wait for a change.
These two callers don't care about a change, so they shouldn't
use the 'hold' flag.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-10 11:02:10 +10:00
NeilBrown eb20ecf101 Assemble: avoid a consistency check when --force is given.
mdadm will normally not include a device into an array if that device
reports that the "best" device has failed, as this normally implies
some sort of inconsistency.
However when --force is given it means that the given drives really
should be assembled if at all possible so in that case the test should
be avoided.

The particular case where this was a problem was a RAID5 were all
devices had the same event count but three of them reported that the
first two had failed.
As they all had the same event count the first was taken as the 'best'
and that caused the later ones to be excluded.  Listing one of the
later ones first allowed the array to be assembled.  So in this case
the test clearly just got in the way and did nothing useful.

Reported-by: "Marek Jaros" <mjaros1@nbox.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-08 12:02:23 +10:00
NeilBrown be7c26b48c Assemble: improve messages when restarting a reshape.
If the restarted reshape needs a backup file and we don't have one,
that should be reported before we try to start the array.
Also we shouldn't say the "Cannot grow" but "cannot complete".

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-02 13:09:07 +10:00
NeilBrown c39b2e633f Assemble: ignore devices= if container= is present.
If "container=" is present, then we are going to assemble from the
given container where that container is made of those devices or not.
So in this case the "devices=" is purely documentation and is best
ignored.

As part of this, move the test on the "container=" value when that
start with "/" up before the device is opened.  There sooner we test
things, the better.

Reported-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-02 11:14:09 +10:00
NeilBrown babb8dd427 Assemble: write raid-disks should be less fatal.
If the container metadata doesn't know how many device to expect (as
is the case with IMSM), don't fail an --assemble which over-specifies
the number of devices.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-02 10:33:35 +10:00