Commit Graph

188 Commits

Author SHA1 Message Date
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 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 ec9688ca70 Make super super0.c function static.
So only 'super0' is externally visible.
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 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
Neil Brown b8ac196795 Remove 'major' from superswitch.
It isn't generally meaningful.
2008-07-12 20:27:37 +10:00
Neil Brown 1522c538b1 Use text_version in map_file rather than major.minor. 2008-07-12 20:27:37 +10:00
Neil Brown a0c8a17f66 Fix write_init_super usage when hot-adding a spare
Using write_init_super to add a spare to an active array is quite
different to how it is used when creating an array.

It mostly works, but if we are adding two devices to an array,
then when we add the second, there are still traces of the first
which confuse write_init_super.

So get write_init_super to ignore those traces.  Longer term, we
probably want to do this differently as for DDF, hot-adding to
an active array will have to be quite different - it will want to
write to all metadata, possibly via mdmon.
2008-07-12 20:27:36 +10:00
Neil Brown ef60947720 Always initialise a struct super_type to zero 2008-07-12 20:27:36 +10:00
Neil Brown 370ac380fd Merge branch 'master' into devel-3.0
Conflicts:

	Makefile
2008-06-19 16:38:37 +10:00
Neil Brown 56f8add211 Fix an error when assembling arrays that are in the middle of a reshape.
It is important that dup_super always returns an 'st' with the same
->ss and ->minor_version as the st that was passed.
This wasn't happening for 0.91 metadata (i.e. in the middle of a reshape).
2008-06-19 16:30:36 +10:00
Neil Brown 111d01fcc7 Change write_init_super to be called only once.
The current model for creating arrays involves writing
a superblock to each device in the array.
With containers (as with DDF), that model doesn't work.
Every device in the container may need to be updated
for an array made from just some the devices in a container.

So instead of calling write_init_super for each device,
we call it once for the array and have it iterate over
all the devices in the array.

To help with this, ->add_to_super now passes in an 'fd' and name for
the device.  These get saved for use by write_init_super.  So
add_to_super takes ownership of the fd, and write_init_super will
close it.
This information is stored in the new 'info' field of supertype.

As part of this, write_init_super now removes any old traces of raid
metadata rather than doing this in common code.
2008-05-15 16:48:12 +10:00
Neil Brown 17f25ca6fb Add 'container' level and ->validate_geometry method.
These will be used for ddf.
2008-05-15 16:47:41 +10:00
Neil Brown ff1f6545db Fix support for --update=swapsuper
The user of dup_super broke it.
2008-05-15 15:50:48 +10:00
Neil Brown 294d6f450f Recent change broken handling of metadata-less arrays.
In particular, failing a device would give a silly
error message.
2008-05-15 15:50:47 +10:00
Kay Sievers 0d726f17e1 add --export option to --examine
From: Kay Sievers <kay.sievers@vrfy.org>

Cc: David Zeuthen <david@fubar.dk>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
2008-05-06 10:02:38 +10:00
Neil Brown 5f98d3cbd9 Small improvements to --incremental for arrays that are in the middle of reshape
There is still a problem:  If array is partially assembled and started
read-only, the last device doesn't get added properly.  Probably a kernel
problem.
2008-04-28 16:30:31 +10:00
Neil Brown 1486e43fec Print 'Events' more sensibly.
Instead of MSW.LSW, just print it as a 64bit number.
2008-04-28 16:29:45 +10:00
Neil Brown 3da92f272d Drop the superblock arg from all metadata methods.
It is now in the 'supertype'
2007-12-14 20:14:33 +11:00
Neil Brown 64557c3391 Fix compare_super to take supertype instead of a superblock.
As this function takes 2 superblocks, the change is a bit more subtle,
so is done separately.
2007-12-14 20:14:27 +11:00
Neil Brown 68c7d6d790 Add 'supertype' arg to almost all metadata methods.
The 'superblock' will be moved into this structure soon.
2007-12-14 20:14:16 +11:00
Neil Brown df37ffc039 Allow metadata handlers to free their own superblock.
As the metadata handler allocates the superblock, it should free it
too.  DDF will have a more complex 'superblock' which needs more complex
freeing.
2007-12-14 20:14:00 +11:00
Neil Brown aba69144fd Remove spaces/tabs from ends of lines. 2007-12-14 20:13:43 +11:00
Neil Brown eb6dae9850 Fix error message when adding a device that is too small.
We were multiplying MD_RESERVED_SECTORS by 1024 instead of 512,
so lots of 'is it too small' checks were wrong.
2007-08-20 14:14:28 +10:00
Neil Brown f752781f81 Fix --grow --add for linear arrays.
The new superblock needs to have a new disk.number.  This is a bit of a hack...
Fix handling of negative bitmap offsets on 64bit hosts.

