Fix moving of the last block in vitastor-disk resize
This commit is contained in:
@@ -118,9 +118,11 @@ TEST_NAME=csum_4k_dj OSD_ARGS="--data_csum_type crc32c --inmemory_journal fals
|
||||
TEST_NAME=csum_4k OSD_ARGS="--data_csum_type crc32c" OFFSET_ARGS=$OSD_ARGS ./test_heal.sh
|
||||
|
||||
./test_resize.sh
|
||||
./test_resize_last.sh
|
||||
./test_resize_auto.sh
|
||||
|
||||
OLD=1 ./test_resize.sh
|
||||
OLD=1 ./test_resize_last.sh
|
||||
OLD=1 ./test_resize_auto.sh
|
||||
|
||||
./test_osd_tags.sh
|
||||
|
||||
@@ -29,12 +29,11 @@ for i in $(seq 1 $OSD_COUNT); do
|
||||
data_offset=$(echo $offsets | jq -r .data_offset)
|
||||
if [[ "$meta_format" = "3" ]]; then
|
||||
build/src/disk_tool/vitastor-disk dump-meta --io cached $opts >./testdata/meta_before_resize.json
|
||||
new_data_offset=$((128*1024*1024+data_offset%131072))
|
||||
else
|
||||
build/src/disk_tool/vitastor-disk dump-journal --io cached --json ./testdata/bin/test_osd$i.bin 4096 0 $meta_offset >./testdata/journal_before_resize.json
|
||||
build/src/disk_tool/vitastor-disk dump-meta --io cached ./testdata/bin/test_osd$i.bin 4096 $meta_offset $((data_offset-meta_offset)) >./testdata/meta_before_resize.json
|
||||
new_data_offset=$((128*1024*1024+32768))
|
||||
fi
|
||||
new_data_offset=$((128*1024*1024 + data_offset%131072))
|
||||
build/src/disk_tool/vitastor-disk raw-resize --io cached \
|
||||
$opts \
|
||||
--new_meta_offset 0 \
|
||||
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
PG_COUNT=1
|
||||
PG_SIZE=1
|
||||
PG_MINSIZE=1
|
||||
SCHEME=replicated
|
||||
OSD_COUNT=1
|
||||
. `dirname $0`/run_3osds.sh
|
||||
|
||||
kill -9 $OSD1_PID
|
||||
offsets=$(build/src/disk_tool/vitastor-disk simple-offsets --format json ./testdata/bin/test_osd$i.bin $OFFSET_ARGS)
|
||||
opts=$(build/src/disk_tool/vitastor-disk simple-offsets --format options ./testdata/bin/test_osd$i.bin $OFFSET_ARGS)
|
||||
meta_format=$(echo $offsets | jq -r .meta_format)
|
||||
meta_offset=$(echo $offsets | jq -r .meta_offset)
|
||||
data_offset=$(echo $offsets | jq -r .data_offset)
|
||||
data_len=$((1024*1024*1024 - data_offset))
|
||||
last_block=$((data_len/128/1024 - 1))
|
||||
|
||||
if [[ "$meta_format" = "3" ]]; then
|
||||
cat >>./testdata/meta.json <<EOF
|
||||
{"version":"3.0","meta_block_size":4096,"data_block_size":131072,"bitmap_granularity":4096,"data_csum_type":"none","csum_block_size":0,"entries":[
|
||||
{"pool":1,"inode":"0x1","stripe":"0x0","writes":[{"lsn":1,"version":1,"type":"big","stable":true,"location":$((last_block*128*1024)),"offset":0,"len":131072,"bitmap":"ffffffff","ext_bitmap":"ffffffff"}]}
|
||||
]}
|
||||
EOF
|
||||
build/src/disk_tool/vitastor-disk write-meta --io cached $opts <./testdata/meta.json
|
||||
build/src/disk_tool/vitastor-disk raw-resize --io cached \
|
||||
$opts \
|
||||
--new_data_len $((data_len - data_len%131072 - 4096))
|
||||
build/src/disk_tool/vitastor-disk dump-meta --io cached $opts >./testdata/meta1.json
|
||||
if ! jq -s -e '(.[0].entries | length) == 1 and .[0].entries[0].writes[0].location < '$((last_block*128*1024)) <./testdata/meta1.json; then
|
||||
format_error "Last block not moved"
|
||||
fi
|
||||
else
|
||||
cat >>./testdata/meta.json <<EOF
|
||||
{"version":"0.9","meta_block_size":4096,"data_block_size":131072,"bitmap_granularity":4096,"data_csum_type":"none","csum_block_size":0,"entries":[
|
||||
{"block":$last_block,"pool":1,"inode":"0x1","stripe":"0x0","version":1,"bitmap":"ffffffff","ext_bitmap":"ffffffff"}
|
||||
]}
|
||||
EOF
|
||||
build/src/disk_tool/vitastor-disk write-meta --io cached $opts <./testdata/meta.json
|
||||
build/src/disk_tool/vitastor-disk raw-resize --io cached \
|
||||
$opts \
|
||||
--new_data_len $((data_len - data_len%131072 - 4096))
|
||||
build/src/disk_tool/vitastor-disk dump-meta --io cached \
|
||||
./testdata/bin/test_osd1.bin 4096 $meta_offset $((data_offset-meta_offset)) >./testdata/meta1.json
|
||||
if ! jq -s -e '(.[0].entries | length) == 1 and .[0].entries[0].block < '$last_block <./testdata/meta1.json; then
|
||||
format_error "Last block not moved"
|
||||
fi
|
||||
fi
|
||||
|
||||
format_green OK
|
||||
Reference in New Issue
Block a user