Commit Graph

3393 Commits

Author SHA1 Message Date
Jes Sorensen 935795398d mdassemble: Kill off the last remains
Having gotten rid of mdassemble, lets get rid of the man page too

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-04 11:57:41 -04:00
Jes Sorensen 2b7bddf06c kernel-patch: Remove obsolete kernel patches against 2.6
While we still support some of these kernels, I do not think it makes
sense to carry this patches around at this point.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-04 11:39:05 -04:00
Jes Sorensen 9db2ab4e9b util: md_array_valid(): Introduce md_array_valid() helper
Using md_get_array_info() to determine if an array is valid is broken
during creation, since the ioctl() returns -ENODEV if the device is
valid but not active.

Where did I leave my stash of brown paper bags?

Fixes: ("40b054e mdopen/open_mddev: Use md_get_array_info() to determine valid array")
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-03 16:15:16 -04:00
Zhilong Liu 99148c19bd change back 0644 permission for Grow.c
Fixes commit:
26714713cd ("mdadm: Change timestamps to unsigned data type.")

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-03 10:50:59 -04:00
Jes Sorensen 9e4524df1c Grow: Grow_continue_command: Avoid aliasing array variable
While this would cause a warning since the two are different types,
lets avoid aliasing an existing variable.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-02 11:46:49 -04:00
Pawel Baldysiak 2a24dc1b09 IMSM: Initialize my_vol_raid_dev_num during vol creation
This field was not initialized so far. This ID needs to be unique
for every newly created array in container.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-02 10:48:24 -04:00
Jes Sorensen 80223cb4db Manage: Manage_ro(): Use md_array_active()
One call less to md_get_array_info() for determining whether an array
is active or not.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-02 10:41:23 -04:00
Jes Sorensen 6921010d95 Incremental: Use md_array_active() to determine state of array
One less call to md_get_array_info()

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-02 10:36:51 -04:00
NeilBrown cd6cbb08c4 Create: tell udev md device is not ready when first created.
When an array is created the content is not initialized,
so it could have remnants of an old filesystem or md array
etc on it.
udev will see this and might try to activate it, which is almost
certainly not what is wanted.

So create a mechanism for mdadm to communicate with udev to tell
it that the device isn't ready.  This mechanism is the existance
of a file /run/mdadm/created-mdXXX where mdXXX is the md device name.

When creating an array, mdadm will create the file.
A new udev rule file, 01-md-raid-creating.rules, will detect the
precense of thst file and set ENV{SYSTEMD_READY}="0".
This is fairly uniformly used to suppress actions based on the
contents of the device.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-02 09:41:39 -04:00
Jes Sorensen f8c432bfc9 Incremental: Cleanup some if() statement spaghetti
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-25 15:07:26 -04:00
Jes Sorensen ff4ad24b1c Incremental: Use md_array_active() where applicable
md_get_array_info() == 0 implies an array is active, however this is more
correct.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-25 14:57:46 -04:00
Jes Sorensen 0885b942b3 Detail: Reinstate support for not having sysfs
While sysfs support will hopefully go away eventually, lets not break
it unnecessarily for now.

Fixes: 901d5ee ("Detail: Stop bothering about md drivers older than 0.90.00")
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-25 14:34:31 -04:00
Jes Sorensen 5737086ed7 Detail: Respect code lines are 80 character wide
In addition apply spaces and don'f do 'if () action()' on the same line.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-25 12:21:39 -04:00
Jes Sorensen a4dcdb23ea Detail: determine array state from sysfs
This is easily obtained from sysfs as part of the existing call to
sysfs_read() and it simplifies the code a little too.

