Imported Upstream version 0.4.1
This commit is contained in:
commit
7ea26e619b
3
AUTHOR
Normal file
3
AUTHOR
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
Other than the included megaraid2 driver code from LSI (GPLv2), and the SCSI header files from Joerg Schilling (GPLv2), this software was written entirely by Jefferson Ogata <ogata@antibozo.net>.
|
||||
|
348
COPYING
Normal file
348
COPYING
Normal file
@ -0,0 +1,348 @@
|
||||
|
||||
Note: This program includes megaraid2 driver source code, which was copied from
|
||||
the kernel source of a Red Hat system, and header files from Joerg Schilling's
|
||||
cdrecord, also as distributed on Red Hat, and also under GPL.
|
||||
|
||||
|
||||
----------------------------------------
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
205
README
Normal file
205
README
Normal file
@ -0,0 +1,205 @@
|
||||
LSI Megaraid Control and Monitoring Tools by Jefferson Ogata
|
||||
------------------------------------------------------------
|
||||
|
||||
|
||||
Disclaimer
|
||||
----------
|
||||
|
||||
WARNING: Use this software at your own risk. The author accepts no
|
||||
responsibility for the consequences of your use of this software.
|
||||
|
||||
WARNING: Use this software at your own risk. The author accepts no
|
||||
responsibility for the consequences of your use of this software.
|
||||
|
||||
WARNING: Use this software at your own risk. The author accepts no
|
||||
responsibility for the consequences of your use of this software.
|
||||
|
||||
These programs directly query megaraid adapters via the ioctl(2) driver
|
||||
interface and do a number of undocumented things. I and my colleagues use this
|
||||
software regularly and have had no problems, but your mileage may vary. If
|
||||
something goes terribly wrong and your RAID configs all get blown away, the
|
||||
author accepts no responsibility for the consequences.
|
||||
|
||||
Please read this document carefully as it contains a warning or two. If you
|
||||
have built the programs but are having any issues running them, please see the
|
||||
Building, Device Nodes, and Limitations notes further down in this document.
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
I've spent a fair amount of time working out the low-level interface to
|
||||
megaraid adapters. This stems from the fact that I use a lot of these beasts
|
||||
and have had failures at one time or another. The adapters are fast and
|
||||
extremely useful, but they aren't bulletproof. For example, disks showing a
|
||||
certain number of media errors are not failed immediately by the adapters; the
|
||||
adapters seem to want to pass some threshold of failure before they decide that
|
||||
a disk really needs to be dropped from a RAID, and by that time it's possible
|
||||
there could be consistency problems. I wrote these tools so I could more
|
||||
effectively monitor media errors (dellmgr makes this very tedious) and also
|
||||
take advantage of the device self-test functions provided with drives.
|
||||
Self-tests are in my opinion a suitable way to detect imminent drive failures
|
||||
without tying up the adapter and SCSI bandwidth doing patrol reads. It is also
|
||||
very useful to be able to conduct a self-test on a spare disk before using it
|
||||
for a rebuild.
|
||||
|
||||
Another issue I've had with megaraids is keeping current documentation on RAID
|
||||
configuration. You may choose a completely logical RAID layout when first
|
||||
configuration a system, but that doesn't mean you'll remember it if you have to
|
||||
reconstruct it in an emergency--did I leave out a disk for a hot spare? Which
|
||||
one? Furthermore, as disks fail and hot spares are rotated in place, the
|
||||
configuration changes over time. If you don't update your documentation every
|
||||
time a disk fails, you lose track of it. While LSI's MegaCli program provides
|
||||
methods for dumping the configuration (although verbosely) and saving and
|
||||
restoring it from files, Dell's dellmgr doesn't give you any sensible way to
|
||||
track down what spans comprise a logical disk. I wrote these programs in part
|
||||
to solve this problem.
|
||||
|
||||
|
||||
Programs
|
||||
--------
|
||||
|
||||
This distribution contains three programs and a script:
|
||||
|
||||
|
||||
*megactl*
|
||||
|
||||
megactl queries PERC2, PERC3, and PERC4 adapters and reports adapter
|
||||
configuration, physical and logical drive condition, drive log sense pages, and
|
||||
various other useful information. This allows you to document the actual
|
||||
configuration of the adapter, since, for one thing, Dell's dellmgr does not
|
||||
tell you which specific logical drive a given disk belongs to.
|
||||
|
||||
megactl has several features to query SCSI drive log pages, where each drive
|
||||
controller saves accumulated error counts, drive temperature, self-test
|
||||
results, et al. To get a list of supported log pages for a given drive, use
|
||||
"megactl -vv -l 0 <target>" where target is the name of the drive, e.g. a0c1t2
|
||||
for SCSI target 2 on channel 1 of adapter 0. In addition "-s" is shorthand for
|
||||
"-l 0x10", "-t" is shorthand for "-l 0x0d", and "-e" is shorthand for "-l 0x02
|
||||
-l 0x03 -l 0x05". megactl knows how to parse several useful log pages, but
|
||||
there are others where you'll have to interpret the results yourself. Feel free
|
||||
to write more parsing code.
|
||||
|
||||
megactl output is governed by a verbosity flag. At lower verbosity levels, the
|
||||
program tends to minimize log page output unless it represents an actual
|
||||
problem. So to see the full self-test log, you need to add "-vv". I usually run
|
||||
the program with a single "-v".
|
||||
|
||||
Self-test and most status operations allow you to designate either an entire
|
||||
adapter (a0), a specific channel (a0c1), or a specific drive (a0c1t2). When
|
||||
performing drive self-test operations (q.v.), be sure to specify the actual
|
||||
drive you wish to test, or you will end up starting a test on every drive on
|
||||
the system. You may designate as many objects as you please, e.g.
|
||||
"a0c0t{1,2,3,4,5,8} a0c1 a1".
|
||||
|
||||
megactl provides a health-check function, which inspects health check operation
|
||||
allows only entire adapters to be designated. If no target is designated, the
|
||||
program operates on all possible objects.
|
||||
|
||||
megactl with the -H option performs a health check of all (or specified)
|
||||
adapters. By default, the health check checks the state of the adapter battery,
|
||||
the state of all logical drives, and for each physical drive, the media error
|
||||
count logged by the adapter, the read, write,and verify error log pages, and
|
||||
the temperature log page. You can tune the log pages the health check will
|
||||
inspect by specifying them with "-e", "-s", "-t", or "-l"; note that if you do
|
||||
this, there is no default and you must specify every log page you wish to
|
||||
inspect ("-et" for the default behaviour). If a problem is found, the program
|
||||
prints the adapter and relevant drive info. If everything is okay, the program
|
||||
is completely silent. So "megactl -vH" can be a useful cron job.
|
||||
|
||||
When using the health check you may specify which adapters you want to check,
|
||||
but you may not designate specific channels or drives.
|
||||
|
||||
megactl also allows you to instruct the drive to perform a long ("-T long") or
|
||||
short ("-T short") background self-test procedure, which does not take the
|
||||
drive offline. I have performed self-tests on drives that are part of an
|
||||
operational RAID many times with no problems. I recommend that you self-test
|
||||
only one drive in a given span at a time; if the self-test causes the drive to
|
||||
log errors, the adapter may fail the drive, and you don't want that to happen
|
||||
to two drives in a span simultaneously or you may lose data.
|
||||
|
||||
You can get full usage info for megactl by executing it with the -? flag.
|
||||
|
||||
I use megactl on a number of PERC models, especially PERC3/QCs and PERC4/DCs.
|
||||
In the past, megactl was known to work well with PERC2/DC adapters but I no
|
||||
longer operate any systems with these adapters, so this may have broken. Please
|
||||
let me know if you have success or problems.
|
||||
|
||||
megactl generally tries not to do anything harmful, so it's pretty safe.
|
||||
Primarily it queries disks; the only instructions it issues in its current form
|
||||
are to execute self-test operations.
|
||||
|
||||
|
||||
*megasasctl*
|
||||
|
||||
The second program, megasasctl, is just like megactl, but intended for PERC5
|
||||
adapters. The only syntactic difference is that instead of naming targets with
|
||||
channels and ids, they are named with enclosures and slots, e.g. a0, a1e0,
|
||||
a2e1s9.
|
||||
|
||||
The SAS support is brand new, and I'm sure I've got some things wrong. I
|
||||
haven't been able to fully test SAS support yet because I don't have any bad
|
||||
SAS disks.
|
||||
|
||||
|
||||
*megatrace*
|
||||
|
||||
megatrace is a debugging program which can be used to trace PERC-related
|
||||
ioctl() system calls that another program makes. You won't need that unless
|
||||
you're trying to add features to megactl, or are exceptionally curious. This
|
||||
program uses ptrace(2) and can inspect and modify data structures to help you
|
||||
suss out what's going on in dellmgr and MegaCli.
|
||||
|
||||
|
||||
*megarpt*
|
||||
|
||||
megarpt is a script I run in a cron job each night. It performs a health check
|
||||
on all adapters, and emails any problems, along with the adapter configuration,
|
||||
to root. It is handy to have the adapter configuration logged in case you need
|
||||
to reconstruct adapter state in a catastrophic failure. There are various
|
||||
scenarios involving hot spares and multiple drive failures where the adapter
|
||||
configuration may not be quite what you thought it was. To use megarpt, copy
|
||||
megarpt and megactl into /root/ and add a cron entry for /root/megarpt. Or
|
||||
tweak as you see fit; there isn't much to it.
|
||||
|
||||
megarpt needs to be tweaked for megasasctl applications; it currently works
|
||||
only with pre-SAS models.
|
||||
|
||||
|
||||
*megasasrpt*
|
||||
|
||||
megasasrpt is just like megarpt, but for PERC5 adapters.
|
||||
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
This software has been built successfully on RHEL 3, 4, and 5, and Debian Etch,
|
||||
using the default gcc compiler, and Red Hat Linux 7.3 or RHEL 2.1 should work
|
||||
as well. Simply run make in the src directory.
|
||||
|
||||
|
||||
Device Nodes
|
||||
------------
|
||||
|
||||
megactl and megasasctl require the existence of an appropriate device node in
|
||||
order to communicate with adapters. For megactl, this device node should be
|
||||
/dev/megadev0, and is created automatically by Dell's dellmgr program. You may
|
||||
create it yourself by finding the major device number for megadev in
|
||||
/proc/devices and creating a character device with that major number and minor
|
||||
number 0. See the megarpt shell script if this is not clear. For megasasctl,
|
||||
the device node is /dev/megaraid_sas_ioctl_node, and is created automatically
|
||||
by LSI's MegaCli program. It should have the major number of megaraid_sas_ioctl
|
||||
from /proc/devices and minor number 0. See the megasasrpt shell script for an
|
||||
example of how to create this.
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
Currently these programs only operate if built as 32-bit targets. On 64-bit
|
||||
architectures, you therefore will need 32-bit compatibility libraries. This
|
||||
should not require any special action on Red Hat, but on Debian you may need to
|
||||
install a few things.
|
||||
|
||||
|
42
src/Makefile
Normal file
42
src/Makefile
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
SRCS= megactl.c adapter.c megaioctl.c megatrace.c callinfo.c dumpbytes.c logpage.c ntrim.c
|
||||
INC= -I./schily -Iincludes-hack
|
||||
HDRS= mega.h adapter.h megaioctl.h callinfo.h logpage.h dumpbytes.h
|
||||
ARCH= -m32
|
||||
CFLAGS= -g -Wall $(INC) $(ARCH)
|
||||
LDFLAGS= -g $(ARCH)
|
||||
PROGRAMS= megactl megasasctl megatrace
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
megatrace: megatrace.o callinfo.o dumpbytes.o
|
||||
$(CC) $(LDFLAGS) -o $@ megatrace.o callinfo.o dumpbytes.o
|
||||
|
||||
megactl: megactl.o adapter.o dumpbytes.o megaioctl.o logpage.o ntrim.o
|
||||
$(CC) $(LDFLAGS) -o $@ megactl.o adapter.o dumpbytes.o megaioctl.o logpage.o ntrim.o
|
||||
|
||||
megasasctl: megasasctl.o adapter.o dumpbytes.o megaioctl.o logpage.o ntrim.o
|
||||
$(CC) $(LDFLAGS) -o $@ megasasctl.o adapter.o dumpbytes.o megaioctl.o logpage.o ntrim.o
|
||||
|
||||
megasasctl.o: megactl.c
|
||||
$(CC) $(CFLAGS) -c -o $@ -DMEGA_SAS_CTL megactl.c
|
||||
|
||||
%.o: Makefile.bak %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $*.c
|
||||
|
||||
clean:
|
||||
$(RM) $(PROGRAMS) *.o
|
||||
|
||||
depend:
|
||||
makedepend -- $(CFLAGS) -- $(SRCS)
|
||||
|
||||
megactl.o: mega.h adapter.h megaioctl.h logpage.h dumpbytes.h
|
||||
megasasctl.o: mega.h adapter.h megaioctl.h logpage.h dumpbytes.h
|
||||
adapter.o: mega.h megaioctl.h logpage.h ntrim.h
|
||||
megaioctl.o: mega.h megaioctl.h logpage.h
|
||||
megatrace.o: mega.h megaioctl.h logpage.h callinfo.h dumpbytes.h
|
||||
callinfo.o: callinfo.h
|
||||
logpage.o: mega.h megaioctl.h logpage.h ntrim.h dumpbytes.h
|
||||
ntrim.o: ntrim.h
|
||||
|
||||
# DO NOT DELETE
|
845
src/adapter.c
Normal file
845
src/adapter.c
Normal file
@ -0,0 +1,845 @@
|
||||
/*
|
||||
* High-level interface to adapter information.
|
||||
*
|
||||
* Copyright (c) 2007 by Jefferson Ogata
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; see the file COPYING. If not, write to the Free Software
|
||||
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "megaioctl.h"
|
||||
#include "logpage.h"
|
||||
#include "ntrim.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include <scg/scsireg.h>
|
||||
|
||||
|
||||
static void batteryStatus (struct adapter_config *a, uint8_t status)
|
||||
{
|
||||
a->battery.module_missing = (status & BATTERY_MODULE_MISSING) != 0;
|
||||
a->battery.pack_missing = (status & BATTERY_PACK_MISSING) != 0;
|
||||
a->battery.low_voltage = (status & BATTERY_LOW_VOLTAGE) != 0;
|
||||
a->battery.high_temperature = (status & BATTERY_TEMP_HIGH) != 0;
|
||||
a->battery.cycles_exceeded = (status & BATTERY_CYCLES_EXCEEDED) != 0;
|
||||
switch (status & BATTERY_CHARGE_MASK)
|
||||
{
|
||||
case BATTERY_CHARGE_FAIL: a->battery.charger_state = ChargerStateFailed; break;
|
||||
case BATTERY_CHARGE_DONE: a->battery.charger_state = ChargerStateComplete; break;
|
||||
case BATTERY_CHARGE_INPROG: a->battery.charger_state = ChargerStateInProgress; break;
|
||||
default: a->battery.charger_state = ChargerStateUnknown; break;
|
||||
}
|
||||
a->battery.voltage = -1;
|
||||
a->battery.temperature = -1;
|
||||
a->battery.healthy = !(a->battery.module_missing || a->battery.pack_missing || a->battery.low_voltage || a->battery.high_temperature || a->battery.cycles_exceeded || (a->battery.charger_state != ChargerStateComplete));
|
||||
}
|
||||
|
||||
static void batteryStatus5 (struct adapter_config *a)
|
||||
{
|
||||
struct mega_battery_state_sas *b = &a->q.v5.battery.state;
|
||||
|
||||
a->battery.module_missing = !(a->q.v5.adapinfo.hw_present.bbu);
|
||||
a->battery.pack_missing = b->type == MEGA_BATTERY_TYPE_NONE;
|
||||
a->battery.low_voltage = b->remaining_capacity_alarm || b->remaining_time_alarm || b->fully_discharged;
|
||||
a->battery.high_temperature = b->over_temperature != 0;
|
||||
a->battery.over_charged = b->over_charged != 0;
|
||||
switch (b->charger_status)
|
||||
{
|
||||
case 0: a->battery.charger_state = ChargerStateFailed; break;
|
||||
case 1: a->battery.charger_state = ChargerStateComplete; break;
|
||||
case 2: a->battery.charger_state = ChargerStateInProgress; break;
|
||||
default: a->battery.charger_state = ChargerStateUnknown; break;
|
||||
}
|
||||
a->battery.voltage = b->voltage;
|
||||
a->battery.temperature = b->temperature;
|
||||
a->battery.healthy = !(a->battery.module_missing || a->battery.pack_missing || a->battery.low_voltage || a->battery.high_temperature || a->battery.cycles_exceeded || (a->battery.charger_state != ChargerStateComplete) || (!b->health));
|
||||
|
||||
}
|
||||
|
||||
|
||||
static struct log_page_list *getPage (struct physical_drive_info *d, uint8_t page)
|
||||
{
|
||||
struct log_page_list *p;
|
||||
|
||||
if ((p = (struct log_page_list *) malloc (sizeof (*p))) == NULL)
|
||||
return NULL;
|
||||
memset (p, 0, sizeof (*p));
|
||||
|
||||
if (megaScsiLogSense (&d->adapter->target, d->target, &p->buf, sizeof (p->buf), 1, page, 0) < 0)
|
||||
{
|
||||
free (p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (parseLogPage (&p->buf, sizeof (p->buf), &p->log) < 0)
|
||||
{
|
||||
free (p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
struct log_page_list *getDriveLogPage (struct physical_drive_info *d, uint8_t page)
|
||||
{
|
||||
struct supportedLogsPage *supported = NULL;
|
||||
struct log_page_list *p;
|
||||
|
||||
for (p = d->log; p; p = p->next)
|
||||
{
|
||||
if (p->log.h.page_code == page)
|
||||
return p;
|
||||
if (p->log.h.page_code == 0)
|
||||
supported = &p->log.u.supported;
|
||||
}
|
||||
|
||||
if (supported == NULL)
|
||||
{
|
||||
if ((p = getPage (d, 0)) == NULL)
|
||||
return NULL;
|
||||
p->next = d->log;
|
||||
d->log = p;
|
||||
if (page == 0)
|
||||
return p;
|
||||
|
||||
supported = &p->log.u.supported;
|
||||
}
|
||||
|
||||
/* Is the requested page supported? */
|
||||
if (supported->page[page] == 0)
|
||||
return NULL;
|
||||
|
||||
if ((p = getPage (d, page)) == NULL)
|
||||
return NULL;
|
||||
p->next = d->log;
|
||||
d->log = p;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
int cmpPhysical (const void *a, const void *b)
|
||||
{
|
||||
struct physical_drive_info *x = *((struct physical_drive_info **) a);
|
||||
struct physical_drive_info *y = *((struct physical_drive_info **) b);
|
||||
|
||||
if (x->adapter->target.adapno != y->adapter->target.adapno)
|
||||
return (int) (x->adapter->target.adapno) - (int) (y->adapter->target.adapno);
|
||||
if (x->channel != y->channel)
|
||||
return (int) (x->channel) - (int) (y->channel);
|
||||
if (x->id != y->id)
|
||||
return (int) (x->id) - (int) (y->id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct physical_drive_info *getPhysicalDriveInfo (struct adapter_config *a, uint16_t target, int fetch)
|
||||
{
|
||||
int k;
|
||||
struct physical_drive_info *d;
|
||||
|
||||
/* Look for it. */
|
||||
for (k = 0, d = a->physical; k < a->num_physicals; ++k, ++d)
|
||||
{
|
||||
if (d->adapter == NULL)
|
||||
break;
|
||||
if (d->target == target)
|
||||
return d->present ? d : NULL;
|
||||
}
|
||||
|
||||
/* Not there and no place for it. That's just wrong. */
|
||||
if (k >= a->num_physicals)
|
||||
{
|
||||
fprintf (stderr, "me so crazy, me think adapter crazy too. sorry, mister.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If we don't want to query it, we're done. */
|
||||
if (!fetch)
|
||||
return NULL;
|
||||
|
||||
d->adapter = a;
|
||||
d->target = target;
|
||||
|
||||
if (a->is_sas)
|
||||
{
|
||||
struct mega_physical_disk_info_sas *info = &d->q.v5.info;
|
||||
|
||||
if (megaSasGetDiskInfo (&a->target, target, info) < 0)
|
||||
{
|
||||
d->error_string = megaErrorString ();
|
||||
d->present = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
d->channel = info->enclosure;
|
||||
d->id = info->slot;
|
||||
|
||||
snprintf (d->name, sizeof (d->name), "%se%us%u", a->name, d->channel, d->id);
|
||||
|
||||
d->inquiry = info->inquiry.inq;
|
||||
strncpy (d->vendor, d->inquiry.vendor_info, sizeof (d->vendor) - 1);
|
||||
d->vendor[sizeof (d->vendor) - 1] = '\0';
|
||||
ntrim (d->vendor);
|
||||
strncpy (d->model, d->inquiry.prod_ident, sizeof (d->model) - 1);
|
||||
d->model[sizeof (d->model) - 1] = '\0';
|
||||
ntrim (d->model);
|
||||
strncpy (d->revision, d->inquiry.prod_revision, sizeof (d->revision) - 1);
|
||||
d->revision[sizeof (d->revision) - 1] = '\0';
|
||||
ntrim (d->revision);
|
||||
|
||||
if ((d->inquiry.qualifier == INQ_DEV_PRESENT) && (d->inquiry.type == INQ_DASD))
|
||||
{
|
||||
d->present = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d->present = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strncpy (d->serial, (char *) info->inquiry.buf + sizeof (info->inquiry.inq), sizeof (d->serial));
|
||||
d->serial[sizeof (d->serial) - 1] = '\0';
|
||||
ntrim (d->serial);
|
||||
|
||||
if (info->configured)
|
||||
{
|
||||
if (info->online)
|
||||
d->state = PdStateOnline;
|
||||
else if (info->rebuild)
|
||||
d->state = PdStateRebuild;
|
||||
else if (info->failure)
|
||||
d->state = PdStateFailed;
|
||||
else
|
||||
d->state = PdStateUnknown;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info->hotspare)
|
||||
d->state = PdStateHotspare;
|
||||
else if (info->failure)
|
||||
d->state = PdStateUnconfiguredBad;
|
||||
else
|
||||
d->state = PdStateUnconfiguredGood;
|
||||
}
|
||||
d->blocks = info->raw_size;
|
||||
d->media_errors = info->media_errors;
|
||||
d->other_errors = info->other_errors;
|
||||
d->predictive_failures = info->predictive_failures;
|
||||
}
|
||||
else
|
||||
{
|
||||
int status;
|
||||
struct scsi_inquiry inq;
|
||||
uint8_t evpd[128];
|
||||
struct mega_physical_drive_error_info errors;
|
||||
|
||||
d->channel = (target >> 4) & 0xf;
|
||||
d->id = target & 0xf;
|
||||
|
||||
snprintf (d->name, sizeof (d->name), "%sc%ut%u", a->name, d->channel, d->id);
|
||||
|
||||
if (megaScsiDriveInquiry (&a->target, target, &inq, sizeof (inq), 0, 0) == 0)
|
||||
{
|
||||
d->inquiry = inq;
|
||||
strncpy (d->vendor, d->inquiry.vendor_info, sizeof (d->vendor) - 1);
|
||||
d->vendor[sizeof (d->vendor) - 1] = '\0';
|
||||
ntrim (d->vendor);
|
||||
strncpy (d->model, d->inquiry.prod_ident, sizeof (d->model) - 1);
|
||||
d->model[sizeof (d->model) - 1] = '\0';
|
||||
ntrim (d->model);
|
||||
strncpy (d->revision, d->inquiry.prod_revision, sizeof (d->revision) - 1);
|
||||
d->revision[sizeof (d->revision) - 1] = '\0';
|
||||
ntrim (d->revision);
|
||||
|
||||
if ((d->inquiry.qualifier == INQ_DEV_PRESENT) && (d->inquiry.type == INQ_DASD))
|
||||
{
|
||||
d->present = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d->present = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d->error_string = megaErrorString ();
|
||||
d->present = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (megaScsiDriveInquiry (&a->target, target, evpd, sizeof evpd, 0x80, 1) == 0)
|
||||
{
|
||||
uint8_t len = evpd[3];
|
||||
|
||||
if ((evpd[1] == 0x80) && (len + 4 <= sizeof evpd))
|
||||
{
|
||||
if (len > sizeof (d->serial) - 1)
|
||||
len = sizeof (d->serial) - 1;
|
||||
strncpy (d->serial, (char *) evpd + 4, len);
|
||||
d->serial[len] = '\0';
|
||||
ntrim (d->serial);
|
||||
}
|
||||
}
|
||||
|
||||
if ((status = megaGetDriveErrorCount (&a->target, target, &errors)) == 0)
|
||||
{
|
||||
d->media_errors = errors.media;
|
||||
d->other_errors = errors.other;
|
||||
}
|
||||
else
|
||||
d->error_string = megaErrorString ();
|
||||
}
|
||||
|
||||
/* Add it to the device list and sort it. */
|
||||
for (k = 0; k < a->num_physicals; ++k)
|
||||
if (a->physical_list[k] == NULL)
|
||||
break;
|
||||
if (k >= a->num_physicals)
|
||||
{
|
||||
fprintf (stderr, "not ok at the ok corral. freak out, mama!\n");
|
||||
return NULL;
|
||||
}
|
||||
a->physical_list[k++] = d;
|
||||
qsort (a->physical_list, k, sizeof (*a->physical_list), cmpPhysical);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
/* Adapter handling for PERC2. */
|
||||
static char *getAdapterConfig2 (struct adapter_config *a)
|
||||
{
|
||||
int k;
|
||||
logdrv_8ld_span8_t *ml;
|
||||
int spanIndex;
|
||||
mraid_adapinfo1_t *pinfo = &a->q.v2.inquiry.adapter_info;
|
||||
mraid_inquiry1_t *inquiry = &a->q.v2.inquiry;
|
||||
disk_array_8ld_span8_t *config = &a->q.v2.config;
|
||||
|
||||
a->target.type = MEGA_ADAPTER_V2;
|
||||
|
||||
if (megaGetAdapterInquiry (&a->target, inquiry) < 0)
|
||||
return "cannot query adapter";
|
||||
if (megaGetAdapterConfig8 (&a->target, config) < 0)
|
||||
return "cannot read adapter config";
|
||||
if (megaGetPredictiveMap (&a->target, &a->q.v2.map) < 0)
|
||||
return "cannot read adapter predictive map";
|
||||
|
||||
a->rebuild_rate = pinfo->rebuild_rate;
|
||||
a->dram_size = pinfo->dram_size;
|
||||
|
||||
snprintf (a->name, sizeof (a->name), "a%u", a->target.adapno);
|
||||
strcpy (a->product, "PERC2/");
|
||||
switch (pinfo->nchannels)
|
||||
{
|
||||
case 1: strcat (a->product, "SC"); break;
|
||||
case 2: strcat (a->product, "DC"); break;
|
||||
case 4: strcat (a->product, "QC"); break;
|
||||
default: return "invalid number of channels";
|
||||
}
|
||||
strncpy (a->bios, (char *) pinfo->bios_version, sizeof (a->bios));
|
||||
a->bios[sizeof (a->bios) - 1] = '\0';
|
||||
ntrim (a->bios);
|
||||
strncpy (a->firmware, (char *) pinfo->fw_version, sizeof (a->firmware));
|
||||
a->firmware[sizeof (a->firmware) - 1] = '\0';
|
||||
ntrim (a->firmware);
|
||||
|
||||
batteryStatus (a, pinfo->battery_status);
|
||||
|
||||
if (config->numldrv > sizeof (config->ldrv) / sizeof (config->ldrv[0]))
|
||||
return "invalid number of logical drives";
|
||||
|
||||
a->num_channels = pinfo->nchannels;
|
||||
if ((a->channel = (uint8_t *) malloc (a->num_channels * sizeof (*a->channel))) == NULL)
|
||||
return "out of memory (channels)";
|
||||
for (k = 0; k < a->num_channels; ++k)
|
||||
a->channel[k] = k;
|
||||
|
||||
a->num_physicals = FC_MAX_PHYSICAL_DEVICES;
|
||||
if ((a->physical = (struct physical_drive_info *) malloc (a->num_physicals * sizeof (*a->physical))) == NULL)
|
||||
return "out of memory (physical drives)";
|
||||
memset (a->physical, 0, a->num_physicals * sizeof (*a->physical));
|
||||
if ((a->physical_list = (struct physical_drive_info **) malloc (a->num_physicals * sizeof (*a->physical_list))) == NULL)
|
||||
return "out of memory (physical drives)";
|
||||
memset (a->physical_list, 0, a->num_physicals * sizeof (*a->physical_list));
|
||||
|
||||
a->num_logicals = config->numldrv;
|
||||
if ((a->logical = (struct logical_drive_info *) malloc (a->num_logicals * sizeof (*a->logical))) == NULL)
|
||||
return "out of memory (logical drives)";
|
||||
memset (a->logical, 0, a->num_logicals * sizeof (*a->logical));
|
||||
|
||||
/* Count how many spans there are. */
|
||||
for (k = 0, ml = config->ldrv, a->num_spans = 0; k < config->numldrv; ++k, ++ml)
|
||||
a->num_spans += ml->lparam.span_depth;
|
||||
|
||||
if ((a->span = (struct span_info *) malloc (a->num_spans * sizeof (*a->span))) == NULL)
|
||||
return "out of memory (spans)";
|
||||
memset (a->span, 0, a->num_spans * sizeof (*a->span));
|
||||
|
||||
/* Copy drive states. */
|
||||
for (k = 0; k < sizeof (inquiry->pdrv_info.pdrv_state) / sizeof (inquiry->pdrv_info.pdrv_state[0]); ++k)
|
||||
switch (inquiry->pdrv_info.pdrv_state[k] & 0xf)
|
||||
{
|
||||
case PDRV_UNCNF: a->physical[k].state = PdStateUnconfiguredGood; continue;
|
||||
case PDRV_ONLINE: a->physical[k].state = PdStateOnline; continue;
|
||||
case PDRV_FAILED: a->physical[k].state = PdStateFailed; continue;
|
||||
case PDRV_RBLD: a->physical[k].state = PdStateRebuild; continue;
|
||||
case PDRV_HOTSPARE: a->physical[k].state = PdStateHotspare; continue;
|
||||
default: a->physical[k].state = PdStateUnknown; continue;
|
||||
}
|
||||
|
||||
/* Copy drive sizes. */
|
||||
for (k = 0; k < sizeof (config->pdrv) / sizeof (config->pdrv[0]); ++k)
|
||||
a->physical[k].blocks = config->pdrv[k].size;
|
||||
|
||||
/* Copy drive predictive failures flag */
|
||||
for (k = 0; k < 8 * sizeof (a->q.v2.map.map) / sizeof (a->q.v2.map.map[0]); ++k)
|
||||
a->physical[k].predictive_failures = ((a->q.v2.map.map[k >> 3] & (1 << (k & 0x7))) != 0);
|
||||
|
||||
/* Examine all the logical drives. */
|
||||
for (k = 0, ml = config->ldrv, spanIndex = 0; k < config->numldrv; ++k, ++ml)
|
||||
{
|
||||
struct span_info *span;
|
||||
adap_span_8ld_t *mr;
|
||||
int j;
|
||||
struct logical_drive_info *l = &a->logical[k];
|
||||
|
||||
l->adapter = a;
|
||||
snprintf (l->name, sizeof (l->name), "a%ud%u", a->target.adapno, k);
|
||||
l->target = k;
|
||||
switch (ml->lparam.status)
|
||||
{
|
||||
case RDRV_OFFLINE: l->state = LdStateOffline; break;
|
||||
case RDRV_DEGRADED: l->state = LdStateDegraded; break;
|
||||
case RDRV_OPTIMAL: l->state = LdStateOptimal; break;
|
||||
case RDRV_DELETED: l->state = LdStateDeleted; break;
|
||||
default: l->state = LdStateUnknown; break;
|
||||
}
|
||||
l->raid_level = ml->lparam.level;
|
||||
l->span_size = ml->lparam.row_size;
|
||||
|
||||
l->num_spans = ml->lparam.span_depth;
|
||||
if ((l->span = (struct span_reference *) malloc (l->num_spans * sizeof (*l->span))) == NULL)
|
||||
return "out of memory (span references)";
|
||||
|
||||
for (j = 0, mr = ml->span; j < ml->lparam.span_depth; ++j, ++mr)
|
||||
{
|
||||
int i;
|
||||
|
||||
span = &a->span[spanIndex++];
|
||||
span->adapter = a;
|
||||
span->num_logical_drives = 1;
|
||||
if ((span->logical_drive = (struct logical_drive_info **) malloc (span->num_logical_drives * sizeof (*span->logical_drive))) == NULL)
|
||||
return "out of memory (span -> ldrv pointers)";
|
||||
span->logical_drive[0] = l;
|
||||
span->blocks_per_disk = mr->num_blks;
|
||||
span->num_disks = ml->lparam.row_size;
|
||||
if ((span->disk = (struct physical_drive_info **) malloc (span->num_disks * sizeof (*span->disk))) == NULL)
|
||||
return "out of memory (span -> disk pointers)";
|
||||
|
||||
/* Logical drives use the whole span. */
|
||||
l->span[j].offset = 0;
|
||||
l->span[j].blocks_per_disk = span->blocks_per_disk;
|
||||
l->span[j].span = span;
|
||||
|
||||
for (i = 0; i < span->num_disks; ++i)
|
||||
{
|
||||
span->disk[i] = &a->physical[mr->device[i].target];
|
||||
span->disk[i]->span = span;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Adapter handling for PERC3 and PERC4 adapters. */
|
||||
static char *getAdapterConfig3 (struct adapter_config *a)
|
||||
{
|
||||
int k;
|
||||
logdrv_40ld_t *ml;
|
||||
int spanIndex;
|
||||
mraid_pinfo_t *pinfo = &a->q.v3.adapinfo;
|
||||
mraid_inquiry3_t *enquiry3 = &a->q.v3.enquiry3;
|
||||
disk_array_40ld_t *config = &a->q.v3.config;
|
||||
|
||||
a->target.type = MEGA_ADAPTER_V34;
|
||||
|
||||
if (megaGetAdapterEnquiry3 (&a->target, &a->q.v3.enquiry3) < 0)
|
||||
return "cannot query adapter";
|
||||
if (megaGetAdapterConfig40 (&a->target, config) < 0)
|
||||
return "cannot read adapter config";
|
||||
if (megaGetPredictiveMap (&a->target, &a->q.v3.map) < 0)
|
||||
return "cannot read adapter predictive map";
|
||||
|
||||
a->rebuild_rate = enquiry3->rebuild_rate;
|
||||
a->dram_size = pinfo->dram_size;
|
||||
|
||||
snprintf (a->name, sizeof (a->name), "a%u", a->target.adapno);
|
||||
switch (pinfo->nchannels)
|
||||
{
|
||||
case 1: break;
|
||||
case 2: break;
|
||||
case 4: break;
|
||||
default: return "invalid number of channels";
|
||||
}
|
||||
strncpy (a->product, (char *) pinfo->product_name, sizeof (pinfo->product_name));
|
||||
a->product[sizeof (a->product) - 1] = '\0';
|
||||
ntrim (a->product);
|
||||
strncpy (a->bios, (char *) pinfo->bios_version, sizeof (a->bios));
|
||||
a->bios[sizeof (a->bios) - 1] = '\0';
|
||||
ntrim (a->bios);
|
||||
strncpy (a->firmware, (char *) pinfo->fw_version, sizeof (a->firmware));
|
||||
a->firmware[sizeof (a->firmware) - 1] = '\0';
|
||||
ntrim (a->firmware);
|
||||
|
||||
batteryStatus (a, enquiry3->battery_status);
|
||||
|
||||
if (config->numldrv > sizeof (config->ldrv) / sizeof (config->ldrv[0]))
|
||||
return "invalid number of logical drives";
|
||||
|
||||
a->num_channels = pinfo->nchannels;
|
||||
if ((a->channel = (uint8_t *) malloc (a->num_channels * sizeof (*a->channel))) == NULL)
|
||||
return "out of memory (channels)";
|
||||
for (k = 0; k < a->num_channels; ++k)
|
||||
a->channel[k] = k;
|
||||
|
||||
a->num_physicals = FC_MAX_PHYSICAL_DEVICES;
|
||||
if ((a->physical = (struct physical_drive_info *) malloc (a->num_physicals * sizeof (*a->physical))) == NULL)
|
||||
return "out of memory (physical drives)";
|
||||
memset (a->physical, 0, a->num_physicals * sizeof (*a->physical));
|
||||
if ((a->physical_list = (struct physical_drive_info **) malloc (a->num_physicals * sizeof (*a->physical_list))) == NULL)
|
||||
return "out of memory (physical drives)";
|
||||
memset (a->physical_list, 0, a->num_physicals * sizeof (*a->physical_list));
|
||||
|
||||
a->num_logicals = config->numldrv;
|
||||
if ((a->logical = (struct logical_drive_info *) malloc (a->num_logicals * sizeof (*a->logical))) == NULL)
|
||||
return "out of memory (logical drives)";
|
||||
memset (a->logical, 0, a->num_logicals * sizeof (*a->logical));
|
||||
|
||||
/* Count how many spans there are. */
|
||||
for (k = 0, ml = config->ldrv, a->num_spans = 0; k < config->numldrv; ++k, ++ml)
|
||||
a->num_spans += ml->lparam.span_depth;
|
||||
|
||||
if ((a->span = (struct span_info *) malloc (a->num_spans * sizeof (*a->span))) == NULL)
|
||||
return "out of memory (spans)";
|
||||
memset (a->span, 0, a->num_spans * sizeof (*a->span));
|
||||
|
||||
/* Copy drive states. */
|
||||
for (k = 0; k < sizeof (enquiry3->pdrv_state) / sizeof (enquiry3->pdrv_state[0]); ++k)
|
||||
switch (enquiry3->pdrv_state[k] & 0xf)
|
||||
{
|
||||
case PDRV_UNCNF: a->physical[k].state = PdStateUnconfiguredGood; continue;
|
||||
case PDRV_ONLINE: a->physical[k].state = PdStateOnline; continue;
|
||||
case PDRV_FAILED: a->physical[k].state = PdStateFailed; continue;
|
||||
case PDRV_RBLD: a->physical[k].state = PdStateRebuild; continue;
|
||||
case PDRV_HOTSPARE: a->physical[k].state = PdStateHotspare; continue;
|
||||
default: a->physical[k].state = PdStateUnknown; continue;
|
||||
}
|
||||
|
||||
/* Copy drive sizes. */
|
||||
for (k = 0; k < sizeof (config->pdrv) / sizeof (config->pdrv[0]); ++k)
|
||||
a->physical[k].blocks = config->pdrv[k].size;
|
||||
|
||||
/* Copy drive predictive failures flag */
|
||||
for (k = 0; k < 8 * sizeof (a->q.v3.map.map) / sizeof (a->q.v3.map.map[0]); ++k)
|
||||
a->physical[k].predictive_failures = ((a->q.v3.map.map[k >> 3] & (1 << (k & 0x7))) != 0);
|
||||
|
||||
/* Examine all the logical drives. */
|
||||
for (k = 0, ml = config->ldrv, spanIndex = 0; k < config->numldrv; ++k, ++ml)
|
||||
{
|
||||
struct span_info *span;
|
||||
adap_span_40ld_t *mr;
|
||||
int j;
|
||||
struct logical_drive_info *l = &a->logical[k];
|
||||
|
||||
l->adapter = a;
|
||||
snprintf (l->name, sizeof (l->name), "a%ud%u", a->target.adapno, k);
|
||||
l->target = k;
|
||||
switch (ml->lparam.status)
|
||||
{
|
||||
case RDRV_OFFLINE: l->state = LdStateOffline; break;
|
||||
case RDRV_DEGRADED: l->state = LdStateDegraded; break;
|
||||
case RDRV_OPTIMAL: l->state = LdStateOptimal; break;
|
||||
case RDRV_DELETED: l->state = LdStateDeleted; break;
|
||||
default: l->state = LdStateUnknown; break;
|
||||
}
|
||||
l->raid_level = ml->lparam.level;
|
||||
l->span_size = ml->lparam.row_size;
|
||||
|
||||
l->num_spans = ml->lparam.span_depth;
|
||||
if ((l->span = (struct span_reference *) malloc (l->num_spans * sizeof (*l->span))) == NULL)
|
||||
return "out of memory (span references)";
|
||||
|
||||
for (j = 0, mr = ml->span; j < ml->lparam.span_depth; ++j, ++mr)
|
||||
{
|
||||
int i;
|
||||
|
||||
span = &a->span[spanIndex++];
|
||||
span->adapter = a;
|
||||
span->num_logical_drives = 1;
|
||||
if ((span->logical_drive = (struct logical_drive_info **) malloc (span->num_logical_drives * sizeof (*span->logical_drive))) == NULL)
|
||||
return "out of memory (span -> ldrv pointers)";
|
||||
span->logical_drive[0] = l;
|
||||
span->blocks_per_disk = mr->num_blks;
|
||||
span->num_disks = ml->lparam.row_size;
|
||||
if ((span->disk = (struct physical_drive_info **) malloc (span->num_disks * sizeof (*span->disk))) == NULL)
|
||||
return "out of memory (span -> disk pointers)";
|
||||
|
||||
/* Logical drives use the whole span. */
|
||||
l->span[j].offset = 0;
|
||||
l->span[j].blocks_per_disk = span->blocks_per_disk;
|
||||
l->span[j].span = span;
|
||||
|
||||
for (i = 0; i < span->num_disks; ++i)
|
||||
{
|
||||
span->disk[i] = &a->physical[mr->device[i].target];
|
||||
span->disk[i]->span = span;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Go ahead and hit all the other devices that have a non-zero scsi transfer rate. */
|
||||
for (k = 0; k < sizeof (a->q.v3.enquiry3.targ_xfer) / sizeof (a->q.v3.enquiry3.targ_xfer[0]); ++k)
|
||||
if (a->q.v3.enquiry3.targ_xfer[k])
|
||||
(void) getPhysicalDriveInfo (a, (uint8_t) k, 1);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int cmpChannel (const void *a, const void *b)
|
||||
{
|
||||
int x = (int) *((uint8_t *) a);
|
||||
int y = (int) *((uint8_t *) b);
|
||||
return x - y;
|
||||
}
|
||||
|
||||
/* Adapter handling for PERC5 adapters. */
|
||||
static char *getAdapterConfig5 (struct adapter_config *a)
|
||||
{
|
||||
int k;
|
||||
struct mega_array_span_def_sas *ms;
|
||||
struct mega_array_disk_def_sas *ml;
|
||||
struct megasas_ctrl_info *pinfo = &a->q.v5.adapinfo;
|
||||
struct mega_device_list_sas *device;
|
||||
struct mega_array_config_sas *config = &a->q.v5.config;
|
||||
|
||||
a->target.type = MEGA_ADAPTER_V5;
|
||||
|
||||
if (megaSasGetDeviceList (&a->target, &(a->q.v5.device)) < 0)
|
||||
return "cannot retrieve device list";
|
||||
device = a->q.v5.device;
|
||||
if (megaSasGetArrayConfig (&a->target, &(a->q.v5.config)) < 0)
|
||||
return "cannot retrieve array configuration";
|
||||
if (megaSasGetBatteryInfo (&a->target, &(a->q.v5.battery)) < 0)
|
||||
return "cannot retrieve battery info";
|
||||
|
||||
a->rebuild_rate = pinfo->properties.rebuild_rate;
|
||||
a->dram_size = pinfo->memory_size;
|
||||
|
||||
snprintf (a->name, sizeof (a->name), "a%u", a->target.adapno);
|
||||
strncpy (a->product, (char *) pinfo->product_name, sizeof (pinfo->product_name));
|
||||
a->product[sizeof (a->product) - 1] = '\0';
|
||||
ntrim (a->product);
|
||||
|
||||
for (k = 0; k < pinfo->image_component_count; ++k)
|
||||
{
|
||||
if (!strcmp (pinfo->image_component[k].name, "BIOS"))
|
||||
{
|
||||
strncpy (a->bios, pinfo->image_component[k].version, sizeof (a->bios));
|
||||
a->bios[sizeof (a->bios) - 1] = '\0';
|
||||
ntrim (a->bios);
|
||||
}
|
||||
else if (!strcmp (pinfo->image_component[k].name, "APP "))
|
||||
{
|
||||
strncpy (a->firmware, pinfo->image_component[k].version, sizeof (a->firmware));
|
||||
a->firmware[sizeof (a->firmware) - 1] = '\0';
|
||||
ntrim (a->firmware);
|
||||
}
|
||||
}
|
||||
|
||||
batteryStatus5 (a);
|
||||
|
||||
/* Build enclosure map. */
|
||||
for (k = 0, a->num_channels = 0, a->channel = NULL; k < device->num_devices; ++k)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; j < a->num_channels; ++j)
|
||||
if (device->device[k].enclosure == a->channel[j])
|
||||
break;
|
||||
if (j < a->num_channels)
|
||||
continue;
|
||||
|
||||
/* Didn't find this enclosure; extend the map */
|
||||
++a->num_channels;
|
||||
if ((a->channel = (uint8_t *) realloc (a->channel, a->num_channels * sizeof (*a->channel))) == NULL)
|
||||
return "out of memory (channels)";
|
||||
a->channel[a->num_channels - 1] = device->device[k].enclosure;
|
||||
}
|
||||
qsort (a->channel, a->num_channels, sizeof (*a->channel), cmpChannel);
|
||||
|
||||
a->num_physicals = pinfo->pd_present_count;
|
||||
if ((a->physical = (struct physical_drive_info *) malloc (a->num_physicals * sizeof (*a->physical))) == NULL)
|
||||
return "out of memory (physical drives)";
|
||||
memset (a->physical, 0, a->num_physicals * sizeof (*a->physical));
|
||||
if ((a->physical_list = (struct physical_drive_info **) malloc (a->num_physicals * sizeof (*a->physical_list))) == NULL)
|
||||
return "out of memory (physical drives)";
|
||||
memset (a->physical_list, 0, a->num_physicals * sizeof (*a->physical_list));
|
||||
|
||||
a->num_logicals = config->header->num_disk_defs;
|
||||
if ((a->logical = (struct logical_drive_info *) malloc (a->num_logicals * sizeof (*a->logical))) == NULL)
|
||||
return "out of memory (logical drives)";
|
||||
memset (a->logical, 0, a->num_logicals * sizeof (*a->logical));
|
||||
|
||||
a->num_spans = config->header->num_span_defs;
|
||||
if ((a->span = (struct span_info *) malloc (a->num_spans * sizeof (*a->span))) == NULL)
|
||||
return "out of memory (spans)";
|
||||
memset (a->span, 0, a->num_spans * sizeof (*a->span));
|
||||
|
||||
/* Get drive info. (This is fast on a PERC5.) */
|
||||
for (k = 0; k < device->num_devices; ++k)
|
||||
if ((device->device[k].type == INQ_DASD) && (getPhysicalDriveInfo (a, device->device[k].device_id, 1) == NULL))
|
||||
return "cannot get physical device info";
|
||||
|
||||
/* Examine all the spans. */
|
||||
for (k = 0, ms = config->span; k < config->header->num_span_defs; ++k, ++ms)
|
||||
{
|
||||
struct span_info *span = &a->span[k];
|
||||
int i;
|
||||
|
||||
span->adapter = a;
|
||||
span->num_logical_drives = 0;
|
||||
span->logical_drive = NULL;
|
||||
span->blocks_per_disk = ms->sectors_per_disk;
|
||||
span->num_disks = ms->span_size;
|
||||
if ((span->disk = (struct physical_drive_info **) malloc (span->num_disks * sizeof (*span->disk))) == NULL)
|
||||
return "out of memory (span -> disk pointers)";
|
||||
|
||||
for (i = 0; i < span->num_disks; ++i)
|
||||
{
|
||||
span->disk[i] = getPhysicalDriveInfo (a, ms->disk[i].device_id, 1);
|
||||
span->disk[i]->span = span;
|
||||
}
|
||||
}
|
||||
|
||||
/* Examine all the logical drives. */
|
||||
for (k = 0, ml = config->disk; k < config->header->num_disk_defs; ++k, ++ml)
|
||||
{
|
||||
struct span_info *span;
|
||||
struct mega_array_disk_entry_sas *mr;
|
||||
int j;
|
||||
struct logical_drive_info *l = &a->logical[k];
|
||||
|
||||
l->adapter = a;
|
||||
snprintf (l->name, sizeof (l->name), "a%ud%u", a->target.adapno, k);
|
||||
l->target = k;
|
||||
switch (ml->state)
|
||||
{
|
||||
case MEGA_SAS_LD_OFFLINE: l->state = LdStateOffline; break;
|
||||
case MEGA_SAS_LD_PARTIALLY_DEGRADED: l->state = LdStatePartiallyDegraded; break;
|
||||
case MEGA_SAS_LD_DEGRADED: l->state = LdStateDegraded; break;
|
||||
case MEGA_SAS_LD_OPTIMAL: l->state = LdStateOptimal; break;
|
||||
default: l->state = LdStateUnknown; break;
|
||||
}
|
||||
l->raid_level = ml->raid_level;
|
||||
l->span_size = ml->disks_per_span;
|
||||
|
||||
l->num_spans = ml->num_spans;
|
||||
if ((l->span = (struct span_reference *) malloc (l->num_spans * sizeof (*l->span))) == NULL)
|
||||
return "out of memory (span references)";
|
||||
|
||||
for (j = 0, mr = ml->span; j < ml->num_spans; ++j, ++mr)
|
||||
{
|
||||
span = &a->span[mr->span_index];
|
||||
++(span->num_logical_drives);
|
||||
if ((span->logical_drive = (struct logical_drive_info **) realloc (span->logical_drive, span->num_logical_drives * sizeof (*span->logical_drive))) == NULL)
|
||||
return "out of memory (span -> ldrv pointers)";
|
||||
span->logical_drive[span->num_logical_drives - 1] = l;
|
||||
|
||||
l->span[j].offset = mr->offset;
|
||||
l->span[j].blocks_per_disk = mr->sectors_per_disk;
|
||||
l->span[j].span = span;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
struct adapter_config *getAdapterConfig (int fd, uint8_t adapno, int sas)
|
||||
{
|
||||
static struct adapter_config *cf = NULL;
|
||||
struct adapter_config *a;
|
||||
char *status;
|
||||
|
||||
for (a = cf; a; a = a->next)
|
||||
if ((a->target.adapno == adapno) && (a->is_sas == sas))
|
||||
return a;
|
||||
|
||||
if ((a = (struct adapter_config *) malloc (sizeof (*a))) == NULL)
|
||||
return NULL;
|
||||
memset (a, 0, sizeof (*a));
|
||||
|
||||
a->target.fd = fd;
|
||||
a->target.adapno = adapno;
|
||||
a->is_sas = sas;
|
||||
|
||||
if (sas)
|
||||
{
|
||||
if (megaSasGetAdapterProductInfo (fd, adapno, &a->q.v5.adapinfo) < 0)
|
||||
return NULL;
|
||||
|
||||
status = getAdapterConfig5 (a);
|
||||
}
|
||||
else
|
||||
{
|
||||
mraid_pinfo_t pinfo;
|
||||
|
||||
if (megaGetAdapterProductInfo (fd, adapno, &pinfo) < 0)
|
||||
return NULL;
|
||||
|
||||
if (pinfo.data_size == 0)
|
||||
status = getAdapterConfig2 (a);
|
||||
else
|
||||
{
|
||||
a->q.v3.adapinfo = pinfo;
|
||||
status = getAdapterConfig3 (a);
|
||||
}
|
||||
}
|
||||
|
||||
if (status)
|
||||
{
|
||||
free (a);
|
||||
fprintf (stderr, "adapter %d: %s\n", adapno, status);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
a->next = cf;
|
||||
cf = a;
|
||||
|
||||
return a;
|
||||
}
|
34
src/adapter.h
Normal file
34
src/adapter.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef _ADAPTER_H
|
||||
#define _ADAPTER_H
|
||||
/*
|
||||
* Definitions for high-level adapter interface.
|
||||
*
|
||||
* Copyright (c) 2007 by Jefferson Ogata
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program |