Commit Graph

593 Commits

Author SHA1 Message Date
NeilBrown 9fe3204317 mdmon: fork and run as a daemon.
start_mdmon now waits for mdmon to complete initialisation and,
importantly, listen on the socket, before continuing.

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:20 +10:00
NeilBrown 8dfb8619f9 sysfs: avoid possible data corruption in sys_load.
Don't retry to remove a newline from the end of an empty string.

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:18 +10:00
NeilBrown 7364918895 Correct readlink usage in sysfs.c
readlink doesn't nul-terminate the returned string, so we must
be sure to do that.

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:16 +10:00
NeilBrown 44d2e36556 Don't assume that mdmon is in the current directory.
Rather, assume that it is in the same directory from which
mdadm was run.  If not, then maybe /sbin or current directory.

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:13 +10:00
NeilBrown 8850ee3e1e Factor common code into new "start_mdmon".
Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:11 +10:00
Neil Brown daf7a3ce96 Stop managed arrays more carefully.
If an array is being managed by mdmon, then just
write "inactive" to stop it, and let mdmon do the
final "clear".  This makes sure mdmon has a chance
to read the final state and update the metadata properly.

After writing "inactive" with use "ping_monitor" to synchronise
with mdadm, then STOP the array just in case it is still running,
else we will get into an infinite loop in "mdadm -Ss".

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:09 +10:00
NeilBrown 1eb252b848 mdmon: ping will wait for manage_mon to catch up.
When a 'ping' (empty message) is sent to mdmon, we wait for
'monitor' to do a full loop to make sure it has caught up
with anything that needs doing.
This allows synchronisation between mdadm and mdmon.

Maybe monitor should signal managemon rather than managemon polling...

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:06 +10:00
Neil Brown 103f2410ec Make sure resync_start is initialised properly and maintained properly
Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:04 +10:00
Neil Brown 120f767760 ddf: endian fixes.
We forgot to convert endian for lba_offset at one point,
and use le32 instead of be32 right nearby!!

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:03 +10:00
Dan Williams 00e021427e mdmon: close possibility of re-marking the metadata dirty on shutdown
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 14:59:39 -07:00
Dan Williams 0a6bdbee8d mdmon: notify metadata of recovery completion
Array may no longer be degraded.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 14:59:39 -07:00
Dan Williams 272bcc48d1 mdmon: initialize component_size in manage_new
When we go to activate a spare for an array we expect ->info.component_size
is valid.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 14:59:39 -07:00
Dan Williams 2cc98f9ea5 mdmon: close small window of invalid mon_tid
There is a small chance that the manager tries to wake the monitor before
mon_tid is set.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 14:59:39 -07:00
Dan Williams 5dcfcb715d mdadm: add an environment variable to prevent auto-launching mdmon
Useful for attaching gdb to mdmon before any action is taken on the array.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 14:59:32 -07:00
Dan Williams 00451d9874 managemon: don't treat sysfs_add_disk as boolean function
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 14:10:02 -07:00
Dan Williams e8319a19f2 imsm: process update
Handle 'activate_spare' events
2008-07-14 14:10:02 -07:00
Dan Williams 88758e9daa imsm: activate_spare
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 14:09:48 -07:00
Dan Williams 2da8544a39 imsm: metadata only supports a global 'data_offset'
When creating a volume a drive must have free space starting at the same
location as all the other drives in the array.
2008-07-14 13:59:56 -07:00
Dan Williams ef6ffaded4 imsm: fix raid1 creation
Need to supply dummy values for the chunk size and number of data stripes

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 13:58:19 -07:00
Dan Williams 0372d5a2f4 imsm: fail ->open_new if container_member is out of range
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 13:57:33 -07:00
Dan Williams a3d6757fbf imsm: kill obsolete call to fsync() in store_imsm_mpb
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 13:56:42 -07:00
Dan Williams 2c092cada6 imsm: fix insufficient mpb buffer allocation
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 13:56:28 -07:00
Dan Williams ad97895ec8 imsm: catch posix_memalign allocation failures
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 13:55:12 -07:00
Dan Williams bf5a934aff imsm: remove extra superswitches
Following the lead of 75ede16d.  This incidentally fixes creation of a second
array by gating call to getinfo_super_imsm_volume with a valid ->current_vol.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 13:55:12 -07:00
Dan Williams 99e2926423 imsm: fix store_imsm_mpb() alignment for O_DIRECT
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-07-14 13:55:02 -07:00
Neil Brown f7f1b6a1db Print used message in place of "default metadata" message.
When creating an array in a container, print e.g.
   Creating array inside ddf container /dev/whatever
rather than
   Defaulting to version /md127/1 metadata