Another small step in the process of getting rid of the GET_ARRAY_STATE
ioctl.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-25 11:40:27 -04:00
Artur Paszkiewicz b75805662e Don't use UnSet with consistency_policy
Use CONSISTENCY_POLICY_UNKNOWN instead. Simplify some checks because
since 5e8e35fb7e ("maps: Use keyvalue for null terminator to indicate
'unset' value") map_name() can return this default directly.

Suggested-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
2017-04-24 17:10:56 -04:00
Jes Sorensen 4a4379b054 maps: Simplify implementation of map_name()
Reported-By: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-21 12:11:21 -04:00
Jes Sorensen 966188e959 maps: Remove incorrect comment about strcmp()
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-21 12:09:12 -04:00
Jes Sorensen 17d80e6eb6 Makefile: Default to -O2 optimization
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-21 12:06:35 -04:00
Jes Sorensen 0dfff0f243 Query: Quiet gcc since it cannot know errno != 0 in this case
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-21 12:04:05 -04:00
NeilBrown b9c9bd9bac Detail: ensure --export names are acceptable as shell variables.
If an array contains a device which has a name that
contains something other than alphnumerics and underscores,
then some values reported by "mdadm --detail --export" will
not be valid as variable assignment of the shell.
This particularly affects dm devices.
e.g.
   MD_DEVICE_dm-4_ROLE=1
   MD_DEVICE_dm-4_DEV=/dev/dm-4

As it is particularly useful to be able to work with these
in a shell script, and as the precise name is not important,
change all non-alphanumerics to '_'.

   MD_DEVICE_dm_4_ROLE=1
   MD_DEVICE_dm_4_DEV=/dev/dm-4

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 12:59:22 -04:00
NeilBrown 5c4b3b9aa9 systemd/mdadm-last-resort: use ConditionPathExists instead of Conflicts
Commit cec72c071b ("systemd/mdadm-last-resort: add Conflicts to .service file.")

added a 'Conflicts' directive to the mdadm-last-resort@.service file in
the hope that this would make sure the service didn't run after the device
was active, even if the timer managed to get started, which is possible in
race conditions.

This seemed to work is testing, but it isn't clear why, and it is known
to cause problems.
If systemd happens to know that the mentioned device is a dependency of a
mount point, the Conflicts can unmount that mountpoint, which is certainly
not wanted.

So remove the "Conflicts" and instead use
 ConditionPathExists=!/sys/devices/virtual/block/%i/md/sync_action

The "sync_action" file exists for any array which requires last-resort
handling, and only appears when the array is activated.  So it is safe
to rely on it to determine if the last-resort is really needed.

Fixes: cec72c071b ("systemd/mdadm-last-resort: add Conflicts to .service file.")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 12:57:27 -04:00
NeilBrown a250ce240f Grow_continue_command: ensure 'content' is properly initialised.
Grow_continue_command() call verify_reshape_position(), which assumes
that info->sys_name is initialised.
'info' in verify_reshape_position() is 'content' in Grow_continue_command().

In the st->ss->external != 0 branch of that function, sysfs_init() is called
to initialize content->sys_name.
In the st->ss->external == 0 branch, ->sys_name is not initialized so
verify_reshape_position() will not do the right thing.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 12:56:21 -04:00
Coly Li b63804583e mdadm: retire mdassemble in make everything
make everything reports no rule to make mdassemble, because mdassemble
is removed from mdadm. This patch removes mdassemble from "everything"
in Makefile, now there is no failure when compiling a static mdadm binary.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 12:28:32 -04:00
Jes Sorensen 44356754ec util: Get rid of unused enough_fd()
enough_fd() is no longer used, so lets get rid of it.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 11:53:30 -04:00
Jes Sorensen 5e8e35fb7e maps: Use keyvalue for null terminator to indicate 'unset' value
This simplifies the code calling map_name() so it no longer has to
manually check for UnSet and convert the value manually.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 00:27:42 -04:00
Jes Sorensen e47781fcea maps: Terminate 'modes' map correctly.
While we are unlikely to fail here, terminate the modes map correctly
to ensure we don't start running over undefined data.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 00:13:31 -04:00
Jes Sorensen 3ab8f4bf33 util: Introduce md_array_active() helper
Rather than querying md_get_array_info() to determine whether an array
is valid, do the work in md_array_active() using sysfs, and fall back
on md_get_array_info() if sysfs fails.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 00:12:34 -04:00
Jes Sorensen 5e4ca8bb82 sysfs: Parse array_state in sysfs_read()
Rather than copying in the array_state string, parse it and use an
enum to indicate the state.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 00:12:27 -04:00
Jes Sorensen f22d6cde7c Query: Use sysfs to obtain data if possible
Use sysfs to obtain leve, raid_disks, and spare_disks. If sysfs fails,
fall back to calling the ioctl via md_get_array_info().

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-13 12:20:46 -04:00
Jes Sorensen 8d0cd09d73 Query: Handle error returned by fstat()
We shouldn't ignore any error returned by fstat() even if open() didn't
fail.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-13 11:53:21 -04:00
Jes Sorensen 776b199e41 Detail: Fixup ugly if () foo() abuse
Cosmetic change only

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-12 17:05:55 -04:00
Jes Sorensen 0ef1043ce8 Assemble: Remove obsolete test for kernels older than 2.4
We only support 2.6.15+ at this point

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-12 14:50:02 -04:00
Jes Sorensen 5e13ef714d Detail: Remove pre-2.6 code for printing info on rebuilding
Since we no longer support anything pre-2.6.15, there is no point in
keeping this around.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-12 14:48:10 -04:00
Jes Sorensen 94b53b777e Assemble: Clean up start_array()
This is purely cosmetic, no codeflow changes.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-12 14:23:45 -04:00
Zhilong Liu e39c76b9b7 mdadm/manpage:clustered arrays don't support array-size yet
Update manpage for array-size section:
Clustered arrays don't support the --array-size yet.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-12 13:55:43 -04:00
Zhilong Liu 8a70632fc2 mdadm/manpage:update manpage for readonly parameter
update readonly in manpage:
Currently both the readwrite and readonly are worked well,
update the readonly section.
One commit in linux/driver/md. Cleared "MD_CLOSING bit" to
Fixes: af8d8e6f0315 ("md: changes for MD_STILL_CLOSED flag")

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-12 13:51:07 -04:00
NeilBrown 039df36231 mdopen: use parameters/new_array to create arrays whenever possible.
In a sufficiently recent kernel, an md%d array can be
created by writing to .../parameters/new_array.
If mdadm does this consistently, then another new
feature, disabling create_on_open, can be enabled.
This avoids races on shutdown.

An added benefit of using new_array (where available)
is that it allows md arrays with numbers larger than 511
(e.g. md999) to be created.  The old create_on_open
mechanism doesn't support such devices since
Commit: af5628f05db6 ("md: disable probing for md devices 512 and over.")
in Linux 3.17.

After a few more mdadm releases it would be good to
have mdadm disable create_on_open automatically.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-12 13:34:44 -04:00
Jes Sorensen 46a533a90c super1: Clean up various style abuses
Code is 80 characters wide, so lets try to respect that. In addition, we
should never have one-line 'if () action()' statements. Fixup various
whitespace abuse.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-11 14:25:24 -04:00
Jes Sorensen 32141c1765 Retire mdassemble
mdassemble doesn't handle container based arrays, no support for sysfs,
etc. It has not been actively maintained for years, so time to send it
off to retirement.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-11 12:54:26 -04:00
Jes Sorensen 2cfe6f7c64 Revert "mdadm/grow: reshape would be stuck from raid1 to raid5"
This reverts commit 5b2846684e.

This was a red herring and shouldn't have been applied in the first
place.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-11 11:30:23 -04:00
Zhilong Liu 5fbc1f1527 mdadm.c:fix compile warning "mdfd is uninitialized"
Initialized the mdfd as -1 to prevent compile error
of some compilers.
For example, gcc version 4.8.5(SUSE Linux).

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-11 11:27:53 -04:00
Jes Sorensen dcf3d4de95 mdadm: Fail for kernels older than 2.6.15
With the removal of old kernel API support, mdadm will no longer run
on kernels older than 2.6.15.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-06 15:46:31 -04:00
Jes Sorensen 303949f6f0 util: Finally kill off md_get_version()
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:49:18 -04:00
Jes Sorensen b6e60be628 Assemble/Assemble: Get rid of last use of md_get_version()
At this point in the code, we know we have a valid array, and any
recent kernel will return 9003, so no point in querying the kernel for
this.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:47:37 -04:00
Jes Sorensen 1c9591115d mdassemble: Use md_get_array_info() to check for valid array
Get rid of another use of md_get_version()

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:46:35 -04:00
Jes Sorensen 40b054e1dc mdopen/open_mddev: Use md_get_array_info() to determine valid array
md_get_array_info() can be used instead of md_get_version() to
determine this is in fact a valid array.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:44:20 -04:00
Jes Sorensen 15d924d363 mdmon: Stop bothering about md_get_version()
If anyone has a kernel with md driver older than 0.90.03 they will
also know where to find older versions of mdadm.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:39:51 -04:00
Jes Sorensen 5d89b18da8 bitmap: Remove use of md_get_version()
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:38:48 -04:00
Jes Sorensen 5cb859962f Query: Remove all references to md_get_version()
More legacy code removed

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:37:38 -04:00
Jes Sorensen 091e8e6e06 Manage: Remove all references to md_get_version()
At this point, support for md driver prior to 0.90.03 is going to
disappear.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:34:44 -04:00