Skip to content

Commit

Permalink
Correcting code for cache cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vibhansa-msft committed Mar 8, 2025
1 parent db543ab commit 03e72e4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
14 changes: 7 additions & 7 deletions component/block_cache/block_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 13 additions & 3 deletions perf_testing/scripts/fio_bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=$?
Expand Down Expand Up @@ -113,7 +115,7 @@ iterate_fio_files() {
execute_test $job_file

blobfuse2 unmount all
sleep 5
sleep 10

rm -rf ~/.blobfuse2/*
done
Expand Down Expand Up @@ -165,6 +167,7 @@ list_files() {

# Unmount and cleanup now
blobfuse2 unmount all
sleep 10

echo $avg_list_time " : " $avg_del_time

Expand Down Expand Up @@ -194,6 +197,7 @@ read_write_using_app() {

# Unmount and cleanup now
blobfuse2 unmount all
sleep 10

cat ${output}/app_write_*.json

Expand All @@ -213,6 +217,7 @@ read_write_using_app() {

# Unmount and cleanup now
blobfuse2 unmount all
sleep 10

cat ${output}/app_read_*.json

Expand All @@ -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

Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 03e72e4

Please sign in to comment.