Update parameter name context to wb_context
authorAndres Freund <andres@anarazel.de>
Wed, 17 May 2023 18:17:12 +0000 (11:17 -0700)
committerAndres Freund <andres@anarazel.de>
Wed, 17 May 2023 18:18:30 +0000 (11:18 -0700)
For clarity of review, renaming the function parameter "context" in
ScheduleBufferTagForWriteback() and IssuePendingWritebacks() to
"wb_context" is a separate commit. The next commit adds an "io_context"
parameter and "wb_context" makes it more clear which is which.

Author: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/CAAKRu_acc6iL4M3hvOTeztf_ZPpsB3Pqio5aVHgZ5q=Pi3BZKg@mail.gmail.com

src/backend/storage/buffer/bufmgr.c
src/include/storage/buf_internals.h

index 1fa689052e9da6bdbef1f7c11b3be83bf2a8312b..31f63c180b8a8d920b2cf4f4f771cfc31041b456 100644 (file)
@@ -5445,7 +5445,7 @@ WritebackContextInit(WritebackContext *context, int *max_pending)
  * Add buffer to list of pending writeback requests.
  */
 void
-ScheduleBufferTagForWriteback(WritebackContext *context, BufferTag *tag)
+ScheduleBufferTagForWriteback(WritebackContext *wb_context, BufferTag *tag)
 {
        PendingWriteback *pending;
 
@@ -5456,11 +5456,11 @@ ScheduleBufferTagForWriteback(WritebackContext *context, BufferTag *tag)
         * Add buffer to the pending writeback array, unless writeback control is
         * disabled.
         */
-       if (*context->max_pending > 0)
+       if (*wb_context->max_pending > 0)
        {
-               Assert(*context->max_pending <= WRITEBACK_MAX_PENDING_FLUSHES);
+               Assert(*wb_context->max_pending <= WRITEBACK_MAX_PENDING_FLUSHES);
 
-               pending = &context->pending_writebacks[context->nr_pending++];
+               pending = &wb_context->pending_writebacks[wb_context->nr_pending++];
 
                pending->tag = *tag;
        }
@@ -5470,8 +5470,8 @@ ScheduleBufferTagForWriteback(WritebackContext *context, BufferTag *tag)
         * includes the case where previously an item has been added, but control
         * is now disabled.
         */
-       if (context->nr_pending >= *context->max_pending)
-               IssuePendingWritebacks(context);
+       if (wb_context->nr_pending >= *wb_context->max_pending)
+               IssuePendingWritebacks(wb_context);
 }
 
 #define ST_SORT sort_pending_writebacks
@@ -5489,25 +5489,26 @@ ScheduleBufferTagForWriteback(WritebackContext *context, BufferTag *tag)
  * error out - it's just a hint.
  */
 void
-IssuePendingWritebacks(WritebackContext *context)
+IssuePendingWritebacks(WritebackContext *wb_context)
 {
        int                     i;
 
-       if (context->nr_pending == 0)
+       if (wb_context->nr_pending == 0)
                return;
 
        /*
         * Executing the writes in-order can make them a lot faster, and allows to
         * merge writeback requests to consecutive blocks into larger writebacks.
         */
-       sort_pending_writebacks(context->pending_writebacks, context->nr_pending);
+       sort_pending_writebacks(wb_context->pending_writebacks,
+                                                       wb_context->nr_pending);
 
        /*
         * Coalesce neighbouring writes, but nothing else. For that we iterate
         * through the, now sorted, array of pending flushes, and look forward to
         * find all neighbouring (or identical) writes.
         */
-       for (i = 0; i < context->nr_pending; i++)
+       for (i = 0; i < wb_context->nr_pending; i++)
        {
                PendingWriteback *cur;
                PendingWriteback *next;
@@ -5517,7 +5518,7 @@ IssuePendingWritebacks(WritebackContext *context)
                RelFileLocator currlocator;
                Size            nblocks = 1;
 
-               cur = &context->pending_writebacks[i];
+               cur = &wb_context->pending_writebacks[i];
                tag = cur->tag;
                currlocator = BufTagGetRelFileLocator(&tag);
 
@@ -5525,10 +5526,10 @@ IssuePendingWritebacks(WritebackContext *context)
                 * Peek ahead, into following writeback requests, to see if they can
                 * be combined with the current one.
                 */
-               for (ahead = 0; i + ahead + 1 < context->nr_pending; ahead++)
+               for (ahead = 0; i + ahead + 1 < wb_context->nr_pending; ahead++)
                {
 
-                       next = &context->pending_writebacks[i + ahead + 1];
+                       next = &wb_context->pending_writebacks[i + ahead + 1];
 
                        /* different file, stop */
                        if (!RelFileLocatorEquals(currlocator,
@@ -5555,7 +5556,7 @@ IssuePendingWritebacks(WritebackContext *context)
                smgrwriteback(reln, BufTagGetForkNum(&tag), tag.blockNum, nblocks);
        }
 
-       context->nr_pending = 0;
+       wb_context->nr_pending = 0;
 }
 
 
index 136cf8fbaf3899629305396b7bfbb62e7e9c60af..f8ac811379b53b2dc821984189166b66a6e63ce5 100644 (file)
@@ -388,8 +388,8 @@ extern PGDLLIMPORT CkptSortItem *CkptBufferIds;
  */
 /* bufmgr.c */
 extern void WritebackContextInit(WritebackContext *context, int *max_pending);
-extern void IssuePendingWritebacks(WritebackContext *context);
-extern void ScheduleBufferTagForWriteback(WritebackContext *context, BufferTag *tag);
+extern void IssuePendingWritebacks(WritebackContext *wb_context);
+extern void ScheduleBufferTagForWriteback(WritebackContext *wb_context, BufferTag *tag);
 
 /* freelist.c */
 extern IOContext IOContextForStrategy(BufferAccessStrategy strategy);