From 03e72e47d37985e5c28051c0ff17bdc0c7315e74 Mon Sep 17 00:00:00 2001 From: vibhansa Date: Fri, 7 Mar 2025 23:48:22 -0800 Subject: [PATCH] Correcting code for cache cleanup --- component/block_cache/block_cache.go | 14 +++++++------- perf_testing/scripts/fio_bench.sh | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/component/block_cache/block_cache.go b/component/block_cache/block_cache.go index 8f876b60f..3d8dd145a 100644 --- a/component/block_cache/block_cache.go +++ b/component/block_cache/block_cache.go @@ -140,13 +140,6 @@ func (bc *BlockCache) SetNextComponent(nc internal.Component) { func (bc *BlockCache) Start(ctx context.Context) error { log.Trace("BlockCache::Start : Starting component %s", bc.Name()) - if bc.cleanupOnStart { - err := common.TempCacheCleanup(bc.tmpPath) - if err != nil { - return fmt.Errorf("error in %s error [fail to cleanup temp cache]", bc.Name()) - } - } - bc.blockPool = NewBlockPool(bc.blockSize, bc.memSize) if bc.blockPool == nil { log.Err("BlockCache::Start : failed to init block pool") @@ -320,6 +313,13 @@ func (bc *BlockCache) Configure(_ bool) error { log.Err("BlockCache: config error creating directory of temp path after clean [%s]", err.Error()) return fmt.Errorf("config error in %s [%s]", bc.Name(), err.Error()) } + } else { + if bc.cleanupOnStart { + err := common.TempCacheCleanup(bc.tmpPath) + if err != nil { + return fmt.Errorf("error in %s error [fail to cleanup temp cache]", bc.Name()) + } + } } if !common.IsDirectoryEmpty(bc.tmpPath) { diff --git a/perf_testing/scripts/fio_bench.sh b/perf_testing/scripts/fio_bench.sh index 3eeb5924e..e761ac0f0 100755 --- a/perf_testing/scripts/fio_bench.sh +++ b/perf_testing/scripts/fio_bench.sh @@ -27,9 +27,11 @@ mount_blobfuse() { if [ -d "/mnt/blob_mnt" ]; then rm -rf /mnt/blob_mnt/* fi + if [ -d "/mnt/tempcache" ]; then rm -rf /mnt/tempcache/* fi + blobfuse2 mount ${mount_dir} --config-file=./config.yaml --log-type=${log_type} --log-level=${log_level} ${cache_path} mount_status=$? set -e @@ -41,7 +43,7 @@ mount_blobfuse() { fi # Wait for daemon to come up and stablise - sleep 5 + sleep 10 df -h | grep blobfuse df_status=$? @@ -113,7 +115,7 @@ iterate_fio_files() { execute_test $job_file blobfuse2 unmount all - sleep 5 + sleep 10 rm -rf ~/.blobfuse2/* done @@ -165,6 +167,7 @@ list_files() { # Unmount and cleanup now blobfuse2 unmount all + sleep 10 echo $avg_list_time " : " $avg_del_time @@ -194,6 +197,7 @@ read_write_using_app() { # Unmount and cleanup now blobfuse2 unmount all + sleep 10 cat ${output}/app_write_*.json @@ -213,6 +217,7 @@ read_write_using_app() { # Unmount and cleanup now blobfuse2 unmount all + sleep 10 cat ${output}/app_read_*.json @@ -236,13 +241,16 @@ read_write_using_app() { python3 ./perf_testing/scripts/highspeed_create.py ${mount_dir} 10 > ${output}/highspeed_app_write.json blobfuse2 unmount all - sleep 3 + sleep 10 + mount_blobfuse + python3 ./perf_testing/scripts/highspeed_read.py ${mount_dir}/20GFile* > ${output}/highspeed_app_read.json rm -rf ${mount_dir}/20GFile* # Unmount and cleanup now blobfuse2 unmount all + sleep 10 cat ${output}/highspeed_app_*.json @@ -279,6 +287,7 @@ rename_files() { # Method to prepare the system for test prepare_system() { blobfuse2 unmount all + sleep 10 # Clean up logs and create output directory mkdir -p ${output} chmod 777 ${output} @@ -324,6 +333,7 @@ then find . -name "create_1l_files_in_20_threads*" -delete cd - ./blobfuse2 unmount all + sleep 10 # Execute file create tests echo "Running Create test cases"