From 40b7c21fb1e045d78b928de15b15538cef289fb1 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 8 Apr 2021 11:08:38 +0300 Subject: [PATCH] Followup to 307c1731c14bb52dea5b9ac526c4c1115f0093c2 - fix mark_stable --- src/blockstore_stable.cpp | 10 +++++----- tests/test_write.sh | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/blockstore_stable.cpp b/src/blockstore_stable.cpp index cd676b90..370d5c50 100644 --- a/src/blockstore_stable.cpp +++ b/src/blockstore_stable.cpp @@ -168,6 +168,9 @@ resume_5: for (i = 0, v = (obj_ver_id*)op->buf; i < op->len; i++, v++) { // Mark all dirty_db entries up to op->version as stable +#ifdef BLOCKSTORE_DEBUG + printf("Stabilize %lx:%lx v%lu\n", v->oid.inode, v->oid.stripe, v->version); +#endif mark_stable(*v); } // Acknowledge op @@ -183,6 +186,7 @@ void blockstore_impl_t::mark_stable(const obj_ver_id & v, bool forget_dirty) { while (1) { + bool was_stable = IS_STABLE(dirty_it->second.state); if ((dirty_it->second.state & BS_ST_WORKFLOW_MASK) == BS_ST_SYNCED) { dirty_it->second.state = (dirty_it->second.state & ~BS_ST_WORKFLOW_MASK) | BS_ST_STABLE; @@ -207,11 +211,7 @@ void blockstore_impl_t::mark_stable(const obj_ver_id & v, bool forget_dirty) erase_dirty(dirty_it, erase_end, clean_loc); break; } - if (IS_STABLE(dirty_it->second.state)) - { - break; - } - if (dirty_it == dirty_db.begin()) + if (was_stable || dirty_it == dirty_db.begin()) { break; } diff --git a/tests/test_write.sh b/tests/test_write.sh index 73c96ff5..1adf9b5b 100755 --- a/tests/test_write.sh +++ b/tests/test_write.sh @@ -37,6 +37,10 @@ fi LD_PRELOAD=libasan.so.5 \ fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=4M -direct=1 -iodepth=1 -fsync=1 -rw=write -etcd=$ETCD_URL -pool=1 -inode=1 -size=128M -cluster_log_level=10 +LD_PRELOAD=libasan.so.5 \ + fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=4k -direct=1 -iodepth=1 -fsync=32 -buffer_pattern=0xdeadface \ + -rw=randwrite -etcd=$ETCD_URL -pool=1 -inode=1 -size=128M -number_ios=1024 + qemu-img convert -S 4096 -p \ -f raw "vitastor:etcd_host=127.0.0.1\:$ETCD_PORT/v3:pool=1:inode=1:size=$((128*1024*1024))" \ -O raw ./testdata/read.bin