ddf: prevent superblock being zeroed on --update
The full fix would be to support updating ddf metadata, but this minimal fix just prevents the superblock from being zeroed when someone inadvertently passes an unsupported --update option during assembly. Reported-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
e683ca88ac
commit
955e9ea139
27
super-ddf.c
27
super-ddf.c
|
@ -1589,13 +1589,8 @@ static int init_super_ddf(struct supertype *st,
|
||||||
struct phys_disk *pd;
|
struct phys_disk *pd;
|
||||||
struct virtual_disk *vd;
|
struct virtual_disk *vd;
|
||||||
|
|
||||||
if (!info) {
|
|
||||||
st->sb = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (st->sb)
|
if (st->sb)
|
||||||
return init_super_ddf_bvd(st, info, size, name, homehost,
|
return init_super_ddf_bvd(st, info, size, name, homehost, uuid);
|
||||||
uuid);
|
|
||||||
|
|
||||||
if (posix_memalign((void**)&ddf, 512, sizeof(*ddf)) != 0) {
|
if (posix_memalign((void**)&ddf, 512, sizeof(*ddf)) != 0) {
|
||||||
fprintf(stderr, Name ": %s could not allocate superblock\n", __func__);
|
fprintf(stderr, Name ": %s could not allocate superblock\n", __func__);
|
||||||
|
@ -1604,6 +1599,12 @@ static int init_super_ddf(struct supertype *st,
|
||||||
memset(ddf, 0, sizeof(*ddf));
|
memset(ddf, 0, sizeof(*ddf));
|
||||||
ddf->dlist = NULL; /* no physical disks yet */
|
ddf->dlist = NULL; /* no physical disks yet */
|
||||||
ddf->conflist = NULL; /* No virtual disks yet */
|
ddf->conflist = NULL; /* No virtual disks yet */
|
||||||
|
st->sb = ddf;
|
||||||
|
|
||||||
|
if (info == NULL) {
|
||||||
|
/* zeroing superblock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* At least 32MB *must* be reserved for the ddf. So let's just
|
/* At least 32MB *must* be reserved for the ddf. So let's just
|
||||||
* start 32MB from the end, and put the primary header there.
|
* start 32MB from the end, and put the primary header there.
|
||||||
|
@ -2971,12 +2972,22 @@ static struct mdinfo *container_content_ddf(struct supertype *st)
|
||||||
return rest;
|
return rest;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int store_zero_ddf(struct supertype *st, int fd)
|
static int store_super_ddf(struct supertype *st, int fd)
|
||||||
{
|
{
|
||||||
|
struct ddf_super *ddf = st->sb;
|
||||||
unsigned long long dsize;
|
unsigned long long dsize;
|
||||||
void *buf;
|
void *buf;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (!ddf)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* ->dlist and ->conflist will be set for updates, currently not
|
||||||
|
* supported
|
||||||
|
*/
|
||||||
|
if (ddf->dlist || ddf->conflist)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (!get_dev_size(fd, NULL, &dsize))
|
if (!get_dev_size(fd, NULL, &dsize))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -3627,7 +3638,7 @@ struct superswitch super_ddf = {
|
||||||
|
|
||||||
.load_super = load_super_ddf,
|
.load_super = load_super_ddf,
|
||||||
.init_super = init_super_ddf,
|
.init_super = init_super_ddf,
|
||||||
.store_super = store_zero_ddf,
|
.store_super = store_super_ddf,
|
||||||
.free_super = free_super_ddf,
|
.free_super = free_super_ddf,
|
||||||
.match_metadata_desc = match_metadata_desc_ddf,
|
.match_metadata_desc = match_metadata_desc_ddf,
|
||||||
.container_content = container_content_ddf,
|
.container_content = container_content_ddf,
|
||||||
|
|
Loading…
Reference in New Issue