2008-07-12 20:28:38 +10:00
Neil Brown 77472ff8d0 Introduce devname2devnum
and use it instead of opencoding.
2008-07-12 20:28:38 +10:00
Neil Brown d7161f3b51 Fix fd comparison in Incremental
fd==0 is theoretically possible...
2008-07-12 20:28:38 +10:00
Neil Brown 2c514b7120 Pass 'verbose' flag to validate_geometry
That way it can be silent when we are just trying to figure out
which metadata to use, and noisy when detecting a real problem.
2008-07-12 20:28:38 +10:00
Neil Brown 047d2e49f5 Correct unit conversion for component_size and dev/size in sysfs.
These are both Kilobytes, so do the conversion to sectors properly.
2008-07-12 20:28:38 +10:00
Neil Brown 6416d5275d Use O_DIRECT for all IO to devices.
Using buffered IO risks non-atomic updates to parts of the
device that we don't actually want to write to.  This isn't in
general safe.
So switch to O_DIRECT for all that IO and make sure we have
properly aligned buffers.
2008-07-12 20:28:33 +10:00
Neil Brown 908ef18519 Stop all arrays before running each test in regression test driver.
Sometimes I forget to stop arrays at the end of scripts, and
that shows errors in the next script, which is confusing.
2008-07-12 20:27:42 +10:00
Neil Brown 3576e302fe ddf: Set container_member from subarray in getinfo_super.
Also go direct from subarray to text_version.
2008-07-12 20:27:42 +10:00
Neil Brown 18a2f463fd Reduce the number of metadata updates done by ddf.
1/ track if there are any actual updates pending, and only
   write metadata when we have changed something.

2/ when writing null virtual-configs, write full blocks,
   not just the first 4 bytes.  This will allow O_DIRECT
   writes in a subsequent patch.
2008-07-12 20:27:42 +10:00
Neil Brown 48561b0142 Improve shutdown for container-based arrays.
1/ close a race where multiple arrays disappear at once
   and monitor isn't woken up to find out that the last one
   has gone.
2/ "mdadm -Ss" needs to pause briefly for mdmon to exit.
2008-07-12 20:27:42 +10:00
Neil Brown c7c149300b Keep container device open in monitor
... so that it cannot be stopped while there are active arrays.
I don't know where that second 'close' came from ....
2008-07-12 20:27:42 +10:00
Neil Brown 207aac36d5 Make sure we remove pid file in monitor before manager exits. 2008-07-12 20:27:42 +10:00
Neil Brown a35c070bcd Remove some noisy printfs. 2008-07-12 20:27:41 +10:00
Neil Brown edd8d13c02 Create arrays via metadata-update
Support creating arrays inside an active ddf container by
sending a metadata update over a pipe to mdmon.
2008-07-12 20:27:40 +10:00
Neil Brown bfa44e2e7a Revise message passing code.
More here
2008-07-12 20:27:40 +10:00
Neil Brown 4d43913ce0 Remove mgr_pipe for communicating from manage to monitor.
Data is being passed in shared memory, so the pipe is only being
use as a wakeup.  This can more easily be done with a thread-signal.
2008-07-12 20:27:40 +10:00
Neil Brown 2f64e61a50 Remove mon_pipe for communicating from monitor to manager
The returned value was never used, and we don't really want
this return path anyway as writing to a pipe could conceivably
block, and the monitor must not block.
2008-07-12 20:27:40 +10:00
Neil Brown f94d52f43e Handle device removal from container
This really should be done in mdadm, not mdmon.
We ensure the device won't be suddenly commited as a hot-spare
using O_EXCL, then check the 'holders' sysfs directory
to make sure it is only in use once.
2008-07-12 20:27:40 +10:00
Neil Brown d4da74fc9c Fix kernel patch 2008-07-12 20:27:39 +10:00
Neil Brown ec9688ca70 Make super super0.c function static.
So only 'super0' is externally visible.
2008-07-12 20:27:39 +10:00
Neil Brown 78e449282e Remove the multiple super_switchs for ddf.
It is simpler if there is just one, and the methods
make decisions as appropriate.
2008-07-12 20:27:39 +10:00
Neil Brown ba7eb04f71 Remove silly convention that major='-1' means 'zero superblock'.
Use 'info pointer is NULL' instead.
2008-07-12 20:27:39 +10:00
Neil Brown d2ca644994 Remove getinfo_super_n and do some other cleaning up.
Getting close to a sensible description of what some of the
superswitch methods are supposed to do!
2008-07-12 20:27:39 +10:00
Neil Brown 0d481d3723 External metadata shouldn't set array.*_version
It doesn't mean anything and is never used.
2008-07-12 20:27:39 +10:00
Neil Brown f7e7067b47 Add subarray field to supertype.
When loading the metadata for a subarray (super_by_fd), we set
->subarray to be the name read from md/metadata_version so that
getinfo_super can return info about the correct array.

With this we can differentiate between a container and
an array within the container by looking at ->subarray[0].
2008-07-12 20:27:38 +10:00