Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions sbin/raidctl/raidctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ static void rf_output_pmstat(int, int);
static void rf_pm_configure(int, int, char *, int[]);
static void rf_simple_create(int, int, char *[]);
static unsigned int xstrtouint(const char *);
static void rf_scrub_begin(int, int, char *[]);

int verbose;

Expand Down Expand Up @@ -141,8 +142,12 @@ main(int argc,char *argv[])
last_unit = 0;
openmode = O_RDWR; /* default to read/write */

if (argc > 5) {
/* we have at least 5 args, so it might be a simplified config */
if (argc > 5 || (argc > 2 && !strncmp(argv[2], "scrub", 5))) {

/*
* we have at least 5 args, so it might be a simplified config
* for cases where we will be doing scrubbing, args may be less than 5
*/

strlcpy(name, argv[1], sizeof(name));
fd = opendisk(name, openmode, dev_name, sizeof(dev_name), 0);
Expand All @@ -168,6 +173,8 @@ main(int argc,char *argv[])
strlcpy(autoconf, "yes", sizeof(autoconf));
set_autoconfig(fd, raidID, autoconf);

} else if (strncmp(argv[2], "scrub", 5) == 0) {
rf_scrub_begin(fd, argc-3, &argv[3]);
} else
usage();

Expand Down Expand Up @@ -435,7 +442,6 @@ do_ioctl(int fd, unsigned long command, void *arg, const char *ioctl_name)
err(1, "ioctl (%s) failed", ioctl_name);
}


static void
rf_configure(int fd, char *config_file, int force)
{
Expand Down Expand Up @@ -1227,6 +1233,41 @@ get_time_string(char *string, size_t len, int simple_time)

}

static void
rf_scrub_begin(int fd, int argc, char *argv[])
{
int rate;
int portion;
RF_Scrub_t scrb;
RF_ComponentLabel_t label;
/* initialize default values for scrubbing */
scrb.rate = 2;
scrb.portion = 100;

for (int i = 0; i < argc; i++)
{
if (strcmp(argv[i], "rate" == 0)) {
rate = atoi(argv[++i]);
scrb.rate = rate;
}
else if (strcmp(argv[i], "portion" == 0)) {
portion = atoi(argv[++i]);
if (portion > 100)
errx(1, "scrubbing portion should not be more than 100 percent");
}
}

memset(&label, 0, sizeof(label));
do_ioctl(fd, RAIDFRAME_GET_COMPONENT_LABEL, &label,
"RAIDFRAME_GET_COMPONENT_LABEL");

scrb.level = label.parityConfig;

do_ioctl(fd, RAIDFRAME_COMPONENT_SCRUB, &scrb,
"RAIDFRAME_COMPONENT_SCRUB");

}

/* Simplified RAID creation with a single command line... */
static void
rf_simple_create(int fd, int argc, char *argv[])
Expand Down
1 change: 1 addition & 0 deletions sys/dev/raidframe/raidframeio.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,6 @@
#define RAIDFRAME_GET_INFO _IOWR('r', 42, RF_DeviceConfig_t *) /* get configuration */
#define RAIDFRAME_CONFIGURE _IOW ('r', 43, void *) /* configure the driver */
#define RAIDFRAME_RESCAN _IO ('r', 44)
#define RAIDFRAME_COMPONENT_SCRUB _IOW('r', 45, RF_Scrub_t *)
#endif /* !_RF_RAIDFRAMEIO_H_ */

10 changes: 9 additions & 1 deletion sys/dev/raidframe/raidframevar.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ typedef struct RF_CallbackValueDesc_s RF_CallbackValueDesc_t;
typedef struct RF_ChunkDesc_s RF_ChunkDesc_t;
typedef struct RF_CommonLogData_s RF_CommonLogData_t;
typedef struct RF_Config_s RF_Config_t;
typedef struct RF_Scrub_s RF_Scrub_t;
typedef struct RF_CumulativeStats_s RF_CumulativeStats_t;
typedef struct RF_DagHeader_s RF_DagHeader_t;
typedef struct RF_DagList_s RF_DagList_t;
Expand Down Expand Up @@ -351,6 +352,13 @@ struct RF_Config_s {
*/
};

/* introduce a scrub components containing scrub rate and portion to scrub */
struct RF_Scrub_s {
int rate;
int portion;
int level; /* parityConfig from config*/
}

typedef RF_uint32 RF_ReconReqFlags_t;
/* flags that can be put in the rf_recon_req structure */
#define RF_FDFLAGS_NONE 0x0 /* just fail the disk */
Expand Down Expand Up @@ -386,7 +394,7 @@ enum RF_DiskStatus_e {
rf_ds_reconstructing, /* reconstruction ongoing */
rf_ds_dist_spared, /* reconstruction complete to distributed
* spare space, dead disk not yet replaced */
rf_ds_spared, /* reconstruction complete, dead disk not
rf_ds_spared, /* reconstruction complete, dead disk not
yet replaced */
rf_ds_spare, /* an available spare disk */
rf_ds_used_spare, /* a spare which has been used, and hence is
Expand Down
14 changes: 8 additions & 6 deletions sys/dev/raidframe/rf_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ __KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.144 2024/09/19 06:13:03 andvar Exp $
/* main configuration routines */
static int raidframe_booted = 0;

/* RAID scrubbing starting*/

static void rf_ConfigureDebug(RF_Config_t * cfgPtr);
static void set_debug_option(char *name, long val);
static void rf_UnconfigureArray(void);
Expand Down Expand Up @@ -361,7 +363,7 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac)
DO_RAID_INIT_CONFIGURE(rf_ConfigureReconstruction);
DO_RAID_INIT_CONFIGURE(rf_ConfigureDiskQueueSystem);
DO_RAID_INIT_CONFIGURE(rf_ConfigurePSStatus);

DO_RAID_INIT_CONFIGURE(rf_ConfigureEngine);
DO_RAID_INIT_CONFIGURE(rf_ConfigureStripeLocks);

Expand All @@ -384,8 +386,8 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr, RF_AutoConfig_t *ac)
DO_RAID_INIT_CONFIGURE(rf_ConfigureLayout);




/* Initialize per-RAID PSS bits */
rf_InitPSStatus(raidPtr);

Expand Down Expand Up @@ -560,7 +562,7 @@ rf_ShutdownRDFreeList(void *arg)
RF_Raid_t *raidPtr;

raidPtr = (RF_Raid_t *) arg;

pool_destroy(&raidPtr->pools.rad);
}

Expand Down Expand Up @@ -706,9 +708,9 @@ rf_DoAccess(RF_Raid_t * raidPtr, RF_IoType_t type, RF_RaidAddr_t raidAddress, RF
RF_ETIMER_START(desc->tracerec.tot_timer);
#endif

if (raidPtr->parity_map != NULL &&
if (raidPtr->parity_map != NULL &&
type == RF_IO_TYPE_WRITE)
rf_paritymap_begin(raidPtr->parity_map, raidAddress,
rf_paritymap_begin(raidPtr->parity_map, raidAddress,
numBlocks);

rf_ContinueRaidAccess(desc);
Expand Down
3 changes: 3 additions & 0 deletions sys/dev/raidframe/rf_netbsdkintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,9 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
return retcode;
return rf_construct(rs, k_cfg);

case RAIDFRAME_COMPONENT_SCRUB:
/* think about kernel later */

/* shutdown the system */
case RAIDFRAME_SHUTDOWN:

Expand Down