From 660a42bc783cfa7a8bdea434c4edf859bc01d837 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 19 Oct 2011 16:36:01 +0000 Subject: [PATCH] Add internal expected_errno dm_tast var Certain errno codes could be expected in some situations thus add experimental support for them. When expected errno is set after ioctl error - function skips error printing and exits succefully. Currently only useful for thin pool messages. --- libdm/ioctl/libdm-iface.c | 3 ++- libdm/ioctl/libdm-targets.h | 1 + libdm/libdm-deptree.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index fb2fdd117..737180f75 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -1635,7 +1635,8 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command, dmt->sector, _sanitise_message(dmt->message), dmi->data_size, retry_repeat_count); #ifdef DM_IOCTLS - if (ioctl(_control_fd, command, dmi) < 0) { + if (ioctl(_control_fd, command, dmi) < 0 && + dmt->expected_errno != errno) { if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) || (dmt->type == DM_DEVICE_MKNODES) || (dmt->type == DM_DEVICE_STATUS))) diff --git a/libdm/ioctl/libdm-targets.h b/libdm/ioctl/libdm-targets.h index ca08fe835..cc11e99ba 100644 --- a/libdm/ioctl/libdm-targets.h +++ b/libdm/ioctl/libdm-targets.h @@ -65,6 +65,7 @@ struct dm_task { int secure_data; int retry_remove; int enable_checks; + int expected_errno; char *uuid; }; diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index d1b0e902f..7125df632 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -111,6 +111,7 @@ struct seg_area { struct thin_message { struct dm_list list; struct dm_thin_message message; + int expected_errno; }; /* Replicator-log has a list of sites */ @@ -1314,6 +1315,9 @@ static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_messa 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)) goto_out; @@ -2912,11 +2916,13 @@ int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node, if (!_thin_validate_device_id(message->u.m_create_thin.device_id)) return_0; tm->message.u.m_create_thin.device_id = message->u.m_create_thin.device_id; + tm->expected_errno = EEXIST; break; case DM_THIN_MESSAGE_DELETE: if (!_thin_validate_device_id(message->u.m_delete.device_id)) return_0; tm->message.u.m_delete.device_id = message->u.m_delete.device_id; + tm->expected_errno = ENODATA; break; case DM_THIN_MESSAGE_TRIM: if (!_thin_validate_device_id(message->u.m_trim.device_id))