1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

libdm: enhance thin transaction_id validation

Reuse _node_send_messages for just checking
for valid transaction_id with preload.

This allows earlier detection of incosistent thin pool.

Code does the same thing, except for sending messages.
This commit is contained in:
Zdenek Kabelac 2014-02-24 09:43:14 +01:00
parent c7b7cb60e4
commit 203affffc7
2 changed files with 20 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
Reuse _node_send_messages() for validation of transaction_id in preload.
Transaction_id could be lower by one only when messages are prepared.
Do not call callback when preload fails.
Wrap is_selinux_enabled() to be called just once.

View File

@ -1478,9 +1478,11 @@ out:
return r;
}
/* For preload pass only validate pool's transaction_id */
static int _node_send_messages(struct dm_tree_node *dnode,
const char *uuid_prefix,
size_t uuid_prefix_len)
size_t uuid_prefix_len,
int send)
{
struct load_segment *seg;
struct thin_message *tmsg;
@ -1522,6 +1524,9 @@ static int _node_send_messages(struct dm_tree_node *dnode,
return 0;
}
if (!send)
return 1; /* transaction_id is matching */
dm_list_iterate_items(tmsg, &seg->thin_messages)
if (!(_thin_pool_node_message(dnode, tmsg)))
return_0;
@ -1865,7 +1870,7 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
* has to report failure.
*/
if (r && dnode->props.send_messages &&
!(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len)))
!(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len, 1)))
stack;
return r;
@ -2713,6 +2718,18 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
if (!child->info.live_table) {
/* Collect newly introduced devices for revert */
dm_list_add_h(&dnode->activated, &child->activated_list);
/* When creating new node also check transaction_id. */
if (child->props.send_messages &&
!_node_send_messages(child, uuid_prefix, uuid_prefix_len, 0)) {
stack;
if (!dm_udev_wait(dm_tree_get_cookie(dnode)))
stack;
dm_tree_set_cookie(dnode, 0);
(void) _dm_tree_revert_activated(dnode);
r = 0;
continue;
}
}
/* Update cached info */