return 0;
}
+void BlueStore::open_statfs()
+{
+ bufferlist bl;
+ int r = db->get(PREFIX_STAT, "bluestore_statfs", &bl);
+ if (r >= 0) {
+ if (size_t(bl.length()) >= sizeof(vstatfs.values)) {
+ auto it = bl.begin();
+ vstatfs.decode(it);
+ }
+ else {
+ dout(10) << __func__ << " store_statfs is corrupt, using empty" << dendl;
+ }
+ }
+ else {
+ dout(10) << __func__ << " store_statfs missed, using empty" << dendl;
+ }
+}
+
int BlueStore::_setup_block_symlink_or_file(
string name,
string epath,
}
}
- bufferlist bl;
- int r = db->get(PREFIX_STAT, "bluestore_statfs", &bl);
- if (r >= 0) {
- volatile_statfs vstatfs;
- if (size_t(bl.length()) >= sizeof(vstatfs.values)) {
- auto it = bl.begin();
- vstatfs.decode(it);
-
- buf->allocated = vstatfs.allocated();
- buf->stored = vstatfs.stored();
- buf->compressed = vstatfs.compressed();
- buf->compressed_original = vstatfs.compressed_original();
- buf->compressed_allocated = vstatfs.compressed_allocated();
- } else {
- dout(10) << __func__ << " store_statfs is corrupt, using empty" << dendl;
- }
- } else {
- dout(10) << __func__ << " store_statfs missed, using empty" << dendl;
+ {
+ std::lock_guard<std::mutex> l(vstatfs_lock);
+
+ buf->allocated = vstatfs.allocated();
+ buf->stored = vstatfs.stored();
+ buf->compressed = vstatfs.compressed();
+ buf->compressed_original = vstatfs.compressed_original();
+ buf->compressed_allocated = vstatfs.compressed_allocated();
}
-
dout(20) << __func__ << *buf << dendl;
return 0;
}
dout(10) << __func__ << " min_alloc_size 0x" << std::hex << min_alloc_size
<< std::dec << dendl;
}
+ open_statfs();
_set_alloc_sizes();
_set_throttle_params();
logger->inc(l_bluestore_compressed_allocated, txc->statfs_delta.compressed_allocated());
logger->inc(l_bluestore_compressed_original, txc->statfs_delta.compressed_original());
+ {
+ std::lock_guard<std::mutex> l(vstatfs_lock);
+ vstatfs += txc->statfs_delta;
+ }
+
bufferlist bl;
txc->statfs_delta.encode(bl);
_txc_state_proc(txc);
kv_committed.pop_front();
}
+
for (auto b : deferred_stable) {
auto p = b->txcs.begin();
while (p != b->txcs.end()) {
void reset() {
*this = volatile_statfs();
}
+ volatile_statfs& operator+=(const volatile_statfs& other) {
+ for (size_t i = 0; i < STATFS_LAST; ++i) {
+ values[i] += other.values[i];
+ }
+ return *this;
+ }
int64_t& allocated() {
return values[STATFS_ALLOCATED];
}
// cache trim control
+ std::mutex vstatfs_lock;
+ volatile_statfs vstatfs;
+
struct MempoolThread : public Thread {
BlueStore *store;
Cond cond;
int _open_super_meta();
+ void open_statfs();
+
int _reconcile_bluefs_freespace();
int _balance_bluefs_freespace(PExtentVector *extents);
void _commit_bluefs_freespace(const PExtentVector& extents);