int use_layer, struct lvinfo *info,
const struct lv_segment *seg,
struct lv_seg_status *seg_status,
- int with_open_count, int with_read_ahead)
+ int with_open_count, int with_read_ahead, int with_name_check)
{
struct dm_info dminfo;
/* New thin-pool has no layer, but -tpool suffix needs to be queried */
if (!use_layer && lv_is_new_thin_pool(lv)) {
/* Check if there isn't existing old thin pool mapping in the table */
- if (!dev_manager_info(cmd, lv, NULL, 0, 0, &dminfo, NULL, NULL))
+ if (!dev_manager_info(cmd, lv, NULL, 0, 0, 0, &dminfo, NULL, NULL))
return_0;
if (!dminfo.exists)
use_layer = 1;
if (!dev_manager_info(cmd, lv,
(use_layer) ? lv_layer(lv) : NULL,
- with_open_count, with_read_ahead,
- &dminfo, (info) ? &info->read_ahead : NULL,
+ with_open_count, with_read_ahead, with_name_check,
+ &dminfo,
+ (info) ? &info->read_ahead : NULL,
seg_status))
return_0;
if (!activation())
return 0;
- return _lv_info(cmd, lv, use_layer, info, NULL, NULL, with_open_count, with_read_ahead);
+ return _lv_info(cmd, lv, use_layer, info, NULL, NULL, with_open_count, with_read_ahead, 0);
+}
+
+int lv_info_with_name_check(struct cmd_context *cmd, const struct logical_volume *lv,
+ int use_layer, struct lvinfo *info)
+{
+ if (!activation())
+ return 0;
+
+ return _lv_info(cmd, lv, use_layer, info, NULL, NULL, 0, 0, 1);
}
/*
* STATUS is collected from cache LV */
if (!(lv_seg = get_only_segment_using_this_lv(lv)))
return_0;
- (void) _lv_info(cmd, lv_seg->lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
+ (void) _lv_info(cmd, lv_seg->lv, 1, NULL, lv_seg, &status->seg_status, 0, 0, 0);
return 1;
}
if (lv_is_thin_pool(lv)) {
/* Always collect status for '-tpool' */
- if (_lv_info(cmd, lv, 1, &status->info, lv_seg, &status->seg_status, 0, 0) &&
+ if (_lv_info(cmd, lv, 1, &status->info, lv_seg, &status->seg_status, 0, 0, 0) &&
(status->seg_status.type == SEG_STATUS_THIN_POOL)) {
/* There is -tpool device, but query 'active' state of 'fake' thin-pool */
- if (!_lv_info(cmd, lv, 0, NULL, NULL, NULL, 0, 0) &&
+ if (!_lv_info(cmd, lv, 0, NULL, NULL, NULL, 0, 0, 0) &&
!status->seg_status.thin_pool->needs_check)
status->info.exists = 0; /* So pool LV is not active */
}
if (lv_is_external_origin(lv)) {
if (!_lv_info(cmd, lv, 0, &status->info, NULL, NULL,
- with_open_count, with_read_ahead))
+ with_open_count, with_read_ahead, 0))
return_0;
- (void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
+ (void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0, 0);
return 1;
}
/* Show INFO for actual origin and grab status for merging origin */
if (!_lv_info(cmd, lv, 0, &status->info, lv_seg,
lv_is_merging_origin(lv) ? &status->seg_status : NULL,
- with_open_count, with_read_ahead))
+ with_open_count, with_read_ahead, 0))
return_0;
if (status->info.exists &&
(status->seg_status.type != SEG_STATUS_SNAPSHOT)) /* Not merging */
/* Grab STATUS from layered -real */
- (void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
+ (void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0, 0);
return 1;
}
olv = origin_from_cow(lv);
if (!_lv_info(cmd, olv, 0, &status->info, first_seg(olv), &status->seg_status,
- with_open_count, with_read_ahead))
+ with_open_count, with_read_ahead, 0))
return_0;
if (status->seg_status.type == SEG_STATUS_SNAPSHOT ||
if (lv_is_vdo(lv)) {
if (!_lv_info(cmd, lv, 0, &status->info, NULL, NULL,
- with_open_count, with_read_ahead))
+ with_open_count, with_read_ahead, 0))
return_0;
if (status->info.exists) {
/* Status for VDO pool */
(void) _lv_info(cmd, seg_lv(lv_seg, 0), 1, NULL,
first_seg(seg_lv(lv_seg, 0)),
- &status->seg_status, 0, 0);
+ &status->seg_status, 0, 0, 0);
/* Use VDO pool segtype result for VDO segtype */
status->seg_status.seg = lv_seg;
}
if (lv_is_vdo_pool(lv)) {
/* Always collect status for '-vpool' */
- if (_lv_info(cmd, lv, 1, &status->info, lv_seg, &status->seg_status, 0, 0) &&
+ if (_lv_info(cmd, lv, 1, &status->info, lv_seg, &status->seg_status, 0, 0, 0) &&
(status->seg_status.type == SEG_STATUS_VDO_POOL)) {
/* There is -tpool device, but query 'active' state of 'fake' vdo-pool */
- if (!_lv_info(cmd, lv, 0, NULL, NULL, NULL, 0, 0))
+ if (!_lv_info(cmd, lv, 0, NULL, NULL, NULL, 0, 0, 0))
status->info.exists = 0; /* So VDO pool LV is not active */
}
}
return _lv_info(cmd, lv, 0, &status->info, lv_seg, &status->seg_status,
- with_open_count, with_read_ahead);
+ with_open_count, with_read_ahead, 0);
}
#define OPEN_COUNT_CHECK_RETRIES 25
laopts->noscan ? " noscan" : "",
laopts->temporary ? " temporary" : "");
- if (!lv_info(cmd, lv, 0, &info, 0, 0))
+ if (!lv_info_with_name_check(cmd, lv, 0, &info))
goto_out;
/*
static int _info_run(const char *dlid, struct dm_info *dminfo,
uint32_t *read_ahead,
struct lv_seg_status *seg_status,
+ const char *name_check,
int with_open_count, int with_read_ahead,
uint32_t major, uint32_t minor)
{
void *target = NULL;
uint64_t target_start, target_length, start, length;
char *target_name, *target_params;
+ const char *dev_name;
if (seg_status) {
dmtask = DM_DEVICE_STATUS;
with_open_count, with_flush, 0)))
return_0;
+ if (name_check && dminfo->exists &&
+ (dev_name = dm_task_get_name(dmt)) &&
+ (strcmp(name_check, dev_name) != 0))
+ dminfo->exists = 0; /* mismatching name -> device does not exist */
+
if (with_read_ahead && dminfo->exists) {
if (!dm_task_get_read_ahead(dmt, read_ahead))
goto_out;
static int _info(struct cmd_context *cmd,
const char *name, const char *dlid,
- int with_open_count, int with_read_ahead,
+ int with_open_count, int with_read_ahead, int with_name_check,
struct dm_info *dminfo, uint32_t *read_ahead,
struct lv_seg_status *seg_status)
{
char old_style_dlid[sizeof(UUID_PREFIX) + 2 * ID_LEN];
const char *suffix, *suffix_position;
+ const char *name_check = (with_name_check) ? name : NULL;
unsigned i = 0;
log_debug_activation("Getting device info for %s [%s].", name, dlid);
/* Check for dlid */
- if (!_info_run(dlid, dminfo, read_ahead, seg_status,
+ if (!_info_run(dlid, dminfo, read_ahead, seg_status, name_check,
with_open_count, with_read_ahead, 0, 0))
return_0;
(void) strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
old_style_dlid[sizeof(old_style_dlid) - 1] = '\0';
if (!_info_run(old_style_dlid, dminfo, read_ahead, seg_status,
- with_open_count, with_read_ahead, 0, 0))
+ name_check, with_open_count, with_read_ahead,
+ 0, 0))
return_0;
if (dminfo->exists)
return 1;
/* Check for dlid before UUID_PREFIX was added */
if (!_info_run(dlid + sizeof(UUID_PREFIX) - 1, dminfo, read_ahead, seg_status,
- with_open_count, with_read_ahead, 0, 0))
+ name_check, with_open_count, with_read_ahead, 0, 0))
return_0;
return 1;
static int _info_by_dev(uint32_t major, uint32_t minor, struct dm_info *info)
{
- return _info_run(NULL, info, NULL, 0, 0, 0, major, minor);
+ return _info_run(NULL, info, NULL, NULL, NULL, 0, 0, major, minor);
}
int dev_manager_check_prefix_dm_major_minor(uint32_t major, uint32_t minor, const char *prefix)
int dev_manager_info(struct cmd_context *cmd,
const struct logical_volume *lv, const char *layer,
- int with_open_count, int with_read_ahead,
+ int with_open_count, int with_read_ahead, int with_name_check,
struct dm_info *dminfo, uint32_t *read_ahead,
struct lv_seg_status *seg_status)
{
if (!(dlid = build_dm_uuid(cmd->mem, lv, layer)))
goto_out;
- if (!(r = _info(cmd, name, dlid, with_open_count, with_read_ahead,
+ if (!(r = _info(cmd, name, dlid,
+ with_open_count, with_read_ahead, with_name_check,
dminfo, read_ahead, seg_status)))
stack;
out:
if (!(dlid = build_dm_uuid(dm->track_pending_delete ? dm->cmd->pending_delete_mem : dm->mem, lv, layer)))
return_0;
- if (!_info(dm->cmd, name, dlid, 1, 0, &info, NULL, NULL))
+ if (!_info(dm->cmd, name, dlid, 1, 0, 0, &info, NULL, NULL))
return_0;
/*
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, pool_lv->name, layer)))
return_0;
- if (!_info(dm->cmd, name, dlid, 1, 0, &info, NULL, NULL))
+ if (!_info(dm->cmd, name, dlid, 1, 0, 0, &info, NULL, NULL))
return_0;
if (info.exists) {
seg->lv->name, errid)))
return_NULL;
- if (!_info(dm->cmd, name, dlid, 1, 0, &info, NULL, NULL))
+ if (!_info(dm->cmd, name, dlid, 1, 0, 0, &info, NULL, NULL))
return_NULL;
if (!info.exists) {