common/populate: support multiple cached images
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 20 Mar 2019 00:45:35 +0000 (17:45 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sat, 23 Mar 2019 13:27:12 +0000 (21:27 +0800)
Enhance the populated fs metadump image cache to support multiple
configurations per filesystem so that we reduce the image creation
overhead even further.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/populate

index 1f921ac57b4cd968dd7c65cffc861abb6b24e019..4fa118f0fbdb4a2697c0478a6e48b022aee9a672 100644 (file)
@@ -805,10 +805,12 @@ _scratch_populate_restore_cached() {
 # Populate a scratch FS from scratch or from a cached image.
 _scratch_populate_cached() {
        local meta_descr="$(_scratch_populate_cache_tag "$@")"
 # Populate a scratch FS from scratch or from a cached image.
 _scratch_populate_cached() {
        local meta_descr="$(_scratch_populate_cache_tag "$@")"
+       local meta_tag="$(echo "${meta_descr}" | md5sum - | cut -d ' ' -f 1)"
+       local metadump_stem="${TEST_DIR}/__populate.${FSTYP}.${meta_tag}"
 
        # These variables are shared outside this function
 
        # These variables are shared outside this function
-       POPULATE_METADUMP="${TEST_DIR}/__populate.${FSTYP}"
-       POPULATE_METADUMP_DESCR="${TEST_DIR}/__populate.${FSTYP}.txt"
+       POPULATE_METADUMP="${metadump_stem}.metadump"
+       POPULATE_METADUMP_DESCR="${metadump_stem}.txt"
 
        # Don't keep metadata images cached for more 48 hours...
        rm -rf "$(find "${POPULATE_METADUMP}" -mtime +2 2>/dev/null)"
 
        # Don't keep metadata images cached for more 48 hours...
        rm -rf "$(find "${POPULATE_METADUMP}" -mtime +2 2>/dev/null)"