The bitmap offset is a signed 32bit number, so casting to (long)
isn't sufficient.  We must cast to (int32_t).
Fix various problems with --grow --add for linear.

The code to add a drive to a live linear array had never
been tested properly and so was buggy.  This tidies it up
and means that the new regression-test passes.
2007-05-21 14:25:37 +10:00
Kay Sievers 54bad3644f Add --export option to --detail to use key=value pairs.
udev likes to get information about a device as key=value pairs so it
can create disk/by-id links etc.  So add --export flag which causes
the output of --detail to easily parsable.

From: Kay Sievers <kay.sievers@novell.com>
2007-05-08 17:17:33 +10:00
Neil Brown f8409e5478 Release 2.6 2006-12-21 17:24:38 +11: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 3d3dd91e38 Support --uuid= with --create to choose your own UUID. 2006-12-14 17:33:10 +11:00
Neil Brown beae1dfe2e Central calls to ioctl BLKGETSIZE
Instead of opencoding the same thing everywhere.
2006-12-14 17:32:57 +11:00
Neil Brown e336254463 Change 'Device Size' to 'Used Dev Size'
because it only shows how much of each device is actually used, not
how big they are.
2006-12-14 17:31:19 +11:00
Neil Brown 583315d9c5 Give useful message if raid4/5/6 cannot be started because it is not clean and is also degraded. 2006-12-14 17:31:13 +11:00
Neil Brown 199171a297 Improve allocation and use of space for bitmaps in version1 metadata
Depending on the size of the array we reserve space for up to 128K
of bitmap, and we use it where possible.
When hot-adding to a version 1.0 we can still only use the 3K at the
end though - need a sysfs interface to improve that.

If a small chunksize is requested on Create, we don't auto-enlarge
the reserved space - this still needs to be fixed.
2006-12-14 17:31:00 +11:00
Neil Brown b5e3d1901f Remove some unused interfaces to the metadata handlers.
This stuff has never been used (at least as far as git history can
see).  I wonder why it was there...
2006-12-14 17:30:53 +11:00
Neil Brown 67a8c82d60 Make Assemble/Force work on raid6 with 2 missing devices.
Previously it onl worked when one missing device.
Also split the "force" update_super method into two and it
is really serving two functions.
2006-12-14 17:30:51 +11:00
Neil Brown 2c102711fd Make --examine report chunk size when it should
Currently it doesn't for raid6 and raid10
2006-10-09 11:16:56 +10:00
Neil Brown c56d3db4d3 Remove indeterminism from names in --examine --brief output.
It is much better for this sort of thing to be predictable
rather than depending on what devices exist, especially as
these days entries in /dev/ often don't pre-exist.
So make it always
   /dev/mdX

for version0 superblocks.

Version1 are always /dev/md/NAME
2006-08-11 17:59:53 +10:00
Neil Brown 08110d41bc Fix a recently introduced bug, and make --assemble more resilient to it.
Make -assemble a bit more resilient to finding strange
 information in superblocks.
Don't claim newly added spares are InSync!! (don't know why that
 code was ever in there)
