From a5d9ac551499321aa00b52ad996fa6c7c05656f7 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 13 Nov 2020 11:15:30 -0800 Subject: [PATCH] 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 --- kmod/src/alloc.c | 22 ++++++---------------- kmod/src/alloc.h | 4 ++-- kmod/src/srch.c | 2 +- kmod/src/trans.c | 2 +- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/kmod/src/alloc.c b/kmod/src/alloc.c index 2eb855b3..3f0c6aaa 100644 --- a/kmod/src/alloc.c +++ b/kmod/src/alloc.c @@ -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; diff --git a/kmod/src/alloc.h b/kmod/src/alloc.h index d2cc1f58..d7cffb49 100644 --- a/kmod/src/alloc.h +++ b/kmod/src/alloc.h @@ -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, diff --git a/kmod/src/srch.c b/kmod/src/srch.c index bfe7a567..2b8569bb 100644 --- a/kmod/src/srch.c +++ b/kmod/src/srch.c @@ -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 { diff --git a/kmod/src/trans.c b/kmod/src/trans.c index 9f36a19d..d029fb19 100644 --- a/kmod/src/trans.c +++ b/kmod/src/trans.c @@ -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;