Fix moving of the last block in vitastor-disk resize
This commit is contained in:
@@ -1530,6 +1530,24 @@ jobs:
|
||||
echo ""
|
||||
done
|
||||
|
||||
test_resize_last:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
container: ${{env.TEST_IMAGE}}:${{github.sha}}
|
||||
steps:
|
||||
- name: Run test
|
||||
id: test
|
||||
timeout-minutes: 3
|
||||
run: /root/vitastor/tests/test_resize_last.sh
|
||||
- name: Print logs
|
||||
if: always() && steps.test.outcome == 'failure'
|
||||
run: |
|
||||
for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do
|
||||
echo "-------- $i --------"
|
||||
cat $i
|
||||
echo ""
|
||||
done
|
||||
|
||||
test_resize_auto:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
@@ -1566,6 +1584,24 @@ jobs:
|
||||
echo ""
|
||||
done
|
||||
|
||||
test_old_resize_last:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
container: ${{env.TEST_IMAGE}}:${{github.sha}}
|
||||
steps:
|
||||
- name: Run test
|
||||
id: test
|
||||
timeout-minutes: 3
|
||||
run: OLD=1 /root/vitastor/tests/test_resize_last.sh
|
||||
- name: Print logs
|
||||
if: always() && steps.test.outcome == 'failure'
|
||||
run: |
|
||||
for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do
|
||||
echo "-------- $i --------"
|
||||
cat $i
|
||||
echo ""
|
||||
done
|
||||
|
||||
test_old_resize_auto:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
|
||||
@@ -213,7 +213,8 @@ void disk_tool_t::resize_init(blockstore_meta_header_v3_t *hdr)
|
||||
data_idx_diff = ((int64_t)(dsk.data_offset-new_data_offset))/((int64_t)dsk.data_block_size);
|
||||
free_first = new_data_offset > dsk.data_offset ? (new_data_offset-dsk.data_offset) / dsk.data_block_size : 0;
|
||||
free_last = (new_data_offset+new_data_len < dsk.data_offset+dsk.data_len)
|
||||
? (dsk.data_offset+dsk.data_len-new_data_offset-new_data_len) / dsk.data_block_size
|
||||
? ((dsk.data_offset-new_data_offset)/dsk.data_block_size +
|
||||
dsk.data_len/dsk.data_block_size - new_data_len/dsk.data_block_size)
|
||||
: 0;
|
||||
uint32_t new_clean_entry_header_size = sizeof(clean_disk_entry) + 4 /*entry_csum*/;
|
||||
new_clean_entry_bitmap_size = dsk.data_block_size / (hdr ? hdr->bitmap_granularity : 4096) / 8;
|
||||
|
||||
@@ -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