scoutfs: rework scoutfs_alloc_meta_low, takes arg

Previously, scoutfs_alloc_meta_lo_thresh() returned true when a small
static number of metadata blocks were either available to allocate or
had space for freeing.  This didn't make a lot of sense as the correct
number depends on how many allocations each caller will make during
their atomic transaction.

Rework the call to take an argument for the number of avail or freed
blocks available to test.  This first pass just uses the existing
number, we'll get to the callers.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2020-12-02 09:25:13 -08:00
committed by Zach Brown
parent cf278f5fa0
commit a5d9ac5514
4 changed files with 10 additions and 20 deletions
+6 -16
View File
@@ -1085,27 +1085,17 @@ out:
}
/*
* Returns true if we're running low on avail blocks or running out of
* space for freed blocks.
*
* On the avail side, we're avoiding spurious enospc as our avail block
* runs low. If we commit it can be refilled by the server.
*
* On the freed side, we're avoiding getting errors in frees where they
* can't be recovered from. This is mostly in freeing cowed blocks in
* the data allocator btree which is related to its height.
*
* And both of these need to be mindful of multiple tasks entering the
* transaction.
* Returns true if meta avail and free don't have room for the given
* number of alloctions or frees.
*/
bool scoutfs_alloc_meta_lo_thresh(struct super_block *sb,
struct scoutfs_alloc *alloc)
bool scoutfs_alloc_meta_low(struct super_block *sb,
struct scoutfs_alloc *alloc, u32 nr)
{
bool lo;
spin_lock(&alloc->lock);
lo = le32_to_cpu(alloc->avail.first_nr) < 8 ||
list_block_space(alloc->freed.first_nr) < 8;
lo = le32_to_cpu(alloc->avail.first_nr) < nr ||
list_block_space(alloc->freed.first_nr) < nr;
spin_unlock(&alloc->lock);
return lo;
+2 -2
View File
@@ -119,8 +119,8 @@ int scoutfs_alloc_splice_list(struct super_block *sb,
struct scoutfs_alloc_list_head *dst,
struct scoutfs_alloc_list_head *src);
bool scoutfs_alloc_meta_lo_thresh(struct super_block *sb,
struct scoutfs_alloc *alloc);
bool scoutfs_alloc_meta_low(struct super_block *sb,
struct scoutfs_alloc *alloc, u32 nr);
typedef int (*scoutfs_alloc_foreach_cb_t)(struct super_block *sb, void *arg,
int owner, u64 id,
+1 -1
View File
@@ -1482,7 +1482,7 @@ static bool should_commit(struct super_block *sb, struct scoutfs_alloc *alloc,
{
return (scoutfs_block_writer_dirty_bytes(sb, wri) >=
SRCH_COMPACT_DIRTY_LIMIT_BYTES) ||
scoutfs_alloc_meta_lo_thresh(sb, alloc);
scoutfs_alloc_meta_low(sb, alloc, 8);
}
struct tourn_node {
+1 -1
View File
@@ -376,7 +376,7 @@ static bool acquired_hold(struct super_block *sb,
goto out;
}
if (scoutfs_alloc_meta_lo_thresh(sb, &tri->alloc)) {
if (scoutfs_alloc_meta_low(sb, &tri->alloc, 8)) {
scoutfs_inc_counter(sb, trans_commit_meta_alloc_low);
queue_trans_work(sbi);
goto out;