From 3d16cde23c605ea8f5fd4ae866b46db838144152 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 20 Feb 2024 19:41:48 +0300 Subject: [PATCH] Fix assertions, add small sequential write test --- src/blockstore_journal.cpp | 2 +- src/blockstore_write.cpp | 4 ++-- tests/test_write.sh | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/blockstore_journal.cpp b/src/blockstore_journal.cpp index 1420eff4..867fc0ee 100644 --- a/src/blockstore_journal.cpp +++ b/src/blockstore_journal.cpp @@ -146,7 +146,7 @@ journal_entry* prefill_single_journal_entry(journal_t & journal, uint16_t type, journal.in_sector_pos = 0; auto next_next_free = (journal.next_free+journal.block_size) < journal.len ? journal.next_free + journal.block_size : journal.block_size; // double check that next_free doesn't cross used_start from the left - assert(journal.next_free >= journal.used_start || next_next_free < journal.used_start); + assert(journal.next_free >= journal.used_start && next_next_free >= journal.next_free || next_next_free < journal.used_start); journal.next_free = next_next_free; memset(journal.inmemory ? (uint8_t*)journal.buffer + journal.sector_info[journal.cur_sector].offset diff --git a/src/blockstore_write.cpp b/src/blockstore_write.cpp index 99e749aa..238d5ff3 100644 --- a/src/blockstore_write.cpp +++ b/src/blockstore_write.cpp @@ -475,7 +475,7 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op) } } // double check that next_free doesn't cross used_start from the left - assert(journal.next_free >= journal.used_start || next_next_free < journal.used_start); + assert(journal.next_free >= journal.used_start && next_next_free >= journal.next_free || next_next_free < journal.used_start); journal.next_free = next_next_free; je->oid = op->oid; je->version = op->version; @@ -517,7 +517,7 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op) if (next_next_free >= journal.len) next_next_free = dsk.journal_block_size; // double check that next_free doesn't cross used_start from the left - assert(journal.next_free >= journal.used_start || next_next_free < journal.used_start); + assert(journal.next_free >= journal.used_start && next_next_free >= journal.next_free || next_next_free < journal.used_start); journal.next_free = next_next_free; if (!(dirty_it->second.state & BS_ST_INSTANT)) { diff --git a/tests/test_write.sh b/tests/test_write.sh index c16b52e6..867ef456 100755 --- a/tests/test_write.sh +++ b/tests/test_write.sh @@ -6,21 +6,37 @@ check_qemu #LD_PRELOAD=libasan.so.5 \ # fio -thread -name=test -ioengine=build/src/libfio_vitastor_sec.so -bs=4k -fsync=128 `$ETCDCTL get /vitastor/osd/state/1 --print-value-only | jq -r '"-host="+.addresses[0]+" -port="+(.port|tostring)'` -rw=write -size=32M +# Small sequential writes were causing various bugs at different moments + +echo Small sequential writes + +LD_PRELOAD="build/src/libfio_vitastor.so" \ + fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=4k -direct=1 -numjobs=1 -iodepth=16 \ + -rw=write -etcd=$ETCD_URL -pool=1 -inode=1 -size=128M -runtime=10 + # Random writes without immediate_commit were stalling OSDs +echo 68k random writes + LD_PRELOAD="build/src/libfio_vitastor.so" \ fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=68k -direct=1 -numjobs=16 -iodepth=4 \ -rw=randwrite -etcd=$ETCD_URL -pool=1 -inode=1 -size=128M -runtime=10 # A lot of parallel syncs was crashing the primary OSD at some point +echo T64Q1 writes with fsync + LD_PRELOAD="build/src/libfio_vitastor.so" \ fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=4k -direct=1 -numjobs=64 -iodepth=1 -fsync=1 \ -rw=randwrite -etcd=$ETCD_URL -pool=1 -inode=1 -size=128M -number_ios=100 +echo Linear write + LD_PRELOAD="build/src/libfio_vitastor.so" \ 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 +echo T1Q1 writes with fsync=32 + LD_PRELOAD="build/src/libfio_vitastor.so" \ 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