Commit Graph

3366 Commits

Author SHA1 Message Date
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
Jes Sorensen 5f4cc23926 Create: Remove all attemps to handle md driver older than 0.90.03
More legacy code moved to the bit-bucket.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:32:40 -04:00
Jes Sorensen 901d5ee6da Detail: Stop bothering about md drivers older than 0.90.00
Remove further handling of md driver version older than 0.90.00

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:29:29 -04:00
Jes Sorensen 6ae8b2b314 Grow: Stop bothering about md driver versions older than 0.90.00
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:29:29 -04:00
Jes Sorensen e6e5f8f126 Build: Stop bothering about supporting md driver older than 0.90.00
The kernel has been stuck at md driver version 0.90.03 for at least  a
decade. No point in continuing to support the older API.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:29:22 -04:00
Jes Sorensen 6142741d14 Assemble/Assemble: Stop checking kernel md driver version
Any kernel released during the last decade will return 9003 from
md_get_version() so no point in checking that.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:09:18 -04:00
Jes Sorensen 700483a223 util/set_array_info: Simplify code since md_get_version returns a constant
md_get_version() always returns (0 * 1000) + (90 * 100) + 3, so no
point in calling it.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 15:06:24 -04:00
Jes Sorensen f5c924f441 util/must_be_container: Use sysfs_read(GET_VERSION) to determine valid array
Use sysfs_read() instead of ioctl(RAID_VERSION) to determine this is
in fact a valid raid array fd.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 14:01:30 -04:00
Jes Sorensen 98dbf73cba Create: Fixup various whitespace issues
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 11:57:30 -04:00
Jes Sorensen cf622ec1d8 Create: Fixup bad placement of logical || && in multi-line if statements
These always go at the end of the line, never at the front

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 11:53:12 -04:00
Zhilong Liu 230a0dde09 mdadm/Create: declaring an existing struct within same function
Create:declaring 'struct stat stb' twice within the same
function, rename stb as stb2 when declares 'struct stat'
at the second time.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-04-05 11:47:04 -04:00
Jes Sorensen dae131379f sysfs: Make sysfs_init() return an error code
Rather than have the caller inspect the returned content, return an
error code from sysfs_init(). In addition make all callers actually
check it.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-30 16:52:37 -04:00
Jes Sorensen 67a02d5200 sysfs: Use the presence of /sys/block/<dev>/md as indicator of valid device
Rather than calling ioctl(RAID_VERSION), use the presence of
/sys/block/<dev>/md as indicator of the device being valid and sysfs
being active for it. The ioctl could return valid data, but sysfs
not mounted, which renders sysfs_init() useless anyway.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-30 16:02:36 -04:00
Gioh Kim 13428e2e76 mdadm.c: fix compile error "switch condition has boolean value"
Remove a boolean expression in switch condition
to prevent compile error of some compilers,
for example, gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2).

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-30 13:46:14 -04:00
Tomasz Majchrzak b53bfba611 imsm: use rounded size for metadata initialization
Array size is rounded to the nearest MB, however number of data stripes
and blocks per disk are calculated using size passed by the user. If
given size is not aligned, there is a mismatch. It's not possible to
assemble raid0 migrated to raid5 since raid5 arrays use number of data
stripes to calculate array size.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-30 11:54:53 -04:00
Zhilong Liu 5b2846684e mdadm/grow: reshape would be stuck from raid1 to raid5
systemctl doesn't interpret mdadm-grow-continue@.service
correctly due to the wrong argument provided in [service],
it should be corrected %I as %i. Otherwise, if the service
cannot start by systemctl and the reshap progress would be
stuck all time when grows array from raid1 to raid5.

reproduce steps:
./mdadm -CR /dev/md0 -l1 -b internal -n2 /dev/loop[0-1]
./mdadm --grow /dev/md0 -l5 -n3 -a /dev/loop2

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-30 11:49:44 -04:00
Jes Sorensen 49948a3561 Grow: Do not shadow an existing variable
Declaring 'int rv' twice within the same function is asking for
trouble.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-30 10:46:01 -04:00
Jes Sorensen 758b327cf5 Grow: Remove unnecessary optimization
Per explanation by Neil, this optimization of writing "size" to the
attribute of each device, however when reducing the size of devices,
the size change isn't permitted until the array has been shrunk, so
this will fail anyway.

This effectively reverts 65a9798b58

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-30 10:44:36 -04:00
Jes Sorensen b0ba6a1dee md_u: Remove some unused ioctl declarations
These were no longer used in the code, so get rid of them.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 15:48:24 -04:00
Jes Sorensen 018a488238 util: Introduce md_set_array_info()
Switch from using ioctl(SET_ARRAY_INFO) to using md_set_array_info()

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 15:43:53 -04:00
Jes Sorensen d97572f5a5 util: Introduce md_get_disk_info()
This removes all the inline ioctl calls for GET_DISK_INFO, allowing us
to switch to sysfs in one place, and improves type checking.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 15:23:50 -04:00
Jes Sorensen 5b13d2e1fb Incremental: Remove redundant call for GET_ARRAY_INFO
The code above just called md_get_array_info() and only reached this
point if it returned an error that isn't ENODEV, so it's pointless to
check this again here.

In addition it was incorrectly retrieving ioctl data into a
mdu_bitmap_file_t instead of mdu_array_info_t.

Fixes: ("8382f19 Add new mode: --incremental")
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 14:40:36 -04:00
Jes Sorensen 9cd39f0155 util: Introduce md_get_array_info()
Remove most direct ioctl calls for GET_ARRAY_INFO, except for one,
which will be addressed in the next patch.

This is the start of the effort to clean up the use of ioctl calls and
introduce a more structured API, which will use sysfs and fall back to
ioctl for backup.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 14:35:41 -04:00
Jes Sorensen 6ebf34e6bd Grow: Fixup a pile of cosmetic issues
No code change, simply cleanup ugliness.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 12:15:20 -04:00
Jes Sorensen efa295309f util: Cosmetic changes
Fixup a number of indentation and whitespace issues

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 12:05:12 -04:00
Jes Sorensen 8ea982179a mdadm: Fixup a number of whitespace inconsistency cases
Lots of code lacked whitespaces in assignments, and in other places
had them in the wrong place.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 12:02:14 -04:00
Jes Sorensen ed18099698 mdadm: Clean up some ugly multiple actions on single line
'foo(); continue;' on the same line within a switch statement is
always wrong. Get rid of some of it.

Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 11:55:19 -04:00
Gioh Kim aa31311836 super1: replace hard-coded values with bit definitions
Some hard-coded values for disk status are replaced
with bit definitions.

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 11:40:40 -04:00