mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmcache: add mode debug prints
Decorate NULL returns with debug_cache output so the debug log doesn't contain spurios <bactrace> line without any reason for it. Add internal errors when cache is misused.
This commit is contained in:
parent
21b3c983fd
commit
599a05f658
20
lib/cache/lvmcache.c
vendored
20
lib/cache/lvmcache.c
vendored
@ -429,11 +429,15 @@ struct lvmcache_vginfo *lvmcache_vginfo_from_vgname(const char *vgname, const ch
|
||||
if (!vgname)
|
||||
return lvmcache_vginfo_from_vgid(vgid);
|
||||
|
||||
if (!_vgname_hash)
|
||||
if (!_vgname_hash) {
|
||||
log_debug_cache(INTERNAL_ERROR "Internal cache is no yet initialized.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(vginfo = dm_hash_lookup(_vgname_hash, vgname)))
|
||||
if (!(vginfo = dm_hash_lookup(_vgname_hash, vgname))) {
|
||||
log_debug_cache("Metadata cache has no info for vgname: \"%s\"", vgname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (vgid)
|
||||
do
|
||||
@ -441,6 +445,10 @@ struct lvmcache_vginfo *lvmcache_vginfo_from_vgname(const char *vgname, const ch
|
||||
return vginfo;
|
||||
while ((vginfo = vginfo->next));
|
||||
|
||||
if (!vginfo)
|
||||
log_debug_cache("Metadata cache has not found vgname \"%s\" with vgid \"%s\"",
|
||||
vgname, vgid);
|
||||
|
||||
return vginfo;
|
||||
}
|
||||
|
||||
@ -514,15 +522,19 @@ struct lvmcache_vginfo *lvmcache_vginfo_from_vgid(const char *vgid)
|
||||
struct lvmcache_vginfo *vginfo;
|
||||
char id[ID_LEN + 1] __attribute__((aligned(8)));
|
||||
|
||||
if (!_vgid_hash || !vgid)
|
||||
if (!_vgid_hash || !vgid) {
|
||||
log_debug_cache(INTERNAL_ERROR "Internal cache cannot lookup vgid.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* vgid not necessarily NULL-terminated */
|
||||
strncpy(&id[0], vgid, ID_LEN);
|
||||
id[ID_LEN] = '\0';
|
||||
|
||||
if (!(vginfo = dm_hash_lookup(_vgid_hash, id)))
|
||||
if (!(vginfo = dm_hash_lookup(_vgid_hash, id))) {
|
||||
log_debug_cache("Metadata cache has no info for vgid \"%s\"", id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return vginfo;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user