} *dlist, *add_list;
};
-#ifndef MDASSEMBLE
static int load_super_ddf_all(struct supertype *st, int fd,
void **sbp, char *devname);
static int get_svd_state(const struct ddf_super *, const struct vcl *);
unsigned long long data_offset,
char *dev, unsigned long long *freesize,
int verbose);
-#endif
static void free_super_ddf(struct supertype *st);
static int all_ff(const char *guid);
sec_elmnt_count = array->raid_disks / 2;
srl = DDF_2SPANNED;
prl = DDF_RAID1;
- } else if (array->raid_disks % 3 == 0
- && array->layout == 0x103) {
+ } else if (array->raid_disks % 3 == 0 &&
+ array->layout == 0x103) {
rlq = DDF_RAID1_MULTI;
prim_elmnt_count = cpu_to_be16(3);
sec_elmnt_count = array->raid_disks / 3;
int dofree = (buf == NULL);
if (check)
- if (len != 2 && len != 8 && len != 32
- && len != 128 && len != 512)
+ if (len != 2 && len != 8 && len != 32 &&
+ len != 128 && len != 512)
return NULL;
if (len > 1024)
if (load_ddf_header(fd, be64_to_cpu(super->anchor.secondary_lba),
dsize >> 9, 2,
&super->secondary, &super->anchor)) {
- if (super->active == NULL
- || (be32_to_cpu(super->primary.seq)
- < be32_to_cpu(super->secondary.seq) &&
- !super->secondary.openflag)
- || (be32_to_cpu(super->primary.seq)
- == be32_to_cpu(super->secondary.seq) &&
- super->primary.openflag && !super->secondary.openflag)
- )
+ if (super->active == NULL ||
+ (be32_to_cpu(super->primary.seq)
+ < be32_to_cpu(super->secondary.seq) &&
+ !super->secondary.openflag) ||
+ (be32_to_cpu(super->primary.seq) ==
+ be32_to_cpu(super->secondary.seq) &&
+ super->primary.openflag && !super->secondary.openflag))
super->active = &super->secondary;
} else if (devname &&
be64_to_cpu(super->anchor.secondary_lba) != ~(__u64)0)
return st;
}
-#ifndef MDASSEMBLE
-
static mapping_t ddf_state[] = {
{ "Optimal", 0},
{ "Degraded", 1},
{ "Spanned", DDF_2SPANNED},
{ NULL, 0}
};
-#endif
static int all_ff(const char *guid)
{
return (const char *) buf;
}
-#ifndef MDASSEMBLE
static void print_guid(char *guid, int tstamp)
{
/* A GUIDs are part (or all) ASCII and part binary.
struct ddf_super *sb = st->sb;
int cnt = be16_to_cpu(sb->virt->populated_vdes);
- printf(" Container GUID : "); print_guid(sb->anchor.guid, 1);
+ printf(" Container GUID : "); print_guid(sb->anchor.guid, 1);
printf("\n");
- printf(" Seq : %08x\n", be32_to_cpu(sb->active->seq));
- printf(" Virtual Disks : %d\n", cnt);
+ printf(" Seq : %08x\n", be32_to_cpu(sb->active->seq));
+ printf(" Virtual Disks : %d\n", cnt);
printf("\n");
}
-#endif
static const char *vendors_with_variable_volume_UUID[] = {
"LSI ",
memcpy(uuid, sha, 4*4);
}
-#ifndef MDASSEMBLE
static void brief_detail_super_ddf(struct supertype *st)
{
struct mdinfo info;
fname_from_uuid(st, &info, nbuf,':');
printf(" UUID=%s", nbuf + 5);
}
-#endif
static int match_home_ddf(struct supertype *st, char *homehost)
{
ddf->controller.vendor_data[len] == 0);
}
-#ifndef MDASSEMBLE
static int find_index_in_bvd(const struct ddf_super *ddf,
const struct vd_config *conf, unsigned int n,
unsigned int *n_bvd)
nsec = n / be16_to_cpu(conf->prim_elmnt_count);
if (conf->sec_elmnt_seq != nsec) {
for (ibvd = 1; ibvd < conf->sec_elmnt_count; ibvd++) {
- if (v->other_bvds[ibvd-1]->sec_elmnt_seq
- == nsec)
+ if (v->other_bvds[ibvd-1]->sec_elmnt_seq ==
+ nsec)
break;
}
if (ibvd == conf->sec_elmnt_count)
pr_err("Could't find disk %d in array %u\n", n, inst);
return NULL;
}
-#endif
static int find_phys(const struct ddf_super *ddf, be32 phys_refnum)
{
be32_to_cpu(ddf->phys->entries[e].refnum) == 0xffffffff)
e++;
if (i < info->array.raid_disks && e < max &&
- !(be16_to_cpu(ddf->phys->entries[e].state)
- & DDF_Failed))
+ !(be16_to_cpu(ddf->phys->entries[e].state) &
+ DDF_Failed))
map[i] = 1;
else
map[i] = 0;
info->resync_start = 0;
info->reshape_active = 0;
info->recovery_blocked = 0;
- if (!(ddf->virt->entries[info->container_member].state
- & DDF_state_inconsistent) &&
- (ddf->virt->entries[info->container_member].init_state
- & DDF_initstate_mask)
- == DDF_init_full)
+ if (!(ddf->virt->entries[info->container_member].state &
+ DDF_state_inconsistent) &&
+ (ddf->virt->entries[info->container_member].init_state &
+ DDF_initstate_mask) == DDF_init_full)
info->resync_start = MaxSector;
uuid_from_super_ddf(st, info->uuid);
if (map)
for (j = 0; j < map_disks; j++) {
map[j] = 0;
- if (j < info->array.raid_disks) {
+ if (j < info->array.raid_disks) {
int i = find_phys(ddf, vc->conf.phys_refnum[j]);
if (i >= 0 &&
(be16_to_cpu(ddf->phys->entries[i].state)
return DDF_NOTFOUND;
}
-#ifndef MDASSEMBLE
static unsigned int find_vde_by_guid(const struct ddf_super *ddf,
const char *guid)
{
return i;
return DDF_NOTFOUND;
}
-#endif
static int init_super_ddf(struct supertype *st,
mdu_array_info_t *info,
- unsigned long long size, char *name, char *homehost,
+ struct shape *s, char *name, char *homehost,
int *uuid, unsigned long long data_offset)
{
/* This is primarily called by Create when creating a new array.
struct virtual_disk *vd;
if (st->sb)
- return init_super_ddf_bvd(st, info, size, name, homehost, uuid,
+ return init_super_ddf_bvd(st, info, s->size, name, homehost, uuid,
data_offset);
if (posix_memalign((void**)&ddf, 512, sizeof(*ddf)) != 0) {
return ffs(chunksize/512)-1;
}
-#ifndef MDASSEMBLE
struct extent {
unsigned long long start, size;
};
free(e);
return INVALID_SECTORS;
}
-#endif
static int init_super_ddf_bvd(struct supertype *st,
mdu_array_info_t *info,
free(vcl);
return 0;
}
- vc->blocks = cpu_to_be64(info->size * 2);
+ vc->blocks = cpu_to_be64(size * 2);
vc->array_blocks = cpu_to_be64(
calc_array_size(info->level, info->raid_disks, info->layout,
- info->chunk_size, info->size*2));
+ info->chunk_size, size * 2));
memset(vc->pad1, 0xff, 8);
vc->spare_refs[0] = cpu_to_be32(0xffffffff);
vc->spare_refs[1] = cpu_to_be32(0xffffffff);
return 1;
}
-#ifndef MDASSEMBLE
static void add_to_super_ddf_bvd(struct supertype *st,
mdu_disk_info_t *dk, int fd, char *devname,
unsigned long long data_offset)
}
return 0;
}
-#endif
/*
* This is the write_init_super method for a ddf container. It is
memcpy(&ddf->primary, &ddf->anchor, 512);
memcpy(&ddf->secondary, &ddf->anchor, 512);
+ ddf->anchor.type = DDF_HEADER_ANCHOR;
ddf->anchor.openflag = 0xFF; /* 'open' means nothing */
ddf->anchor.seq = cpu_to_be32(0xFFFFFFFF); /* no sequencing in anchor */
ddf->anchor.crc = calc_crc(&ddf->anchor, 512);
return 1;
}
-#ifndef MDASSEMBLE
static int __write_init_super_ddf(struct supertype *st)
{
struct ddf_super *ddf = st->sb;
}
}
-#endif
-
static __u64 avail_size_ddf(struct supertype *st, __u64 devsize,
unsigned long long data_offset)
{
return devsize - 32*1024*2;
}
-#ifndef MDASSEMBLE
-
static int reserve_space(struct supertype *st, int raiddisks,
unsigned long long size, int chunk,
unsigned long long data_offset,
int *chunk, unsigned long long size,
unsigned long long data_offset,
char *dev, unsigned long long *freesize,
- int verbose)
+ int consistency_policy, int verbose)
{
int fd;
struct mdinfo *sra;
char *dev, unsigned long long *freesize,
int verbose)
{
- struct stat stb;
+ dev_t rdev;
struct ddf_super *ddf = st->sb;
struct dl *dl;
unsigned long long maxsize;
if (minsize == 0)
minsize = 8;
for (dl = ddf->dlist; dl ; dl = dl->next) {
- if (find_space(ddf, dl, data_offset, &minsize)
- != INVALID_SECTORS)
+ if (find_space(ddf, dl, data_offset, &minsize) !=
+ INVALID_SECTORS)
dcnt++;
}
if (dcnt < raiddisks) {
return 1;
}
/* This device must be a member of the set */
- if (stat(dev, &stb) < 0)
- return 0;
- if ((S_IFMT & stb.st_mode) != S_IFBLK)
+ if (!stat_is_blkdev(dev, &rdev))
return 0;
for (dl = ddf->dlist ; dl ; dl = dl->next) {
- if (dl->major == (int)major(stb.st_rdev) &&
- dl->minor == (int)minor(stb.st_rdev))
+ if (dl->major == (int)major(rdev) &&
+ dl->minor == (int)minor(rdev))
break;
}
if (!dl) {
char nm[20];
int dfd;
- sra = sysfs_read(fd, 0, GET_LEVEL|GET_VERSION|GET_DEVS|GET_STATE);
+ sra = sysfs_read(fd, NULL, GET_LEVEL|GET_VERSION|GET_DEVS|GET_STATE);
if (!sra)
return 1;
if (sra->array.major_version != -1 ||
return load_super_ddf_all(st, fd, &st->sb, devname);
}
-#endif /* MDASSEMBLE */
-
static int check_secondary(const struct vcl *vc)
{
const struct vd_config *conf = &vc->conf;
unsigned int iphys;
int stt;
- if (be32_to_cpu(ddf->phys->entries[pd].refnum)
- == 0xFFFFFFFF)
+ if (be32_to_cpu(ddf->phys->entries[pd].refnum) ==
+ 0xffffffff)
continue;
stt = be16_to_cpu(ddf->phys->entries[pd].state);
- if ((stt & (DDF_Online|DDF_Failed|DDF_Rebuilding))
- != DDF_Online)
+ if ((stt & (DDF_Online|DDF_Failed|DDF_Rebuilding)) !=
+ DDF_Online)
continue;
i = get_pd_index_from_refnum(
continue;
if (posix_memalign((void **)&dl1, 512,
- sizeof(*dl1) + (first->max_part) * sizeof(dl1->vlist[0]))
- != 0) {
+ sizeof(*dl1) + (first->max_part) *
+ sizeof(dl1->vlist[0])) != 0) {
pr_err("could not allocate disk info buffer\n");
return 3;
}
return 0;
}
-#ifndef MDASSEMBLE
/*
* A new array 'a' has been started which claims to be instance 'inst'
* within container 'c'.
if (pd < 0)
continue;
st = be16_to_cpu(ddf->phys->entries[pd].state);
- if ((st & (DDF_Online|DDF_Failed|DDF_Rebuilding))
- == DDF_Online) {
+ if ((st & (DDF_Online|DDF_Failed|DDF_Rebuilding)) ==
+ DDF_Online) {
working++;
avail[i] = 1;
}
0xFFFFFFFF)
continue;
if (be16_and(ddf->phys->entries[pdnum].state,
- cpu_to_be16(DDF_Failed))
- && be16_and(ddf->phys->entries[pdnum].state,
- cpu_to_be16(DDF_Transition))) {
+ cpu_to_be16(DDF_Failed)) &&
+ be16_and(ddf->phys->entries[pdnum].state,
+ cpu_to_be16(DDF_Transition))) {
/* skip this one unless in dlist*/
for (dl = ddf->dlist; dl; dl = dl->next)
if (dl->pdnum == (int)pdnum)
vc = (struct vd_config *)(mu->buf
+ i_sec * ddf->conf_rec_len * 512);
for (dl = ddf->dlist; dl; dl = dl->next)
- if (dl->major == di->disk.major
- && dl->minor == di->disk.minor)
+ if (dl->major == di->disk.major &&
+ dl->minor == di->disk.minor)
break;
if (!dl || dl->pdnum < 0) {
pr_err("BUG: can't find disk %d (%d/%d)\n",
*updates = mu;
return rv;
}
-#endif /* MDASSEMBLE */
static int ddf_level_to_layout(int level)
{
}
struct superswitch super_ddf = {
-#ifndef MDASSEMBLE
.examine_super = examine_super_ddf,
.brief_examine_super = brief_examine_super_ddf,
.brief_examine_subarrays = brief_examine_subarrays_ddf,
.load_container = load_container_ddf,
.copy_metadata = copy_metadata_ddf,
.kill_subarray = kill_subarray_ddf,
-#endif
.match_home = match_home_ddf,
.uuid_from_super= uuid_from_super_ddf,
.getinfo_super = getinfo_super_ddf,
.external = 1,
-#ifndef MDASSEMBLE
/* for mdmon */
.open_new = ddf_open_new,
.set_array_state= ddf_set_array_state,
.process_update = ddf_process_update,
.prepare_update = ddf_prepare_update,
.activate_spare = ddf_activate_spare,
-#endif
.name = "ddf",
};