mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
display: Avoid internal snapshot LV names in msgs.
vg/snapshotN should not appear anywhere. No code should be showing this, but it was noticed in some logs last week and we can deal with it in display_lvname().
This commit is contained in:
parent
2763b928de
commit
0778d2e985
@ -1,5 +1,6 @@
|
||||
Version 2.02.151 -
|
||||
=================================
|
||||
Avoid internal snapshot LV names in messages.
|
||||
Autodetect and use /run/lock dir when available instead of /var/lock.
|
||||
lvchange --refresh for merging thin origin will retry to deactivate snapshot.
|
||||
Recognize in-progress snapshot merge for thin volumes from dm table.
|
||||
|
@ -121,19 +121,29 @@ const char *get_percent_string(percent_type_t def)
|
||||
return _percent_types[def];
|
||||
}
|
||||
|
||||
static const char *_lv_name(const struct logical_volume *lv)
|
||||
{
|
||||
/* Never try to display names of the internal snapshot structures. */
|
||||
if (lv_is_snapshot(lv))
|
||||
return find_cow(lv)->name;
|
||||
|
||||
return lv->name;
|
||||
}
|
||||
|
||||
const char *display_lvname(const struct logical_volume *lv)
|
||||
{
|
||||
char *name;
|
||||
const char *lv_name = _lv_name(lv);
|
||||
int r;
|
||||
|
||||
if ((lv->vg->cmd->display_lvname_idx + NAME_LEN) >= sizeof((lv->vg->cmd->display_buffer)))
|
||||
lv->vg->cmd->display_lvname_idx = 0;
|
||||
|
||||
name = lv->vg->cmd->display_buffer + lv->vg->cmd->display_lvname_idx;
|
||||
r = dm_snprintf(name, NAME_LEN, "%s/%s", lv->vg->name, lv->name);
|
||||
r = dm_snprintf(name, NAME_LEN, "%s/%s", lv->vg->name, lv_name);
|
||||
|
||||
if (r < 0) {
|
||||
log_error("Full LV name \"%s/%s\" is too long.", lv->vg->name, lv->name);
|
||||
log_error("Full LV name \"%s/%s\" is too long.", lv->vg->name, lv_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1082,6 +1082,9 @@ struct lv_segment *find_snapshot(const struct logical_volume *lv);
|
||||
/* Given a cow LV, return its origin */
|
||||
struct logical_volume *origin_from_cow(const struct logical_volume *lv);
|
||||
|
||||
/* Given an internal snapshot LV, return its cow */
|
||||
struct logical_volume *find_cow(const struct logical_volume *snap);
|
||||
|
||||
void init_snapshot_seg(struct lv_segment *seg, struct logical_volume *origin,
|
||||
struct logical_volume *cow, uint32_t chunk_size, int merge);
|
||||
|
||||
|
@ -34,6 +34,11 @@ int lv_is_cow(const struct logical_volume *lv)
|
||||
return (!lv_is_thin_volume(lv) && !lv_is_origin(lv) && lv->snapshot) ? 1 : 0;
|
||||
}
|
||||
|
||||
struct logical_volume *find_cow(const struct logical_volume *snap)
|
||||
{
|
||||
return first_seg(snap)->cow;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some kernels have a bug that they may leak space in the snapshot on crash.
|
||||
* If the kernel is buggy, we add some extra space.
|
||||
|
Loading…
Reference in New Issue
Block a user