summaryrefslogtreecommitdiffstats
path: root/Create.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* imsm: Allow create RAID volume with link to containerMichal Zylowski2018-04-101-1/+1
| | | | | | | | | | | | | After 1db03765("Subdevs can't be all missing when create raid device") raid volume can't be created with link to container. This feature should not be blocked in Create function. IMSM code forbids creation of container with missing disk, so case like all dev's missing is already handled. Permit IMSM volume creation when devices are given as link to container. Signed-off-by: Michal Zylowski <michal.zylowski@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Subdevs can't be all missing when create raid deviceXiao Ni2018-01-261-0/+4
| | | | | Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm/util: unify fstat checking blkdev into functionZhilong Liu2017-05-051-13/+10
| | | | | | | | | | | | declare function fstat_is_blkdev() to integrate repeated fstat checking block device operations, it returns true/1 when it is a block device, and returns false/0 when it isn't. The fd and devname are necessary parameters, *rdev is optional, parse the pointer of dev_t *rdev, if valid, assigned the device number to dev_t *rdev, if NULL, ignores. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Create: tell udev md device is not ready when first created.NeilBrown2017-05-021-1/+8
| | | | | | | | | | | | | | | | | | | | | When an array is created the content is not initialized, so it could have remnants of an old filesystem or md array etc on it. udev will see this and might try to activate it, which is almost certainly not what is wanted. So create a mechanism for mdadm to communicate with udev to tell it that the device isn't ready. This mechanism is the existance of a file /run/mdadm/created-mdXXX where mdXXX is the md device name. When creating an array, mdadm will create the file. A new udev rule file, 01-md-raid-creating.rules, will detect the precense of thst file and set ENV{SYSTEMD_READY}="0". This is fairly uniformly used to suppress actions based on the contents of the device. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Create: Remove all attemps to handle md driver older than 0.90.03Jes Sorensen2017-04-051-25/+5
| | | | | | More legacy code moved to the bit-bucket. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Create: Fixup various whitespace issuesJes Sorensen2017-04-051-26/+24
| | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Create: Fixup bad placement of logical || && in multi-line if statementsJes Sorensen2017-04-051-17/+11
| | | | | | These always go at the end of the line, never at the front Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* mdadm/Create: declaring an existing struct within same functionZhilong Liu2017-04-051-6/+6
| | | | | | | | | Create:declaring 'struct stat stb' twice within the same function, rename stb as stb2 when declares 'struct stat' at the second time. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* sysfs: Make sysfs_init() return an error codeJes Sorensen2017-03-301-2/+8
| | | | | | | | Rather than have the caller inspect the returned content, return an error code from sysfs_init(). In addition make all callers actually check it. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* util: Introduce md_get_array_info()Jes Sorensen2017-03-291-3/+2
| | | | | | | | | | | Remove most direct ioctl calls for GET_ARRAY_INFO, except for one, which will be addressed in the next patch. This is the start of the effort to clean up the use of ioctl calls and introduce a more structured API, which will use sysfs and fall back to ioctl for backup. Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* super1: PPL supportArtur Paszkiewicz2017-03-291-0/+2
| | | | | | | | | | | | | | | | Enable creating and assembling raid5 arrays with PPL for 1.x metadata. When creating, reserve enough space for PPL and store its size and location in the superblock and set MD_FEATURE_PPL bit. Write an initial empty header in the PPL area on each device. PPL is stored in the metadata region reserved for internal write-intent bitmap, so don't allow using bitmap and PPL together. While at it, fix two endianness issues in write_empty_r5l_meta_block() and write_init_super1(). Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Generic support for --consistency-policy and PPLArtur Paszkiewicz2017-03-291-4/+14
| | | | | | | | | | | | | Add a new parameter to mdadm: --consistency-policy=. It determines how the array maintains consistency in case of unexpected shutdown. This maps to the md sysfs attribute 'consistency_policy'. It can be used to create a raid5 array using PPL. Add the necessary plumbing to pass this option to metadata handlers. The write journal and bitmap functionalities are treated as different policies, which are implicitly selected when using --write-journal or --bitmap options. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Introduce enum flag_mode for setting and clearing flags.NeilBrown2016-11-291-2/+2
| | | | | | | | | | | | | | We currently use '1' to indicate that a flag (writemostly or failfast) needs to be set, and '2' to indicate that it needs to be cleared. Using magic number like this is not a best-practice. So replaced them with values from a enum. No functional change. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* Add failfast support.NeilBrown2016-11-281-0/+2
| | | | | | | | | | | | | Allow per-device "failfast" flag to be set when creating an array or adding devices to an array. When re-adding a device which had the failfast flag, it can be removed using --nofailfast. failfast status is printed in --detail and --examine output. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* mdadm: Make add_internal_bitmap() return 0 on successJes Sorensen2016-05-121-3/+3
| | | | | | | | add_internal_bitmap() returned 1 on success and 0 on error which is inconsistent. This changes it to return 0 on success and use more reasonable error codes on error. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* Create: check the node nums when create clustered raidGuoqing Jiang2016-05-091-1/+6
| | | | | | | | | It doesn't make sense to create a clustered raid with only 1 node. Reported-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* Create: minor fix when adding a journal deviceNeilBrown2016-01-141-2/+3
| | | | | | | | | The check of "is there a filesystem here" is still appropriate for a journal device. Also set active_disks correctly - even though it is ignored. Signed-off-by: NeilBrown <neilb@suse.com>
* Create: fix regression in setting raid_diskNeilBrown2016-01-141-1/+4
| | | | | | | Recent commit caused 'missing' declarations to not be handled correctly. Fixes: cc1799c3ddc9 ("Enable create array with write journal (--write-journal DEVICE).") Signed-off-by: NeilBrown <neilb@suse.com>
* Enable create array with write journal (--write-journal DEVICE).Song Liu2015-10-191-6/+14
| | | | | | | | | | | | | | | | | | | | | Specify the write journal device with --write-journal DEVICE ./mdadm --create -f /dev/md0 --assume-clean -c 32 --raid-devices=4 --level=5 /dev/sd[c-f] --write-journal /dev/sdb1 mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started. Only one journal device is allowed. If multiple --write-journal are given, mdadm will use the first and ignore others ./mdadm --create -f /dev/md0 --assume-clean -c 32 --raid-devices=4 --level=5 /dev/sd[c-f] --write-journal /dev/sdb1 --write-journal /dev/sdx mdadm: Please specify only one journal device for the array. mdadm: Ignoring --write-journal /dev/sdx... mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started. Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: NeilBrown <neilb@suse.com>
* Increment version for clustered bitmapsGoldwyn Rodrigues2015-09-281-0/+2
| | | | | | | | | | | | | | | Add BITMAP_MAJOR_CLUSTERED as 5, in order to prevent older kernels to assemble a clustered device. In order to maximize compatibility, the major version is set to BITMAP_MAJOR_CLUSTERED *only* if the bitmap is clustered. Also, added MD_FEATURE_CLUSTERED in order to return error for older kernels which would assemble MD in case bitmap is corrupted. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
* Set home-cluster while creating an arrayGuoqing Jiang2015-06-171-0/+1
| | | | | | | | | | | | | | | The home-cluster is stored in the bitmap super block of the array. The device can be assembled on a cluster with the cluster name same as the one recorded in the bitmap. If home-cluster is not specified, this is auto-detected using dlopen corosync cmap library. neilb: allow code to compile when corosync-devel is not installed. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Add nodes option while creating mdGuoqing Jiang2015-06-171-0/+1
| | | | | | | | | | Specifies the maximum number of nodes in the cluster that may use this device simultaneously. This is equivalent to the number of bitmaps created in the internal superblock (patches to follow). Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Create n bitmaps for clustered modeGuoqing Jiang2015-06-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | For a clustered MD, create bitmaps equal to number of nodes so each node has an independent bitmap. Only the first bitmap is has the bits set so that the first node that assembles the device also performs the sync. The bitmaps are aligned to 4k boundaries. On-disk format: 0 4k 8k 12k ------------------------------------------------------------------- | idle | md super | bm super [0] + bits | | bm bits[0, contd] | bm super[1] + bits | bm bits[1, contd] | | bm super[2] + bits | bm bits [2, contd] | bm super[3] + bits | | bm bits [3, contd] | | | Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Don't break long strings onto multiple lines.NeilBrown2015-02-121-30/+15
| | | | | | | | | | | | | | | | | It is best to keep strings all together so that they are easier to search for in the source code. If a string is so long that it looks ugly one line, them maybe it should be broken into multiple lines for display too. Only strings which contain a newline can be broken into multiple lines: "It is OK to\n" "break this string\n" Signed-off-by: NeilBrown <neilb@suse.de>
* DDF: add support of --data-offset when creating array.NeilBrown2014-05-211-0/+6
| | | | | | | | | Infrastructure is there, so use it. This requires making sure that ->data_offset is correctly set, even for containers. Signed-off-by: NeilBrown <neilb@suse.de>
* Create: don't default to bitmap=internal when it is not supportedArtur Paszkiewicz2014-05-011-0/+1
| | | | | | | | | | | | For large arrays (component size > 100GB) if write-intent bitmap is not enabled, then it is set by default to "internal", even if the metadata format does support internal bitmaps, which causes Create to fail. This patch adds checking if add_internal_bitmap is set in the superswitch before setting bitmap_file to "internal". Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Fix race between --create and --incrementalArtur Paszkiewicz2014-05-011-14/+15
| | | | | | | | | | | | This modifies locking in Create to eliminate a situation where --incremental can assemble a device between write_init_super() and add_disk(), which causes Create to fail. It sporadically occurs e.g. when metadata is written on a device, causing an udev change event which triggers mdadm --incremental. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Release mdadm-3.3mdadm-3.3NeilBrown2013-09-031-1/+1
| | | | | | (and various cosmetic fixes) Signed-off-by: NeilBrown <neilb@suse.de>
* Make sure NOFILE resource limit is big enough.NeilBrown2013-05-301-1/+1
| | | | | | | | | | Some people want to create truely enormous arrays. As we sometimes need to hold one file descriptor for each device, this can hit the NOFILE limit. So raise the limit if it ever looks like it might be a problem. Signed-off-by: NeilBrown <neilb@suse.de>
* Create: over-ride "start_ro" setting when creating an array.NeilBrown2013-05-151-0/+5
| | | | | | | | | | If module parameter start_ro is set, arrays start readonly. This is OK when assembling, but is very surprising when creating an array as the resync won't start. So over-ride the setting (unless --read-only was given) make arrays RW when created. Signed-off-by: NeilBrown <neilb@suse.de>
* create_mddev: add support for /dev/md_XXX non-numeric names.NeilBrown2013-05-151-3/+3
| | | | | | | | | | With the 'devnm' infrastructure fixed, it is quite easy to support names like "md_home" for md arrays. The currently defaults to "off" and can be enabled in mdadm.conf with CREATE names=yes This is incase other tools get confused by the new names. Signed-off-by: NeilBrown <neilb@suse.de>
* Create: fix bug with --data-offset.NeilBrown2013-05-131-1/+1
| | | | | | Test for VARIABLE_OFFSET was wrong. Signed-off-by: NeilBrown <neilb@suse.de>
* Create: default to bitmap=internal for large arrays.NeilBrown2013-03-051-0/+11
| | | | | | | | Here, "large" means components are 100G or more. It is usually beneficial to have write-intent bitmaps on such arrays. They can be suppressed with --bitmap=none Signed-off-by: NeilBrown <neilb@suse.de>
* Discard devnum in favour of devnmNeilBrown2013-02-211-26/+26
| | | | | | | | | | | | | | 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>
* Create.c: check if freesize is equal 0Lukasz Dorau2012-11-201-0/+5
| | | | | | | | "freesize" can be equal 0, particularly after rounding to the chunk's size. Creating should be aborted in such case. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Replace a lot of leading spaces with tabs.NeilBrown2012-10-101-1/+1
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Allow data-offset to be specified per-device for createNeilBrown2012-10-041-3/+15
| | | | | | | | | mdadm --create /dev/md0 .... /dev/sda1:1024 /dev/sdb1:2048 ... The size is in K unless a suffix: K M G is given. The suffix 's' means sectors. Signed-off-by: NeilBrown <neilb@suse.de>
* Add --data-offset flag for Create and GrowNeilBrown2012-10-041-6/+6
| | | | | | | | | | This can be used to over-ride the automatic assignment of data offset. For --create, it is useful to re-create old arrays where different defaults applied. For --grow it may be able to force a reshape in the reverse direction. Signed-off-by: NeilBrown <neilb@suse.de>
* Add data_offset arg to ->init_super and use it in super1.cNeilBrown2012-10-041-1/+2
| | | | | | | So if ->data_offset is already set, use that rather than computing one. Signed-off-by: NeilBrown <neilb@suse.de>
* Add data_offset arg to ->validate_geometry.NeilBrown2012-10-041-5/+10
| | | | | | | This is needed to return correct available size. It isn't really used yet. Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: Allow to specify controller for --detail-platform.Maciej Naruszewicz2012-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usually, 'mdadm --detail-platform -e imsm' scans all the controllers looking for IMSM capabilities. This patch provides the possibility to specify a controller to scan, enabling custom usage by other processes - especially with the --export switch. $ mdadm --detail-platform Platform : Intel(R) Matrix Storage Manager Version : 9.5.0.1037 RAID Levels : raid0 raid1 raid10 raid5 Chunk Sizes : 4k 8k 16k 32k 64k 128k 2TB volumes : supported 2TB disks : not supported Max Disks : 7 Max Volumes : 2 per array, 4 per controller I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA) $ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.2 Platform : Intel(R) Matrix Storage Manager Version : 9.5.0.1037 RAID Levels : raid0 raid1 raid10 raid5 Chunk Sizes : 4k 8k 16k 32k 64k 128k 2TB volumes : supported 2TB disks : not supported Max Disks : 7 Max Volumes : 2 per array, 4 per controller I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA) $ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.2 --export MD_FIRMWARE_TYPE=imsm IMSM_VERSION=9.5.0.1037 IMSM_SUPPORTED_RAID_LEVELS=raid0 raid1 raid10 raid5 IMSM_SUPPORTED_CHUNK_SIZES=4k 8k 16k 32k 64k 128k IMSM_2TB_VOLUMES=yes IMSM_2TB_DISKS=no IMSM_MAX_DISKS=7 IMSM_MAX_VOLUMES_PER_ARRAY=2 IMSM_MAX_VOLUMES_PER_CONTROLLER=4 $ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.0 # This isn't an IMSM-capable controller mdadm: no active Intel(R) RAID controller found under /sys/devices/pci0000:00/0000:00:1f.0 Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Minor cosmetic fixes in various files.NeilBrown2012-08-131-6/+3
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Use new 'struct shape' to pass args to CreateNeilBrown2012-07-091-124/+121
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Create: Remove unnecessary cast from 'size'.NeilBrown2012-07-091-4/+3
| | | | | | 'size' is already unsigned long long, so no need to cast it. Signed-off-by: NeilBrown <neilb@suse.de>
* Change the values for "max size" from -1 to 1.NeilBrown2012-07-091-1/+3
| | | | | | | | Both are impossible, and '1' allows size to be unsigned, which is neater. Also #define MAX_SIZE to be '1' to make it all more explicit. Signed-off-by: NeilBrown <neilb@suse.de>
* Change Create to take a struct contextNeilBrown2012-07-091-35/+34
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Create: support --readonly flag.NeilBrown2012-07-091-3/+16
| | | | | | Allow array to be created read-only Signed-off-by: NeilBrown <neilb@suse.de>
* Remove scattered checks for malloc success.NeilBrown2012-07-091-6/+2
| | | | | | | | | | | | | | 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-091-80/+68
| | | | | | | 'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": ' cont_err() is also available. Signed-off-by: NeilBrown <neilb@suse.de>
* Create: round off size for RAID1 arrays.NeilBrown2012-03-221-0/+13
| | | | | | | | | | | RAID1 arrays don't have a chunk size, but if you ever convert one to RAID5 you will need at least a small one >= 4K. So round of size to a multiple of 64K. This only affect Create, not "--grow --size=max". The latter is too hard and with smaller returns. Signed-off-by: NeilBrown <neilb@suse.de>