vitastor-disk: Refuse a disk given both as data and in --fast-devices #135

Merged
vitalif merged 1 commits from koolkhel/vitastor:prepare-fast-data-overlap into master 2026-11-20 19:20:12 +03:00
2 changed files with 15 additions and 0 deletions

View File

@@ -728,6 +728,17 @@ int disk_tool_t::prepare(std::vector<std::string> devices)
fprintf(stderr, "No fast devices found\n");
return 1;
}
for (auto & ssd: ssds)
{
for (auto & dev: devinfo)
{
if (dev.path == ssd.path)
{
fprintf(stderr, "%s is specified both in the device list and in --fast-devices\n", dev.path.c_str());
return 1;
}
}
}
if (options["journal_size"] == "")
{
auto auto_journal_size = DEFAULT_HYBRID_SSD_JOURNAL;

View File

@@ -12,6 +12,10 @@ dd if=/dev/zero of=./testdata/bin/test_meta.bin bs=1 count=1 seek=$((1024*1024*1
LOOP2=$(sudo losetup --show -f ./testdata/bin/test_meta.bin)
trap "kill -9 $(jobs -p) || true; sudo losetup -d $LOOP1 $LOOP2"' || true' EXIT
# prepare should refuse a disk given both in the device list and in --fast-devices
sudo -E build/src/disk_tool/vitastor-disk-test prepare --dry-run --hybrid --fast-devices $LOOP1 $LOOP1 2>&1 |
grep 'both in the device list and in --fast-devices'
# also test prepare --hybrid :)
# non-vitastor random type UUID to prevent udev activation
mount | grep '/dev type devtmpfs' || sudo mount udev /dev/ -t devtmpfs