From 9a22e746b5ba86bde47fa5e3e061a20b601eb8e1 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 5 Dec 2007 16:24:41 +0000 Subject: [PATCH] work out device name to use for read ahead request --- libdm/ioctl/libdm-iface.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index 663abecd5..26427ba45 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -922,7 +922,29 @@ int dm_task_get_info(struct dm_task *dmt, struct dm_info *info) uint32_t dm_task_get_read_ahead(const struct dm_task *dmt, uint32_t *read_ahead) { - return get_dev_node_read_ahead(dmt->dev_name, read_ahead); + const char *dev_name; + + *read_ahead = 0; + +#ifdef DM_COMPAT + /* Not supporting this */ + if (_dm_version == 1) + return 1; +#endif + + if (!dmt->dmi.v4 || !(dmt->dmi.v4->flags & DM_EXISTS_FLAG)) + return 0; + + if (*dmt->dmi.v4->name) + dev_name = dmt->dmi.v4->name; + else if (dmt->dev_name) + dev_name = dmt->dev_name; + else { + log_error("Get read ahead request failed: device name unrecorded."); + return 0; + } + + return get_dev_node_read_ahead(dev_name, read_ahead); } const char *dm_task_get_name(const struct dm_task *dmt)