geom_vinum_raid5.h revision 139778
1139778Simp/*- 2130389Sle * Copyright (c) 2004 Lukas Ertl 3130389Sle * All rights reserved. 4130389Sle * 5130389Sle * Redistribution and use in source and binary forms, with or without 6130389Sle * modification, are permitted provided that the following conditions 7130389Sle * are met: 8130389Sle * 1. Redistributions of source code must retain the above copyright 9130389Sle * notice, this list of conditions and the following disclaimer. 10130389Sle * 2. Redistributions in binary form must reproduce the above copyright 11130389Sle * notice, this list of conditions and the following disclaimer in the 12130389Sle * documentation and/or other materials provided with the distribution. 13130389Sle * 14130389Sle * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15130389Sle * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16130389Sle * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17130389Sle * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18130389Sle * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19130389Sle * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20130389Sle * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21130389Sle * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22130389Sle * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23130389Sle * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24130389Sle * SUCH DAMAGE. 25130389Sle * 26130389Sle * $FreeBSD: head/sys/geom/vinum/geom_vinum_raid5.h 139778 2005-01-06 18:27:30Z imp $ 27130389Sle */ 28130389Sle 29130389Sle#ifndef _GEOM_VINUM_RAID5_H_ 30130389Sle#define _GEOM_VINUM_RAID5_H_ 31130389Sle 32130389Sle/* 33130389Sle * A single RAID5 request usually needs more than one I/O transaction, 34130389Sle * depending on the state of the associated subdisks and the direction of the 35135426Sle * transaction (read or write). 36130389Sle */ 37130389Sle 38135426Sle#define GV_ENQUEUE(bp, cbp, pbp) \ 39135426Sle do { \ 40135426Sle if (bp->bio_driver1 == NULL) { \ 41135426Sle bp->bio_driver1 = cbp; \ 42135426Sle } else { \ 43135426Sle pbp = bp->bio_driver1; \ 44135426Sle while (pbp->bio_caller1 != NULL) \ 45135426Sle pbp = pbp->bio_caller1; \ 46135426Sle pbp->bio_caller1 = cbp; \ 47135426Sle } \ 48135426Sle } while (0); 49130389Sle 50130389Slestruct gv_raid5_packet { 51135426Sle caddr_t data; /* Data buffer of this sub-request- */ 52130389Sle off_t length; /* Size of data buffer. */ 53130389Sle off_t lockbase; /* Deny access to our plex offset. */ 54130389Sle off_t offset; /* The drive offset of the subdisk. */ 55130389Sle int bufmalloc; /* Flag if data buffer was malloced. */ 56130389Sle int active; /* Count of active subrequests. */ 57130389Sle int rqcount; /* Count of subrequests. */ 58130389Sle 59130389Sle struct bio *bio; /* Pointer to the original bio. */ 60135426Sle struct bio *parity; /* The bio containing the parity data. */ 61135426Sle struct bio *waiting; /* A bio that need to wait for other bios. */ 62130389Sle 63135426Sle TAILQ_HEAD(,gv_bioq) bits; /* List of subrequests. */ 64135426Sle TAILQ_ENTRY(gv_raid5_packet) list; /* Entry in plex's packet list. */ 65130389Sle}; 66130389Sle 67135426Sleint gv_stripe_active(struct gv_plex *, struct bio *); 68135426Sleint gv_build_raid5_req(struct gv_plex *, struct gv_raid5_packet *, 69135426Sle struct bio *, caddr_t, off_t, off_t); 70138110Sleint gv_check_raid5(struct gv_plex *, struct gv_raid5_packet *, 71138110Sle struct bio *, caddr_t, off_t, off_t); 72135966Sleint gv_rebuild_raid5(struct gv_plex *, struct gv_raid5_packet *, 73135966Sle struct bio *, caddr_t, off_t, off_t); 74130389Slevoid gv_raid5_worker(void *); 75135426Slevoid gv_plex_done(struct bio *); 76130389Sle 77130389Sle#endif /* !_GEOM_VINUM_RAID5_H_ */ 78