Skip to content

Commit

Permalink
fix: Inconsistent total capacity in CGI and statfs
Browse files Browse the repository at this point in the history
The CGI and statfs system call where reporting different total
capacities of the filesystem.

The CGI monitoring was showing the total capacity of all hard drives,
regardless of limits in HDD_LEAVE_SPACE_DEFAULT option. Meanwhile,
statfs was showing total capacity as space available on all hard drives
+ actual used bytes for chunks (or the reported total capacity on all
hard drives, whichever was lower).

This commit tries to get rid of these discrepancies by discounting the
HDD_LEAVE_SPACE_DEFAULT value towards the final capacity of a drive in
the chunkserver. Both statfs and CGI will now show this capacity in the
same way.

Signed-off-by: Urmas Rist <[email protected]>
  • Loading branch information
uristdwarf committed Feb 26, 2025
1 parent ca70b28 commit b6f7d12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/chunkserver/chunkserver-common/cmr_disk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ void CmrDisk::refreshDataDiskUsage() {
} else {
setAvailableSpace(availableSpace() - leaveFreeSpace());
}
if (totalSpace() < leaveFreeSpace()) {
setTotalSpace(0ULL);
} else {
setTotalSpace(totalSpace() - leaveFreeSpace());
}
}

int CmrDisk::updateChunkAttributes(IChunk *chunk, bool isFromScan) {
Expand Down
3 changes: 0 additions & 3 deletions src/master/filesystem_operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,6 @@ void fs_statfs(const FsContext &context, uint64_t *totalspace, uint64_t *availsp
fsnodes_quota_adjust_space(rn, *totalspace, *availspace);
fsnodes_get_stats(rn, &sr);
*inodes = sr.inodes;
if (sr.realsize + *availspace < *totalspace) {
*totalspace = sr.realsize + *availspace;
}
}
++gFsStatsArray[FsStats::Statfs];
}
Expand Down

0 comments on commit b6f7d12

Please sign in to comment.