1/* 2 * Copyright (c) 2001-2007 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23 24#ifndef _APPLERAIDMIRRORSET_H 25#define _APPLERAIDMIRRORSET_H 26 27#define kAppleRAIDLevelNameMirror "Mirror" 28 29#ifdef KERNEL 30 31class AppleRAIDMirrorSet : public AppleRAIDSet 32{ 33 OSDeclareDefaultStructors(AppleRAIDMirrorSet); 34 35 private: 36 UInt32 arExpectingLiveAdd; 37 thread_call_t arSetCompleteThreadCall; 38 39 UInt64 * arLastSeek; 40 UInt64 * arSkippedIOCount; 41 42 AppleRAIDMember * arRebuildingMember; 43 thread_call_t arRebuildThreadCall; 44 45 queue_head_t arFailedRequestQueue; 46 47 48 protected: 49 virtual bool init(void); 50 virtual bool initWithHeader(OSDictionary * header, bool firstTime); 51 virtual void free(); 52 53 virtual IOBufferMemoryDescriptor * readPrimaryMetaData(AppleRAIDMember * member); 54 virtual IOReturn writePrimaryMetaData(IOBufferMemoryDescriptor * primaryBuffer); 55 56 virtual void rebuildStart(void); 57 virtual void rebuild(void); 58 virtual void rebuildComplete(bool wasRebuilt); 59 60 virtual void getRecoverQueue(queue_head_t *oldRequestQueue, queue_head_t *newRequestQueue); 61 virtual bool recover(void); 62 63 virtual void startSetCompleteTimer(); 64 virtual void setCompleteTimeout(void); 65 66public: 67 static AppleRAIDSet * createRAIDSet(AppleRAIDMember * firstMember); 68 virtual bool addMember(AppleRAIDMember * member); 69 virtual bool removeMember(AppleRAIDMember * member, IOOptionBits options); 70 71 virtual bool resizeSet(UInt32 newMemberCount); 72 virtual bool startSet(void); 73 virtual bool publishSet(void); 74 75 virtual bool isSetComplete(void); 76 virtual bool bumpOnError(void); 77 virtual UInt32 nextSetState(void); 78 virtual OSDictionary * getSetProperties(void); 79 80 virtual void activeReadMembers(AppleRAIDMember ** activeMembers, UInt64 byteStart, UInt32 byteCount); 81 82 virtual void completeRAIDRequest(AppleRAIDStorageRequest *storageRequest); 83 84 virtual AppleRAIDMemoryDescriptor * allocateMemoryDescriptor(AppleRAIDStorageRequest *storageRequest, UInt32 memberIndex); 85}; 86 87 88 89class AppleRAIDMirrorMemoryDescriptor : public AppleRAIDMemoryDescriptor 90{ 91 OSDeclareDefaultStructors(AppleRAIDMirrorMemoryDescriptor); 92 93private: 94 UInt32 mdSetBlockSize; 95 UInt32 mdSetBlockStart; 96 UInt32 mdSetBlockOffset; 97 98protected: 99 virtual bool initWithStorageRequest(AppleRAIDStorageRequest *storageRequest, UInt32 memberIndex); 100 virtual bool configureForMemoryDescriptor(IOMemoryDescriptor *memoryDescriptor, UInt64 byteStart, UInt32 activeIndex); 101 102public: 103 static AppleRAIDMemoryDescriptor *withStorageRequest(AppleRAIDStorageRequest *storageRequest, UInt32 memberIndex); 104 virtual addr64_t getPhysicalSegment(IOByteCount offset, IOByteCount * length, IOOptionBits options = 0); 105}; 106 107#endif KERNEL 108 109#endif /* ! _APPLERAIDMIRRORSET_H */ 110