summaryrefslogtreecommitdiff
path: root/super1.c
Commit message (Collapse)AuthorAge
...
* Remove scattered checks for malloc success.NeilBrown2012-07-09
| | | | | | | | | | | | | | malloc should never fail, and if it does it is unlikely that anything else useful can be done. Best approach is to abort and let some super-daemon restart. So define xmalloc, xcalloc, xrealloc, xstrdup which don't fail but just print a message and exit. Then use those removing all the tests for failure. Also replace all "malloc;memset" sequences with 'xcalloc'. Signed-off-by: NeilBrown <neilb@suse.de>
* Introduce pr_err for printing error messages.NeilBrown2012-07-09
| | | | | | | 'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": ' cont_err() is also available. Signed-off-by: NeilBrown <neilb@suse.de>
* mdadm: Fix Segmentation fault.majianpeng2012-05-29
| | | | | | | | | | | | | In function write_init_super1(): If "rv = store_super1(st, di->fd)" return error and the di is the last. Then the di = NULL && rv > 0, so exec: if (rv) fprintf(stderr, Name ": Failed to write metadata to%s\n", di->devname); will be segmentation fault. Signed-off-by: majianpeng <majianpeng@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* super1: fix choice of data_offset.NeilBrown2012-05-15
| | | | | | | | | | | | | | While it is nice to set a high data_offset to leave plenty of head room it is much more important to leave enough space to allow of the data of the array. So after we check that sb->size is still available, only reduce the 'reserved', don't increase it. This fixes a bug where --adding a spare fails because it does not have enough space in it. Reported-by: nowhere <nowhere@hakkenden.ath.cx> Signed-off-by: NeilBrown <neilb@suse.de>
* Fix sign extension of bitmap_offset in super1.cJes Sorensen2012-04-30
| | | | | | | | | | fbdef49811c9e2b54e2064d9af68cfffa77c6e77 incorrectly tried to fix sign extension of the bitmap offset. However mdinfo->bitmap_offset is a u32 and needs to be converted to a 32 bit signed integer before the sign extension. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* super1: leave more space in front of data by default.NeilBrown2012-04-04
| | | | | | | | | | | | | | | | | The kernel is growing the ability to avoid the need for a backup file during reshape by being able to change the data offset. For this to be useful we need plenty of free space before the data so the data offset can be reduced. So for v1.1 and v1.2 metadata make the default data_offset much larger. Aim for 128Meg, but keep a power of 2 and don't use more than 0.1% of each device. Don't change v1.0 as that is used when the data_offset is required to be zero. Signed-off-by: NeilBrown <neilb@suse.de>
* Bitmap_offset is a signed numberNeilBrown2012-04-04
| | | | | | | As the bitmap can be before the superblock, bitmap_offset is signed. But some of the code didn't honour that :-( Signed-off-by: NeilBrown <neilb@suse.de>
* Examine: fix array size calculation for RAID10.NeilBrown2012-03-22
| | | | | | | | RAID10 arrays with an odd number of devices had the arraysize reported wrongly by --examine due to a rounding error. Reported-by: Chris Francy <zoredache@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* super1.c: use ROUND_UP/ROUND_UP_PTRJes Sorensen2012-03-21
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Use struct align_fd to cache fd's block size for aligned reads/writesJes Sorensen2012-03-21
| | | | | | | | This uses a struct to cache the block size for aligned reads/writes, to avoid repeated ioctl(BLKSSZGET) calls. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Use 4K buffer alignment for superblock allocationsJes Sorensen2012-03-21
| | | | | | | | To better accommodate 4K sector drives, use 4K buffer alignment for superblock buffers. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* match_metadata_desc1(): Use calloc instead of malloc+memsetJes Sorensen2012-03-21
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* init_super1() memset full buffer allocated for superblockJes Sorensen2012-03-21
| | | | | | | | | Avoid possibly using stale data in bitmap and misc area of superblock. In addition, remove superfluous memsets already covered by memset of full superblock. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Define and use SUPER1_SIZE for allocationsJes Sorensen2012-03-21
| | | | | | | | Use a #define rather than calculate the size of the superblock buffer on every allocation. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* super1.c don't keep recalculating bitmap pointerJes Sorensen2012-03-21
| | | | | | | | We just calculated the pointer to the bitmap, so use it instead of recalculating. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* super1: support superblocks up to 4K.NeilBrown2012-03-08
| | | | | | | | | | | | The current 1024 byte limit on 1.x superblocks limits us to 384 devices. Sometimes people want more. The kernel is already prepared for superblocks up to 4K, so enable that in mdadm allowing up to (4096-256)/2 == 1920 devices (active plus spare). Signed-off-by: NeilBrown <neilb@suse.de>
* Print error message if failing to write super for 1.x metadataJes Sorensen2012-02-23
| | | | | | | | | | | | In addition remove attempt to print an error message if write_init_super() fails, as this is handled in the various write_init_super() functions. This avoids a segfault on error. Reported by Jim Meyering in https://bugzilla.redhat.com/show_bug.cgi?id=795461 Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Use posix_memalign() for memory used to write bitmapsJes Sorensen2012-02-16
| | | | | | | | | | | | This makes super[01].c properly align buffers used for the bitmap using posix_memalign() to make sure the writes don't fail in case the bitmap is opened using O_DIRECT. This is based on https://bugzilla.redhat.com/show_bug.cgi?id=789898 and an initial patch by Alexander Murashkin. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* super1: make aread/awrite always use an aligned buffer.NeilBrown2012-02-07
| | | | | | | | | | | A recently change to write_bitmap1 meant awrite would sometimes write from a non-aligned buffer which of course break. So change awrite (and aread) to always use their own aligned buffer to ensure safety. Reported-by: Alexander Lyakas <alex.bolshoy@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* getinfo_super1: Use MaxSector in place of sb->sizeAlexander Lyakas2012-02-07
| | | | | | | | | | | | | | when deciding whether the array is clean or dirty, compare sb->resync_offset against MaxSector and not against sb->size With RAID6 resyncing and subsequent drive failures, it is possible to reach the case, in which sb->resync_offset==sb->size. This happens when resync is aborted due to drive failures, and immediately a rebuild of a spare starts. In this case, mdadm was considered the array as clean, while kernel was considering the array as dirty. It is better for mdadm also to consider the array as dirty in this case. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow/bitmap: support adding bitmap via sysfs.NeilBrown2011-12-23
| | | | | | | | | | Adding a bitmap via ioctl can only add it at a fixed location. That location is not suitable for 4K-block devices. So allow setting the bitmap location via sysfs if kernel supports it and aim to always use 4K alignments. Signed-off-by: NeilBrown <neilb@suse.de>
* super1: use awrite when writing a new bitmap.NeilBrown2011-12-23
| | | | | | This ensures it will succeed on 4K block devices like DASD. Signed-off-by: NeilBrown <neilb@suse.de>
* super1 - fix for bigendian machines.NeilBrown2011-12-23
| | | | | | devflags is a single byte so endian conversions are now wanted. Signed-off-by: NeilBrown <neilb@suse.de>
* super1: getinfo_super should set write-mostly flag.NeilBrown2011-12-20
| | | | | | | Otherwise it is not preserved when you re-add a device to an array. Signed-off-by: NeilBrown <neilb@suse.de>
* Add recovery blocked field to mdinfoAdam Kwolek2011-10-05
| | | | | | | | | | | | | | | | | | | When container is assembled while reshape is active on one of its member whole container can be required to be blocked from monitoring. For such purpose field recovery blocked is added to mdinfo structure. When metadata handler finds active reshape in container it should set recovery_blocked field to disable whole container monitoring during reshape. For arrays that doesn't use containers, recovery_blocked field has the same value as reshape_active field e.g. super0/1. In fact,recovery is blocked during reshape for such arrays. For ddf, metadata handler doesn't set reshape_active field, so recovery_blocked is not set also. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Fix readding of a readwrite drive into a writemostly arrayDoug Ledford2011-09-19
| | | | | | | | | | | | | | | | | | | | | If you create a two drive raid1 array with one device writemostly, then fail the readwrite drive, when you add a new device, it will get the writemostly bit copied out of the remaining device's superblock into it's own. You can then remove the new drive and readd it as readwrite, which will work for the readd, but it leaves the stale WriteMostly1 bit in devflags resulting in the device going back to writemostly on the next assembly. The fix is to make sure that A) when we readd a device and we might have filled the st->sb info from a running device instead of the device being readded, then clear/set the WriteMostly1 bit in the super1 struct in addition to setting the disk state (ditto for super0, but slightly different mechanism) and B) when adding a clean device to an array (when we most certainly did copy the superblock info from an existing device), then clear any writemostly bits. Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* super1: fix spacing for 'Flags' field in --examine.NeilBrown2011-08-02
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* --add incorrectly sets writemostlyScott Schaefer2011-08-02
| | | | | | | Origin: vendor, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=628667 Bug-Debian: http://bugs.debian.org/628667 Signed-off-by: NeilBrown <neilb@suse.de>
* Fix some type-aliasing issues.Luca Berra2011-06-17
| | | | | | | Warnings for these are reported with -Wstrict-aliasing=2, and avoiding the cast is certainly an improvement. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix some compiler warnings.Luca Berra2011-06-17
| | | | | | Original by Luca, with various changes by Neil Signed-off-by: NeilBrown <neilb@suse.de>
* getinfo_super now clears the 'info' structure before filling it in.NeilBrown2011-06-08
| | | | | | | | | | | | | | Some code currently clears 'info' before calling getinfo_super, some code doesn't. To be consistent, change it so no caller ever clears 'info', but ever getinfo_super function must clear it. Note that ->raid_disk may be meaningful if that 'map' is passed non-NULL. In that case it is copied out before the structure is zeroed. Signed-off-by: NeilBrown <neilb@suse.de>
* config: restore the possibility of a NULL homehostNeilBrown2011-05-10
| | | | | | | | | | | | | As homehost defaults to the system name it is not possible to specify a NULL homehost. This patch restored this ability with either --homehost="" or --homehost="<none>". This allows the creation of v1.x arrays without a "hostname:" prefix in the name. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' into devel-3.2NeilBrown2011-03-10
|\ | | | | | | | | | | | | | | | | Conflicts: Grow.c Manage.c managemon.c mdadm.8.in util.c
| * Assemble: add --update=no-bitmapNeilBrown2011-03-10
| | | | | | | | | | | | | | This allows an array with a corrupt internal bitmap to be assembled without the bitmap. Signed-off-by: NeilBrown <neilb@suse.de>
| * Teach --assemble --force to handle reshapes a little better.NeilBrown2011-02-21
| | | | | | | | | | | | | | | | | | | | | | When we force-assemble an array which is in the middle of a reshape, we should repeat the reshape of any parts that aren't recorded in the oldest superblock. This is unlikely to make a significant difference, but could make a small difference, and is safer. Signed-off-by: NeilBrown <neilb@suse.de>
* | Fix chunksize defaulting.NeilBrown2011-03-09
| | | | | | | | | | | | | | | | | | the new code for defaulting chunksizes didn't work quite right - default was set to late in super1/super0/ddf - defaults would over-ride values of '0' imposed by some levels - default value wasn't applied to size properly. Signed-off-by: NeilBrown <neilb@suse.de>
* | set default chunk in validate_geometryCzarnowska, Anna2011-02-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When chunk size is not set from command line we need to guess it depending on metadata given on command line or found on listed devices. Validate_geometry sets the default for it's metadata if chunk is not set. For external metadata chunk is set only when creating in a container. For imsm validate_geometry_imsm_orom is responsible for finding default chunk depending on container metadata loaded. Container will already know which controller it is attached to, and have this controllers orom available. do_default_chunk indicates that we need to find default chunk and if validate_geometry fails for some metadata it tells us to reset chunk that may have been set. Current solution would set default chunk correctly for imsm only if container device was given on command line. With the list of devices chunk was always set to 512. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* | super1: fix regression in write_init_super.NeilBrown2011-01-31
| | | | | | | | | | | | | | | | | | | | | | Now that a 'supertype' container more information, the simplistic copying of 'st' into 'refst' is incorrect and results in closing some fds when load_super1(refst) calls free_super(). So do it more correctly using dup_super. Reported-by: "Labun, Marcin" <Marcin.Labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* | Don't close fds in write_init_superNeilBrown2011-01-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We previously closed all 'fds' associated with an array in write_init_super .. sometimes, and sometimes at bad times. This isn't neat and free_super is a better place to close them. So make sure free_super always closes the fds that the metadata manager kept hold of, and stop closing them in write_init_super. Also add a few more calls to free_super to make sure they really do get closed. Reported-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* | Merge branch 'master' into devel-3.2NeilBrown2010-12-09
|\| | | | | | | | | | | | | | | Conflicts: mdadm.8.in Same conceptual change was written with different words in each version. Signed-off-by: NeilBrown <neilb@suse.de>
| * Fix byte-order conversion in update_super1("assemble")NeilBrown2010-09-16
| | | | | | | | | | | | | | | | | | This code is wrong is several ways, and failed on big-endian machines. Put in correct endian coversions: 'want' is cpu-order, dev_roles[] is little-endian, 16 bit. Reported-by: Doug Nazar <nazard.michi@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* | Assemble: add --update=no-bitmapNeilBrown2010-11-30
| | | | | | | | | | | | | | This allows an array with a corrupt internal bitmap to be assembled without the bitmap. Signed-off-by: NeilBrown <neilb@suse.de>
* | Create: user container_dev rather than subarray for some tests.NeilBrown2010-11-22
| | | | | | | | | | | | | | | | | | It makes more sense to test for container_dev than for subarray for several places in Create where it then uses container_dev. This allows us to subsequently remove subarray. Signed-off-by: NeilBrown <neilb@suse.de>
* | Remove subarray detection from load_super.NeilBrown2010-11-22
| | | | | | | | | | | | Nothing relies on this any more, so remove it. Signed-off-by: NeilBrown <neilb@suse.de>
* | Add subarray arg to container_content.NeilBrown2010-11-22
| | | | | | | | | | | | | | | | | | | | This allows the info for a single array to be extracted, so we don't have to write it into st->subarray. For consistency, implement container_content for super0 and super1, to just return the mdinfo for the single array. Signed-off-by: NeilBrown <neilb@suse.de>
* | get_info_super: report which other devices are thought to be working/failed.NeilBrown2010-11-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | To accurately detect when an array has been split and is now being recombined, we need to track which other devices each thinks is working. We should never include a device in an array if it thinks that the primary device has failed. This patch just allows get_info_super to return a list of devices and whether they are thought to be working or not. Signed-off-by: NeilBrown <neilb@suse.de>
* | Report error in --update string is not recognised.NeilBrown2010-11-22
|/ | | | | | | | If an --update is requested by the relevant metadata doesn't understand it, print a useful message rather than silently ignoring the issue. Signed-off-by: NeilBrown <neilb@suse.de>
* Compile with -Wextra by defaultNeilBrown2010-08-05
| | | | | | This produced lots of warning, some of which pointed to actual bugs. Signed-off-by: NeilBrown <neilb@suse.de>
* Don't report Used Dev Size for RAID0.NeilBrown2010-07-22
| | | | | | | | | | | | This number isn't meaningful for RAID0 as a different amount of space might be used from each device. It isn't meaningful for linear either, but already was not reported for linear. Detail doesn't report it either. So make --examine not report it. Signed-off-by: NeilBrown <neilb@suse.de> Reported-by: Mario 'BitKoenig' Holbe <Mario.Holbe@TU-Ilmenau.DE>
* Compile-time switch to enable 0.9 metadata as defaultmartin f. krafft2010-05-31
| | | | | | | | | | | | | | | | | | | | | | This commit introduces DEFAULT_OLD_METADATA as a preprocessor definition. If defined, it causes mdadm to assume metadata version 0.9 as default. If not defined, version 1.x (currently 1.2) is used as default. The man page mdadm.8 is also modified to reflect the chosen default. The selftests will not work if the old default is chosen. This patch was requested by Debian so they could distribute a current mdadm together with boot loaders that only understand 0.90 metadata for md-raid. Preferred usage is simply make DEFAULT_OLD_METADATA=yes Signed-off-by: martin f. krafft <madduck@debian.org> Signed-off-by: NeilBrown <neilb@suse.de>