Commit Graph

186 Commits

Author SHA1 Message Date
andvar a10c2cec39 fix various typos in comments and log messages. 2024-02-10 09:21:51 +00:00
oster 808873b5c3 We no longer need the deprecated copyback functionality now that
incorporating a used spare is automatic.

Copyback has always been an issue, as to do a copyback all IO to
the array had to be suspended, and so was very, very unlikely to
have been used in anything resembling a production system.
2023-09-25 21:59:38 +00:00
oster 11e80203a4 Remove a couple of unneeded comments. 2023-09-21 01:48:41 +00:00
oster 74ff9ea83b Implement command-line configuration of simple RAID sets with raidctl
based on the usage pattern:

    raidctl <device> create <level> <component1> <component2> ...

For example,

    raidctl raid0 create mirror absent /dev/wd1e

will create a RAID level 1 (mirror) set with an absent first component
and /dev/wd1e as the second component.  The resulting RAID device will
be marked as auto-configurable, will have a serial number set (based
on the current time), and parity will be initialized.  Reasonable
performance values are automatically used by default for other parameters
normally specified in the configuration file.

Also: Only print out Autoconfig status if being verbose.
2023-09-21 01:40:44 +00:00
oster a607180090 Implement hot removal of spares and components. From manu@.
Implement a long desired feature of automatically incorporating
a used spare into the array after a reconstruct.

Given the configuration:
Components:
           /dev/wd0e: failed
           /dev/wd1e: optimal
           /dev/wd2e: optimal
Spares:
           /dev/wd3e: spare

Running 'raidctl -F /dev/wd0e raid0' will now result in the
following configuration after a successful rebuild:
Components:
           /dev/wd3e: optimal
           /dev/wd1e: optimal
           /dev/wd2e: optimal
No spares.

Thanks to manu@ for the development of the initial set of changes
which allowed the changes to automatically incorporate a used spare
to come to fruition.  Thanks also to manu@ for useful discussions
about and additional testing of these changes.
2023-09-17 20:07:39 +00:00
lukem c4b7a9e794 bsd.own.mk: rename GCC_NO_* to CC_WNO_*
Rename compiler-warning-disable variables from
	GCC_NO_warning
to
	CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 09:09:01 +00:00
kre 5c922bdb9e PR bin/56917
If getfsspecname() fails that will usually mean that a NAME=wedge or
ROOT.x partition is unabailable.   raidframe specified unavailable
partitions as "absent" so in this case, pass "absent" rather than the
unaltered NAME= or ROOT.x string, which the kernel has no clue what
do do with, and doesn't configure the raid at all.
2022-07-21 09:19:53 +00:00
kre d73b978a64 Implement "raidctl -t config-file"
This does the same config file parse  that -c/-C do, but only
that (hence no raidframe device is needed, or accepted).

