From c33e3b50be396819a73aca805d33f32d88560ace Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Tue, 18 Mar 2025 16:12:43 +1300
Subject: [PATCH v4 3/3] Remove MAX_IO_COMBINE_LIMIT macro.

Now that we have a setting io_max_combine_limit, the macro is a bit
confusing.  It only has a few references, and they can be replaced with
PG_IOV_MAX.
---
 src/backend/storage/buffer/bufmgr.c | 6 +++---
 src/backend/utils/misc/guc_tables.c | 4 ++--
 src/include/storage/bufmgr.h        | 3 +--
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index d04afa5ab9c..5e4701d6f19 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -1259,7 +1259,7 @@ StartReadBuffersImpl(ReadBuffersOperation *operation,
 	int			maxcombine = 0;
 
 	Assert(*nblocks > 0);
-	Assert(*nblocks <= MAX_IO_COMBINE_LIMIT);
+	Assert(*nblocks <= PG_IOV_MAX);
 
 	for (int i = 0; i < actual_nblocks; ++i)
 	{
@@ -1452,8 +1452,8 @@ WaitReadBuffers(ReadBuffersOperation *operation)
 	for (int i = 0; i < nblocks; ++i)
 	{
 		int			io_buffers_len;
-		Buffer		io_buffers[MAX_IO_COMBINE_LIMIT];
-		void	   *io_pages[MAX_IO_COMBINE_LIMIT];
+		Buffer		io_buffers[PG_IOV_MAX];
+		void	   *io_pages[PG_IOV_MAX];
 		instr_time	io_start;
 		BlockNumber io_first_block;
 
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 720f28a5180..d9540d31c8e 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -3251,7 +3251,7 @@ struct config_int ConfigureNamesInt[] =
 		},
 		&io_max_combine_limit,
 		DEFAULT_IO_COMBINE_LIMIT,
-		1, MAX_IO_COMBINE_LIMIT,
+		1, PG_IOV_MAX,
 		NULL, assign_io_max_combine_limit, NULL
 	},
 
@@ -3265,7 +3265,7 @@ struct config_int ConfigureNamesInt[] =
 		},
 		&io_combine_limit,
 		DEFAULT_IO_COMBINE_LIMIT,
-		1, MAX_IO_COMBINE_LIMIT,
+		1, PG_IOV_MAX,
 		NULL, assign_io_combine_limit, NULL
 	},
 
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index 71b3af61b6a..0452fe1f1e8 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -161,8 +161,7 @@ extern PGDLLIMPORT bool track_io_timing;
 extern PGDLLIMPORT int effective_io_concurrency;
 extern PGDLLIMPORT int maintenance_io_concurrency;
 
-#define MAX_IO_COMBINE_LIMIT PG_IOV_MAX
-#define DEFAULT_IO_COMBINE_LIMIT Min(MAX_IO_COMBINE_LIMIT, (128 * 1024) / BLCKSZ)
+#define DEFAULT_IO_COMBINE_LIMIT Min(PG_IOV_MAX, (128 * 1024) / BLCKSZ)
 extern PGDLLIMPORT int io_combine_limit;	/* min of the two GUCs below */
 extern PGDLLIMPORT int io_combine_limit_guc;
 extern PGDLLIMPORT int io_max_combine_limit;
-- 
2.39.5

