mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dev-cache: fix use of uninitialized device status if reading outdated .cache record
As part of fix that came with cf700151eb
,
I forgot to add the check whether the result of stat was successful or
not. This bug caused uninitialized buffer to be used for entries
from .cache file which are no longer valid.
This bug may have caused these uninitialized values to be used further,
for example (see the unreal (2567,590944) representing major:minor
pair):
$ pvs
/dev/abc: stat failed: No such file or directory
Path /dev/abc no longer valid for device(2567,590944)
PV VG Fmt Attr PSize PFree
/dev/mapper/test lvm2 --- 104.00m 104.00m
/dev/vda2 rhel lvm2 a-- 9.51g 0
This commit is contained in:
parent
9694854082
commit
55c13f3de4
@ -1,5 +1,6 @@
|
||||
Version 2.02.130 -
|
||||
===================================
|
||||
Fix use of uninitialized device status if reading outdated .cache record.
|
||||
Restore support for --monitor option in lvcreate (2.02.112).
|
||||
Read thin-pool data and metadata percent without flush.
|
||||
Detect blocked thin-pool and avoid scanning their thin volumes.
|
||||
|
@ -948,6 +948,7 @@ struct device *dev_cache_get(const char *name, struct dev_filter *f)
|
||||
{
|
||||
struct stat buf;
|
||||
struct device *d = (struct device *) dm_hash_lookup(_cache.names, name);
|
||||
int info_available = 0;
|
||||
|
||||
if (d && (d->flags & DEV_REGULAR))
|
||||
return d;
|
||||
@ -958,7 +959,8 @@ struct device *dev_cache_get(const char *name, struct dev_filter *f)
|
||||
dm_hash_remove(_cache.names, name);
|
||||
log_sys_very_verbose("stat", name);
|
||||
d = NULL;
|
||||
}
|
||||
} else
|
||||
info_available = 1;
|
||||
|
||||
if (d && (buf.st_rdev != d->dev)) {
|
||||
dm_hash_remove(_cache.names, name);
|
||||
@ -966,7 +968,7 @@ struct device *dev_cache_get(const char *name, struct dev_filter *f)
|
||||
}
|
||||
|
||||
if (!d) {
|
||||
_insert(name, &buf, 0, obtain_device_list_from_udev());
|
||||
_insert(name, info_available ? &buf : NULL, 0, obtain_device_list_from_udev());
|
||||
d = (struct device *) dm_hash_lookup(_cache.names, name);
|
||||
if (!d) {
|
||||
_full_scan(0);
|
||||
|
Loading…
Reference in New Issue
Block a user