2006-06-26 12:26:12 +10:00
Neil Brown 8268ed7403 Remove libssl dependancy and always use sha1.c code
Apparently there are license issues with openssl, so
just use sha1.c always.   This means we can get rid of
SHA1.c

Signed-off-by: Neil Brown <neilb@suse.de>
2006-06-02 06:12:19 +00:00
Neil Brown 9fca7d6236 check return status of all write/fwrite functions as required by glibc 2.4
From: Luca Berra <bluca@vodka.it>

glibc 2.4 is pedantic on ignoring return values from fprintf, fwrite and
write, so now we check the rval and actually do something with it.
in the Grow.c case i only print a warning, since i don't think we can do
anything in case we fail invalidating those superblocks (is should never
happen, but then...)

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-29 02:06:32 +00:00
Neil Brown d1f1011b94 Make sure everything compiles...
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-26 04:28:33 +00:00
Neil Brown 2998bc013c Improve names reported by --examine --brief
Instead of depending (too much) on what is in /dev,
we make names based on the content of the superblock.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-26 02:29:12 +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 8a46fe8487 Allow autoassembly to choose it's own name for the array.
This cannot be used yet, but it is working towards auto-assembly.

When auto-assembling an array, we make a name in /dev/md/
giving a number (from the peferred minor) or name (from set-name).

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-23 06:46:40 +00:00
Neil Brown 83b6208e89 When assembly arrays using incomplete detail, prefer arrays built for this host.
i.e. if assembling with --name or --super-minor, then if we find two
different arrays with the same apparent identity, and one was built
for 'this' host, then prefer that one instead of giving up in disgust.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-23 06:33:28 +00:00
Neil Brown 0237e0cafd Support --update=homehost to allow updating of homehost information.
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-23 05:16:32 +00:00
Neil Brown e5eac01f3d Make sure homehost is set correctly when --update=uuid
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-23 04:51:39 +00:00
Neil Brown a1cbd7d053 Include homehost information in --examine as appropriate
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-19 07:19:04 +00:00
Neil Brown b6750aa8da Include homehost information in --detail where appropriate.
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-19 07:13:03 +00:00
Neil Brown 05697ec1e2 Make homehost information appear in superblock.
When an array is created, if the homehost is know,
the superblock gets it, either in the uuid, (via sha1)
or in the name field.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-19 06:56:06 +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 14263cf12c When updating uuid, update the bitmap as well - internal bitmaps.
Otherwise when you "--update==uuid" an array with an internal
bitmap, it will break, badly.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-16 05:52:51 +00:00
Neil Brown 8686f3ed06 Fix problem with sector/KB size confuision for bitmap sizing.
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-15 03:57:53 +00:00
Neil Brown b578481ca3 Support new offset layout for raid10
Requires 2.6.18.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-15 02:46:54 +00:00
Neil Brown c4d831e164 [PATCH] Make sure update_super returns correct value.
For 'force' and 'assemble', update_super must return true
if anything was changed.

Also fix a bug with wonly handling in super0.

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./super0.c |   18 ++++++++++++++----
 ./super1.c |    7 +++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff ./super0.c~current~ ./super0.c
2006-04-28 14:10:38 +10: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 313176636e Remove ident arg from getinfo_super;
Add a 'name' field to 'info' to compensate.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-27 04:34:38 +00:00
Neil Brown 353632d927 Support restarting of a reshape on --assemble
Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-20 03:17:31 +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 b674b5b869 Have --examine report reshape details.
Signed-off-by: Neil Brown <neilb@suse.de>
2006-01-27 07:28:34 +00:00
Neil Brown 5dd497eecb Enable support for v.large raid1.
clean up 'long long' usage for size of array, so that
with v-1 superblocks a raid1 larger than 2TB is possible.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-01-27 06:21:06 +00:00
Neil Brown 29e766a5f4 Minor fixes
Signed-off-by: Neil Brown <neilb@suse.de>
2006-01-27 04:48:28 +00:00
Neil Brown 7d99579f6a Support updating of uuid during --assemble.
Signed-off-by: Neil Brown <neilb@suse.de>
2005-12-05 05:56:33 +00:00
Neil Brown f9c25f1d2a Support bitmaps with raid10
And a couple of other little things

