mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
RAID: Cache previous results of lv_raid_dev_health for future use
We can avoid many dev_manager (ioctl) calls by caching the results of previous calls to lv_raid_dev_health. Just considering the case where 'lvs -a' is called to get the attributes of a RAID LV and its sub-lvs, this function would be called many times. (It would be called at least 7 times for a 3-way RAID1 - once for the health of each sub-LV and once for the health of the top-level LV.) This is a good idea because the sub-LVs are processed in groups along with their parent RAID LV and in each case, it is the parent LV whose status will be queried. Therefore, there only needs to be one trip through dev_manager for each time the group is processed.
This commit is contained in:
parent
c8242e5cf4
commit
37ffe6a13a
@ -786,7 +786,17 @@ int lv_raid_dev_health(const struct logical_volume *lv, char **dev_health)
|
|||||||
int r;
|
int r;
|
||||||
struct dev_manager *dm;
|
struct dev_manager *dm;
|
||||||
struct dm_status_raid *status;
|
struct dm_status_raid *status;
|
||||||
|
static char *cached_dev_health = NULL;
|
||||||
|
static const struct logical_volume *cached_lv = NULL;
|
||||||
|
|
||||||
|
if ((lv == cached_lv) && cached_dev_health) {
|
||||||
|
*dev_health = cached_dev_health;
|
||||||
|
log_debug("Using cached raid status for %s/%s: %s",
|
||||||
|
lv->vg->name, lv->name, *dev_health);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cached_lv = lv;
|
||||||
*dev_health = NULL;
|
*dev_health = NULL;
|
||||||
|
|
||||||
if (!activation())
|
if (!activation())
|
||||||
@ -806,6 +816,7 @@ int lv_raid_dev_health(const struct logical_volume *lv, char **dev_health)
|
|||||||
status->dev_health)))
|
status->dev_health)))
|
||||||
stack;
|
stack;
|
||||||
|
|
||||||
|
cached_dev_health = *dev_health;
|
||||||
dev_manager_destroy(dm);
|
dev_manager_destroy(dm);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
Loading…
Reference in New Issue
Block a user