summaryrefslogtreecommitdiffstats
path: root/super0.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* mdadm/super0: fix coverity issue CHECKED_RETURN and EVALUATION_ORDERXiao Ni2024-08-051-3/+7
| | | | | | | | Fix coverity problems in super0. It needs to check return value when functions return value. And fix EVALUATION_ORDER problems in super0.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* super0: use define for char array in examine_super0Kinga Stefaniuk2024-07-301-1/+1
| | | | | | | | | Using nb with 11 length may cause format-truncation errors, because it was possible to use snprintf with 12 length input and write it to 11 length output. Added new define and use it to avoid this error. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* mdadm: set swapuuid in all handlersMariusz Tkaczyk2024-03-221-0/+2
| | | | | | | | | | | | It is not set, so it should be 0 but it may vary on compilation settings. Set it always to 0. metadata should care to set UUID and read in proper endianness so it doesn't follow super1 concept of swapuuid to depend on endianness. It is not an attempt to fix endianness issues. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Change update to enum in update_super and update_subarrayMateusz Kusiak2023-01-041-5/+4
| | | | | | | | | | Use already existing enum, change update_super and update_subarray update to enum globally. Refactor function references also. Remove code specific options from update_options. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* super0: refactor the code for enumMateusz Kusiak2023-01-041-39/+63
| | | | | | | | It prepares update_super0 for change context->update to enum. Change if else statements to switch. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: replace container level checking with inlineKinga Tanska2022-09-291-1/+1
| | | | | | | | | To unify all containers checks in code, is_container() function is added and propagated. Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Acked-by: Coly Li <colyli@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: block update=ppl for non raid456 levelsLukasz Florczak2022-06-241-1/+1
| | | | | | | | | | | | Option ppl should be used only for raid levels 4, 5 and 6. Cancel update for other levels. Applied globally for imsm and ddf format. Additionally introduce is_level456() helper function. Signed-off-by: Lukasz Florczak <lukasz.florczak@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: add map_num_s()Mariusz Tkaczyk2022-04-051-1/+1
| | | | | | | | | | | | | | map_num() returns NULL if key is not defined. This patch adds alternative, non NULL version for cases where NULL is not expected. There are many printf() calls where map_num() is called on variable without NULL verification. It works, even if NULL is passed because gcc is able to ignore NULL argument quietly but the behavior is undefined. For safety reasons such usages will use map_num_s() now. It is a potential point of regression. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: add verbose flag to compare_superMariusz Tkaczyk2021-03-081-1/+2
| | | | | | | | | | | IMSM does more than comparing metadata and errors reported directly from compare_super_imsm can be useful. Add verbose flag to compare_super method and make all not critical error printing configurable. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Create: add support for RAID0 layouts.NeilBrown2019-12-021-0/+6
| | | | | | | | | | | | | | Since Linux 5.4 a layout is needed for RAID0 arrays with varying device sizes. This patch makes the layout of an array visible (via --examine) and sets the layout on newly created arrays. --layout=dangerous can be used to avoid setting a layout so that they array can be used on older kernels. Tested-by: dann frazier <dann.frazier@canonical.com> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* imsm: return correct uuid for volume in detailBlazej Kucman2019-12-021-2/+2
| | | | | | | | | | | Fixes the side effect of the patch b6180160f ("imsm: save current_vol number") - wrong UUID is printed in detail for each volume. New parameter "subarray" is added to determine what info should be extracted from metadata (subarray or container). The parameter affects only IMSM metadata. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* super0: Use memmove() when adjusting sparc2.2 superblock dataJes Sorensen2018-05-311-3/+4
| | | | | | memcpy() does not allow overlapping copies, switch to memmove() Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* mdadm: Fixup != broken formattingJes Sorensen2017-05-161-4/+4
| | | | Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Retire mdassembleJes Sorensen2017-04-111-11/+0
| | | | | | | | mdassemble doesn't handle container based arrays, no support for sysfs, etc. It has not been actively maintained for years, so time to send it off to retirement. Signed-off-by: Jes Sorensen <jsorensen@fb.com>
* Detail: show consistency policyArtur Paszkiewicz2017-03-291-2/+2
| | | | | | | | | Show the currently enabled consistency policy in the output from --detail. Add 3 spaces to all existing items in Detail output to align with "Consistency Policy : ". 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/+4
| | | | | | | | | | | | | 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>
* mdadm: Specify enough length when write to bufferXiao Ni2017-03-171-1/+1
| | | | | | | | | | | | | | | | | | | | | In Detail.c the buffer path in function Detail is defined as path[200], in fact the max lenth of content which needs to write to the buffer is 287. Because the length of dname of struct dirent is 255. During building it reports error: error: ā€˜%sā€™ directive writing up to 255 bytes into a region of size 189 [-Werror=format-overflow=] In function examine_super0 there is a buffer nb with length 5. But it need to show a int type argument. The lenght of max number of int is 10. So the buffer length should be 11. In human_size function the length of buf is 30. During building there is a error: output between 20 and 47 bytes into a destination of size 30. Change the length to 47. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
* Add failfast support.NeilBrown2016-11-281-4/+8
| | | | | | | | | | | | | 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>
* super0: Clean up formatting in examine_super0()Jes Sorensen2016-08-151-39/+62
| | | | | | No funcionality change - should be purely cosmetic Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* super0: Fix spelling of 'version' in comment and fix formattingJes Sorensen2016-08-151-8/+6
| | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* super0: Use random_uuid() in init_super0()Jes Sorensen2016-08-151-10/+6
| | | | | | This shaves another 80 bytes off the mdadm binary. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* mdadm: Make add_internal_bitmap() return 0 on successJes Sorensen2016-05-121-2/+2
| | | | | | | | 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>
* Fix wrong bitmap output for cluster raidGuoqing Jiang2016-03-071-1/+1
| | | | | | | | | | | | For cluster raid, we need to displays bitmap related contents from different bitmaps which are based on node num. So bitmap_file_open and locate_bitmap are changed a little bit for the purpose. Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com> Fixes: b98043a2f8 ("Show all bitmaps while examining bitmap") Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
* super0: Fix reporting of devices between 2GB and 4GBNeilBrown2016-01-281-1/+2
| | | | | | | | v0.90 metadata can handle devices between 2GB and 4GB, but we need to treat the 'size' and unsigned. In a couple of places we don't. URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809447 Signed-off-by: NeilBrown <neilb@suse.com>
* mdadm: do not display bitmap info if it is clearedGuoqing Jiang2015-12-161-3/+4
| | | | | | | | | | | | "mdadm -X DISK" is used to report information about a bitmap file, it is better to not display all the related infos if bitmap is cleared with "--bitmap=none" under grow mode. To do that, the locate_bitmap is changed a little to have a return value based on MD_FEATURE_BITMAP_OFFSET. Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
* mdadm: add the ability to change cluster nameGuoqing Jiang2015-06-171-2/+2
| | | | | | | | | | | | To support change the cluster name, the commit do the followings: 1. extend original write_bitmap function for new scenario. 2. add the scenarion to handle the modification of cluster's name in write_bitmap1. 3. let the cluster name also show in examine_super1 and detail_super1 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-2/+1
| | | | | | | | | | | | | | | | | 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>
* Consistently print program Name and __func__ in debug messages.NeilBrown2015-02-121-3/+3
| | | | | | | | | | | | make dprintf() print program name and __func__, so that this messaging is consistent. Also remove all __func__ messages from pr_err(). We shouldn't leak that internal data in error message. If we really want function name there, we new pr_XXX might be wanted. Signed-off-by: NeilBrown <neilb@suse.de>
* super: make sure to ignore disk state flags that we don't understand.NeilBrown2014-08-071-4/+3
| | | | | | | This make it easier to add new flags that some super-types don't understand. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: remove call to validate_geometry.NeilBrown2013-07-301-1/+1
| | | | | | | | | | | | | | This call to validate_geometry is really rather gratuitous. It is purely about the fact that super0 cannot use more than 4TB. So just make it an explicit test - less confusing that way. With this, validate_geometry is only called from Create, which makes it easier to reason about. Also validate_geometry is now never passed NULL for the 'chunk' parameter, so we can remove those annoying tests for NULL. Signed-off-by: NeilBrown <neilb@suse.de>
* super0/1: fix typo in error messages.NeilBrown2013-07-241-1/+1
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* revert-reshape: only impose reshape_position tests on raid[456]NeilBrown2013-07-021-2/+3
| | | | | | | This test is irrelevant for RAID10, so restrict it to those levels in which it is meaningful. Signed-off-by: NeilBrown <neilb@suse.de>
* revert-reshape: make sure reshape_position is acceptable.NeilBrown2013-06-271-0/+9
| | | | | | | | | | We can only revert a reshape if the reshape_position aligns properly for the old geometry. If it doesn't we just fail for now. Also fix a +/- error with updating raid_disks for super1.c Signed-off-by: NeilBrown <neilb@suse.de>
* Remove lots of unnecessary white space.NeilBrown2013-06-191-7/+2
| | | | | | | 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>
* super0: set uninitialized variable.NeilBrown2013-06-191-1/+1
| | | | | | Reported by -O3 Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: allow --update=revert-reshapeNeilBrown2013-05-281-0/+22
| | | | This will cause a reshape to start going backwards.
* Assemble: --update=metadata converts v0.90 to v1.0NeilBrown2013-05-281-0/+39
| | | | | | | | | | This allows the smooth conversion of legacy 0.90 arrays to 1.0 metadata. Old metadata is likely to remain but will be ignored. It can be removed with mdadm --zero-superblock --metadata=0.90 /dev/whatever Signed-off-by: NeilBrown <neilb@suse.de>
* Change some "fprintf(stderr,"s to pr_err.NeilBrown2013-05-211-1/+1
| | | | | | They just keep slipping in.. Signed-off-by: NeilBrown <neilb@suse.de>
* Add --dump / --restore functionality.NeilBrown2013-05-161-1/+46
| | | | | | | | This allows the metadata on a device to be saved and later restored. This can be useful before experimenting on an array that is misbehaving. Suggested-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Discard devnum in favour of devnmNeilBrown2013-02-211-1/+1
| | | | | | | | | | | | | | 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>
* make --update=homehost work againNeilBrown2013-02-101-6/+12
| | | | | | | | | | Commit 1e2b276535cea41c348292a019bdda8a58cb1679 (Report error in --update string is not recognised) broke homehost updating functionality because it depended on each string comparison being done even after we already found a match. Make it work again by restructuring code. Reported-by: (and original version by) Justin Maggard <jmaggard10@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Avoid using BLKFLSBUF.NeilBrown2013-02-051-2/+0
| | | | | | | | | | | Now that we use O_DIRECT for all device IO, BLKFLSBUF is not needed to ensure we get current data, and it can impose a cost if any flush-out is needed. So remove it. To be safe, add O_DIRECT to one place where it isn't currently used: when reading a bitmap. Signed-off-by: NeilBrown <neilb@suse.de>
* super0: allow creation of array on 2TB+ devices.NeilBrown2012-10-221-2/+2
| | | | | | | | | | As 'info->size' is signed, it cannot even hold values above 2TB. But it isn't used much. sb->size is the important value and it is unsigned. So use that to check for overflow of size. Reported-by: Eugene San <eugenesan@gmail.com>
* Trivial bugfix and spelling fixes.Michael Tokarev2012-10-211-1/+1
| | | | | | | | | And here's another trivial bugfix, now for spelling mistakes in various places, authred by Sergey Kirpichev (Cc'ed) and carried in debian mdadm package. Signed-off-by: NeilBrown <neilb@suse.de>
* mdadm: super0: do not override uuid with homehostMichael Tokarev2012-10-211-1/+1
| | | | | | | | | | When --uuid is specified in the command line, even for v0.90 superblock we override last portion of uuid with data from --homehost, which is wrong (and disagrees with the manpage). Only use homehost in super0 if no uuid is specified. Signed-off-By: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: NeilBrown <neilb@suse.de>
* Allow data-offset to be specified per-device for createNeilBrown2012-10-041-1/+1
| | | | | | | | | 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 arg to ->init_super and use it in super1.cNeilBrown2012-10-041-1/+6
| | | | | | | 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-0/+1
| | | | | | | This is needed to return correct available size. It isn't really used yet. Signed-off-by: NeilBrown <neilb@suse.de>
* Add data_offset arg to ->avail_sizeNeilBrown2012-10-041-1/+4
| | | | | | | This is currently only useful for 1.x metadata and will allow an explicit --data-offset request on command line. Signed-off-by: NeilBrown <neilb@suse.de>
* Convert 'quiet' to 'not verbose' in various places.NeilBrown2012-07-091-1/+1
| | | | | | | | If we change some functions to accept 'verbose', where <0 means to be quiet, in place of 'quiet', then we will be able to merge 'quiet' and 'verbose' together for simplicity. Signed-off-by: NeilBrown <neilb@suse.de>