[gparted] Delay loading LVM2_PV_info cache until actually needed (#750582)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Delay loading LVM2_PV_info cache until actually needed (#750582)
- Date: Sat, 13 Jun 2015 17:29:00 +0000 (UTC)
commit 9be8d3760003a4bc726e37e42a99c2dd921263d6
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sun Jun 7 21:42:08 2015 +0100
Delay loading LVM2_PV_info cache until actually needed (#750582)
The lvm query commands were always run and the cache loaded even if
GParted, actually blkid, didn't identify any LVM2 PVs. (GParted uses
libparted and blkid to identify partition content and the lvm commands
to provide the needed configuration details).
Now implement complete lazy initialization of the cache. Never force
loading of the cache. The cache is only loaded when the first value is
accessed from it. When there are no LVM2 PVs, the cache is never
queried, so never loaded. All the needed infrastructure for delayed
loading was previously added by this commit from 2011-12-11:
ff8ad0412057dd6644cd290a8affc71786b5d89f
Lazy initialize the cache from querying LVM2 PVs (#160787)
Every public member function which access values from the cache already
calls initialize_if_required(). Just need to replace force loading of
the cache with a function which just clears the cache.
On my desktop, only when there are no LVM2 PVs, not loading the cache
and therefore not executing these external commands in
load_lvm2_pv_info_cache() saves 1.0 seconds of the 3.7 seconds it takes
to perform the a refresh in GParted:
lvm vgscan
lvm pvs ... -o pv_name,...
lvm pvs ... -o vg_name,...
Bug 750582 - Refactor the LVM2_PV_Info module object interface and
internal cache representation
include/LVM2_PV_Info.h | 2 +-
src/GParted_Core.cc | 2 +-
src/LVM2_PV_Info.cc | 14 +++++++-------
3 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/include/LVM2_PV_Info.h b/include/LVM2_PV_Info.h
index 543d580..c7cc010 100644
--- a/include/LVM2_PV_Info.h
+++ b/include/LVM2_PV_Info.h
@@ -49,8 +49,8 @@ struct LVM2_VG
class LVM2_PV_Info
{
public:
- static void load_cache();
static bool is_lvm2_pv_supported();
+ static void clear_cache();
static Glib::ustring get_vg_name( const Glib::ustring & path );
static Byte_Value get_size_bytes( const Glib::ustring & path );
static Byte_Value get_free_bytes( const Glib::ustring & path );
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 84738ca..d5121af 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -150,7 +150,7 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
Proc_Partitions_Info pp_info( true ) ; //Refresh cache of proc partition information
FS_Info fs_info( true ) ; //Refresh cache of file system information
DMRaid dmraid( true ) ; //Refresh cache of dmraid device information
- LVM2_PV_Info::load_cache(); // Refresh cache of LVM2 PV information
+ LVM2_PV_Info::clear_cache(); // Cache automatically loaded if and when needed
btrfs::clear_cache() ;
init_maps() ;
diff --git a/src/LVM2_PV_Info.cc b/src/LVM2_PV_Info.cc
index a6c5ebd..2bfa97e 100644
--- a/src/LVM2_PV_Info.cc
+++ b/src/LVM2_PV_Info.cc
@@ -70,19 +70,19 @@ std::vector<LVM2_PV> LVM2_PV_Info::lvm2_pv_cache;
std::vector<LVM2_VG> LVM2_PV_Info::lvm2_vg_cache;
std::vector<Glib::ustring> LVM2_PV_Info::error_messages ;
-void LVM2_PV_Info::load_cache()
-{
- set_command_found();
- load_lvm2_pv_info_cache();
- lvm2_pv_info_cache_initialized = true;
-}
-
bool LVM2_PV_Info::is_lvm2_pv_supported()
{
set_command_found() ;
return ( lvm_found ) ;
}
+void LVM2_PV_Info::clear_cache()
+{
+ lvm2_pv_cache.clear();
+ lvm2_vg_cache.clear();
+ lvm2_pv_info_cache_initialized = false;
+}
+
Glib::ustring LVM2_PV_Info::get_vg_name( const Glib::ustring & path )
{
initialize_if_required() ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]