2004-01-10 03:56:27 +03:00
|
|
|
/* $NetBSD: rf_raid.h,v 1.25 2004/01/10 00:56:28 oster Exp $ */
|
1998-11-13 07:20:26 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Carnegie-Mellon University.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Mark Holland
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**********************************************
|
|
|
|
* rf_raid.h -- main header file for RAID driver
|
|
|
|
**********************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _RF__RF_RAID_H_
|
|
|
|
#define _RF__RF_RAID_H_
|
|
|
|
|
2001-10-04 19:58:51 +04:00
|
|
|
#include <dev/raidframe/raidframevar.h>
|
1998-11-13 07:20:26 +03:00
|
|
|
#include "rf_archs.h"
|
|
|
|
#include "rf_threadstuff.h"
|
|
|
|
|
|
|
|
#include "rf_netbsd.h"
|
|
|
|
|
|
|
|
#include <sys/disklabel.h>
|
|
|
|
#include <sys/types.h>
|
2002-10-05 00:05:14 +04:00
|
|
|
#include <sys/queue.h>
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
#include "rf_alloclist.h"
|
|
|
|
#include "rf_stripelocks.h"
|
|
|
|
#include "rf_layout.h"
|
|
|
|
#include "rf_disks.h"
|
|
|
|
#include "rf_debugMem.h"
|
|
|
|
#include "rf_diskqueue.h"
|
|
|
|
#include "rf_reconstruct.h"
|
|
|
|
#include "rf_acctrace.h"
|
2002-10-05 00:05:14 +04:00
|
|
|
#include "rf_fifo.h"
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
#if RF_INCLUDE_PARITYLOGGING > 0
|
|
|
|
#include "rf_paritylog.h"
|
1999-02-05 03:06:06 +03:00
|
|
|
#endif /* RF_INCLUDE_PARITYLOGGING > 0 */
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2000-02-13 07:53:57 +03:00
|
|
|
#define RF_COMPONENT_LABEL_VERSION_1 1
|
|
|
|
#define RF_COMPONENT_LABEL_VERSION 2
|
1999-02-24 02:57:53 +03:00
|
|
|
#define RF_RAID_DIRTY 0
|
|
|
|
#define RF_RAID_CLEAN 1
|
|
|
|
|
|
|
|
|
1998-11-13 07:20:26 +03:00
|
|
|
/*
|
|
|
|
* Each row in the array is a distinct parity group, so
|
|
|
|
* each has it's own status, which is one of the following.
|
|
|
|
*/
|
|
|
|
typedef enum RF_RowStatus_e {
|
1999-02-05 03:06:06 +03:00
|
|
|
rf_rs_optimal,
|
|
|
|
rf_rs_degraded,
|
|
|
|
rf_rs_reconstructing,
|
|
|
|
rf_rs_reconfigured
|
|
|
|
} RF_RowStatus_t;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
struct RF_CumulativeStats_s {
|
1999-02-05 03:06:06 +03:00
|
|
|
struct timeval start; /* the time when the stats were last started */
|
|
|
|
struct timeval stop; /* the time when the stats were last stopped */
|
|
|
|
long sum_io_us; /* sum of all user response times (us) */
|
|
|
|
long num_ios; /* total number of I/Os serviced */
|
|
|
|
long num_sect_moved; /* total number of sectors read or written */
|
1998-11-13 07:20:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RF_ThroughputStats_s {
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_DECLARE_MUTEX(mutex) /* a mutex used to lock the configuration
|
|
|
|
* stuff */
|
|
|
|
struct timeval start; /* timer started when numOutstandingRequests
|
|
|
|
* moves from 0 to 1 */
|
|
|
|
struct timeval stop; /* timer stopped when numOutstandingRequests
|
|
|
|
* moves from 1 to 0 */
|
|
|
|
RF_uint64 sum_io_us; /* total time timer is enabled */
|
|
|
|
RF_uint64 num_ios; /* total number of ios processed by RAIDframe */
|
|
|
|
long num_out_ios; /* number of outstanding ios */
|
1998-11-13 07:20:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RF_Raid_s {
|
1999-02-05 03:06:06 +03:00
|
|
|
/* This portion never changes, and can be accessed without locking */
|
|
|
|
/* an exception is Disks[][].status, which requires locking when it is
|
1999-02-24 02:57:53 +03:00
|
|
|
* changed. XXX this is no longer true. numSpare and friends can
|
|
|
|
* change now.
|
|
|
|
*/
|
1999-02-05 03:06:06 +03:00
|
|
|
u_int numCol; /* number of columns of disks, typically == #
|
|
|
|
* of disks/rank */
|
|
|
|
u_int numSpare; /* number of spare disks */
|
|
|
|
int maxQueueDepth; /* max disk queue depth */
|
|
|
|
RF_SectorCount_t totalSectors; /* total number of sectors in the
|
|
|
|
* array */
|
|
|
|
RF_SectorCount_t sectorsPerDisk; /* number of sectors on each
|
|
|
|
* disk */
|
|
|
|
u_int logBytesPerSector; /* base-2 log of the number of bytes
|
|
|
|
* in a sector */
|
|
|
|
u_int bytesPerSector; /* bytes in a sector */
|
|
|
|
RF_int32 sectorMask; /* mask of bytes-per-sector */
|
|
|
|
|
|
|
|
RF_RaidLayout_t Layout; /* all information related to layout */
|
2003-12-29 05:38:17 +03:00
|
|
|
RF_RaidDisk_t *Disks; /* all information related to physical disks */
|
|
|
|
RF_DiskQueue_t *Queues;/* all information related to disk queues */
|
2003-02-09 13:04:32 +03:00
|
|
|
const RF_DiskQueueSW_t *qType;/* pointer to the DiskQueueSW used for the
|
2000-02-24 20:12:10 +03:00
|
|
|
component queues. */
|
1999-02-05 03:06:06 +03:00
|
|
|
/* NOTE: This is an anchor point via which the queues can be
|
|
|
|
* accessed, but the enqueue/dequeue routines in diskqueue.c use a
|
|
|
|
* local copy of this pointer for the actual accesses. */
|
|
|
|
/* The remainder of the structure can change, and therefore requires
|
|
|
|
* locking on reads and updates */
|
|
|
|
RF_DECLARE_MUTEX(mutex) /* mutex used to serialize access to
|
|
|
|
* the fields below */
|
2003-12-29 05:38:17 +03:00
|
|
|
RF_RowStatus_t status; /* the status of each row in the array */
|
1999-02-05 03:06:06 +03:00
|
|
|
int valid; /* indicates successful configuration */
|
|
|
|
RF_LockTableEntry_t *lockTable; /* stripe-lock table */
|
|
|
|
RF_LockTableEntry_t *quiesceLock; /* quiesnce table */
|
|
|
|
int numFailures; /* total number of failures in the array */
|
2000-02-23 06:44:02 +03:00
|
|
|
int numNewFailures; /* number of *new* failures (that havn't
|
|
|
|
caused a mod_counter update */
|
1999-03-02 06:18:48 +03:00
|
|
|
|
|
|
|
int parity_good; /* !0 if parity is known to be correct */
|
|
|
|
int serial_number; /* a "serial number" for this set */
|
|
|
|
int mod_counter; /* modification counter for component labels */
|
1999-02-24 02:57:53 +03:00
|
|
|
int clean; /* the clean bit for this array. */
|
1999-07-08 04:45:23 +04:00
|
|
|
|
|
|
|
int openings; /* Number of IO's which can be scheduled
|
|
|
|
simultaneously (high-level - not a
|
|
|
|
per-component limit)*/
|
|
|
|
|
2000-02-23 05:04:21 +03:00
|
|
|
int maxOutstanding; /* maxOutstanding requests (per-component) */
|
|
|
|
int autoconfigure; /* automatically configure this RAID set.
|
|
|
|
0 == no, 1 == yes */
|
|
|
|
int root_partition; /* Use this set as /
|
|
|
|
0 == no, 1 == yes*/
|
|
|
|
int last_unit; /* last unit number (e.g. 0 for /dev/raid0)
|
|
|
|
of this component. Used for autoconfigure
|
|
|
|
only. */
|
|
|
|
int config_order; /* 0 .. n. The order in which the component
|
|
|
|
should be auto-configured. E.g. 0 is will
|
|
|
|
done first, (and would become raid0).
|
|
|
|
This may be in conflict with last_unit!!?! */
|
|
|
|
/* Not currently used. */
|
|
|
|
|
2002-10-05 00:05:14 +04:00
|
|
|
/* queue to gather up requests from KernelWakeupFunc() and let
|
|
|
|
a kernel thread deal with calling rf_DiskIOComplete and any
|
|
|
|
callback functions. */
|
|
|
|
TAILQ_HEAD(iodone_q,RF_DiskQueueData_s) iodone;
|
|
|
|
/* and a lock to protect it */
|
|
|
|
struct simplelock iodone_lock;
|
|
|
|
|
2004-01-10 03:56:27 +03:00
|
|
|
/* DAG Node Pool - a pool that contains "arrays" of RF_DagNode_t's */
|
|
|
|
struct pool dag_node_pool;
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
/*
|
|
|
|
* Cleanup stuff
|
|
|
|
*/
|
|
|
|
RF_ShutdownList_t *shutdownList; /* shutdown activities */
|
|
|
|
RF_AllocListElem_t *cleanupList; /* memory to be freed at
|
|
|
|
* shutdown time */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Recon stuff
|
|
|
|
*/
|
|
|
|
RF_HeadSepLimit_t headSepLimit;
|
|
|
|
int numFloatingReconBufs;
|
|
|
|
int reconInProgress;
|
|
|
|
RF_DECLARE_COND(waitForReconCond)
|
|
|
|
RF_RaidReconDesc_t *reconDesc; /* reconstruction descriptor */
|
2003-12-29 05:38:17 +03:00
|
|
|
RF_ReconCtrl_t *reconControl; /* reconstruction control structure
|
1999-02-05 03:06:06 +03:00
|
|
|
* pointers for each row in the array */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Array-quiescence stuff
|
|
|
|
*/
|
|
|
|
RF_DECLARE_MUTEX(access_suspend_mutex)
|
|
|
|
RF_IoCount_t accesses_suspended;
|
|
|
|
RF_IoCount_t accs_in_flight;
|
|
|
|
int access_suspend_release;
|
|
|
|
int waiting_for_quiescence;
|
|
|
|
RF_CallbackDesc_t *quiesce_wait_list;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Statistics
|
|
|
|
*/
|
1999-01-26 05:33:49 +03:00
|
|
|
#if !defined(_KERNEL) && !defined(SIMULATE)
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ThroughputStats_t throughputstats;
|
|
|
|
#endif /* !KERNEL && !SIMULATE */
|
|
|
|
RF_CumulativeStats_t userstats;
|
2000-01-05 05:57:28 +03:00
|
|
|
int parity_rewrite_stripes_done;
|
|
|
|
int recon_stripes_done;
|
|
|
|
int copyback_stripes_done;
|
|
|
|
|
|
|
|
int recon_in_progress;
|
|
|
|
int parity_rewrite_in_progress;
|
|
|
|
int copyback_in_progress;
|
2002-10-22 07:15:28 +04:00
|
|
|
int adding_hot_spare;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Engine thread control
|
|
|
|
*/
|
|
|
|
RF_DECLARE_MUTEX(node_queue_mutex)
|
|
|
|
RF_DagNode_t *node_queue;
|
2000-01-05 05:57:28 +03:00
|
|
|
RF_Thread_t parity_rewrite_thread;
|
|
|
|
RF_Thread_t copyback_thread;
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_Thread_t engine_thread;
|
2002-10-05 00:05:14 +04:00
|
|
|
RF_Thread_t engine_helper_thread;
|
2000-01-05 05:57:28 +03:00
|
|
|
RF_Thread_t recon_thread;
|
1999-02-05 03:06:06 +03:00
|
|
|
int shutdown_engine;
|
2002-10-05 00:05:14 +04:00
|
|
|
int shutdown_raidio;
|
1999-02-05 03:06:06 +03:00
|
|
|
int dags_in_flight; /* debug */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PSS (Parity Stripe Status) stuff
|
|
|
|
*/
|
|
|
|
long pssTableSize;
|
2002-10-11 06:10:08 +04:00
|
|
|
struct pool pss_pool;
|
|
|
|
struct pool pss_issued_pool;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reconstruction stuff
|
|
|
|
*/
|
|
|
|
int procsInBufWait;
|
|
|
|
int numFullReconBuffers;
|
|
|
|
RF_AccTraceEntry_t *recon_tracerecs;
|
|
|
|
unsigned long accumXorTimeUs;
|
2003-12-29 08:58:34 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
/*
|
|
|
|
* nAccOutstanding, waitShutdown protected by desc freelist lock
|
|
|
|
* (This may seem strange, since that's a central serialization point
|
|
|
|
* for a per-array piece of data, but otherwise, it'd be an extra
|
|
|
|
* per-array lock, and that'd only be less efficient...)
|
|
|
|
*/
|
|
|
|
RF_DECLARE_COND(outstandingCond)
|
|
|
|
int waitShutdown;
|
|
|
|
int nAccOutstanding;
|
|
|
|
|
|
|
|
RF_DiskId_t **diskids;
|
|
|
|
|
|
|
|
int raidid;
|
|
|
|
RF_AccTotals_t acc_totals;
|
|
|
|
int keep_acc_totals;
|
|
|
|
|
2003-12-29 05:38:17 +03:00
|
|
|
struct raidcinfo *raid_cinfo; /* array of component info */
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
int terminate_disk_queues;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
*
|
|
|
|
* config-specific information should be moved
|
|
|
|
* somewhere else, or at least hung off this
|
|
|
|
* in some generic way
|
|
|
|
*/
|
2004-01-05 04:19:07 +03:00
|
|
|
#if RF_INCLUDE_CHAINDECLUSTER > 0
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
/* used by rf_compute_workload_shift */
|
2003-12-29 05:38:17 +03:00
|
|
|
RF_RowCol_t hist_diskreq[RF_MAXCOL];
|
2004-01-05 04:19:07 +03:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
/* used by declustering */
|
|
|
|
int noRotate;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
#if RF_INCLUDE_PARITYLOGGING > 0
|
1999-02-05 03:06:06 +03:00
|
|
|
/* used by parity logging */
|
|
|
|
RF_SectorCount_t regionLogCapacity;
|
|
|
|
RF_ParityLogQueue_t parityLogPool; /* pool of unused parity logs */
|
|
|
|
RF_RegionInfo_t *regionInfo; /* array of region state */
|
|
|
|
int numParityLogs;
|
|
|
|
int numSectorsPerLog;
|
|
|
|
int regionParityRange;
|
|
|
|
int logsInUse; /* debugging */
|
|
|
|
RF_ParityLogDiskQueue_t parityLogDiskQueue; /* state of parity
|
|
|
|
* logging disk work */
|
|
|
|
RF_RegionBufferQueue_t regionBufferPool; /* buffers for holding
|
|
|
|
* region log */
|
|
|
|
RF_RegionBufferQueue_t parityBufferPool; /* buffers for holding
|
|
|
|
* parity */
|
|
|
|
caddr_t parityLogBufferHeap; /* pool of unused parity logs */
|
|
|
|
RF_Thread_t pLogDiskThreadHandle;
|
|
|
|
|
|
|
|
#endif /* RF_INCLUDE_PARITYLOGGING > 0 */
|
1998-11-13 07:20:26 +03:00
|
|
|
};
|
1999-02-05 03:06:06 +03:00
|
|
|
#endif /* !_RF__RF_RAID_H_ */
|