__u8 pad1[12]; /* 12 * 0xff */
/* 64 bytes so far */
__u8 header_ext[32]; /* reserved: fill with 0xff */
- __u64 primary_lba;
- __u64 secondary_lba;
+ be64 primary_lba;
+ be64 secondary_lba;
__u8 type;
__u8 pad2[3]; /* 0xff */
be32 workspace_len; /* sectors for vendor space -
* at least 32768(sectors) */
- __u64 workspace_lba;
+ be64 workspace_lba;
__u16 max_pd_entries; /* one of 15, 63, 255, 1023, 4095 */
__u16 max_vd_entries; /* 2^(4,6,8,10,12)-1 : i.e. as above */
__u16 max_partitions; /* i.e. max num of configuration
be32 refnum;
__u16 type;
__u16 state;
- __u64 config_size; /* DDF structures must be after here */
+ be64 config_size; /* DDF structures must be after here */
char path[18]; /* another horrible structure really */
__u8 pad[6];
} entries[0];
__u8 sec_elmnt_count;
__u8 sec_elmnt_seq;
__u8 srl;
- __u64 blocks; /* blocks per component could be different
+ be64 blocks; /* blocks per component could be different
* on different component devices...(only
* for concat I hope) */
- __u64 array_blocks; /* blocks in array */
+ be64 array_blocks; /* blocks in array */
__u8 pad1[8];
be32 spare_refs[8];
__u8 cache_pol[8];
/*__u64 lba_offset[0]; LBA offset in each phys. Note extents in a
bvd are always the same size */
};
-#define LBA_OFFSET(ddf, vd) ((__u64 *) &(vd)->phys_refnum[(ddf)->mppe])
+#define LBA_OFFSET(ddf, vd) ((be64 *) &(vd)->phys_refnum[(ddf)->mppe])
/* vd_config.cache_pol[7] is a bitmap */
#define DDF_cache_writeback 1 /* else writethrough */
__u16 entry_count;
be32 spare_count;
__u8 pad[10];
- __u64 first_spare;
+ be64 first_spare;
struct mapped_block {
- __u64 defective_start;
+ be64 defective_start;
be32 replacement_start;
__u16 remap_count;
__u8 pad[2];
char *devname;
int fd;
unsigned long long size; /* sectors */
- unsigned long long primary_lba; /* sectors */
- unsigned long long secondary_lba; /* sectors */
- unsigned long long workspace_lba; /* sectors */
+ be64 primary_lba; /* sectors */
+ be64 secondary_lba; /* sectors */
+ be64 workspace_lba; /* sectors */
int pdnum; /* index in ->phys */
struct spare_assign *spare;
void *mdupdate; /* hold metadata update */
return 0;
if (memcmp(anchor->guid, hdr->guid, DDF_GUID_LEN) != 0 ||
memcmp(anchor->revision, hdr->revision, 8) != 0 ||
- anchor->primary_lba != hdr->primary_lba ||
- anchor->secondary_lba != hdr->secondary_lba ||
+ !be64_eq(anchor->primary_lba, hdr->primary_lba) ||
+ !be64_eq(anchor->secondary_lba, hdr->secondary_lba) ||
hdr->type != type ||
memcmp(anchor->pad2, hdr->pad2, 512 -
offsetof(struct ddf_header, pad2)) != 0)
return NULL;
if (super->active->type == 1)
- offset += __be64_to_cpu(super->active->primary_lba);
+ offset += be64_to_cpu(super->active->primary_lba);
else
- offset += __be64_to_cpu(super->active->secondary_lba);
+ offset += be64_to_cpu(super->active->secondary_lba);
if ((unsigned long long)lseek64(fd, offset<<9, 0) != (offset<<9)) {
if (dofree)
return 2;
}
super->active = NULL;
- if (load_ddf_header(fd, __be64_to_cpu(super->anchor.primary_lba),
+ if (load_ddf_header(fd, be64_to_cpu(super->anchor.primary_lba),
dsize >> 9, 1,
&super->primary, &super->anchor) == 0) {
if (devname)
} else
super->active = &super->primary;
- if (load_ddf_header(fd, __be64_to_cpu(super->anchor.secondary_lba),
+ if (load_ddf_header(fd, be64_to_cpu(super->anchor.secondary_lba),
dsize >> 9, 2,
&super->secondary, &super->anchor)) {
if (super->active == NULL
map_num(ddf_sec_level, vc->srl) ?: "-unknown-");
}
printf(" Device Size[%d] : %llu\n", n,
- (unsigned long long)__be64_to_cpu(vc->blocks)/2);
+ be64_to_cpu(vc->blocks)/2);
printf(" Array Size[%d] : %llu\n", n,
- (unsigned long long)__be64_to_cpu(vc->array_blocks)/2);
+ be64_to_cpu(vc->array_blocks)/2);
}
}
printf(" %3d %08x ", i,
be32_to_cpu(pd->refnum));
printf("%8lluK ",
- (unsigned long long)__be64_to_cpu(pd->config_size)>>1);
+ be64_to_cpu(pd->config_size)>>1);
for (dl = sb->dlist; dl ; dl = dl->next) {
if (be32_eq(dl->disk.refnum, pd->refnum)) {
char *dv = map_dev(dl->major, dl->minor, 0);
goto err;
offset = dsize - 512;
- if ((__be64_to_cpu(ddf->primary_lba) << 9) < offset)
- offset = __be64_to_cpu(ddf->primary_lba) << 9;
- if ((__be64_to_cpu(ddf->secondary_lba) << 9) < offset)
- offset = __be64_to_cpu(ddf->secondary_lba) << 9;
+ if ((be64_to_cpu(ddf->primary_lba) << 9) < offset)
+ offset = be64_to_cpu(ddf->primary_lba) << 9;
+ if ((be64_to_cpu(ddf->secondary_lba) << 9) < offset)
+ offset = be64_to_cpu(ddf->secondary_lba) << 9;
bytes = dsize - offset;
info->disk.number = be32_to_cpu(ddf->dlist->disk.refnum);
info->disk.raid_disk = find_phys(ddf, ddf->dlist->disk.refnum);
- info->data_offset = __be64_to_cpu(ddf->phys->
+ info->data_offset = be64_to_cpu(ddf->phys->
entries[info->disk.raid_disk].
config_size);
info->component_size = ddf->dlist->size - info->data_offset;
if (cd >= 0 && (unsigned)cd < ddf->mppe) {
info->data_offset =
- __be64_to_cpu(LBA_OFFSET(ddf, conf)[cd]);
+ be64_to_cpu(LBA_OFFSET(ddf, conf)[cd]);
if (vc->block_sizes)
info->component_size = vc->block_sizes[cd];
else
- info->component_size = __be64_to_cpu(conf->blocks);
+ info->component_size = be64_to_cpu(conf->blocks);
}
for (dl = ddf->dlist; dl ; dl = dl->next)
ddf->anchor.pad0 = 0xff;
memset(ddf->anchor.pad1, 0xff, 12);
memset(ddf->anchor.header_ext, 0xff, 32);
- ddf->anchor.primary_lba = ~(__u64)0;
- ddf->anchor.secondary_lba = ~(__u64)0;
+ ddf->anchor.primary_lba = cpu_to_be64(~(__u64)0);
+ ddf->anchor.secondary_lba = cpu_to_be64(~(__u64)0);
ddf->anchor.type = DDF_HEADER_ANCHOR;
memset(ddf->anchor.pad2, 0xff, 3);
ddf->anchor.workspace_len = cpu_to_be32(32768); /* Must be reserved */
- ddf->anchor.workspace_lba = ~(__u64)0; /* Put this at bottom
- of 32M reserved.. */
+ /* Put this at bottom of 32M reserved.. */
+ ddf->anchor.workspace_lba = cpu_to_be64(~(__u64)0);
max_phys_disks = 1023; /* Should be enough */
ddf->anchor.max_pd_entries = __cpu_to_be16(max_phys_disks);
max_virt_disks = 255;
get_pd_index_from_refnum(v, dl->disk.refnum, ddf->mppe,
&bvd, &ibvd) == DDF_NOTFOUND)
continue;
- rv[n].start = __be64_to_cpu(LBA_OFFSET(ddf, bvd)[ibvd]);
- rv[n].size = __be64_to_cpu(bvd->blocks);
+ rv[n].start = be64_to_cpu(LBA_OFFSET(ddf, bvd)[ibvd]);
+ rv[n].size = be64_to_cpu(bvd->blocks);
n++;
}
qsort(rv, n, sizeof(*rv), cmp_extent);
- rv[n].start = __be64_to_cpu(ddf->phys->entries[dl->pdnum].config_size);
+ rv[n].start = be64_to_cpu(ddf->phys->entries[dl->pdnum].config_size);
rv[n].size = 0;
return rv;
}
free(vcl);
return 0;
}
- vc->blocks = __cpu_to_be64(info->size * 2);
- vc->array_blocks = __cpu_to_be64(
+ vc->blocks = cpu_to_be64(info->size * 2);
+ vc->array_blocks = cpu_to_be64(
calc_array_size(info->level, info->raid_disks, info->layout,
info->chunk_size, info->size*2));
memset(vc->pad1, 0xff, 8);
return;
i = 0; pos = 0;
- blocks = __be64_to_cpu(vc->blocks);
+ blocks = be64_to_cpu(vc->blocks);
if (ddf->currentconf->block_sizes)
blocks = ddf->currentconf->block_sizes[dk->raid_disk];
ddf->currentdev = dk->raid_disk;
vc->phys_refnum[raid_disk] = dl->disk.refnum;
- LBA_OFFSET(ddf, vc)[raid_disk] = __cpu_to_be64(pos);
+ LBA_OFFSET(ddf, vc)[raid_disk] = cpu_to_be64(pos);
for (i = 0; i < ddf->max_part ; i++)
if (dl->vlist[i] == NULL)
#define __calc_lba(new, old, lba, mb) do { \
unsigned long long dif; \
if ((old) != NULL) \
- dif = (old)->size - __be64_to_cpu((old)->lba); \
+ dif = (old)->size - be64_to_cpu((old)->lba); \
else \
dif = (new)->size; \
if ((new)->size > dif) \
- (new)->lba = __cpu_to_be64((new)->size - dif); \
+ (new)->lba = cpu_to_be64((new)->size - dif); \
else \
- (new)->lba = __cpu_to_be64((new)->size - (mb*1024*2)); \
+ (new)->lba = cpu_to_be64((new)->size - (mb*1024*2)); \
} while (0)
__calc_lba(dd, ddf->dlist, workspace_lba, 32);
__calc_lba(dd, ddf->dlist, primary_lba, 16);
switch (type) {
case DDF_HEADER_PRIMARY:
header = &ddf->primary;
- sector = __be64_to_cpu(header->primary_lba);
+ sector = be64_to_cpu(header->primary_lba);
break;
case DDF_HEADER_SECONDARY:
header = &ddf->secondary;
- sector = __be64_to_cpu(header->secondary_lba);
+ sector = be64_to_cpu(header->secondary_lba);
break;
default:
return 0;
*/
get_dev_size(fd, NULL, &size);
size /= 512;
- if (d->workspace_lba != 0)
+ if (be64_to_cpu(d->workspace_lba) != 0ULL)
ddf->anchor.workspace_lba = d->workspace_lba;
else
ddf->anchor.workspace_lba =
- __cpu_to_be64(size - 32*1024*2);
- if (d->primary_lba != 0)
+ cpu_to_be64(size - 32*1024*2);
+ if (be64_to_cpu(d->primary_lba) != 0ULL)
ddf->anchor.primary_lba = d->primary_lba;
else
ddf->anchor.primary_lba =
- __cpu_to_be64(size - 16*1024*2);
- if (d->secondary_lba != 0)
+ cpu_to_be64(size - 16*1024*2);
+ if (be64_to_cpu(d->secondary_lba) != 0ULL)
ddf->anchor.secondary_lba = d->secondary_lba;
else
ddf->anchor.secondary_lba =
- __cpu_to_be64(size - 32*1024*2);
+ cpu_to_be64(size - 32*1024*2);
ddf->anchor.seq = ddf->active->seq;
memcpy(&ddf->primary, &ddf->anchor, 512);
memcpy(&ddf->secondary, &ddf->anchor, 512);
pr_err("Different strip sizes for BVDs are unsupported\n");
return -1;
}
- if (bvd->array_blocks != conf->array_blocks) {
+ if (!be64_eq(bvd->array_blocks, conf->array_blocks)) {
pr_err("Different BVD sizes are unsupported\n");
return -1;
}
this->name[j] = 0;
memset(this->uuid, 0, sizeof(this->uuid));
- this->component_size = __be64_to_cpu(vc->conf.blocks);
+ this->component_size = be64_to_cpu(vc->conf.blocks);
this->array.size = this->component_size / 2;
this->container_member = i;
dev->events = be32_to_cpu(ddf->primary.seq);
dev->data_offset =
- __be64_to_cpu(LBA_OFFSET(ddf, bvd)[iphys]);
- dev->component_size = __be64_to_cpu(bvd->blocks);
+ be64_to_cpu(LBA_OFFSET(ddf, bvd)[iphys]);
+ dev->component_size = be64_to_cpu(bvd->blocks);
if (d->devname)
strcpy(dev->name, d->devname);
}
pd = dl->pdnum; /* FIXME: is this really correct ? */
vc->phys_refnum[n_bvd] = dl->disk.refnum;
LBA_OFFSET(ddf, vc)[n_bvd] =
- __cpu_to_be64(mdi->data_offset);
+ cpu_to_be64(mdi->data_offset);
ddf->phys->entries[pd].type &=
~__cpu_to_be16(DDF_Global_Spare);
ddf->phys->entries[pd].type |=
vc->phys_refnum[di->disk.raid_disk] =
ddf->phys->entries[dl->pdnum].refnum;
LBA_OFFSET(ddf, vc)[di->disk.raid_disk]
- = __cpu_to_be64(di->data_offset);
+ = cpu_to_be64(di->data_offset);
}
*updates = mu;
return rv;