mirror of
https://github.com/versity/scoutfs.git
synced 2026-09-19 14:34:16 +00:00
Report free blocks in statfs
Our statfs callback was still using the old buddy allocator. We add a free segments field to the super and have it track the number of free segments in the allocator. We then use that to calculate the number of free blocks for statfs. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
+23
-1
@@ -166,8 +166,10 @@ int scoutfs_alloc_segno(struct super_block *sb, u64 *segno)
|
||||
|
||||
ret = 0;
|
||||
out:
|
||||
if (ret == 0)
|
||||
if (ret == 0) {
|
||||
scoutfs_inc_counter(sb, alloc_alloc);
|
||||
le64_add_cpu(&super->free_segs, -1);
|
||||
}
|
||||
up_write(&sal->rwsem);
|
||||
|
||||
trace_printk("segno %llu ret %d\n", *segno, ret);
|
||||
@@ -180,6 +182,8 @@ out:
|
||||
*/
|
||||
int scoutfs_alloc_free(struct super_block *sb, u64 segno)
|
||||
{
|
||||
struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb);
|
||||
struct scoutfs_super_block *super = &sbi->super;
|
||||
struct pending_region *pend;
|
||||
DECLARE_SEG_ALLOC(sb, sal);
|
||||
u64 ind;
|
||||
@@ -205,6 +209,7 @@ int scoutfs_alloc_free(struct super_block *sb, u64 segno)
|
||||
|
||||
set_bit_le(nr, pend->reg.bits);
|
||||
scoutfs_inc_counter(sb, alloc_free);
|
||||
le64_add_cpu(&super->free_segs, 1);
|
||||
ret = 0;
|
||||
out:
|
||||
up_write(&sal->rwsem);
|
||||
@@ -281,6 +286,23 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of blocks free for statfs.
|
||||
*/
|
||||
u64 scoutfs_alloc_bfree(struct super_block *sb)
|
||||
{
|
||||
struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb);
|
||||
struct scoutfs_super_block *super = &sbi->super;
|
||||
DECLARE_SEG_ALLOC(sb, sal);
|
||||
u64 bfree;
|
||||
|
||||
down_read(&sal->rwsem);
|
||||
bfree = le64_to_cpu(super->free_segs) << SCOUTFS_SEGMENT_BLOCK_SHIFT;
|
||||
up_read(&sal->rwsem);
|
||||
|
||||
return bfree;
|
||||
}
|
||||
|
||||
static int alloc_treap_compare(void *key, void *data)
|
||||
{
|
||||
u64 *ind = key;
|
||||
|
||||
Reference in New Issue
Block a user