int dm_exception_store_type_register(struct dm_exception_store_type *type)
{ int r = 0;
spin_lock(&_lock); if (!__find_exception_store_type(type->name))
list_add(&type->list, &_exception_store_types); else
r = -EEXIST;
spin_unlock(&_lock);
int dm_exception_store_set_chunk_size(struct dm_exception_store *store, unsignedint chunk_size, char **error)
{ /* Check chunk_size is a power of 2 */ if (!is_power_of_2(chunk_size)) {
*error = "Chunk size is not a power of 2"; return -EINVAL;
}
/* Validate the chunk size against the device block size */ if (chunk_size %
(bdev_logical_block_size(dm_snap_cow(store->snap)->bdev) >> 9) ||
chunk_size %
(bdev_logical_block_size(dm_snap_origin(store->snap)->bdev) >> 9)) {
*error = "Chunk size is not a multiple of device blocksize"; return -EINVAL;
}
if (chunk_size > INT_MAX >> SECTOR_SHIFT) {
*error = "Chunk size is too high"; return -EINVAL;
}
int dm_exception_store_create(struct dm_target *ti, int argc, char **argv, struct dm_snapshot *snap, unsignedint *args_used, struct dm_exception_store **store)
{ int r = 0; struct dm_exception_store_type *type = NULL; struct dm_exception_store *tmp_store; char persistent;
if (argc < 2) {
ti->error = "Insufficient exception store arguments"; return -EINVAL;
}
tmp_store = kzalloc(sizeof(*tmp_store), GFP_KERNEL); if (!tmp_store) {
ti->error = "Exception store allocation failed"; return -ENOMEM;
}
persistent = toupper(*argv[0]); if (persistent == 'P')
type = get_type("P"); elseif (persistent == 'N')
type = get_type("N"); else {
ti->error = "Exception store type is not P or N";
r = -EINVAL; goto bad_type;
}
if (!type) {
ti->error = "Exception store type not recognised";
r = -EINVAL; goto bad_type;
}
tmp_store->type = type;
tmp_store->snap = snap;
r = set_chunk_size(tmp_store, argv[1], &ti->error); if (r) goto bad;
r = type->ctr(tmp_store, (strlen(argv[0]) > 1 ? &argv[0][1] : NULL)); if (r) {
ti->error = "Exception store type constructor failed"; goto bad;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.