From 118dfb42dfce72ada4e8a1f7ce081bf5da149809 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Wed, 1 Apr 2026 09:52:41 +0800 Subject: [PATCH v1] bufmgr: pass through I/O stats context in FlushUnlockedBuffer() FlushUnlockedBuffer() accepted io_object and io_context arguments, but ignored them and always called FlushBuffer() with IOOBJECT_RELATION and IOCONTEXT_NORMAL. Fix that by passing the caller-provided io_object and io_context through to FlushBuffer(). While here, make FlushBuffer() use its io_object parameter when reporting I/O timing, instead of hardcoding IOOBJECT_RELATION. Author: Chao Li Reviewed-by: Discussion: https://postgr.es/m/ --- src/backend/storage/buffer/bufmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 17499451ad2..0619d7b8d62 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -4583,7 +4583,7 @@ FlushBuffer(BufferDesc *buf, SMgrRelation reln, IOObject io_object, * When a strategy is not in use, the write can only be a "regular" write * of a dirty shared buffer (IOCONTEXT_NORMAL IOOP_WRITE). */ - pgstat_count_io_op_time(IOOBJECT_RELATION, io_context, + pgstat_count_io_op_time(io_object, io_context, IOOP_WRITE, io_start, 1, BLCKSZ); pgBufferUsage.shared_blks_written++; @@ -4614,7 +4614,7 @@ FlushUnlockedBuffer(BufferDesc *buf, SMgrRelation reln, Buffer buffer = BufferDescriptorGetBuffer(buf); BufferLockAcquire(buffer, buf, BUFFER_LOCK_SHARE_EXCLUSIVE); - FlushBuffer(buf, reln, IOOBJECT_RELATION, IOCONTEXT_NORMAL); + FlushBuffer(buf, reln, io_object, io_context); BufferLockUnlock(buffer, buf); } -- 2.50.1 (Apple Git-155)