diff --git a/blockstore_impl.h b/blockstore_impl.h index 34ef453d..874e7e0d 100644 --- a/blockstore_impl.h +++ b/blockstore_impl.h @@ -177,7 +177,7 @@ class blockstore_impl_t uint32_t block_size; uint64_t meta_offset; uint64_t data_offset; - uint64_t cfg_journal_size; + uint64_t cfg_journal_size, cfg_data_size; // Required write alignment and journal/metadata/data areas' location alignment uint32_t disk_alignment = 512; // Journal block size - minimum_io_size of the journal device is the best choice diff --git a/blockstore_open.cpp b/blockstore_open.cpp index 85e3320e..481dc3ec 100644 --- a/blockstore_open.cpp +++ b/blockstore_open.cpp @@ -38,6 +38,7 @@ void blockstore_impl_t::parse_config(blockstore_config_t & config) cfg_journal_size = strtoull(config["journal_size"].c_str(), NULL, 10); data_device = config["data_device"]; data_offset = strtoull(config["data_offset"].c_str(), NULL, 10); + cfg_data_size = strtoull(config["data_size"].c_str(), NULL, 10); meta_device = config["meta_device"]; meta_offset = strtoull(config["meta_offset"].c_str(), NULL, 10); block_size = strtoull(config["block_size"].c_str(), NULL, 10); @@ -151,6 +152,15 @@ void blockstore_impl_t::calc_lengths() data_len = data_len < journal.offset-data_offset ? data_len : journal.offset-data_offset; } + if (cfg_data_size != 0) + { + if (data_len < cfg_data_size) + { + throw std::runtime_error("Data area ("+std::to_string(data_len)+ + " bytes) is less than configured size ("+std::to_string(cfg_data_size)+" bytes)"); + } + data_len = cfg_data_size; + } // meta meta_area = (meta_fd == data_fd ? data_size : meta_size) - meta_offset; if (meta_fd == data_fd && meta_offset <= data_offset)