From bd526cee922b8e2b279f04ca067f729e9b0ee723 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 20 May 2002 11:17:18 +0000 Subject: [PATCH] mdadm-1.0.1 --- ChangeLog | 7 ++++++- Examine.c | 30 +++++++++++++++++++++++++++++- ReadMe.c | 4 +++- mdadm.8 | 7 ++++++- mdadm.c | 17 ++++++++++++++++- mdadm.h | 2 +- mdadm.spec | 2 +- util.c | 14 +++++++------- 8 files changed, 69 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5ed49fd..43adfa24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -Changes Prior to 1.0.0 reease +Changes Prior to this release + - Round off MB/GiB etc values instead of round down. + - Add --sparc2.2 option to examine to shift superblock around + and --sparc2.2update to rewrite the superblock + +Changes Prior to 1.0.0 release - Allow --config with Misc mode (for --examine --scan) - Add $(CXFLAGS) to end of CFLAGS in makefile - When making an N disk raid5 array, the Nth drive diff --git a/Examine.c b/Examine.c index 2bc3806a..b886afc2 100644 --- a/Examine.c +++ b/Examine.c @@ -35,7 +35,7 @@ #endif #include "md_u.h" #include "md_p.h" -int Examine(mddev_dev_t devlist, int brief, int scan) +int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust) { /* Read the raid superblock from a device and @@ -162,6 +162,17 @@ int Examine(mddev_dev_t devlist, int brief, int scan) printf(" Checksum : %x - correct\n", super.sb_csum); else printf(" Checksum : %x - expected %x\n", super.sb_csum, calc_sb_csum(&super)); + if (SparcAdjust) { + /* 2.2 sparc put the events in the wrong place + * So we copy the tail of the superblock + * up 4 bytes before continuing + */ + __u32 *sb32 = (__u32*)&super; + memcpy(sb32+MD_SB_GENERIC_CONSTANT_WORDS+7, + sb32+MD_SB_GENERIC_CONSTANT_WORDS+7+1, + MD_SB_WORDS - (MD_SB_GENERIC_CONSTANT_WORDS+7+1)); + printf (" --- adjusting superblock for 2.2/sparc compatability ---\n"); + } printf(" Events : %d.%d\n", super.events_hi, super.events_lo); printf("\n"); if (super.level == 5) { @@ -199,6 +210,23 @@ int Examine(mddev_dev_t devlist, int brief, int scan) printf("\n"); } } + if (SparcAdjust == 2) { + printf(" ----- updating superblock on device ----\n"); + fd = open(devlist->devname, O_RDWR); + if (fd < 0) { + fprintf(stderr, Name ": cannot open %s to update superblock: %s\n", + devlist->devname, strerror(errno)); + err = 1; + } else { + super.sb_csum = calc_sb_csum(&super); + if (store_super(fd, &super)) { + fprintf(stderr, Name ": Count not re-write superblock on %s\n", + devlist->devname); + err = 1; + } + close(fd); + } + } } if (brief) { struct array *ap; diff --git a/ReadMe.c b/ReadMe.c index afb26d2f..5c67eeba 100644 --- a/ReadMe.c +++ b/ReadMe.c @@ -29,7 +29,7 @@ #include "mdadm.h" -char Version[] = Name " - v1.0.0 - 10 May 2002\n"; +char Version[] = Name " - v1.0.1 - 20 May 2002\n"; /* * File: ReadMe.c * @@ -138,6 +138,8 @@ struct option long_options[] = { /* For Detail/Examine */ {"brief", 0, 0, 'b'}, + {"sparc2.2", 0, 0, 22}, + {"sparc2.2update", 0, 0, 23}, /* For Follow/monitor */ {"mail", 1, 0, 'm'}, diff --git a/mdadm.8 b/mdadm.8 index 2d45ff01..a64ae656 100644 --- a/mdadm.8 +++ b/mdadm.8 @@ -594,9 +594,14 @@ is given, then any other md devices that appear in will also be monitored. The result of monitoring the arrays is the generation of events. -These events are passed to a separate program (is specified) and may +These events are passed to a separate program (if specified) and may be mailed to a given E-mail address. +When passing event to program, the program is run once for each event +and is given 2 or 3 command-line arguements. The first is the +name of the event (see below). The second is the name of the +md device which is affected, and the third is the name of a related +device if relevant, such as a component device that has failed. If .B --scan diff --git a/mdadm.c b/mdadm.c index b01af945..95e7005a 100644 --- a/mdadm.c +++ b/mdadm.c @@ -69,6 +69,7 @@ int main(int argc, char *argv[]) char devmode = 0; int runstop = 0; int readonly = 0; + int SparcAdjust = 0; mddev_dev_t devlist = NULL; mddev_dev_t *devlistend = & devlist; mddev_dev_t dv; @@ -481,6 +482,20 @@ int main(int argc, char *argv[]) devmode = opt; continue; + case O(MISC, 22): + if (devmode != 'E') { + fprintf(stderr, Name ": --sparc2.2 only allowed with --examine\n"); + exit(2); + } + SparcAdjust = 1; + continue; + case O(MISC,23): + if (devmode != 'E') { + fprintf(stderr, Name ": --sparc2.2update only allowed with --examine\n"); + exit(2); + } + SparcAdjust = 2; + continue; } /* We have now processed all the valid options. Anything else is * an error @@ -596,7 +611,7 @@ int main(int argc, char *argv[]) fprintf(stderr, Name ": No devices listed in %s\n", configfile?configfile:DefaultConfFile); exit(1); } - rv = Examine(devlist, scan?!verbose:brief, scan); + rv = Examine(devlist, scan?!verbose:brief, scan, SparcAdjust); } else { if (devlist == NULL) { if ((devmode == 'S' ||devmode=='D') && scan) { diff --git a/mdadm.h b/mdadm.h index a44ce950..50860ed5 100644 --- a/mdadm.h +++ b/mdadm.h @@ -164,7 +164,7 @@ extern int Create(char *mddev, int mdfd, extern int Detail(char *dev, int brief); extern int Query(char *dev); -extern int Examine(mddev_dev_t devlist, int brief, int scan); +extern int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust); extern int Monitor(mddev_dev_t devlist, char *mailaddr, char *alert_cmd, int period, int scan, diff --git a/mdadm.spec b/mdadm.spec index fffd1888..04d6ec26 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,6 +1,6 @@ Summary: mdadm is used for controlling Linux md devices (aka RAID arrays) Name: mdadm -Version: 1.0.0 +Version: 1.0.1 Release: 1 Source: http://www.cse.unsw.edu.au/~neilb/source/mdadm/mdadm-%{version}.tgz URL: http://www.cse.unsw.edu.au/~neilb/source/mdadm/ diff --git a/util.c b/util.c index f818eabc..f2d16be1 100644 --- a/util.c +++ b/util.c @@ -437,16 +437,16 @@ char *human_size(long long bytes) else if (bytes < 2*1024LL*1024LL*1024LL) sprintf(buf, " (%ld.%02ld MiB %ld.%02ld MB)", (long)(bytes>>20), - (long)(bytes&0xfffff)/(0x100000/100), + (long)((bytes&0xfffff)+0x100000/200)/(0x100000/100), (long)(bytes/1000/1000), - (long)((bytes%1000000)/10000) + (long)(((bytes%1000000)+5000)/10000) ); else sprintf(buf, " (%ld.%02ld GiB %ld.%02ld GB)", (long)(bytes>>30), - (long)((bytes>>10)&0xfffff)/(0x100000/100), + (long)(((bytes>>10)&0xfffff)+0x100000/200)/(0x100000/100), (long)(bytes/1000LL/1000LL/1000LL), - (long)(((bytes/1000)%1000000)/10000) + (long)((((bytes/1000)%1000000)+50000)/10000) ); return buf; } @@ -458,17 +458,17 @@ char *human_size_brief(long long bytes) if (bytes < 5000*1024) sprintf(buf, "%ld.%02ldKiB", - (long)(bytes>>10), (long)((bytes&1023)*100/1024) + (long)(bytes>>10), (long)(((bytes&1023)*100+512)/1024) ); else if (bytes < 2*1024LL*1024LL*1024LL) sprintf(buf, "%ld.%02ldMiB", (long)(bytes>>20), - (long)(bytes&0xfffff)/(0x100000/100) + (long)((bytes&0xfffff)+0x100000/200)/(0x100000/100) ); else sprintf(buf, "%ld.%02ldGiB", (long)(bytes>>30), - (long)((bytes>>10)&0xfffff)/(0x100000/100) + (long)(((bytes>>10)&0xfffff)+0x100000/200)/(0x100000/100) ); return buf; } -- 2.39.2