WRITE_CLASS_ENCODER(RGWMetadataLogData);
-int RGWMetadataLog::add_entry(RGWRados *store, const string& section, const string& key, bufferlist& bl) {
+int RGWMetadataLog::add_entry(RGWRados *store, RGWMetadataHandler *handler, const string& section, const string& key, bufferlist& bl) {
string oid;
- store->shard_name(prefix, cct->_conf->rgw_md_log_max_shards, section, key, oid);
+ string hash_key;
+ handler->get_hash_key(section, key, hash_key);
+
+ store->shard_name(prefix, cct->_conf->rgw_md_log_max_shards, hash_key, oid);
utime_t now = ceph_clock_now(cct);
return store->time_log_add(oid, now, section, key, bl);
}
bufferlist logbl;
::encode(log_data, logbl);
- int ret = md_log->add_entry(store, section, key, logbl);
+ int ret = md_log->add_entry(store, handler, section, key, logbl);
if (ret < 0)
return ret;
return 0;
}
-int RGWMetadataManager::post_modify(const string& section, const string& key, RGWMetadataLogData& log_data,
+int RGWMetadataManager::post_modify(RGWMetadataHandler *handler, const string& section, const string& key, RGWMetadataLogData& log_data,
RGWObjVersionTracker *objv_tracker, int ret)
{
if (ret >= 0)
bufferlist logbl;
::encode(log_data, logbl);
- int r = md_log->add_entry(store, section, key, logbl);
+ int r = md_log->add_entry(store, handler, section, key, logbl);
if (ret < 0)
return ret;
objv_tracker, mtime, pattrs);
/* cascading ret into post_modify() */
- ret = post_modify(section, key, log_data, objv_tracker, ret);
+ ret = post_modify(handler, section, key, log_data, objv_tracker, ret);
if (ret < 0)
return ret;
ret = store->delete_obj(NULL, obj);
/* cascading ret into post_modify() */
- ret = post_modify(section, key, log_data, objv_tracker, ret);
+ ret = post_modify(handler, section, key, log_data, objv_tracker, ret);
if (ret < 0)
return ret;
ret = store->set_attrs(NULL, obj, attrs, rmattrs, objv_tracker);
/* cascading ret into post_modify() */
- ret = post_modify(section, key, log_data, objv_tracker, ret);
+ ret = post_modify(handler, section, key, log_data, objv_tracker, ret);
if (ret < 0)
return ret;
virtual int list_keys_init(RGWRados *store, void **phandle) = 0;
virtual int list_keys_next(void *handle, int max, list<string>& keys, bool *truncated) = 0;
virtual void list_keys_complete(void *handle) = 0;
+
+ /* key to use for hashing entries for log shard placement */
+ virtual void get_hash_key(const string& section, const string& key, string& hash_key) {
+ hash_key = section + ":" + key;
+ }
};
#define META_LOG_OBJ_PREFIX "meta.log."
prefix = META_LOG_OBJ_PREFIX;
}
- int add_entry(RGWRados *store, const string& section, const string& key, bufferlist& bl);
+ int add_entry(RGWRados *store, RGWMetadataHandler *handler, const string& section, const string& key, bufferlist& bl);
struct LogListCtx {
int cur_shard;
int pre_modify(RGWMetadataHandler *handler, string& section, const string& key,
RGWMetadataLogData& log_data, RGWObjVersionTracker *objv_tracker,
RGWMDLogStatus op_type);
- int post_modify(const string& section, const string& key, RGWMetadataLogData& log_data,
+ int post_modify(RGWMetadataHandler *handler, const string& section, const string& key, RGWMetadataLogData& log_data,
RGWObjVersionTracker *objv_tracker, int ret);
public: