]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
bufmgr: use I/O stats arguments in FlushUnlockedBuffer()
authorMelanie Plageman <melanieplageman@gmail.com>
Tue, 21 Apr 2026 21:47:22 +0000 (17:47 -0400)
committerMelanie Plageman <melanieplageman@gmail.com>
Tue, 21 Apr 2026 21:47:50 +0000 (17:47 -0400)
FlushUnlockedBuffer() accepted io_object and io_context arguments but
hardcoded IOOBJECT_RELATION and IOCONTEXT_NORMAL when calling
FlushBuffer(). Pass them through instead. Also fix FlushBuffer() to use
its io_object parameter for I/O timing stats rather than hardcoding
IOOBJECT_RELATION.

Not actively broken since all current callers pass IOOBJECT_RELATION and
IOCONTEXT_NORMAL, so not backpatched.

Author: Chao Li <lic@highgo.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/BC97546F-5C15-42F2-AD57-CFACDB9657D0@gmail.com

src/backend/storage/buffer/bufmgr.c

index 32f501bbd218b25b1d9e8d549718a4a097852aa5..1fee559b7c677cfb8e292ce32d17969834c4c775 100644 (file)
@@ -4598,7 +4598,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++;
@@ -4629,7 +4629,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);
 }