Any syntax errors in the config file will be reported, nothing
else happens.
2022-06-14 08:06:18 +00:00
kre b958b2dc5a Fix some config file parsing.
First, and what got me started on this set of cleanups, the queue
length in the "queue" section (START queue) is limited to what will
fit in a char without losing accuracy (I tried setting it to 200,
rather than the more common (universal?) 100 and found that the
value configured into the array was -56 instead.

Why the value needs to be passed through a char variable I have no
idea (it is an int in the filesystem raidframe headers) - but that's
the way it is done, and changing it would be an ABI change I believe
(and so need versioning to alter) and that isn't worth it for this
(or not now, IMO).

Instead check that the value in the char is the same value as was
read from the config file, and complain if not.   Those of you with
unsigned chars will be able to have queue lengths up to 255, the
rest of us are limited to 127.

While looking at that, I noticed some code that obviously fails to
understand that scanf("%s") will never return a string containing
spaces, and proceeded to attempt to remove trailing spaces from the
result ... amusingly, after having used the result for its intended
purpose (non existent trailing spaces unremoved), after which that
buffer was never used again.   That code is now gone (but for now,
just #if 0'd rather than actually deleted - it should be cleaned up
sometime).

Then I saw some other issues with how the config was parsed - a
simple (unbounded) scanf("%s") into a buffer, which hypothetically
might not be large enough (not a security issue really, raidctl has
no special privs, and it isn't likely that root could easily be
tricked into running it on a bogus config file - or not without
looking first anyway, and a huge long string would rather stand
out).   Bound the string length to something reasonable, and
assert() that the buffer is big enough to contain it.

Lastly, in the event of one particular detected error in the
config file, the code would write a warning, but then just go
ahead and use the bad data (or nothing perhaps) anyway - a
failure of logic flow (unlikely to have ever happened, everyone
seems to simply copy the sample config from the man page, and
make minor adjustments as needed).

If any of these changes make any difference to anyone (except
me with my attempt to make longer queues - for no particularly
well thought out reason), I'd be very surprised.
2022-06-14 08:06:13 +00:00
kre 5a1ff55a3a In the previous (and some earlier) version(s) of raidctl.c
the following comment appeared:

	/*
	 * After NetBSD 9, convert this to not output the numRow's value,
	 * which is no longer required or ever used.
	 */

We are after NetBSD 9 (well after).   The change requested in that
comment is made here, and the comment is thus removed.

A couple of places in rf_configure.c where a value for the "rows"
parameter was output in an error message (always simply as the
constant 0) have also been updated (those messages will no longer
include "row 0", which they always said previously).   One of them
was also slightly reworded to be clearer what problem it was
experiencing (when it said 'unable to get device file' it meant
it was unable to locate the name for the device in the config file,
not that it was found, and there was some other problem with it).
2022-06-14 08:06:07 +00:00
kre 681f9ba5c2 Reorder the getopts() switch () (slightly) to sort the options. NFCI. 2022-06-14 08:06:01 +00:00
kre ee1e729e87 KNF (whitespace & 80 column limits) - NFCI.
This is the first of a series of 5 commits in this
directory, all coming within minutes or now.
2022-06-14 08:05:55 +00:00
oster 7464f2ddcd Support on-demand re-scanning all devices to look for
autoconfig RAID sets.  raidctl now supports looking
for autoconfig RAID sets with a new '-L' flag.
2021-08-02 20:31:14 +00:00
oster 6b2ddebee8 Move case 'l' to be in sorted order. No functional change. 2021-08-01 20:26:53 +00:00
wiz 55f2c23495 Avoid using Pq.
In this case, the parentheses were wrong when a line was extended.
2021-05-27 07:03:27 +00:00
mrg 41c1322c84 move the basic history i wrote from raidctl(8) to raid(4), and
fix the x86 (thanks simonb) and sparc bootable dates, a couple
of spelling errors.
2021-05-27 06:53:37 +00:00
mrg debaf4757e update the list of platforms supporting loading kernels from raid.
expand the HISTORY section to include notable RF moments in netbsd.
bump date.
2021-05-26 08:23:18 +00:00
mlelstv edc4e8445d Allow components to be specified by wedge name. 2020-09-13 06:04:53 +00:00
mrg 07b516d274 avoid trying to printf() a NULL as %s. fixes likely bug. 2020-09-06 05:31:46 +00:00
mrg de11d87641 introduce some common variables for use in GCC warning disables:
GCC_NO_FORMAT_TRUNCATION    -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION  -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW    -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE   -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints.  many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
2019-10-13 07:28:04 +00:00
mlelstv dacdd9d9b5 Need MIN in userland. Also some more signed/unsigned clashes. 2019-09-26 10:47:30 +00:00
mlelstv 3a8aa0a47c nspares is now unsigned. Validate and use as positive integer. 2019-09-26 10:33:30 +00:00
oster 6b6fd5e205 Correct printed IOCTL name that was incorrect since rev 1.5. 2019-02-06 22:38:10 +00:00
mrg 7b743cfc69 - add the string length as an explicit parameter to get_time_string()
- remove casts when the same type is used on both sides
- expand hours_buffer[] to fit the range of hours in an 'int'
- add a work around for the sprintf() truncation checker that fails
  to detect that 'minutes' and 'seconds' have a small range
2019-02-04 09:31:22 +00:00
nakayama 6ebbd813f6 Follow the ioctl arg changes of RAIDFRAME_GET_COMPONENT_LABEL and
RAIDFRAME_CHECK_*_STATUS_EXT.

This should fix strange raidctl -s outputs reported in
current-users ML.
2018-03-24 19:41:35 +00:00
mrg f2b04ca083 implement 32-bit compat support for raidframe.
convert several raidframe ioctls to be bitsize idempotent so that
they work the same in 32 and 64 bit worlds, allowing netbsd32 to
configure and query raid properly.  remove useless 'row' in a few
places.  add COMPAT_80 and put the old ioctls there.

raidframeio.h:
  RAIDFRAME_TEST_ACC
  - remove, unused
  RAIDFRAME_GET_COMPONENT_LABEL
  - convert to label not pointer to label
  RAIDFRAME_CHECK_RECON_STATUS_EXT
  RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT
  RAIDFRAME_CHECK_COPYBACK_STATUS_EXT
  - convert to progress info not pointer to info
  RAIDFRAME_GET_INFO
  - version entirely.
raidframevar.h:
  - rf_recon_req{} has row, flags and raidPtr removed (they're
    not a useful part of this interface.)
  - RF_Config_s{} and RF_DeviceConfig_s{} have numRow/rows removed.
  - RF_RaidDisk_s{} is re-ordered slightly to fix alignment
    padding - the actual data was already OK.
  - InstallSpareTable() loses row argument

rf_compat32.c has code for RF_Config_s{} in 32 bit mode, used
by RAIDFRAME_CONFIGURE and RAIDFRAME_GET_INFO32.

rf_compat80.c has code for rf_recon_req{}, RF_RaidDisk_s{} and
RF_DeviceConfig_s{} to handle RAIDFRAME_FAIL_DISK,
RAIDFRAME_GET_COMPONENT_LABEL, RAIDFRAME_CHECK_RECON_STATUS_EXT,
RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT,
RAIDFRAME_CHECK_COPYBACK_STATUS_EXT, RAIDFRAME_GET_INFO.

move several of the per-ioctl code blocks into separate functions.

add rf_recon_req_internal{} to replace old usage of global
rf_recon_req{} that had unused void * in the structure, ruining
it's 32/64 bit ABI.

add missing case for RAIDFRAME_GET_INFO50.

adjust raid tests to use the new .conf format, and add a case to
test the old method as well.

raidctl:
deal with lack of 'row' members in a couple of places.
fail request no longer takes row.
handle "START array" sections with just "numCol numSpare", ie
no "numRow" specified.  for now, generate old-style configuration
but update raidctl.8 to specify the new style (keeping reference
to the old style.)

note that: RF_ComponentLabel_s::{row,num_rows} and
RF_SingleComponent_s::row are obsolete but not removed yet.
2018-01-18 00:32:48 +00:00
kre 70c1fd98e2 Several more cleanups:
1. Don't force use of "for" when "while" works better.
2. No need to check c != '\0' when we also check (c == ' ' || c == '\t')
3. Use the size of the buffer we're using, rather than a different one
   (not really a concern, they're the same size)
4. Don't use fscanf() to read file data, use fgets() & sscanf().
5. After using a pointer as a char *, validate alignment before switching
   to int * (can only fail if kernel #define gets set stupidly)   Or #6...
6. Validate sparemap file name isn't too long for assigned space.
7. recognise that strlen() returns size_t - don't shove it into an int.
8. On out of mem, be more clear which allocation failed in warning msg.

ATF tests all pass.   But I don't think they use sparemap files.
2017-11-22 00:31:31 +00:00
christos dbab137455 Avoid needless pointer calisthenics: &foo[0] -> foo 2017-11-21 16:31:37 +00:00
kre e8f6b3ae2f With char bug[SIZE] using sizeof(bug[0]) is kind of boring, use
sizeof(bug) instead...
2017-11-21 16:19:31 +00:00
kre 24b75d09bd White space and comment formatting. NFC. 2017-11-20 22:16:23 +00:00
christos 6937a5d56d stop using magic constants
wrap long lines
use warn{,x}
make static
knf
2017-11-20 19:10:45 +00:00
kardel cb7aeb8243 support NAME=<wedge name> syntax for disks and spares 2017-11-20 18:37:56 +00:00
wiz 01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
christos cc8b3fb098 need <sys/stat.h> for fstat() 2017-01-10 20:47:05 +00:00
christos c5f07454d1 PR/50921: David Binderman: Fix memory leak 2016-03-09 19:53:32 +00:00
wiz 704ad63c75 Use standard sort order for options.
Add -U to usage.
2016-01-06 22:57:44 +00:00
christos c4e0e8f498 Access to the SET_LAST_UNIT ioctl. 2016-01-06 17:41:36 +00:00
bad 6c69384dad Rename argument of rf_output_devname() from devname to name to avoid a
warning about shadowing a global symbol when compiled by buildrump.sh.
Discussed with mrg.
2015-09-08 08:59:09 +00:00
mrg ec5f69b6a6 convert "component*" into "absent" for "START disks" part of the
output from "raidctl -G".  now this actually works when fed back
into raidctl -[cC].
2015-07-21 05:54:44 +00:00
wiz e485731cb1 Bump date for previous. Add whitespace.
Fix some mandoc warnings.
2015-06-30 22:16:12 +00:00
sborrill 9a9013c60c Clarify that what was previously known as -A root is now -A forceroot, not
-A softroot and that -A root can still be used for historical reasons.
2015-06-30 17:18:13 +00:00
sborrill 06ac39463d Compare correct length string for force option to -A 2015-06-30 17:02:14 +00:00
pooka 8da4f44455 &stars[offset] -> stars+offset. It's shorter!
Coincidentally, the change also works around a gcc 5.1 bug which causes
a segmentation fault when trying to compile the longer version (guess
the compiler got exhausted, or something).
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66345
2015-06-26 01:16:54 +00:00
christos e304a25c5b use strtou 2015-05-27 17:55:23 +00:00
manu 05c0668e69 Better sanity check numbers given to raidctl(8)
Replace atoi(3) by strtol(3), and check that numbers are valid,
positive, and in int32_t range. The previous lack of check could
silently lead to the same serial being set to all RAID volumes
for instance because given numbers were bigger than INT_MAX. The
consequence is in an awful mess when RAIDframe would mix volumes...
2015-05-27 15:31:15 +00:00
christos 52334fd887 Add the ability to "softroot" mount (i.e. mount root only when the raid
set contains the boot device), as opposed to "hardroot" (the previous
default which forces the raid to be root no matter what).
2014-04-03 18:54:10 +00:00
christos 3e4993b396 fix unused variable warnings. 2013-10-19 01:09:58 +00:00
jdc 6dc8fb4754 Belatedly note root on RAIDframe support for sandpoint. 2013-10-07 10:50:37 +00:00
tron b0eb4d7e9b Note that NetBSD/amd64 can boot of RAID volumes. 2013-09-20 06:43:57 +00:00
njoly af97374da1 Remove unexpected newline between Em macro and text. 2012-03-23 18:28:13 +00:00