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
1 changed files with 6 additions and 4 deletions
|
@ -51,7 +51,7 @@ MAJOR_DEVNUM_MD_RAID = 9
|
|||
|
||||
## cache settings
|
||||
CACHE_ENABLED = True
|
||||
CACHE_EXPIRE_SECONDS = 60
|
||||
CACHE_EXPIRE_SECONDS = 120
|
||||
CACHE_MONITOR_FILE = '/proc/partitions'
|
||||
|
||||
## useful for manual profiling
|
||||
|
@ -139,7 +139,8 @@ class Blockdevice:
|
|||
@type empty_cache: boolean
|
||||
@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.size = self.__get_size()
|
||||
self.size_human = self.__get_size_human()
|
||||
|
@ -387,8 +388,9 @@ class Blockdevice:
|
|||
"""
|
||||
default = 0
|
||||
try:
|
||||
size_kb = int(file(os.path.join(self.devdir, 'size')).read())
|
||||
return int(size_kb/1024)
|
||||
size_blocks = int(file(os.path.join(self.devdir, 'size')).read())
|
||||
## size is defined as the number of blocks (512 byte)
|
||||
return int(size_blocks/512)
|
||||
except OSError:
|
||||
return default
|
||||
except ValueError:
|
||||
|
|
Loading…
Reference in a new issue