diff -crN linux/mdctl-0.4.2.virgin/Makefile mdctl/Makefile *** linux/mdctl-0.4.2.virgin/Makefile Wed Jul 25 22:13:32 2001 --- mdctl/Makefile Mon Aug 13 16:22:52 2001 *************** *** 29,35 **** CFLAGS = -Wall,error,strict-prototypes -ggdb ! OBJS = mdctl.o config.o ReadMe.o util.o Manage.o Assemble.o Build.o Create.o Detail.o Examine.o dlink.o all : mdctl mdctl : $(OBJS) --- 29,36 ---- CFLAGS = -Wall,error,strict-prototypes -ggdb ! OBJS = mdctl.o config.o ReadMe.o util.o Manage.o Assemble.o Build.o \ ! Create.o Detail.o Examine.o Verify.o dlink.o all : mdctl mdctl : $(OBJS) diff -crN linux/mdctl-0.4.2.virgin/ReadMe.c mdctl/ReadMe.c *** linux/mdctl-0.4.2.virgin/ReadMe.c Thu Jul 26 14:47:15 2001 --- mdctl/ReadMe.c Wed Sep 5 17:13:53 2001 *************** *** 78,84 **** * command, subsequent Manage commands can finish the job. */ ! char short_options[]="-ABCDEhVvc:l:p:n:x:u:c:z:sarfRSow"; struct option long_options[] = { {"manage", 0, 0, '@'}, {"assemble", 0, 0, 'A'}, --- 78,84 ---- * command, subsequent Manage commands can finish the job. */ ! char short_options[]="-ABCDEhQVvc:l:p:n:x:u:c:z:sarfRSow"; struct option long_options[] = { {"manage", 0, 0, '@'}, {"assemble", 0, 0, 'A'}, *************** *** 86,91 **** --- 86,92 ---- {"create", 0, 0, 'C'}, {"detail", 0, 0, 'D'}, {"examine", 0, 0, 'E'}, + {"verify", 0, 0, 'Q'}, /* after those will normally come the name of the md device */ {"help", 0, 0, 'h'}, {"version", 0, 0, 'V'}, *************** *** 115,121 **** {"stop", 0, 0, 'S'}, {"readonly", 0, 0, 'o'}, {"readwrite", 0, 0, 'w'}, ! {0, 0, 0, 0} }; --- 116,125 ---- {"stop", 0, 0, 'S'}, {"readonly", 0, 0, 'o'}, {"readwrite", 0, 0, 'w'}, ! /* For Verify */ ! {"fix-defects",0, 0, 'f'}, ! {"wait-verify",0, 0, 'w'}, ! {0, 0, 0, 0} }; *************** *** 145,150 **** --- 149,155 ---- " --build -B : Build a legacy array without superblock\n" " --detail -D : Print detail of a given md array\n" " --examine -E : Print content of md superblock on device\n" + " --verify -Q : Verify contents of a RAID-1, 4 or 5 array\n" " --help -h : This help message or, after above option,\n" " mode specific help message\n" " --version -V : Print version information for mdctl\n" *************** *** 166,171 **** --- 171,180 ---- " --config= -c : config file\n" " --scan -s : scan config file for missing information\n" " --force -f : Assemble the array even if some superblocks appear out-of-date\n" + "\n" + " For verify:\n" + " --fix-defects -f : Fix defects found in a verify run\n" + " --wait-verify -w : Wait for verify to complete\n" "\n" " General management:\n" " --add -a : add, or hotadd subsequent devices\n" diff -crN linux/mdctl-0.4.2.virgin/Verify.c mdctl/Verify.c *** linux/mdctl-0.4.2.virgin/Verify.c Wed Dec 31 17:00:00 1969 --- mdctl/Verify.c Wed Sep 12 17:47:23 2001 *************** *** 0 **** --- 1,81 ---- + /* + * Copyright (c) 2001 Adaptec Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + #include "mdctl.h" + #include "md_u.h" + + int + Verify(char *mddev, int md_fd, int fix_defects, int wait_for_completion) + { + struct mdu_verify_s verify_info; + int retval; + + retval = 0; + + if (fix_defects) + verify_info.type = MDU_VERIFY_AND_FIX; + else + verify_info.type = MDU_VERIFY_SIMPLE; + + /* + * We currently don't give the user the option of waiting for + * the verify to start. + */ + if (wait_for_completion) + verify_info.flags = MDU_VF_WAIT_DONE; + else + verify_info.flags = MDU_VF_NONE; + + if (ioctl(md_fd, VERIFY_ARRAY, &verify_info) == -1) { + fprintf(stderr, Name ": VERIFY_ARRAY ioctl failed: %s\n", + strerror(errno)); + retval = 1; + goto bailout; + } + + if (wait_for_completion) { + fprintf(stdout, "%s: found %lu defects, fixed %lu defects\n", + mddev, verify_info.num_defects, + verify_info.num_defects_fixed); + } + + bailout: + + close(md_fd); + + return (retval); + } diff -crN linux/mdctl-0.4.2.virgin/md_u.h mdctl/md_u.h *** linux/mdctl-0.4.2.virgin/md_u.h Thu May 31 23:45:50 2001 --- mdctl/md_u.h Mon Sep 10 17:10:28 2001 *************** *** 42,47 **** --- 42,48 ---- #define STOP_ARRAY _IO (MD_MAJOR, 0x32) #define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33) #define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34) + #define VERIFY_ARRAY _IOWR (MD_MAJOR, 0x35, mdu_verify_t) typedef struct mdu_version_s { int major; *************** *** 111,116 **** --- 112,136 ---- int chunk_size; /* in bytes */ int max_fault; /* unused for now */ } mdu_param_t; + + typedef enum { + MDU_VERIFY_SIMPLE = 0x00, + MDU_VERIFY_AND_FIX = 0x01, + MDU_VERIFY_MAXVAL = 0x02 + } mdu_verify_type; + + typedef enum { + MDU_VF_NONE = 0x00, + MDU_VF_WAIT_START = 0x01, + MDU_VF_WAIT_DONE = 0x02 + } mdu_verify_flags; + + typedef struct mdu_verify_s { + mdu_verify_type type; + mdu_verify_flags flags; + unsigned long num_defects; + unsigned long num_defects_fixed; + } mdu_verify_t; #endif diff -crN linux/mdctl-0.4.2.virgin/mdctl.c mdctl/mdctl.c *** linux/mdctl-0.4.2.virgin/mdctl.c Thu Jul 26 00:11:19 2001 --- mdctl/mdctl.c Wed Sep 5 17:12:53 2001 *************** *** 58,63 **** --- 58,64 ---- int subdevs = 0; int verbose = 0; int force = 0; + int fix_defects = 0, wait_verify = 0; int mdfd = -1; *************** *** 72,77 **** --- 73,79 ---- case 'C': case 'D': case 'E': + case 'Q': /* setting mode - only once */ if (mode) { fprintf(stderr, Name ": --%s/-%c not allowed, mode already set to %s\n", *************** *** 324,330 **** --- 326,340 ---- } readonly = -1; continue; + + case O('Q','f'): + fix_defects = 1; + continue; + case O('Q','w'): + wait_verify = 1; + continue; } + /* We have now processed all the valid options. Anything else is * an error */ *************** *** 398,403 **** --- 408,416 ---- case 'E': /* Examine */ for (i=0; i