return 0;
}
+static void add_other_bvd(struct vcl *vcl, struct vd_config *vd,
+ unsigned int len)
+{
+ int i;
+ for (i = 0; i < vcl->conf.sec_elmnt_count-1; i++)
+ if (vcl->other_bvds[i] != NULL &&
+ vcl->other_bvds[i]->sec_elmnt_seq == vd->sec_elmnt_seq)
+ break;
+
+ if (i < vcl->conf.sec_elmnt_count-1) {
+ if (vd->seqnum <= vcl->other_bvds[i]->seqnum)
+ return;
+ } else {
+ for (i = 0; i < vcl->conf.sec_elmnt_count-1; i++)
+ if (vcl->other_bvds[i] == NULL)
+ break;
+ if (i == vcl->conf.sec_elmnt_count-1) {
+ pr_err("no space for sec level config %u, count is %u\n",
+ vd->sec_elmnt_seq, vcl->conf.sec_elmnt_count);
+ return;
+ }
+ if (posix_memalign((void **)&vcl->other_bvds[i], 512, len)
+ != 0) {
+ pr_err("%s could not allocate vd buf\n", __func__);
+ return;
+ }
+ }
+ memcpy(vcl->other_bvds[i], vd, len);
+}
+
static int load_ddf_local(int fd, struct ddf_super *super,
char *devname, int keep)
{
if (vcl) {
dl->vlist[vnum++] = vcl;
+ if (vcl->other_bvds != NULL &&
+ vcl->conf.sec_elmnt_seq != vd->sec_elmnt_seq) {
+ add_other_bvd(vcl, vd, super->conf_rec_len*512);
+ continue;
+ }
if (__be32_to_cpu(vd->seqnum) <=
__be32_to_cpu(vcl->conf.seqnum))
continue;
ddf->conflist = v->next;
if (v->block_sizes)
free(v->block_sizes);
- if (v->other_bvds)
+ if (v->other_bvds) {
+ int i;
+ for (i = 0; i < v->conf.sec_elmnt_count-1; i++)
+ if (v->other_bvds[i] != NULL)
+ free(v->other_bvds[i]);
free(v->other_bvds);
+ }
free(v);
}
while (ddf->dlist) {