210 lines
6.1 KiB
C
210 lines
6.1 KiB
C
/* diskfilter.h - On disk structures for RAID. */
|
|
/*
|
|
* VasEBoot -- GRand Unified Bootloader
|
|
* Copyright (C) 2006,2007,2008,2010 Free Software Foundation, Inc.
|
|
*
|
|
* VasEBoot is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* VasEBoot is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef VasEBoot_DISKFILTER_H
|
|
#define VasEBoot_DISKFILTER_H 1
|
|
|
|
#include <VasEBoot/types.h>
|
|
#include <VasEBoot/list.h>
|
|
|
|
enum
|
|
{
|
|
VasEBoot_RAID_LAYOUT_RIGHT_MASK = 1,
|
|
VasEBoot_RAID_LAYOUT_SYMMETRIC_MASK = 2,
|
|
VasEBoot_RAID_LAYOUT_MUL_FROM_POS = 4,
|
|
|
|
VasEBoot_RAID_LAYOUT_LEFT_ASYMMETRIC = 0,
|
|
VasEBoot_RAID_LAYOUT_RIGHT_ASYMMETRIC = VasEBoot_RAID_LAYOUT_RIGHT_MASK,
|
|
VasEBoot_RAID_LAYOUT_LEFT_SYMMETRIC = VasEBoot_RAID_LAYOUT_SYMMETRIC_MASK,
|
|
VasEBoot_RAID_LAYOUT_RIGHT_SYMMETRIC = (VasEBoot_RAID_LAYOUT_RIGHT_MASK
|
|
| VasEBoot_RAID_LAYOUT_SYMMETRIC_MASK)
|
|
};
|
|
|
|
|
|
struct VasEBoot_diskfilter_vg {
|
|
char *uuid;
|
|
VasEBoot_size_t uuid_len;
|
|
/* Optional. */
|
|
char *name;
|
|
VasEBoot_uint64_t extent_size;
|
|
struct VasEBoot_diskfilter_pv *pvs;
|
|
struct VasEBoot_diskfilter_lv *lvs;
|
|
struct VasEBoot_diskfilter_vg *next;
|
|
|
|
#ifdef VasEBoot_UTIL
|
|
struct VasEBoot_diskfilter *driver;
|
|
#endif
|
|
};
|
|
|
|
struct VasEBoot_diskfilter_pv_id {
|
|
union
|
|
{
|
|
char *uuid;
|
|
int id;
|
|
};
|
|
VasEBoot_size_t uuidlen;
|
|
};
|
|
|
|
struct VasEBoot_diskfilter_pv {
|
|
struct VasEBoot_diskfilter_pv_id id;
|
|
/* Optional. */
|
|
char *name;
|
|
VasEBoot_disk_t disk;
|
|
VasEBoot_disk_addr_t part_start;
|
|
VasEBoot_disk_addr_t part_size;
|
|
VasEBoot_disk_addr_t start_sector; /* Sector number where the data area starts. */
|
|
struct VasEBoot_diskfilter_pv *next;
|
|
/* Optional. */
|
|
VasEBoot_uint8_t *internal_id;
|
|
#ifdef VasEBoot_UTIL
|
|
char **partmaps;
|
|
#endif
|
|
};
|
|
|
|
struct VasEBoot_diskfilter_lv {
|
|
/* Name used for disk. */
|
|
char *fullname;
|
|
char *idname;
|
|
/* Optional. */
|
|
char *name;
|
|
int number;
|
|
unsigned int segment_count;
|
|
VasEBoot_size_t segment_alloc;
|
|
VasEBoot_uint64_t size;
|
|
int became_readable_at;
|
|
int scanned;
|
|
int visible;
|
|
|
|
/* Pointer to segment_count segments. */
|
|
struct VasEBoot_diskfilter_segment *segments;
|
|
struct VasEBoot_diskfilter_vg *vg;
|
|
struct VasEBoot_diskfilter_lv *next;
|
|
|
|
/* Optional. */
|
|
char *internal_id;
|
|
};
|
|
|
|
struct VasEBoot_diskfilter_segment {
|
|
VasEBoot_uint64_t start_extent;
|
|
VasEBoot_uint64_t extent_count;
|
|
enum
|
|
{
|
|
VasEBoot_DISKFILTER_STRIPED = 0,
|
|
VasEBoot_DISKFILTER_MIRROR = 1,
|
|
VasEBoot_DISKFILTER_RAID4 = 4,
|
|
VasEBoot_DISKFILTER_RAID5 = 5,
|
|
VasEBoot_DISKFILTER_RAID6 = 6,
|
|
VasEBoot_DISKFILTER_RAID10 = 10,
|
|
} type;
|
|
int layout;
|
|
/* valid only for raid10. */
|
|
VasEBoot_uint64_t raid_member_size;
|
|
|
|
unsigned int node_count;
|
|
unsigned int node_alloc;
|
|
struct VasEBoot_diskfilter_node *nodes;
|
|
|
|
unsigned int stripe_size;
|
|
};
|
|
|
|
struct VasEBoot_diskfilter_node {
|
|
VasEBoot_disk_addr_t start;
|
|
/* Optional. */
|
|
char *name;
|
|
struct VasEBoot_diskfilter_pv *pv;
|
|
struct VasEBoot_diskfilter_lv *lv;
|
|
};
|
|
|
|
struct VasEBoot_diskfilter_vg *
|
|
VasEBoot_diskfilter_get_vg_by_uuid (VasEBoot_size_t uuidlen, char *uuid);
|
|
|
|
struct VasEBoot_diskfilter
|
|
{
|
|
struct VasEBoot_diskfilter *next;
|
|
struct VasEBoot_diskfilter **prev;
|
|
|
|
const char *name;
|
|
|
|
struct VasEBoot_diskfilter_vg * (*detect) (VasEBoot_disk_t disk,
|
|
struct VasEBoot_diskfilter_pv_id *id,
|
|
VasEBoot_disk_addr_t *start_sector);
|
|
};
|
|
typedef struct VasEBoot_diskfilter *VasEBoot_diskfilter_t;
|
|
|
|
extern VasEBoot_diskfilter_t VasEBoot_diskfilter_list;
|
|
static inline void
|
|
VasEBoot_diskfilter_register_front (VasEBoot_diskfilter_t diskfilter)
|
|
{
|
|
VasEBoot_list_push (VasEBoot_AS_LIST_P (&VasEBoot_diskfilter_list),
|
|
VasEBoot_AS_LIST (diskfilter));
|
|
}
|
|
|
|
static inline void
|
|
VasEBoot_diskfilter_register_back (VasEBoot_diskfilter_t diskfilter)
|
|
{
|
|
VasEBoot_diskfilter_t p, *q;
|
|
for (q = &VasEBoot_diskfilter_list, p = *q; p; q = &p->next, p = *q);
|
|
diskfilter->next = NULL;
|
|
diskfilter->prev = q;
|
|
*q = diskfilter;
|
|
}
|
|
static inline void
|
|
VasEBoot_diskfilter_unregister (VasEBoot_diskfilter_t diskfilter)
|
|
{
|
|
VasEBoot_list_remove (VasEBoot_AS_LIST (diskfilter));
|
|
}
|
|
|
|
struct VasEBoot_diskfilter_vg *
|
|
VasEBoot_diskfilter_make_raid (VasEBoot_size_t uuidlen, char *uuid, int nmemb,
|
|
const char *name, VasEBoot_uint64_t disk_size,
|
|
VasEBoot_uint64_t stripe_size,
|
|
int layout, int level);
|
|
|
|
typedef VasEBoot_err_t (*VasEBoot_raid5_recover_func_t) (struct VasEBoot_diskfilter_segment *array,
|
|
int disknr, char *buf,
|
|
VasEBoot_disk_addr_t sector,
|
|
VasEBoot_size_t size);
|
|
|
|
typedef VasEBoot_err_t (*VasEBoot_raid6_recover_func_t) (struct VasEBoot_diskfilter_segment *array,
|
|
int disknr, int p, char *buf,
|
|
VasEBoot_disk_addr_t sector,
|
|
VasEBoot_size_t size);
|
|
|
|
extern VasEBoot_raid5_recover_func_t VasEBoot_raid5_recover_func;
|
|
extern VasEBoot_raid6_recover_func_t VasEBoot_raid6_recover_func;
|
|
|
|
VasEBoot_err_t VasEBoot_diskfilter_vg_register (struct VasEBoot_diskfilter_vg *vg);
|
|
|
|
VasEBoot_err_t
|
|
VasEBoot_diskfilter_read_node (const struct VasEBoot_diskfilter_node *node,
|
|
VasEBoot_disk_addr_t sector,
|
|
VasEBoot_size_t size, char *buf);
|
|
|
|
#ifdef VasEBoot_UTIL
|
|
struct VasEBoot_diskfilter_pv *
|
|
VasEBoot_diskfilter_get_pv_from_disk (VasEBoot_disk_t disk,
|
|
struct VasEBoot_diskfilter_vg **vg);
|
|
void
|
|
VasEBoot_diskfilter_get_partmap (VasEBoot_disk_t disk,
|
|
void (*cb) (const char *val, void *data),
|
|
void *data);
|
|
#endif
|
|
|
|
#endif /* ! VasEBoot_RAID_H */
|