prolong lifetime of blockdevice cache to 120 seconds
fix blockdevice size calculation respect "empty_cache" setting during blockdevice reset
This commit is contained in:
parent
640cfd1b3f
commit
9bf82f30dc
|
@ -51,7 +51,7 @@ MAJOR_DEVNUM_MD_RAID = 9
|
||||||
|
|
||||||
## cache settings
|
## cache settings
|
||||||
CACHE_ENABLED = True
|
CACHE_ENABLED = True
|
||||||
CACHE_EXPIRE_SECONDS = 60
|
CACHE_EXPIRE_SECONDS = 120
|
||||||
CACHE_MONITOR_FILE = '/proc/partitions'
|
CACHE_MONITOR_FILE = '/proc/partitions'
|
||||||
|
|
||||||
## useful for manual profiling
|
## useful for manual profiling
|
||||||
|
@ -139,7 +139,8 @@ class Blockdevice:
|
||||||
@type empty_cache: boolean
|
@type empty_cache: boolean
|
||||||
@param empty_cache: Whether to discard the cached information or not.
|
@param empty_cache: Whether to discard the cached information or not.
|
||||||
"""
|
"""
|
||||||
CACHE.reset(["blockdevice_info", self.name])
|
if empty_cache:
|
||||||
|
CACHE.reset(["blockdevice_info", self.name])
|
||||||
self.devnum = self.__get_major_minor()
|
self.devnum = self.__get_major_minor()
|
||||||
self.size = self.__get_size()
|
self.size = self.__get_size()
|
||||||
self.size_human = self.__get_size_human()
|
self.size_human = self.__get_size_human()
|
||||||
|
@ -387,8 +388,9 @@ class Blockdevice:
|
||||||
"""
|
"""
|
||||||
default = 0
|
default = 0
|
||||||
try:
|
try:
|
||||||
size_kb = int(file(os.path.join(self.devdir, 'size')).read())
|
size_blocks = int(file(os.path.join(self.devdir, 'size')).read())
|
||||||
return int(size_kb/1024)
|
## size is defined as the number of blocks (512 byte)
|
||||||
|
return int(size_blocks/512)
|
||||||
except OSError:
|
except OSError:
|
||||||
return default
|
return default
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in New Issue