#define offsetof(t,f) ((size_t)&(((t*)0)->f))
#endif
+#if DEBUG
+static int all_ff(char *guid);
+static void pr_state(struct ddf_super *ddf, const char *msg)
+{
+ unsigned int i;
+ dprintf("%s/%s: ", __func__, msg);
+ for (i = 0; i < __be16_to_cpu(ddf->active->max_vd_entries); i++) {
+ if (all_ff(ddf->virt->entries[i].guid))
+ continue;
+ dprintf("%u(s=%02x i=%02x) ", i,
+ ddf->virt->entries[i].state,
+ ddf->virt->entries[i].init_state);
+ }
+ dprintf("\n");
+}
+#else
+static void pr_state(const struct ddf_super *ddf, const char *msg) {}
+#endif
+
+#define ddf_set_updates_pending(x) \
+ do { (x)->updates_pending = 1; pr_state(x, __func__); } while (0)
+
static unsigned int calc_crc(void *buf, int len)
{
/* crcs are always at the same place as in the ddf_header */
memset(&vd->entries[i], 0xff, sizeof(struct virtual_entry));
st->sb = ddf;
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
return 1;
}
vcl->next = ddf->conflist;
ddf->conflist = vcl;
ddf->currentconf = vcl;
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
return 1;
}
ddf->phys->entries[dl->pdnum].type &= ~__cpu_to_be16(DDF_Global_Spare);
ddf->phys->entries[dl->pdnum].type |= __cpu_to_be16(DDF_Active_in_VD);
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
}
/* add a device to a container, either while creating it or while
} else {
dd->next = ddf->dlist;
ddf->dlist = dd;
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
}
return 0;
char *null_aligned;
__u32 seq;
+ pr_state(ddf, __func__);
if (posix_memalign((void**)&null_aligned, 4096, NULL_CONF_SZ) != 0) {
return -ENOMEM;
}
else
ddf->virt->entries[inst].state |= DDF_state_inconsistent;
if (old != ddf->virt->entries[inst].state)
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
old = ddf->virt->entries[inst].init_state;
ddf->virt->entries[inst].init_state &= ~DDF_initstate_mask;
else
ddf->virt->entries[inst].init_state |= DDF_init_quick;
if (old != ddf->virt->entries[inst].init_state)
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
dprintf("ddf mark %d %s %llu\n", inst, consistent?"clean":"dirty",
a->info.resync_start);
~__cpu_to_be16(DDF_Global_Spare);
ddf->phys->entries[pd].type |=
__cpu_to_be16(DDF_Active_in_VD);
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
}
} else {
int old = ddf->phys->entries[pd].state;
ddf->phys->entries[pd].state &= __cpu_to_be16(~DDF_Rebuilding);
}
if (old != ddf->phys->entries[pd].state)
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
}
dprintf("ddf: set_disk %d to %x\n", n, state);
ddf->virt->entries[inst].state =
(ddf->virt->entries[inst].state & ~DDF_state_mask)
| state;
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
}
}
break;
}
}
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
return;
}
if (!all_ff(ddf->phys->entries[ent].guid))
ddf->phys->entries[ent] = pd->entries[0];
ddf->phys->used_pdes = __cpu_to_be16(1 +
__be16_to_cpu(ddf->phys->used_pdes));
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
if (ddf->add_list) {
struct active_array *a;
struct dl *al = ddf->add_list;
ddf->virt->entries[ent] = vd->entries[0];
ddf->virt->populated_vdes = __cpu_to_be16(1 +
__be16_to_cpu(ddf->virt->populated_vdes));
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
break;
case DDF_VD_CONF_MAGIC:
pd2++;
}
- ddf->updates_pending = 1;
+ ddf_set_updates_pending(ddf);
break;
case DDF_SPARE_ASSIGN_MAGIC:
default: break;