Report correct file system size depending on enable_nlink

This commit is contained in:
Marcus Holland-Moritz 2021-03-17 15:12:36 +01:00
parent d5f611bfbe
commit 50ef291cd3
4 changed files with 10 additions and 4 deletions

View File

@ -588,9 +588,6 @@ void metadata_<LoggerPolicy>::dump(
os << "modes: " << meta_.modes().size() << std::endl;
os << "names: " << meta_.names().size() << std::endl;
os << "symlinks: " << meta_.symlinks().size() << std::endl;
// TODO: this isn't useful:
os << "hardlinks: " << std::accumulate(nlinks_.begin(), nlinks_.end(), 0)
<< std::endl;
if (auto dev = meta_.devices()) {
os << "devices: " << dev->size() << std::endl;
}
@ -1028,6 +1025,11 @@ int metadata_<LoggerPolicy>::statvfs(struct ::statvfs* stbuf) const {
stbuf->f_bsize = meta_.block_size();
stbuf->f_frsize = 1UL;
stbuf->f_blocks = meta_.total_fs_size();
if (!options_.enable_nlink) {
if (auto ths = meta_.total_hardlink_size()) {
stbuf->f_blocks += *ths;
}
}
stbuf->f_files = inode_count_;
stbuf->f_flag = ST_RDONLY;
stbuf->f_namemax = PATH_MAX;

View File

@ -722,6 +722,7 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
mv2.timestamp_base = ge_data.get_timestamp_base();
mv2.block_size = UINT32_C(1) << cfg_.block_size_bits;
mv2.total_fs_size = prog.original_size;
mv2.total_hardlink_size_ref() = prog.hardlink_size;
mv2.options_ref() = fsopts;
auto [schema, data] = metadata_v2::freeze(mv2);

View File

@ -254,7 +254,7 @@ void basic_end_to_end_test(std::string const& compressor,
EXPECT_EQ(1 << block_size_bits, vfsbuf.f_bsize);
EXPECT_EQ(1, vfsbuf.f_frsize);
EXPECT_EQ(2056934, vfsbuf.f_blocks);
EXPECT_EQ(enable_nlink ? 2056934 : 2080390, vfsbuf.f_blocks);
EXPECT_EQ(9 + 2 * with_devices + with_specials, vfsbuf.f_files);
EXPECT_EQ(ST_RDONLY, vfsbuf.f_flag);
EXPECT_GT(vfsbuf.f_namemax, 0);

View File

@ -232,6 +232,9 @@ struct metadata {
*/
20: optional list<UInt32> shared_files_table,
// total file system size (without hardlinks)
21: optional UInt64 total_hardlink_size,
// TODO: add timestamp
// 21: optional UInt64 timestamp,
}