hammer_off_t owner, int *errorp);
void hammer_freemap_free(hammer_transaction_t trans, hammer_off_t phys_offset,
hammer_off_t owner, int *errorp);
-int hammer_checkspace(hammer_mount_t hmp, int slop);
+int _hammer_checkspace(hammer_mount_t hmp, int slop, int64_t *resp);
hammer_off_t hammer_blockmap_alloc(hammer_transaction_t trans, int zone,
int bytes, hammer_off_t hint, int *errorp);
hammer_reserve_t hammer_blockmap_reserve(hammer_mount_t hmp, int zone,
int hammer_blocksize(int64_t file_offset);
int64_t hammer_blockdemarc(int64_t file_offset1, int64_t file_offset2);
+/*
+ * Shortcut for _hammer_checkspace(), used all over the code.
+ */
+static __inline int
+hammer_checkspace(hammer_mount_t hmp, int slop)
+{
+ return(_hammer_checkspace(hmp, slop, NULL));
+}
+
#endif
static __inline void
* Check space availability
*/
int
-hammer_checkspace(hammer_mount_t hmp, int slop)
+_hammer_checkspace(hammer_mount_t hmp, int slop, int64_t *resp)
{
const int in_size = sizeof(struct hammer_inode_data) +
sizeof(union hammer_btree_elm);
(slop << HAMMER_LARGEBLOCK_BITS);
hammer_count_extra_space_used = usedbytes; /* debugging */
+ if (resp)
+ *resp = usedbytes;
if (hmp->copy_stat_freebigblocks >=
(usedbytes >> HAMMER_LARGEBLOCK_BITS)) {
hammer_volume_ondisk_t ondisk;
int error;
int64_t bfree;
+ int64_t breserved;
volume = hammer_get_root_volume(hmp, &error);
if (error)
/*
* Basic stats
*/
+ _hammer_checkspace(hmp, HAMMER_CHKSPC_WRITE, &breserved);
mp->mnt_vstat.f_files = ondisk->vol0_stat_inodes;
bfree = ondisk->vol0_stat_freebigblocks * HAMMER_LARGEBLOCK_SIZE;
hammer_rel_volume(volume, 0);
- mp->mnt_vstat.f_bfree = bfree / HAMMER_BUFSIZE;
+ mp->mnt_vstat.f_bfree = (bfree - breserved) / HAMMER_BUFSIZE;
mp->mnt_vstat.f_bavail = mp->mnt_stat.f_bfree;
if (mp->mnt_vstat.f_files < 0)
mp->mnt_vstat.f_files = 0;