From 55045339868be703138a76cad6460dfb7f2d7fcd Mon Sep 17 00:00:00 2001
From: Kent Overstreet <kent.overstreet@linux.dev>
Date: Sun, 23 Mar 2025 12:41:35 -0400
Subject: [PATCH] format: kill min_size()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
 c_src/libbcachefs.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/c_src/libbcachefs.c b/c_src/libbcachefs.c
index 358fff09..081a8176 100644
--- a/c_src/libbcachefs.c
+++ b/c_src/libbcachefs.c
@@ -62,12 +62,6 @@ void bch2_sb_layout_init(struct bch_sb_layout *l,
 		    sb_start, sb_pos, sb_end, sb_size);
 }
 
-/* minimum size filesystem we can create, given a bucket size: */
-static u64 min_size(unsigned bucket_size)
-{
-	return BCH_MIN_NR_NBUCKETS * bucket_size;
-}
-
 static u64 dev_max_bucket_size(u64 dev_size)
 {
 	return dev_size / BCH_MIN_NR_NBUCKETS;
@@ -82,14 +76,15 @@ u64 bch2_pick_bucket_size(struct bch_opts opts, dev_opts_list devs)
 	if (opt_defined(opts, btree_node_size))
 		bucket_size = max_t(u64, bucket_size, opts.btree_node_size);
 
-	u64 total_fs_size = 0;
-	darray_for_each(devs, i) {
-		if (i->opts.fs_size < min_size(opts.block_size))
+	u64 min_dev_size = BCH_MIN_NR_NBUCKETS * bucket_size;
+	darray_for_each(devs, i)
+		if (i->opts.fs_size < min_dev_size)
 			die("cannot format %s, too small (%llu bytes, min %llu)",
-			    i->path, i->opts.fs_size, min_size(opts.block_size));
+			    i->path, i->opts.fs_size, min_dev_size);
 
+	u64 total_fs_size = 0;
+	darray_for_each(devs, i)
 		total_fs_size += i->opts.fs_size;
-	}
 
 	struct sysinfo info;
 	si_meminfo(&info);