From 96ad8dd5105c1fce8aa94bdbaa00238e52fba2f6 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 23 Mar 2022 12:42:33 -0700 Subject: [PATCH] Add scoutfs_alloc_meta_remaining Add helper function to give the caller the number of blocks remaining in the first list block that's used for meta allocation and freeing. Signed-off-by: Zach Brown --- kmod/src/alloc.c | 11 +++++++++++ kmod/src/alloc.h | 1 + 2 files changed, 12 insertions(+) diff --git a/kmod/src/alloc.c b/kmod/src/alloc.c index 1d64012d..1a9aeefe 100644 --- a/kmod/src/alloc.c +++ b/kmod/src/alloc.c @@ -1318,6 +1318,17 @@ bool scoutfs_alloc_meta_low(struct super_block *sb, return lo; } +void scoutfs_alloc_meta_remaining(struct scoutfs_alloc *alloc, u32 *avail_total, u32 *freed_space) +{ + unsigned int seq; + + do { + seq = read_seqbegin(&alloc->seqlock); + *avail_total = le32_to_cpu(alloc->avail.first_nr); + *freed_space = list_block_space(alloc->freed.first_nr); + } while (read_seqretry(&alloc->seqlock, seq)); +} + bool scoutfs_alloc_test_flag(struct super_block *sb, struct scoutfs_alloc *alloc, u32 flag) { diff --git a/kmod/src/alloc.h b/kmod/src/alloc.h index 38e1c1f2..353cbffc 100644 --- a/kmod/src/alloc.h +++ b/kmod/src/alloc.h @@ -158,6 +158,7 @@ int scoutfs_alloc_splice_list(struct super_block *sb, bool scoutfs_alloc_meta_low(struct super_block *sb, struct scoutfs_alloc *alloc, u32 nr); +void scoutfs_alloc_meta_remaining(struct scoutfs_alloc *alloc, u32 *avail_total, u32 *freed_space); bool scoutfs_alloc_test_flag(struct super_block *sb, struct scoutfs_alloc *alloc, u32 flag);