summaryrefslogtreecommitdiff
path: root/sysfs.c
Commit message (Collapse)AuthorAge
* Introduce devid2kname - slightly different to devid2devnm.NeilBrown2013-08-01
| | | | | | | | | | | | | The purpose od devid2devnm is to return a kernel name of an md device, whether that device is a whole device or a partition, we want the whole device. md4, never md4p2. In one place I was using devid2devnm where I really wanted the partition if there was one ... and wasn't really interested in it being an md device. So introduce a new 'devid2kname' for that case. Signed-off-by: NeilBrown <neilb@suse.de>
* sysfs: fix bugs in new sysfs_wait function.NeilBrown2013-07-02
| | | | | | | - 'tv' isn't initialised properly. - 100? I'm sure I fixed that already! Seems not. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: check alignment when stopping an array undergoing reshape.NeilBrown2013-07-01
| | | | | | | | | | | | | To be able to revert-reshape of raid4/5/6 which is changing the number of devices, the reshape must has been stopped on a multiple of the old and new stripe sizes. The kernel only enforces the new stripe size multiple. So we enforce the old-stripe-size multiple by careful use of "sync_max" and monitoring "reshape_position". Signed-off-by: NeilBrown <neilb@suse.de>
* New function: sysfs_waitNeilBrown2013-07-01
| | | | | | | We have several places that wait for activity on a sysfs file. Combine most of these into a single 'sysfs_wait' function. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: fix bug in raid0 -> raid5 conversion.NeilBrown2013-06-25
| | | | | | | | | | The moment we change a RAID0 to a RAID5 it will try to recovery. This will abort quite quickly as there are not spare devices, but it could confuse the attempt to freeze the array. So allow 'freeze' to work even on a recovering array. Signed-off-by: NeilBrown <neilb@suse.de>
* Remove lots of unnecessary white space.NeilBrown2013-06-19
| | | | | | | Now that I am using white-space mode in Emacs I can see all of this, and I don't like it :-) Signed-off-by: NeilBrown <neilb@suse.de>
* sysfs_read: return devices in same order as in filesystem.NeilBrown2013-06-19
| | | | | | | | When we read devices from sysfs (../md/dev-*), store them in the same order that they appear. That makes more sense when exposed to a human (as the next patch will). Signed-off-by: NeilBrown <neilb@suse.de>
* Detail: report on inactive arrays.NeilBrown2013-05-13
| | | | | | | | Array can be inactive when e.g. -I is in the process of assembling them. This change allows --detail to report limited information about these arrays. Signed-off-by: NeilBrown <neilb@suse.de>
* Discard devnum in favour of devnmNeilBrown2013-02-21
| | | | | | | | | | | | | | We widely use a "devnum" which is 0 or +ve for md%d devices and -ve for md_d%d devices. But I want to be able to use md_%s device names. So get rid of devnum (a number) and use devnm (a 32char string). eg. md0 md_d2 md_home Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: fix reshape from RAID5 to RAID1.NeilBrown2012-11-20
| | | | | | | | | | | Commit 5da9ab9874cb5896023afae1462550d83a869831 Grow_reshape re-factor in mdadm-3.2 broke conversion from RAID5 and RAID1 - and we never noticed. This fixes it. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: set new_data_offset if appropriateNeilBrown2012-10-04
|
* Manage: fix checks for removal from a container.NeilBrown2012-09-24
| | | | | | | | | | | | | | | | | | We must only remove from a container if the device isn't a member of any member array. To check we look at the 'holders' directory in sysfs. We currently skip that check if ->devname is "detached", however that can never be true since the change that introduced add_detached(). Also sysfs_unique_holder returns status in 'errno' which isn't entirely safe as e.g. closedir() is probably allowed to clear it. So make sysfs_unique_holder return an unambigious value, and us it to decide what to report. Signed-off-by: NeilBrown <neilb@suse.de>
* 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>
* Introduce sysfs_set_num_signed() and use it to set bitmap/offsetJes Sorensen2012-04-30
| | | | | | | | | | mdinfo->bitmap_offset is a signed long and needs to be treated as such when passed to the kernel. This resolves the problem with adding internal bitmaps to a 1.0 array. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> 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>
* sysfs: fixed sysfs_freeze_array array to work properly with Manage_subdevs.NeilBrown2012-03-28
| | | | | | | | | | | | | If the array is already frozen when Manage_subdevs is called we don't want it to unfreeze the array. This is because Grow calls Manage_subdevs to add devices to an array being reshaped, and the array must stay frozen over this call. So if sysfs_freeze_array find the array to be frozen it returns '0', meaning that it didn't and cannot freeze it. Then the caller will not try to unfreeze, which is good. 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>
* get_component_size(): Check read() return value for error before using itJes Sorensen2011-11-03
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* sysfs_unique_holder(): Check read() return value before using as buffer indexJes Sorensen2011-11-02
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Fix off-by-one in readlink() buffer size handlingThomas Jarosch2011-10-17
| | | | | | | | | | | | | | readlink() returns the number of bytes in the buffer. If we do something like len = readlink(path, buf, sizeof(buf)); buf[len] = '\0'; we might write one byte past the end of the buffer. Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com> Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: Do not unblock array accidentallyAdam Kwolek2011-09-21
| | | | | | | | | | | When sysfs_set_array() function is called, it tests if array can be configured using sysfs. Setting metadata_version entry can accidentally unblock mdmon when array is under reshape. To avoid this, blocking character '-' is checked and if is is set, it is used for array test. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* sysfs: fix sysfs_disk_to_scsi_idDan Williams2011-08-30
| | | | | | | | | | Not sure how this ever worked, but now we just try to parse a directory name that looks like <host>:<bus>:<target>:<lun>. Array creation segfaults on Fedora 14 without this. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: ensure clean abort if we cannot read the 'completed' file.NeilBrown2011-07-27
| | | | | | | If a read of 'completed' returns an error, select will never fail, so this loop would never exit. 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>
* FIX: Set proper raid disks during migrationAdam Kwolek2011-04-18
| | | | | | | | | During migration raid_disks field contains new disks number now. It should be set old disks number first and then new disks number to allow md to calculate e.g. delta_disks parameter. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Move WaitClean from sysfs to Monitor.cNeilBrown2011-04-05
| | | | | | | It might not really belong in Monitor, but it really doesn't belong in sysfs.c, and fits well with Wait() Signed-off-by: NeilBrown <neilb@suse.de>
* Change way that reshaping arrays with external-metadata are assembled.NeilBrown2011-03-08
| | | | | | | | | | | | | | Now that the external metadata handler must provide an md-compatible old/new geometry, sys_set_array can do all of the array set-up for an array that is undergoing reshape. That leave less for reshape_array to do. Also clean up how reshape_array tells if the reshape has started or not. Don't use ->reshape_active as that doesn't tell us anything consistent at this stage, only use the 'restart' flag passed in. Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: sysfs_disk_to_scsi_id() adapted to current sysfs formatKrzysztof Wojcik2011-02-18
| | | | | | | | | | Problem: sysfs_disk_to_scsi_id() not returns correct scsi_id value. Reason: sysfs format has been changed This patch adapt sysfs_disk_to_scsi_id() to new sysfs format. Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Fix some issues with setting 'new' state of a reshapeNeilBrown2011-01-26
| | | | | | | | | | | - when reshaping a container, ->reshape_active is already set even though it isn't really active yet, so we need to set the new geometry even when reshape_active is set. This is safe. - When restarting a reshape, make sure the reshape_position is set appropriately when external metadata is used. Signed-off-by: NeilBrown <neilb@suse.de>
* Split fmt_devnum out from devnum2devnameNeilBrown2010-12-16
| | | | | | | Sometimes we want to convert a devnum to a devname without allocating memory. So provide function to do the formatting without allocation. Signed-off-by: NeilBrown <neilb@suse.de>
* Add support to skip slot configurationAdam Kwolek2010-12-03
| | | | | | | When disk is added, set valid slot numbers (positive) only. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* block monitor: freeze spare assignment for external arraysDan Williams2010-11-23
| | | | | | | | | | | | | | | | | | | | | | | In order to support reshape and atomic removal of spares from containers we need to prevent mdmon from activating spares. In the reshape case we additionally need to freeze sync_action while the reshape transaction is initiated with the kernel and recorded in the metadata. When reshaping a raid0 array we need to freeze the array *before* it is transitioned to a redundant raid level. Since sync_action does not exist at this point we extend the '-' prefix of a subarray string to flag mdmon not to activate spares. Mdadm needs to be reasonably certain that the version of mdmon in the system honors this 'freeze' indication. If mdmon is not already active then we assume the version that gets started is the same as the mdadm version. Otherwise, we check the version of mdmon as returned by the extended ping_monitor() operation. This is to catch cases where mdadm is upgraded in the filesystem, but mdmon started in the initramfs is from a previous release. Signed-off-by: Dan Williams <dan.j.williams@intel.com> 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>
* Merge branch 'fixes' into for-neilDan Williams2010-07-01
|\
| * Always assume SKIP_GONE_DEVS behaviour and kill the flagDan Williams2010-06-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...i.e. GET_DEVS == (GET_DEVS|SKIP_GONE_DEVS) A null pointer dereference in Incremental.c can be triggered by replugging a disk while the old name is in use. When mdadm -I is called on the new disk we fail the call to sysfs_read(). I audited all the locations that use GET_DEVS and it appears they can tolerate missing a drive. So just make SKIP_GONE_DEVS the default behaviour. Also fix up remaining unchecked usages of the sysfs_read() return value. Reported-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Remove 'checkpointing' side effect of --wait-cleanDan Williams2010-06-15
|/ | | | | | | | Now that mdmon records periodic checkpoints, and checkpoints every ->set_array_state() event we no longer need to 'idle' sync_action from --wait-clean. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Merge branch 'klockwork' of git://github.com/djbw/mdadmNeilBrown2009-12-30
|\ | | | | | | | | Conflicts: super-intel.c
| * Fix required to enable RAID arrays on SAS disks.Artur Wojcik2009-12-10
| | | | | | | | | | | | | | | | | | | | | | | | The patch increases the capacity of buffers used to store sysfs path names. Originally the buffers were too small to hold the canonical representation of sysfs path (in case of a SAS device, especially a device installed behind an expander). Signed-off-by: Artur Wojcik <artur.wojcik@intel.com> Reviewed-by: Andre Noll <maan@systemlinux.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Support external metadata recovery-resumeDan Williams2009-12-21
| | | | | | | | | | | | | | | | | | Minimal changes needed to permit reassembling partially recovered external metadata arrays. The biggest logical change is that ->container_content() can now surface partially rebuilt members rather than omitting them from the disk list. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Teach sysfs_add_disk() callers to use ->recovery_start versus 'insync' parameterDan Williams2009-12-21
|/ | | | | | Also fixup 'in_sync' versus 'insync' typo. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Merge branch 'master' into devel-3.1NeilBrown2009-10-22
|\
| * mdmon: preserve socket over chrootDan Williams2009-10-13
| | | | | | | | | | | | | | | | | | | | Connect to the monitor in the old namespace and use that connection for WaitClean requests when stopping the victim mdmon instance. This allows ping_monitor() to work post chroot(). Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Merge branch 'master' into devel-3.1NeilBrown2009-10-01
|\| | | | | | | | | Conflicts: mdadm.8
| * Move WaitClean from Monitor.c to sysfs.cNeilBrown2009-06-02
| | | | | | | | | | | | That way mdmon doesn't need to include Monitor.o Signed-off-by: NeilBrown <neilb@suse.de>
| * Update copyright dates and remove references to @cse.unsw.edu.auNeilBrown2009-06-02
| | | | | | | | | | | | Also removed 'paper' addresses. Signed-off-by: NeilBrown <neilb@suse.de>
* | Handle extra 'grow' variations.NeilBrown2009-08-11
| | | | | | | | UNFINISHED
* | restripe: support saving when not all devices are present.NeilBrown2009-07-14
|/
* Merge branch 'master' of git://github.com/djbw/mdadm into devel-3.0NeilBrown2009-04-14
|\ | | | | | | | | | | | | | | | | Conflicts: Grow.c mdadm.h sysfs.c Due to independent fixes for the "mdadm hangs if reshape finishes too quickly" problem.
| * Grow: fix hang when reshape completes too fastDan Williams2009-04-12
| | | | | | | | | | | | | | | | | | | | | | For short reshapes the kernel may be done before mdadm can check that progress has passed the critical section. Signed-off-by: Dan Williams <dan.j.williams@intel.com>