mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: split code for sending message
Move message sending from _thin_pool_node_message to new _node_message for possible better code sharing.
This commit is contained in:
parent
58976ccc34
commit
4c1caa7e26
@ -1428,9 +1428,41 @@ out:
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_message *tm)
|
static int _node_message(uint32_t major, uint32_t minor,
|
||||||
|
int expected_errno, const char *message)
|
||||||
{
|
{
|
||||||
struct dm_task *dmt;
|
struct dm_task *dmt;
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
|
if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
|
||||||
|
return_0;
|
||||||
|
|
||||||
|
if (!dm_task_set_major(dmt, major) ||
|
||||||
|
!dm_task_set_minor(dmt, minor)) {
|
||||||
|
log_error("Failed to set message major minor.");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dm_task_set_message(dmt, message))
|
||||||
|
goto_out;
|
||||||
|
|
||||||
|
/* Internal functionality of dm_task */
|
||||||
|
dmt->expected_errno = expected_errno;
|
||||||
|
|
||||||
|
if (!dm_task_run(dmt)) {
|
||||||
|
log_error("Failed to process message \"%s\".", message);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = 1;
|
||||||
|
out:
|
||||||
|
dm_task_destroy(dmt);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_message *tm)
|
||||||
|
{
|
||||||
struct dm_thin_message *m = &tm->message;
|
struct dm_thin_message *m = &tm->message;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
int r;
|
int r;
|
||||||
@ -1470,33 +1502,11 @@ static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_messa
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = 0;
|
if (!_node_message(dnode->info.major, dnode->info.minor,
|
||||||
|
tm->expected_errno, buf))
|
||||||
if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
|
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (!dm_task_set_major(dmt, dnode->info.major) ||
|
return 1;
|
||||||
!dm_task_set_minor(dmt, dnode->info.minor)) {
|
|
||||||
log_error("Failed to set message major minor.");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dm_task_set_message(dmt, buf))
|
|
||||||
goto_out;
|
|
||||||
|
|
||||||
/* Internal functionality of dm_task */
|
|
||||||
dmt->expected_errno = tm->expected_errno;
|
|
||||||
|
|
||||||
if (!dm_task_run(dmt)) {
|
|
||||||
log_error("Failed to process thin pool message \"%s\".", buf);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = 1;
|
|
||||||
out:
|
|
||||||
dm_task_destroy(dmt);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct load_segment *_get_last_load_segment(struct dm_tree_node *node)
|
static struct load_segment *_get_last_load_segment(struct dm_tree_node *node)
|
||||||
|
Loading…
Reference in New Issue
Block a user