mirror of https://github.com/schoebel/mars
light: prevent races on device size
This commit is contained in:
parent
ffc97c5c68
commit
7a2755a56f
|
@ -443,8 +443,19 @@ int _set_if_params(struct mars_brick *_brick, void *private)
|
||||||
MARS_ERR("bad brick type\n");
|
MARS_ERR("bad brick type\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (rot)
|
if (!rot) {
|
||||||
if_brick->dev_size = rot->dev_size;
|
MARS_ERR("too early\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if (rot->dev_size <= 0) {
|
||||||
|
MARS_ERR("dev_size = %lld\n", rot->dev_size);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if (if_brick->dev_size > 0 && rot->dev_size < if_brick->dev_size) {
|
||||||
|
MARS_ERR("new dev size = %lld < old dev_size = %lld\n", rot->dev_size, if_brick->dev_size);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if_brick->dev_size = rot->dev_size;
|
||||||
if_brick->max_plugged = IF_MAX_PLUGGED;
|
if_brick->max_plugged = IF_MAX_PLUGGED;
|
||||||
if_brick->readahead = IF_READAHEAD;
|
if_brick->readahead = IF_READAHEAD;
|
||||||
if_brick->skip_sync = IF_SKIP_SYNC;
|
if_brick->skip_sync = IF_SKIP_SYNC;
|
||||||
|
|
Loading…
Reference in New Issue