Commit Graph

53 Commits

Author SHA1 Message Date
NeilBrown c3f26510c6 open_mddev: open RDONLY if RDWR doesn't work.
If an array is read-only then "mdadm -S"
cannot open it to stop it without this fix.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-01-31 14:49:39 +11:00
NeilBrown 0eb26465c0 Free some malloced memory that wasn't being freed.
As mdadm is normally a short-lived program it isn't always necessary
to free memory that was allocated, as the 'exit()' call will
automatically free everything.  But it is more obviously correct if
the 'free' is there.
So this patch add a few calls to 'free'

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-22 11:00:56 +11:00
NeilBrown 5ac6db12f9 mdopen: only use 'dev' as chosen name if it is a full path.
Otherwise using names like "r0" causes problem.  They are
handled sufficiently by other paths in the code.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-19 17:11:15 +11:00
NeilBrown e736b62389 Update copyright dates and remove references to @cse.unsw.edu.au
Also removed 'paper' addresses.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-02 14:35:45 +10:00
NeilBrown 9a40c32728 create_mddev: don't replace /dev/mdX with /dev/md/X
If someone creates/assemble an array called "/dev/md0", don't force
it to be "/dev/md/0".  Doing so isn't really necessary and it
likely to confuse people.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:58:44 +10:00
NeilBrown d7ba0c55f0 create_dev - allow array names like mdX and /dev/mdX to appear 'numeric'
When choosing the minor number to use with an array, we currently base
the number of the 'name' stored in the metadata if that name is
numeric.
Extend that so that if it looks like a number md device name (/dev/md0
or just md0 or even /dev/md/0), then we use the number at the end to
suggest a minor number.

