if (ret < 0) {
CLS_LOG(0, "ERROR: get_existing_bucket_entry() key=%s returned %d", key.c_str(), ret);
return ret;
- } else if (ret >= 0) {
+ } else if (ret >= 0 && old_entry.user_stats_sync) {
dec_header_stats(&header, old_entry);
}
- CLS_LOG(20, "storing entry by client/op at %s", key.c_str());
+ CLS_LOG(20, "storing entry for key=%s size=%lld count=%lld",
+ key.c_str(), (long long)entry.size, (long long)entry.count);
+
+ entry.user_stats_sync = true;
ret = write_entry(hctx, key, entry);
if (ret < 0)
add_header_stats(&header, entry);
}
+
+ bufferlist bl;
+
+ CLS_LOG(20, "header: total bytes=%lld entries=%lld", (long long)header.total_bytes, (long long)header.total_entries);
+
+ ::encode(header, bl);
+ ret = cls_cxx_map_write_header(hctx, &bl);
+ if (ret < 0)
+ return ret;
+
return 0;
}
return ret;
}
- dec_header_stats(&header, entry);
+ if (entry.user_stats_sync) {
+ dec_header_stats(&header, entry);
+ }
CLS_LOG(20, "removing entry at %s", key.c_str());
size_t size_rounded;
time_t creation_time;
uint64_t count;
+ bool user_stats_sync;
- cls_user_bucket_entry() : size(0), size_rounded(0), creation_time(0), count(0) {}
+ cls_user_bucket_entry() : size(0), size_rounded(0), creation_time(0), count(0), user_stats_sync(false) {}
void encode(bufferlist& bl) const {
- ENCODE_START(5, 5, bl);
+ ENCODE_START(6, 5, bl);
uint64_t s = size;
__u32 mt = creation_time;
string empty_str; // originally had the bucket name here, but we encode bucket later
::encode(bucket, bl);
s = size_rounded;
::encode(s, bl);
+ ::encode(user_stats_sync, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
- DECODE_START_LEGACY_COMPAT_LEN(5, 5, 5, bl);
+ DECODE_START_LEGACY_COMPAT_LEN(6, 5, 5, bl);
__u32 mt;
uint64_t s;
string empty_str; // backward compatibility
if (struct_v >= 4)
::decode(s, bl);
size_rounded = s;
+ if (struct_v >= 6)
+ ::decode(user_stats_sync, bl);
DECODE_FINISH(bl);
}
};