mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Simple validation of messages in mda
Check we do not combine multiple messages for same LV target and switch to use 'delete_id' to make it clear for what this device_id is being used.
This commit is contained in:
parent
3dcce042f6
commit
8de912b677
@ -455,7 +455,7 @@ int attach_pool_data_lv(struct lv_segment *seg,
|
||||
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv);
|
||||
int detach_pool_lv(struct lv_segment *seg);
|
||||
int attach_pool_message(struct lv_segment *seg, dm_thin_message_t type,
|
||||
struct logical_volume *lv, uint32_t device_id,
|
||||
struct logical_volume *lv, uint32_t delete_id,
|
||||
int read_only);
|
||||
int detach_pool_messages(struct lv_segment *seg);
|
||||
|
||||
|
@ -81,11 +81,36 @@ int detach_pool_lv(struct lv_segment *seg)
|
||||
}
|
||||
|
||||
int attach_pool_message(struct lv_segment *seg, dm_thin_message_t type,
|
||||
struct logical_volume *lv, uint32_t device_id,
|
||||
struct logical_volume *lv, uint32_t delete_id,
|
||||
int read_only)
|
||||
{
|
||||
struct lv_thin_message *tmsg;
|
||||
|
||||
dm_list_iterate_items(tmsg, &seg->thin_messages) {
|
||||
if (tmsg->type == type) {
|
||||
switch (tmsg->type) {
|
||||
case DM_THIN_MESSAGE_CREATE_SNAP:
|
||||
case DM_THIN_MESSAGE_CREATE_THIN:
|
||||
case DM_THIN_MESSAGE_TRIM:
|
||||
if (tmsg->u.lv == lv) {
|
||||
log_error("Message referring LV %s already queued for %s.",
|
||||
tmsg->u.lv->name, seg->lv->name);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case DM_THIN_MESSAGE_DELETE:
|
||||
if (tmsg->u.delete_id == delete_id) {
|
||||
log_error("Delete of device %u already queued for %s.",
|
||||
tmsg->u.delete_id, seg->lv->name);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(tmsg = dm_pool_alloc(seg->lv->vg->vgmem, sizeof(*tmsg)))) {
|
||||
log_error("Failed to allocate memory for message.");
|
||||
return 0;
|
||||
@ -98,7 +123,7 @@ int attach_pool_message(struct lv_segment *seg, dm_thin_message_t type,
|
||||
tmsg->u.lv = lv;
|
||||
break;
|
||||
case DM_THIN_MESSAGE_DELETE:
|
||||
tmsg->u.delete_id = device_id;
|
||||
tmsg->u.delete_id = delete_id;
|
||||
break;
|
||||
default:
|
||||
log_error(INTERNAL_ERROR "Unsupported message type %d", type);
|
||||
|
Loading…
Reference in New Issue
Block a user