summaryrefslogtreecommitdiff
path: root/sysfs.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix off-by-one in readlink() buffer size handlingThomas Jarosch2011-10-171-1/+1
| | | | | | | | | | | | | | 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-211-0/+13
| | | | | | | | | | | 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-301-20/+10
| | | | | | | | | | 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-271-1/+1
| | | | | | | 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-171-0/+5
| | | | | | Original by Luca, with various changes by Neil Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: Set proper raid disks during migrationAdam Kwolek2011-04-181-2/+5
| | | | | | | | | 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-051-103/+0
| | | | | | | 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-081-2/+5
| | | | | | | | | | | | | | 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-181-8/+6
| | | | | | | | | | 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-261-0/+9
| | | | | | | | | | | - 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-161-5/+1
| | | | | | | 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-031-1/+2
| | | | | | | 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-231-0/+33
| | | | | | | | | | | | | | | | | | | | | | | 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-051-3/+3
| | | | | | 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-011-11/+9
|\
| * Always assume SKIP_GONE_DEVS behaviour and kill the flagDan Williams2010-06-161-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...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-151-3/+0
|/ | | | | | | | 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-301-9/+4
|\ | | | | | | | | Conflicts: super-intel.c
| * Fix required to enable RAID arrays on SAS disks.Artur Wojcik2009-12-101-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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-211-1/+10
| | | | | | | | | | | | | | | | | | 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-211-3/+3
|/ | | | | | 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-221-2/+3
|\
| * mdmon: preserve socket over chrootDan Williams2009-10-131-2/+3
| | | | | | | | | | | | | | | | | | | | 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-011-1/+106
|\ \ | |/ | | | | | | Conflicts: mdadm.8
| * Move WaitClean from Monitor.c to sysfs.cNeilBrown2009-06-021-0/+105
| | | | | | | | | | | | 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-021-1/+1
| | | | | | | | | | | | Also removed 'paper' addresses. Signed-off-by: NeilBrown <neilb@suse.de>
* | Handle extra 'grow' variations.NeilBrown2009-08-111-8/+15
| | | | | | | | UNFINISHED
* | restripe: support saving when not all devices are present.NeilBrown2009-07-141-8/+29
|/
* Merge branch 'master' of git://github.com/djbw/mdadm into devel-3.0NeilBrown2009-04-141-0/+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-121-0/+20
| | | | | | | | | | | | | | | | | | | | | | 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>
| * imsm: set array size at Create/AssembleDan Williams2009-04-121-0/+14
| | | | | | | | | | | | | | | | | | | | imsm arrays round down the effective array size to the closest 1 megabyte boundary so teach get_info_super_imsm and sysfs_set_array to set 'md/array_size' if available (and make sure ddf uses the default size). Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | incremental_container: preserve 'in_sync' flag when adding to existing array.NeilBrown2009-04-141-2/+6
| | | | | | | | | | | | | | | | | | | | | | When building container members with -IR, we need to ensure that devices added to an active array preserve the 'in_sync' status so they don't needlessly get rebuilt. So allow sysfs_add_disk to do this (only works in kernels since 2.6.30) and pass the relevant flag down. Signed-off-by: NeilBrown <neilb@suse.de>
* | grow: don't wait forever for critical section to pass.NeilBrown2009-04-011-0/+19
|/ | | | | | | | | | If an array reshape completed within 1 second, then --grow will not notice that it has finished and will keep waiting for the critical section to pass. So be more cautious in the test. Signed-off-by: NeilBrown <neilb@suse.de>
* sysfs: allow sysfs_read to detect and drop removed disksDan Williams2009-02-241-5/+21
| | | | | | | | | | | | | | | All operations that rely on loading from an existing container (like --add) will fail after a disk has been removed. Provide an option to skip missing / offline disks rather than abort. We attempt to do this in the load_super_{imsm,ddf}_all cases when mdmon is running i.e. we already have a consitent version of the metadata running in the system. Otherwise, we fail as normal and let the administrator fix up the container. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* Abort sysfs_read early if no device found.NeilBrown2008-11-041-0/+5
| | | | | | | sysfs_read currently tried to look in sysfs even in no valid sys_name was found. Don't to that. Signed-off-by: NeilBrown <neilb@suse.de>
* Generate 'change' uevents when arrays change in non-obvious ways.NeilBrown2008-11-041-0/+16
| | | | | | | | | | | When a 'container' gets started, we need udev to notice, but the kernel has no way of knowing that a KOBJ_CHANGE event is needed. So send one directly via the 'uevent' sysfs attribute. Also, uevents don't get generated when md arrays are stopped (prior to 2.6.28) so send 'change' events then too. Signed-off-by: NeilBrown <neilb@suse.de>
* Move recently merged /sys/dev/ lookup into stat2devnum.NeilBrown2008-11-041-37/+9
| | | | | | | | But sysfs_init and stat2devnum try to convert stat information into an md devnum. Combine all the value of both pieces of code into stat2devnum and have sysfs_init call that. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' into devel-3.0NeilBrown2008-10-301-3/+26
|\
| * Adjust major number testing to allow for extended minor number in 2.6.28NeilBrown2008-10-301-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | From 2.6.28, normal md device will be able to have partitions. These partitions will have a different major number. Sometimes mdadm tests the major number and so can get confused. Change these tests to test against get_mdp_major(). mdp does not use extended minor number and so this test will always be accurate. Also use /sys/dev links to map major/minor to devnum in sysfs. Signed-off-by: NeilBrown <neilb@suse.de>
* | sysfs_open leaks devnum2devname() resultDan Williams2008-10-151-1/+6
| | | | | | | | Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | --wait-clean: shorten timeoutDan Williams2008-10-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | Set the safemode timeout to a small value to get the array marked clean as soon as possible. We don't write 'clean' directly as it may cause mdmon to miss a 'write-pending' event. Include a couple fixes to sysfs_set_safemode(): 1/ 0 pad the milliseconds field 2/ workaround input truncation in the kernel Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | sysfs: dprintf when we fail to write a sysfs fileDan Williams2008-10-151-1/+4
| | | | | | | | | | | | | | When arrays do not startup correctly it would be nice to know why. Need to move the dprintf definition to mdadm.h Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Move calls to SET_ARRAY_INFO to common helper.NeilBrown2008-09-181-30/+48
| | | | | | | | | | | | | | | | | | | | When we assemble an array, there are three different approaches depending on whether metadata is internal or external, and on kernel version. Move all this to a common helper instead of duplicating in 3 places. Signed-off-by: NeilBrown <neilb@suse.de>
* | Factor out add-disk codeNeilBrown2008-09-181-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | The variety of approaches to 'add_disk' are factored out into a separate function, and Incremental mode benefits by being closer to supporting the assembly of containers. Also remove the adding-to-array-data-structure out of sysfs_add_disk and into add_disk. And add some tests for --incremental mode to make sure we don't break it. Signed-off-by: NeilBrown <neilb@suse.de>
* | sysfs: detect disks that are in the process of being removedDan Williams2008-09-151-5/+24
| | | | | | | | | | | | | | | | | | When removing a disk there is a window where the 'slot' attribute of md/dev-$name will return -EBUSY to read attempts. When this happens look at the the 'block' link, if it is removed then we can be sure the device has been removed, versus some other error. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | 'mdadm --wait-clean' wait for array to be marked cleanDan Williams2008-09-151-0/+55
| | | | | | | | | | | | | | | | | | For use in distro shutdown scripts with a RAID root file system. Returns immediately if the array is 'readonly', or not an externally managed array. It is up to the distro's scripts to make sure no new writes hit the device after this returns 'true'. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Honor safemode_delay at Create() and Incremental() timeDan Williams2008-09-151-0/+13
| | | | | | | | Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | mdmon: allow degraded arrays to be monitoredDan Williams2008-08-151-0/+6
| | | | | | | | | | | | | | manage_new is too strict in the face of failed devices. Teach it to monitor degraded arrays. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | sysfs: deprecate sysfs_disk_to_sgDan Williams2008-07-241-0/+2
| | | | | | | | | | | | | | | | | | | | The cmd_filter patch merged for 2.6.27 broke retrieving the serial number via an ioctl to /dev/sgN. In debugging this I found that other utilities like sdparm simply run the ioctl on /dev/sdX. So just convert to that for protection in numbers, but scream on the mailing list for the inconvenience grr... Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | sysfs: avoid possible data corruption in sys_load.NeilBrown2008-07-181-1/+1
| | | | | | | | | | | | Don't retry to remove a newline from the end of an empty string. Signed-off-by: Neil Brown <neilb@suse.de>