Guoqing Jiang [Mon, 7 Mar 2016 09:31:02 +0000 (17:31 +0800)]
Fix wrong bitmap output for cluster raid
For cluster raid, we need to displays bitmap related
contents from different bitmaps which are based on node
num. So bitmap_file_open and locate_bitmap are changed a
little bit for the purpose.
Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com> Fixes: b98043a2f8 ("Show all bitmaps while examining bitmap") Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
NeilBrown [Thu, 18 Feb 2016 04:53:32 +0000 (15:53 +1100)]
super-intel: ensure suspended region is removed when reshape completes.
A recent commit removed a call to abort_reshape() when IMSM reshape
completed. An unanticipated result of this is that the suspended
region is not cleared as it should be.
So after a reshape, a region of the array will cause all IO to block.
Re-instate the required updates to suspend_{lo,hi} coped from
abort_reshape().
This is caught (sometimes) by the test suite.
Also fix a couple of typos found while exploring the code.
Reported-by: Ken Moffat <zarniwhoop@ntlworld.com> Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Fixes: 2139b03c2080 ("imsm: don't call abort_reshape() in imsm_manage_reshape()") Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Jes Sorensen [Wed, 10 Feb 2016 19:15:38 +0000 (14:15 -0500)]
mdadm.h: rename bswap macros to avoid clash with uClibc definitions
uClibc exposes it's own version of bswap_<X> macros. Rather than
pulling in random macros by change, rename the mdadm ones to make sure
we know what we are getting.
Reported-by: "Maxin B. John" <maxin.john@gmail.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Maxin B. John [Mon, 8 Feb 2016 09:59:29 +0000 (11:59 +0200)]
Makefile: make the CC definition conditional
By hardcoding CC's definition in the Makefile, all the external gcc
parameters set by tune settings are lost. This causes compile failure
with x32 toolchain
Signed-off-by: Maxin B. John <maxin.john@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Xiao Ni [Sat, 6 Feb 2016 01:18:41 +0000 (09:18 +0800)]
Fix some type comparison problems
As 26714713cd2bad9e0bf7f4669f6cc4659ceaab6c said, 32 bit signed
timestamps will overflow in the year 2038. It already changed the
utime and ctime in struct mdu_array_info_s from int to unsigned
int. So we need to change the values that compared with them to
unsigned int too.
Signed-off-by : Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
NeilBrown [Thu, 28 Jan 2016 01:57:08 +0000 (12:57 +1100)]
super1: allow reshape that hasn't really started to be reverted.
A simple revert doesn't work here because the reshape_position is
in the critical section.
The best approach is to let the reshape progress a bit and then
go backwards.
If that isn't possible, assembling with --update=revert-reshape and
--invalid-backup should work.
Reported-by-tested-by: George Rapp <george.rapp@gmail.com> Signed-off-by: NeilBrown <neilb@suse.com>
NeilBrown [Thu, 28 Jan 2016 00:45:53 +0000 (11:45 +1100)]
systemd/mdadm-last-resort: add Conflicts to .service file.
It seems that having the Conflicts in the .timer file is not sufficient.
Sometimes it works, but if the timer gets requested after the conflicting
block device appears (or was it "before" ...) the timer is not aborted.
Having the Conflicts in both files seems to work reliably.
Khem Raj [Thu, 14 Jan 2016 06:32:39 +0000 (22:32 -0800)]
Add casts for the addr arg of connect and bind
glibc allows the addr arg to connect and socket to be any of a number
of 'sockaddr_*' types, but musl requires 'const struct sockaddr *'
which is in line with open group specs. So add casts to allow
compilation with musl.
Khem Raj [Thu, 14 Jan 2016 06:32:38 +0000 (22:32 -0800)]
Define _POSIX_C_SOURCE if undefined
config.c uses _POSIX_C_SOURCE which is defined in features.h when
glibc/uclibc is used, but isn't defined when musl is used.
So provide a reasonable default.
imsm: don't update migration record when reshape is interrupted
Abort imsm_manage_reshape() without updating the migration record if any
error occurs when checking progress. If reshape is interrupted and the
migration record is then updated, the checkpoint will be wrong and will
cause reshape to fail when the array is restarted.
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.com>
imsm: use timeout when waiting for reshape progress
Waiting for reshape progress is done by using select() on sync_completed
to block until an exception condition is signalled on the
filedescriptor. This happens when the attribute's value is updated by
the kernel, but if the array is stopped when mdadm is blocked on
select() this will never happen, because this attribute is then removed
and apparently the kernel doesn't do sysfs_notify() when removing a
sysfs attribute. So set a 3 second timeout for the sysfs_wait() call.
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.com>
Pawel Baldysiak [Tue, 5 Jan 2016 16:03:04 +0000 (17:03 +0100)]
IMSM: Add support for VMD
The Intel Volume Management Device (VMD) is an integrated
endpoint on the platform's PCIe root complex that acts
as a host bridge to a secondary PCIe domain.
This patch adds proper handling of NVMe devices attached to VMD domain.
Each VMD domain is treated as a separate controller (HBA).
Spanning between domains is forbidden.
imsm: abort reshape if sync_action is not "reshape"
When reshape was interrupted, an incorrect checkpoint would be saved in
the migration record. Change wait_for_reshape_imsm() to return -1 when
sync_action is not "reshape" to abort early in imsm_manage_reshape()
without writing the migration record.
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.com>
Grow: close file descriptor earlier to avoid "still in use" when stopping
Close fd2 as soon as it is no longer needed, before calling
Grow_continue(). Otherwise, we won't be able to stop an array with
external metadata during reshape, because mdadm running in background
will be keeping it open.
NeilBrown [Wed, 23 Dec 2015 01:15:32 +0000 (12:15 +1100)]
Detail: fix wrong condition in recent change.
Now that we can print device details with a specific raid_disk but not
disk.number, the condition for "print either disk.number or disk.raid_disk"
must be make more specific.
Reported-by: Coly Li <colyli@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
Xiao Ni [Tue, 22 Dec 2015 03:09:34 +0000 (11:09 +0800)]
Check and remove bitmap first when reshape to raid0
If reshape one raid device with bitmap to raid0, the reshape progress will
start. But it'll fail and lose some components. So it should remove bitmap
first.
Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: NeilBrown <neilb@suse.com>
Song Liu [Mon, 21 Dec 2015 19:23:41 +0000 (11:23 -0800)]
move journal to end of --detail list
As we give journal device raid_disk of 0, the output of --detail is:
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
5 8 24 0 journal /dev/sdb8
1 8 18 1 active sync /dev/sdb2
2 8 19 2 active sync /dev/sdb3
3 8 21 3 active sync /dev/sdb5
4 8 23 - spare /dev/sdb7
This patch makes it back to:
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 18 1 active sync /dev/sdb2
2 8 19 2 active sync /dev/sdb3
3 8 21 3 active sync /dev/sdb5
NeilBrown [Fri, 18 Dec 2015 02:51:54 +0000 (13:51 +1100)]
Detail: don't assume a particular 'disk' number of missing devices.
When a particular raid-disk is missing, we don't know which disk number
it should have, and reporting a number could result in duplicate
numbers (with v1.x metadata - never with the old 0.90).
So set the default to -1 and recoginise that when printing.
NeilBrown [Fri, 18 Dec 2015 02:49:30 +0000 (13:49 +1100)]
Detail: report correct raid-disk for removed drives.
Back in
Commit: 8057db46a15d ("Detail: fix handling of 'disks' array.")
when we doubled the size of the 'disks' array to handle primary and
replacement, we should have halved the setting of the default raid_disk
number.
Reported-by: Coly Li <colyli@suse.de> Signed-off-by: NeilBrown <neilb@suse.com>
Guoqing Jiang [Wed, 16 Dec 2015 17:54:26 +0000 (01:54 +0800)]
mdadm: improve the safeguard for change cluster raid's sb
This commit does the following jobs:
1. rename is_clustered to dlm_funs_ready since it match the
function better.
2. st->cluster_name can't be use to identify the raid is a
clustered or not, we should check the bitmap's version to
perform the identification.
3. for cluster_get_dlmlock/cluster_release_dlmlock funcs, both
of them just need the lockid as parameter since the cluster
name can get by get_cluster_name().
Guoqing Jiang [Wed, 16 Dec 2015 17:54:25 +0000 (01:54 +0800)]
mdadm: do not try to hold dlm lock in free_super1
Since free_super1 actually doesn't change the sb, it
just free the addr space of sb. Also free_super1 is
called in lots of place within mdadm, so remove dlm
lock code since the func doesn't need the protection
and also reduce latency.
Guoqing Jiang [Tue, 1 Dec 2015 16:30:12 +0000 (00:30 +0800)]
mdadm: do not display bitmap info if it is cleared
"mdadm -X DISK" is used to report information about a bitmap
file, it is better to not display all the related infos if
bitmap is cleared with "--bitmap=none" under grow mode.
To do that, the locate_bitmap is changed a little to have a
return value based on MD_FEATURE_BITMAP_OFFSET.
Guoqing Jiang [Tue, 1 Dec 2015 16:30:10 +0000 (00:30 +0800)]
mdadm: output info more precisely when change bitmap to none
WHen change bitmap to none, the infos could be more accurate
based on existed bitmap type.
And s->bitmap_file is passed from cmd "--bitmap=TYPE", so
remove s->bitmap_file from err info since it should means
change the bitmap to one type failed rather than the type is
already presented.
Deepa Dinamani [Tue, 8 Dec 2015 23:10:21 +0000 (15:10 -0800)]
mdadm: Change timestamps to unsigned data type.
32 bit signed timestamps will overflow in the year 2038.
Change the user interface mdu_array_info_s structure timestamps:
ctime and utime values used in ioctls GET_ARRAY_INFO and
SET_ARRAY_INFO to unsigned int. This will extend the field to last
until the year 2106.
Add time_after/time_before and supporting typecheck from
the kernel to take care of unsigned time wraparound.
The long term plan is to get rid of ctime and utime values in
this structure as this information can be read from the on-disk
meta data directly.
v0.90 on disk meta data uses u32 for maintaining time stamps.
So this will also last until year 2106.
Assumption is that the usage of v0.90 will be deprecated by
year 2106.
Timestamp fields in the on disk meta data for v1.0 version already
use 64 bit data types.
Song Liu [Wed, 21 Oct 2015 18:35:14 +0000 (11:35 -0700)]
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>
Guoqing Jiang [Mon, 19 Oct 2015 08:03:19 +0000 (16:03 +0800)]
Safeguard against writing to an active device of another node
Modifying an exiting device's superblock or creating a new superblock
on an existing device needs to be checked because the device could be
in use by another node in another array. So, we check this by taking
all superblock locks in userspace so that we don't step onto an active
device used by another node and safeguard against accidental edits.
After the edit is complete, we release all locks and the lockspace so
that it can be used by the kernel space.
Song Liu [Fri, 9 Oct 2015 05:51:44 +0000 (22:51 -0700)]
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>
Number Major Minor RaidDevice State
0 8 32 0 active sync /dev/sdc
1 8 48 1 active sync /dev/sdd
2 8 64 2 active sync /dev/sde
3 8 80 3 active sync /dev/sdf
4 8 17 - journal /dev/sdb1
./mdadm -E /dev/sdb2
/dev/sdb2:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x201
Array UUID : 562b2334:35b9bcc1:add50892:1f30c4bd
Name : 0
Creation Time : Thu Aug 27 12:55:26 2015
Raid Level : raid5
Raid Devices : 15
Avail Dev Size : 249796608 (119.11 GiB 127.90 GB)
Array Size : 54696423936 (52162.57 GiB 56009.14 GB)
Used Dev Size : 7813774848 (3725.90 GiB 4000.65 GB)
Data Offset : 262144 sectors
Super Offset : 8 sectors
Unused Space : before=262056 sectors, after=0 sectors
State : active
Device UUID : 5015e522:d39ba566:5909cf3c:9c51f2ff
Internal Bitmap : 8 sectors from superblock
Update Time : Thu Aug 27 13:16:55 2015
Bad Block Log : 512 entries available at offset 72 sectors
Checksum : 4e6fd76d - correct
Events : 262
Layout : left-symmetric
Chunk Size : 256K
Device Role : Journal
Array State : AAAAAAAAAAAAAAA ('A' == active, '.' == missing, 'R' == replacing)
Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: NeilBrown <neilb@suse.com>
imsm: don't call abort_reshape() in imsm_manage_reshape()
Calling abort_reshape() in imsm_manage_reshape() is unnecessary in case
of an error because it is handled by reshape_array(). Calling it when
reshape completes successfully is also unnecessary and leads to a race
condition:
- reshape ends
- mdadm calls abort_reshape() -> sets sync_action to idle
- MD_RECOVERY_INTR is set and md_reap_sync_thread() does not finish the
reshape
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Konrad Dabrowski <konrad.dabrowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.com>
Commit 06bd679317a2 ("Skip clustered devices in incremental")
disabled incremental completely on clustered arrays.
What we really want is that mdadm should not start or create
a clustered array but still be able to add or readd to an existing
device. This would enable udev scripts to automatically add
or re-add a device after transient errors.
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.
NeilBrown [Mon, 3 Aug 2015 01:53:01 +0000 (11:53 +1000)]
mdassemble: don't try to perform cluster check.
mdassemble is meant to be small an simple, so avoid
trying to check for a cluster.
Currently it doesn't, but it still includes the code,
which doesn't build because the library isn't provided.
So just exclude the get_cluster_name code from mdassemble.
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.
sometimes the removed device is re-added before the writes
get all the way to the md device - so the array doesn't need
any recovery and the test fails.
So flush first to be safe.
newer versions of mkfs.extX ask before creating a filesystem
on a device which appears to already have a filesystem.
We don't want that, so add the -F flag.
Also be explicit about fs type as one shouldn't depend on defaults.