int r = fs->store->statfs(&s);
if (r < 0)
return r;
- stbuf->f_bsize = s.bsize;
- stbuf->f_blocks = s.blocks;
- stbuf->f_bavail = stbuf->f_bfree = s.available / s.bsize;
+ stbuf->f_bsize = 4096; // LIES!
+ stbuf->f_blocks = s.total / 4096;
+ stbuf->f_bavail = s.available / 4096;
return 0;
}
errors += r;
}
+ // get expected statfs; fill unaffected fields to be able to compare
+ // structs
+ statfs(&actual_statfs);
+ expected_statfs.total = actual_statfs.total;
+ expected_statfs.available = actual_statfs.available;
+
// walk collections, objects
for (ceph::unordered_map<coll_t, CollectionRef>::iterator p = coll_map.begin();
p != coll_map.end();
hash_shared.clear();
bnode.reset();
}
- statfs(&actual_statfs);
- //fill unaffected fields to be able to compare structs
- expected_statfs.blocks = actual_statfs.blocks;
- expected_statfs.bsize = actual_statfs.bsize;
- expected_statfs.available = actual_statfs.available;
if (!(actual_statfs == expected_statfs)) {
dout(30) << __func__ << " actual statfs differs from the expected one:"
<< actual_statfs << " vs. "
bluefs_len += p.get_len();
buf->reset();
-
- buf->blocks = bdev->get_size() / block_size;
- buf->bsize = block_size;
+ buf->total = bdev->get_size();
buf->available = (alloc->get_free() - bluefs_len);
bufferlist bl;
assert(r != -ENOENT);
return r;
}
- buf0->blocks = buf.f_blocks;
- buf0->bsize = buf.f_bsize;
+ buf0->total = buf.f_blocks * buf.f_bsize;
buf0->available = buf.f_bavail * buf.f_bsize;
return 0;
}
{
dout(10) << __func__ << dendl;
st->reset();
- st->bsize = 4096;
-
- // Device size is a configured constant
- st->blocks = g_conf->memstore_device_bytes / st->bsize;
-
- dout(10) << __func__ << ": used_bytes: " << used_bytes << "/" << g_conf->memstore_device_bytes << dendl;
- st->available = MAX((int64_t(st->blocks * st->bsize) - int64_t(used_bytes)), 0);
-
+ st->total = g_conf->memstore_device_bytes;
+ st->available = MAX(int64_t(st->total) - int64_t(used_bytes), 0ll);
+ dout(10) << __func__ << ": used_bytes: " << used_bytes
+ << "/" << g_conf->memstore_device_bytes << dendl;
return 0;
}
return;
}
- uint64_t bytes = stbuf.blocks * stbuf.bsize;
+ uint64_t bytes = stbuf.total;
uint64_t used = bytes - stbuf.available;
uint64_t avail = stbuf.available;
}
snprintf(weight, sizeof(weight), "%.4lf",
MAX((double).00001,
- (double)(st.blocks * st.bsize) /
+ (double)(st.total) /
(double)(1ull << 40 /* TB */)));
}
bool store_statfs_t::operator==(const store_statfs_t& other) const
{
- return blocks == other.blocks
- && bsize == other.bsize
+ return total == other.total
&& available == other.available
&& allocated == other.allocated
&& stored == other.stored
void store_statfs_t::dump(Formatter *f) const
{
+ f->dump_int("total", total);
f->dump_int("available", available);
-
- f->dump_int("blocks", blocks);
- f->dump_int("bsize", bsize);
-
f->dump_int("allocated", allocated);
f->dump_int("stored", stored);
f->dump_int("compressed", compressed);
ostream& operator<<(ostream& out, const store_statfs_t &s)
{
out << std::hex
- << " store_statfs(0x" << s.blocks
- << "*0x" << s.bsize
- << "/0x" << s.available
+ << " store_statfs(0x" << s.available
+ << "/0x" << s.total
<< ", stored 0x" << s.stored
<< "/0x" << s.allocated
<< ", compress 0x" << s.compressed
+*/
struct store_statfs_t
{
-
- uint64_t blocks = 0; // Total data blocks
- uint32_t bsize = 0; // Optimal transfer block size
+ uint64_t total = 0; // Total bytes
uint64_t available = 0; // Free bytes available
int64_t allocated = 0; // Bytes allocated by the store
ASSERT_EQ(r, 0);
ASSERT_EQ( 0u, statfs.allocated);
ASSERT_EQ( 0u, statfs.stored);
- ASSERT_EQ(0x1000u, statfs.bsize);
- ASSERT_EQ(g_conf->bluestore_block_size / 0x1000, statfs.blocks);
+ ASSERT_EQ(g_conf->bluestore_block_size, statfs.total);
ASSERT_TRUE(statfs.available > 0u && statfs.available < g_conf->bluestore_block_size);
//force fsck
EXPECT_EQ(store->umount(), 0);
struct store_statfs_t statfs;
int r = store->statfs(&statfs);
ASSERT_EQ(r, 0);
- ASSERT_EQ( 0u, statfs.allocated);
- ASSERT_EQ( 0u, statfs.stored);
- ASSERT_EQ(0x1000u, statfs.bsize);
- ASSERT_EQ(g_conf->bluestore_block_size / 0x1000, statfs.blocks);
+ ASSERT_EQ(g_conf->bluestore_block_size, statfs.total);
+ ASSERT_EQ(0u, statfs.allocated);
+ ASSERT_EQ(0u, statfs.stored);
ASSERT_TRUE(statfs.available > 0u && statfs.available < g_conf->bluestore_block_size);
}
std::string data;