From c1ede1d97c2c4f4cf7ae7ca84fe19f6bbcaa27cb Mon Sep 17 00:00:00 2001 From: Alberto Planas Date: Thu, 10 Jan 2019 16:24:05 +0100 Subject: [PATCH] mount: cache blkid information During the mount of a device a call to blkid is done, to get information of the current devices. blkid is a slow operation, to avoid that use an internal cache, that is specified in /etc/blkid configuration file, but a single blkid can still redo this cache file, making the second call equally slow. This patch cache the blkid information for _active_mountinfo in the __context__ dict, making the next mount action a fast operation. --- salt/modules/mount.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/salt/modules/mount.py b/salt/modules/mount.py index 68cfd1fc6a..1b3d02de9f 100644 --- a/salt/modules/mount.py +++ b/salt/modules/mount.py @@ -63,7 +63,9 @@ def _active_mountinfo(ret): msg = 'File not readable {0}' raise CommandExecutionError(msg.format(filename)) - blkid_info = __salt__['disk.blkid']() + if 'disk.blkid' not in __context__: + __context__['disk.blkid'] = __salt__['disk.blkid']() + blkid_info = __context__['disk.blkid'] with salt.utils.files.fopen(filename) as ifile: for line in ifile: