mirror of
https://github.com/ceph/ceph
synced 2025-02-23 11:07:35 +00:00
Merge pull request #11195 from xiexingguo/xxg-wip-csum-improve
os/bluestore: a few fixes about the global csum setting Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
233804acac
@ -960,8 +960,7 @@ OPTION(bluestore_block_wal_path, OPT_STR, "")
|
||||
OPTION(bluestore_block_wal_size, OPT_U64, 96 * 1024*1024) // rocksdb wal
|
||||
OPTION(bluestore_block_wal_create, OPT_BOOL, false)
|
||||
OPTION(bluestore_block_preallocate_file, OPT_BOOL, false) //whether preallocate space if block/db_path/wal_path is file rather that block device.
|
||||
OPTION(bluestore_csum, OPT_BOOL, true)
|
||||
OPTION(bluestore_csum_type, OPT_STR, "crc32c")
|
||||
OPTION(bluestore_csum_type, OPT_STR, "crc32c") // none|xxhash32|xxhash64|crc32c|crc32c_16|crc32c_8
|
||||
OPTION(bluestore_min_csum_block, OPT_U32, 4096)
|
||||
OPTION(bluestore_max_csum_block, OPT_U32, 64*1024)
|
||||
OPTION(bluestore_min_alloc_size, OPT_U32, 0)
|
||||
|
@ -2222,7 +2222,6 @@ BlueStore::~BlueStore()
|
||||
const char **BlueStore::get_tracked_conf_keys() const
|
||||
{
|
||||
static const char* KEYS[] = {
|
||||
"bluestore_csum",
|
||||
"bluestore_csum_type",
|
||||
"bluestore_compression",
|
||||
"bluestore_compression_algorithm",
|
||||
@ -2236,8 +2235,7 @@ const char **BlueStore::get_tracked_conf_keys() const
|
||||
void BlueStore::handle_conf_change(const struct md_config_t *conf,
|
||||
const std::set<std::string> &changed)
|
||||
{
|
||||
if (changed.count("bluestore_csum_type") ||
|
||||
changed.count("bluestore_csum")) {
|
||||
if (changed.count("bluestore_csum_type")) {
|
||||
_set_csum();
|
||||
}
|
||||
if (changed.count("bluestore_compression") ||
|
||||
@ -2303,12 +2301,9 @@ void BlueStore::_set_compression()
|
||||
void BlueStore::_set_csum()
|
||||
{
|
||||
csum_type = bluestore_blob_t::CSUM_NONE;
|
||||
if (g_conf->bluestore_csum) {
|
||||
int t = bluestore_blob_t::get_csum_string_type(
|
||||
g_conf->bluestore_csum_type);
|
||||
if (t > bluestore_blob_t::CSUM_NONE)
|
||||
csum_type = t;
|
||||
}
|
||||
int t = bluestore_blob_t::get_csum_string_type(g_conf->bluestore_csum_type);
|
||||
if (t > bluestore_blob_t::CSUM_NONE)
|
||||
csum_type = t;
|
||||
|
||||
dout(10) << __func__ << " csum_type "
|
||||
<< bluestore_blob_t::get_csum_type_string(csum_type)
|
||||
@ -4733,8 +4728,7 @@ int BlueStore::_do_read(
|
||||
} else {
|
||||
for (auto reg : b2r_it->second) {
|
||||
// determine how much of the blob to read
|
||||
uint64_t chunk_size = bptr->get_blob().get_chunk_size(
|
||||
csum_type != bluestore_blob_t::CSUM_NONE, block_size);
|
||||
uint64_t chunk_size = bptr->get_blob().get_chunk_size(true, block_size);
|
||||
uint64_t r_off = reg.blob_xoffset;
|
||||
uint64_t r_len = reg.length;
|
||||
unsigned front = r_off % chunk_size;
|
||||
@ -4820,8 +4814,7 @@ int BlueStore::_verify_csum(OnodeRef& o,
|
||||
{
|
||||
int bad;
|
||||
uint64_t bad_csum;
|
||||
int r = csum_type != bluestore_blob_t::CSUM_NONE ?
|
||||
blob->verify_csum(blob_xoffset, bl, &bad, &bad_csum) :0;
|
||||
int r = blob->verify_csum(blob_xoffset, bl, &bad, &bad_csum);
|
||||
if (r < 0) {
|
||||
if (r == -1) {
|
||||
vector<bluestore_pextent_t> pex;
|
||||
@ -7343,8 +7336,9 @@ int BlueStore::_do_alloc_write(
|
||||
<< dendl;
|
||||
|
||||
// checksum
|
||||
if (csum_type) {
|
||||
b->dirty_blob().init_csum(csum_type, csum_order, csum_length);
|
||||
int csum = csum_type.load();
|
||||
if (csum) {
|
||||
b->dirty_blob().init_csum(csum, csum_order, csum_length);
|
||||
b->dirty_blob().calc_csum(b_off, *l);
|
||||
}
|
||||
if (wi.mark_unused) {
|
||||
|
@ -1336,7 +1336,7 @@ private:
|
||||
set<ghobject_t, ghobject_t::BitwiseComparator> debug_data_error_objects;
|
||||
set<ghobject_t, ghobject_t::BitwiseComparator> debug_mdata_error_objects;
|
||||
|
||||
int csum_type;
|
||||
std::atomic<int> csum_type;
|
||||
|
||||
uint64_t block_size; ///< block size of block device (power of 2)
|
||||
uint64_t block_mask; ///< mask to get just the block offset
|
||||
|
@ -3995,9 +3995,8 @@ TEST_P(StoreTest, SyntheticMatrixCsumAlgorithm) {
|
||||
{ "max_size", "1048576", 0 },
|
||||
{ "alignment", "16", 0 },
|
||||
{ "bluestore_min_alloc_size", "65536", 0 },
|
||||
{ "bluestore_csum", "true", 0 },
|
||||
{ "bluestore_csum_type", "crc32c", "crc32c_16", "crc32c_8", "xxhash32",
|
||||
"xxhash64", 0 },
|
||||
"xxhash64", "none", 0 },
|
||||
{ 0 },
|
||||
};
|
||||
do_matrix(m, store);
|
||||
@ -4013,7 +4012,6 @@ TEST_P(StoreTest, SyntheticMatrixCsumVsCompression) {
|
||||
{ "alignment", "512", 0 },
|
||||
{ "bluestore_min_alloc_size", "32768", "4096", 0 },
|
||||
{ "bluestore_compression", "force", "none", 0},
|
||||
{ "bluestore_csum", "true", 0 },
|
||||
{ "bluestore_csum_type", "crc32c", 0 },
|
||||
{ "bluestore_default_buffered_read", "true", "false", 0 },
|
||||
{ 0 },
|
||||
@ -4061,7 +4059,7 @@ TEST_P(StoreTest, SyntheticMatrixNoCsum) {
|
||||
{ "alignment", "512", 0 },
|
||||
{ "bluestore_min_alloc_size", "65536", "4096", 0 },
|
||||
{ "bluestore_compression", "force", "none", 0},
|
||||
{ "bluestore_csum", "false", 0 },
|
||||
{ "bluestore_csum_type", "none", 0},
|
||||
{ "bluestore_default_buffered_read", "true", "false", 0 },
|
||||
{ 0 },
|
||||
};
|
||||
@ -5060,7 +5058,6 @@ TEST_P(StoreTest, TryMoveRename) {
|
||||
TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
if (string(GetParam()) != "bluestore")
|
||||
return;
|
||||
g_conf->set_val("bluestore_csum", "true");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->apply_changes(NULL);
|
||||
|
||||
@ -5094,8 +5091,7 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
r = apply_transaction(store, &osr, std::move(t));
|
||||
ASSERT_EQ(r, 0);
|
||||
|
||||
g_conf->set_val("bluestore_csum", "false");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->set_val("bluestore_csum_type", "none");
|
||||
g_conf->apply_changes(NULL);
|
||||
|
||||
bufferlist in;
|
||||
@ -5106,9 +5102,6 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
}
|
||||
{
|
||||
//write with csum disabled followed by read with csum enabled
|
||||
g_conf->set_val("bluestore_csum", "false");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->apply_changes(NULL);
|
||||
|
||||
size_t block_size = 64*1024;
|
||||
ObjectStore::Transaction t;
|
||||
@ -5122,7 +5115,6 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
r = apply_transaction(store, &osr, std::move(t));
|
||||
ASSERT_EQ(r, 0);
|
||||
|
||||
g_conf->set_val("bluestore_csum", "true");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->apply_changes(NULL);
|
||||
|
||||
@ -5133,9 +5125,6 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
}
|
||||
{
|
||||
//'mixed' non-overlapping writes to the same blob
|
||||
g_conf->set_val("bluestore_csum", "true");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->apply_changes(NULL);
|
||||
|
||||
ObjectStore::Transaction t;
|
||||
bufferlist bl, orig;
|
||||
@ -5148,8 +5137,7 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
r = apply_transaction(store, &osr, std::move(t));
|
||||
ASSERT_EQ(r, 0);
|
||||
|
||||
g_conf->set_val("bluestore_csum", "false");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->set_val("bluestore_csum_type", "none");
|
||||
g_conf->apply_changes(NULL);
|
||||
|
||||
ObjectStore::Transaction t2;
|
||||
@ -5167,7 +5155,6 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
ASSERT_EQ((int)block_size, r);
|
||||
ASSERT_TRUE(bl_eq(orig, in));
|
||||
|
||||
g_conf->set_val("bluestore_csum", "true");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->apply_changes(NULL);
|
||||
in.clear();
|
||||
@ -5181,9 +5168,6 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
}
|
||||
{
|
||||
//partially blob overwrite under a different csum enablement mode
|
||||
g_conf->set_val("bluestore_csum", "true");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->apply_changes(NULL);
|
||||
|
||||
ObjectStore::Transaction t;
|
||||
bufferlist bl, orig, orig2;
|
||||
@ -5198,8 +5182,7 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
r = apply_transaction(store, &osr, std::move(t));
|
||||
ASSERT_EQ(r, 0);
|
||||
|
||||
g_conf->set_val("bluestore_csum", "false");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->set_val("bluestore_csum_type", "none");
|
||||
g_conf->apply_changes(NULL);
|
||||
|
||||
ObjectStore::Transaction t2;
|
||||
@ -5224,7 +5207,6 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
ASSERT_EQ((int)block_size, r);
|
||||
ASSERT_TRUE(bl_eq(orig2, in));
|
||||
|
||||
g_conf->set_val("bluestore_csum", "true");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->apply_changes(NULL);
|
||||
|
||||
@ -5252,9 +5234,6 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
|
||||
r = apply_transaction(store, &osr, std::move(t));
|
||||
ASSERT_EQ(r, 0);
|
||||
}
|
||||
g_conf->set_val("bluestore_csum", "true");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
g_conf->apply_changes(NULL);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
@ -5369,7 +5348,6 @@ TEST_P(StoreTest, Many4KWritesTest) {
|
||||
TEST_P(StoreTest, Many4KWritesNoCSumTest) {
|
||||
if (string(GetParam()) != "bluestore")
|
||||
return;
|
||||
g_conf->set_val("bluestore_csum", "false");
|
||||
g_conf->set_val("bluestore_csum_type", "none");
|
||||
g_ceph_context->_conf->apply_changes(NULL);
|
||||
store_statfs_t res_stat;
|
||||
@ -5379,7 +5357,6 @@ TEST_P(StoreTest, Many4KWritesNoCSumTest) {
|
||||
|
||||
ASSERT_LE(res_stat.stored, max_object);
|
||||
ASSERT_EQ(res_stat.allocated, max_object);
|
||||
g_conf->set_val("bluestore_csum", "true");
|
||||
g_conf->set_val("bluestore_csum_type", "crc32c");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user