Signed-off-by: Neil Brown <neilb@suse.de>
2005-11-22 03:37:14 +00:00
Neil Brown dcec9ee547 Create version-4 bitmaps if kernel supports it.
Version-3 bitmaps are host-endian.  Version-4 are little-endian
and so more portable.

Signed-off-by: Neil Brown <neilb@suse.de>
2005-10-11 04:44:44 +00:00
Neil Brown f6d75de8e0 Fix remaining problems with hot-add bitmap to version-1 superblock
Also some more tests - r5 and r6 bitmaps

Signed-off-by: Neil Brown <neilb@suse.de>
2005-09-12 05:24:10 +00:00
Neil Brown 265e0f1731 Fix assembling of raid10 in the face of missing devices.
We now check if enough devices are present properly, so
--force can be used to good effect.

Signed-off-by: Neil Brown <neilb@suse.de>
2005-09-12 04:57:52 +00:00
Neil Brown 1bf4e2d962 Passes all tests, nearly ready for release.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-26 06:08:28 +00:00
Neil Brown 34163fc7cf Support internal bitmaps with format-1 superblocks.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-25 04:31:44 +00:00
Neil Brown dab6685f3d Add 'quite' option and tidy up some tests.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-15 06:14:27 +00:00
Neil Brown 947fd4ddb5 Support nameing of version-1 arrays.
--name is recognised in --create and --assemble
name= is recognised in config file.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-09 05:23:20 +00:00
Neil Brown dfd4d8ee42 Add write-behind support
Currently this includes
  --write-behind  to set level of write-behind supported
  --write-mostly  to flag devices as write-mostly.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-09 04:25:47 +00:00
Neil Brown 586ed40547 Support fixing of byte-swapped superblocks.
Good for moving between little-endian and big-endian.
Still needs documentation.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-09 04:25:27 +00:00
Neil Brown f277ce3671 Assorted Fixes for multiple bugs.
Assemble would crash, or just not work.
A few other problem found by a new test-suite.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-04 04:41:12 +00:00
Neil Brown fbf8a0b7a6 Document this...
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-07-18 01:30:42 +00:00
Neil Brown c7654afc29 Fix compiling of mdassemble
(again).

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-14 06:49:05 +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 96395475fc Make --zero-superblock work for version 1 superblocks.
This requires passing the supertype to store_super

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-07 23:03:45 +00:00
Neil Brown ea32955930 Increase max-devs on type-1 superblocks
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-07 23:03:46 +00:00
Neil Brown 8d75b7fce2 Assorted fixes for bitmap related stuff
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-07 23:03:46 +00:00
Neil Brown 55935d5180 Add support for internal bitmaps
For version 0.90 superblocks, an internal bitmap can be specified at create.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-07 23:03:47 +00:00
Neil Brown dfe47e008e Make sure to seed the random number generator for uuids
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-07 23:03:48 +00:00
Neil Brown 234a131a33 Wasn't initialising spare disks on create.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-07 23:16:36 +00:00
Neil Brown 570c054247 Release 1.8.1 after some man page updates and other fixes.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-07 23:16:36 +00:00
Neil Brown 82d9eba687 super1
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Fix raid5 creation with new code.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-05-03 23:44:40 +00:00
Neil Brown f9ce90ba50 Add a 'super-switch' so that different format superblocks can be used.
This includes:
  adding --metadata= option to choose metadata format
  adding metadata= word to config file.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-05-03 23:44:32 +00:00
Neil Brown 4b1ac34b51 Separate sueprblock handling into separate file
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-05-03 23:44:18 +00:00