--- /dev/null
+tasks:
+- exec:
+ client.0:
+ - sudo ceph osd pool create low_tier 4
+- rados:
+ clients: [client.0]
+ low_tier_pool: 'low_tier'
+ ops: 1500
+ objects: 50
+ set_chunk: true
+ enable_dedup: true
+ op_weights:
+ read: 100
+ write: 50
args.extend(['--set_redirect'])
if config.get('set_chunk', False):
args.extend(['--set_chunk'])
+ if config.get('enable_dedup', False):
+ args.extend(['--enable_dedup'])
if config.get('low_tier_pool', None):
args.extend(['--low_tier_pool', config.get('low_tier_pool', None)])
if config.get('pool_snaps', False):
librados::IoCtx low_tier_io_ctx;
int snapname_num;
map<string,string > redirect_objs;
+ bool enable_dedup;
RadosTestContext(const string &pool_name,
int max_in_flight,
bool pool_snaps,
bool write_fadvise_dontneed,
const string &low_tier_pool_name,
+ bool enable_dedup,
const char *id = 0) :
state_lock("Context Lock"),
pool_obj_cont(),
pool_snaps(pool_snaps),
write_fadvise_dontneed(write_fadvise_dontneed),
low_tier_pool_name(low_tier_pool_name),
- snapname_num(0)
+ snapname_num(0),
+ enable_dedup(enable_dedup)
{
}
rados.shutdown();
return r;
}
+ if (enable_dedup) {
+ r = rados.mon_command(
+ "{\"prefix\": \"osd pool set\", \"pool\": \"" + pool_name +
+ "\", \"var\": \"fingerprint_algorithm\", \"val\": \"" + "sha256" + "\"}",
+ inbl, NULL, NULL);
+ if (r < 0) {
+ rados.shutdown();
+ return r;
+ }
+ }
+
char hostname_cstr[100];
gethostname(hostname_cstr, 100);
stringstream hostpid;
uint64_t offset;
uint32_t length;
uint64_t tgt_offset;
+ bool enable_with_reference;
SetChunkOp(int n,
RadosTestContext *context,
const string &oid,
const string &oid_tgt,
const string &tgt_pool_name,
uint64_t tgt_offset,
- TestOpStat *stat = 0)
+ TestOpStat *stat = 0,
+ bool enable_with_reference = false)
: TestOp(n, context, stat),
oid(oid), oid_tgt(oid_tgt), tgt_pool_name(tgt_pool_name),
comp(NULL), done(0),
r(0), offset(offset), length(length),
- tgt_offset(tgt_offset)
+ tgt_offset(tgt_offset), enable_with_reference(enable_with_reference)
{}
void _begin() override
if (src_value.version != 0 && !src_value.deleted())
op.assert_version(src_value.version);
- op.set_chunk(offset, length, context->low_tier_io_ctx,
- context->prefix+oid_tgt, tgt_offset);
+ if (enable_with_reference) {
+ op.set_chunk(offset, length, context->low_tier_io_ctx,
+ context->prefix+oid_tgt, tgt_offset, CEPH_OSD_OP_FLAG_WITH_REFERENCE);
+ } else {
+ op.set_chunk(offset, length, context->low_tier_io_ctx,
+ context->prefix+oid_tgt, tgt_offset);
+ }
pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
new pair<TestOp*, TestOp::CallbackInfo*>(this,
bool ec_pool,
bool balance_reads,
bool set_redirect,
- bool set_chunk) :
+ bool set_chunk,
+ bool enable_dedup) :
m_nextop(NULL), m_op(0), m_ops(ops), m_seconds(max_seconds),
m_objects(objects), m_stats(stats),
m_total_weight(0),
m_ec_pool(ec_pool),
m_balance_reads(balance_reads),
m_set_redirect(set_redirect),
- m_set_chunk(set_chunk)
+ m_set_chunk(set_chunk),
+ m_enable_dedup(enable_dedup)
{
m_start = time(0);
for (map<TestOpType, unsigned int>::const_iterator it = op_weights.begin();
<< " length: " << rand_length << " target oid " << oid2.str()
<< " tgt_offset: " << rand_tgt_offset << std::endl;
op = new SetChunkOp(m_op, &context, oid.str(), rand_offset, rand_length, oid2.str(),
- context.low_tier_pool_name, rand_tgt_offset, m_stats);
+ context.low_tier_pool_name, rand_tgt_offset, m_stats, m_enable_dedup);
return true;
}
} else if (m_op == make_manifest_end + 1) {
cout << " redirect_not_in_use: " << oid.str() << std::endl;
context.oid_redirect_not_in_use.insert(oid.str());
}
- }
+ }
return false;
}
bool m_balance_reads;
bool m_set_redirect;
bool m_set_chunk;
+ bool m_enable_dedup;
};
int main(int argc, char **argv)
bool balance_reads = false;
bool set_redirect = false;
bool set_chunk = false;
+ bool enable_dedup = false;
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--max-ops") == 0)
* to prevent the race. see https://github.com/ceph/ceph/pull/20096
*/
low_tier_pool_name = argv[++i];
+ } else if (strcmp(argv[i], "--enable_dedup") == 0) {
+ enable_dedup = true;
} else {
cerr << "unknown arg " << argv[i] << std::endl;
exit(1);
pool_snaps,
write_fadvise_dontneed,
low_tier_pool_name,
+ enable_dedup,
id);
TestOpStat stats;
WeightedTestGenerator gen = WeightedTestGenerator(
ops, objects,
op_weights, &stats, max_seconds,
- ec_pool, balance_reads, set_redirect, set_chunk);
+ ec_pool, balance_reads, set_redirect, set_chunk, enable_dedup);
int r = context.init();
if (r < 0) {
cerr << "Error initializing rados test context: "