The means that if someone creates and array with "--name md0" or even
"--name /dev/md0" it will continue to do what they expect.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-05-11 15:16:47 +10:00
NeilBrown add394f39e mdopen: be more careful when adding digit to names.
If we need to add digits to a name to make it unique, but don't have
to add '_', we need to avoid adding a digit immediately after a digit.
So if the last character of the name is a digit, add the '_' anyway.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-03-10 16:28:22 +11:00
Dan Williams 614825ea82 some warn_unused_result fixups
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-27 15:29:54 +11:00
NeilBrown e10a79c344 mdopen: typo in buffer-length for a sprintf.
That '10000' should have been '1000'.  Make it a 'sizeof' to avoid
such carelessness.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-07 14:46:51 +11:00
NeilBrown bde2c6e287 mdopen: only let numeric name set minor number if it doesn't cause a conflict.
So if the array with minor number matching the name of a new array
already exists, just assemble with a different minor number.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:54:50 +11:00
NeilBrown f2e55eccfb mdopen: use small sequence number for uniquifying array names.
Rather than appending the md minor number, we now append a small
sequence number to make sure name in /dev/md/ that aren't LOCAL are
unique.  As the map file is locked while we do this, we are sure
of no losing any races.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:51:12 +11:00
Dan Williams 197e3eb690 Quiet unitialized variable warnings
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:39 +11:00
NeilBrown 11fb4c054f mdopen: fix up name parsing.
I think this is closer to what I want.  Fewer surprises anyway.
2008-11-04 20:50:39 +11:00
NeilBrown 215bb3f776 Incremental: adjust to the new naming scheme.
--incremental now uses exactly the same create_mddev that
other code uses.
2008-11-04 20:50:38 +11:00
NeilBrown c4fe2d4f56 mdopen: Restore creation of partition devices and symlink.
Using the 'new' name scheme we restore the creation of partition
links (in the case the udev isn't used).
2008-11-04 20:50:38 +11:00
NeilBrown 69207ff6ac mdopen: Introduce new rules for creating device name.
MORE CONTENT HERE
2008-11-04 20:50:21 +11:00
NeilBrown 6be1d39d1d Introduce new open_mddev which just does an open.
Some cases we aren't interested in creating the mddev, just opening
it.  Make those more explicit.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 10:35:31 +11:00
NeilBrown 2399204ddd Rename open_mddev to create_mddev
This reflect that fact that more often than not it is creating things
in /dev, and allows for a new open_mddev which does just that.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 10:35:10 +11:00
NeilBrown 6c766cf101 Merge branch 'master' into devel-3.0
Conflicts:

	Incremental.c
	super0.c
	super1.c
2008-10-30 13:59:11 +11:00
NeilBrown 7b403fef7e Incremental: allow assembly of foreign array.
If a foreign (i.e. not known to be local) array is discovered
by --incremental assembly, we now assemble it.  However we ignore
any name information in the array so as not to potentially create
a name that conflict with a 'local' array.
Also, foreign arrays are always assembled 'read-auto' to avoid writing
anything until the array is actually used.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-10-30 09:48:18 +11:00
NeilBrown c5afc314e2 Lots of fixes to make incremental assembly of containers work.
So:
  mdadm -I /dev/whatever

will (if appropriate) add whatever to a container, then start
any arrays inside the container.
2008-09-18 16:03:05 +10:00
Doug Ledford fb97b4d691 Clean up usage of open()
Fix on call that passed an invalid mode to open
	Don't pass a third arg unless we also pass O_CREAT
	Use symbolic args for 2nd and 3rd args

Signed-off-by: Doug Ledford <dledford@redhat.com>
2008-07-24 18:35:11 -04:00
Neil Brown 9a02c62af9 Make device-special files for partitions when using --incremental 2008-05-05 21:55:39 +10:00
Neil Brown 63152c1b33 Unify code into find_free_devnum.
Two places have code to find a free md device number.  Make this
a subroutine.
2008-05-05 21:55:36 +10:00
Bill Nottingham 767bd45298 Simplistig locking for --incremental.
From: Bill Nottingham <notting@redhat.com>

mdadm --incremental doesn't really do any locking. If you get multiple
events in parallel for the same device (that has not yet started), they
will all go down the path to create the array. One will succeed, the
rest will have SET_ARRAY_INFO die with -EBUSY (md: array mdX already has disks!)
and will exit without adding the disk.

Original bug report is: https://bugzilla.redhat.com/show_bug.cgi?id=433932

This is solved by adding very very rudimentary locking. Incremental() now
opens the device with O_EXCL to ensure only one invocation is frobbing the
array at once. A simple loop just tries to open 5 times a second for 5
seconds. If the array stays locked that long, you probably have bigger
issues.
2008-05-05 19:44:04 +10:00
Bill Nottingham 62552fdfcc Create /dev/md if needed and it doesn't exist.
From: Bill Nottingham <notting@redhat.com>
2008-05-05 19:44:01 +10:00
Neil Brown aba69144fd Remove spaces/tabs from ends of lines. 2007-12-14 20:13:43 +11:00
Neil Brown dc2ee6b3e3 Make sure --auto=mdp is honoured properly
This would only create partitioned devices if the device name was a
'standard' name.  This this patch, any name will work.
2007-10-17 10:00:55 +10:00
maximilian attems b440882edf mdopen.c don't shadow major() and minor()
s/(major|minor)/\1_num/

Signed-off-by: maximilian attems <max@stro.at>
Signed-off-by: Neil Brown <neilb@suse.de>
2007-09-27 10:08:30 +10:00
Neil Brown 8382f19bdc Add new mode: --incremental
--incremental allows arrays to be assembled one device at a time.
This is expected to be used with udev.
2006-12-21 17:10:52 +11:00
Neil Brown 7572344665 Default to --auto=yes
so the array devices with 'standard' names
get created automatically, as this is almost always what is wanted.
2006-12-14 17:31:10 +11:00
Michael Labuschke 3a43c80392 Check error return on a couple of syscalls.
From: "Michael Labuschke" <michael@labuschke.de>
2006-10-23 14:56:35 +10:00
Luca Berra e60c27d04e Don't fail md_open if array already active.
From: Luca Berra <bluca@comedia.it>

There is no need and it causes occasional problems.
2006-10-16 15:27:16 +10:00
Neil Brown 38098016ca Allow symlink creation to be disabled from command line or mdadm.conf 2006-08-11 18:00:05 +10:00
Neil Brown 0a6e1c6743 Create symlinks from /dev into /dev/md
When (auto)creating devices in /dev/md/, create
an appropriate symlink from /dev to avoid confusion.
2006-08-11 18:00:00 +10:00
Neil Brown 8aec876d2e More consistent honoring of --configfile
Never use /etc/mdadm.conf if --config file is given (previously
some code used one, some used the other).
2006-06-26 15:11:01 +10:00
Neil Brown d55e3aefc0 Support auto-assembling of stacked devices
and assorted bugfixes.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-26 03:11:57 +00:00
Neil Brown 2e2642f2c5 Never remove device nodes of active devices.
This is just too risky.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-26 02:32:15 +00:00
Neil Brown e7bb5d23a9 Choose better devnumbers and tidy up some issues with finding names.
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-26 01:40:53 +00:00
Neil Brown 4f589ad0c5 Just updaqte copyright dates and email address
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-19 05:25:11 +00:00
Neil Brown f1ae21c411 Arrange the 'auto' setting in mdadm.conf can choose default type.
So when you say auto=md or auto=part in mdadm.conf, it give a preference
for type of array, but standard name will override.

But --auto=md is more insistant.

FIXME  I'm not at all happy about handling of names that already exist.
  I don't think that should be removed if the device is active.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-16 07:35:06 +00:00
Neil Brown 5bbb48424b Allow default creation info to to be stored in mdadm.conf
Default owner, group, mode and 'auto' flag can be given in a 'CREATE' line.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-15 06:02:41 +00:00
Neil Brown 16c6fa807c Create missing /dev files where needed.
Whenever we need a device file to open, if one cannot be found in /dev,
create a temporary one.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-28 06:26:53 +00:00
Neil Brown 1e0d770c0f Release some compile fixes.
Signed-off-by: Neil Brown <neilb@suse.de>
2006-02-06 04:18:12 +00:00
Neil Brown 22a8899586 Sort mdstat entries so that composites are well-ordered.
This means that "-Ds" lists arrays in an approprate order
for assembly.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-01-31 00:39:50 +00:00
Neil Brown 8f23b0b3fa Replace sprintf calls with snprintf
To quiet diet-libc

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-14 06:42:13 +00:00
Neil Brown 173fc51539 Add device files created with --auto to list of known device files.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-14 06:37:57 +00:00
Neil Brown 0bbc98b563 Avoid using lstat, it isn't right.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-14 06:30:03 +00:00
Neil Brown a0ef61bfad Fix uninitialised variable compile warning.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-04-04 05:16:31 +00:00
Neil Brown 48f7b27ab4 Document new --auto behaviour
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-04-04 05:16:16 +00:00