Update parameter name context to wb_context

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
This commit is contained in:
Andres Freund 2023-05-17 11:17:12 -07:00
parent 322875597c
commit 52676dc2e0
2 changed files with 17 additions and 16 deletions

View File

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

View File

@ -388,8 +388,8 @@ extern PGDLLIMPORT CkptSortItem *CkptBufferIds;
*/ */
/* bufmgr.c */ /* bufmgr.c */
extern void WritebackContextInit(WritebackContext *context, int *max_pending); extern void WritebackContextInit(WritebackContext *context, int *max_pending);
extern void IssuePendingWritebacks(WritebackContext *context); extern void IssuePendingWritebacks(WritebackContext *wb_context);
extern void ScheduleBufferTagForWriteback(WritebackContext *context, BufferTag *tag); extern void ScheduleBufferTagForWriteback(WritebackContext *wb_context, BufferTag *tag);
/* freelist.c */ /* freelist.c */
extern IOContext IOContextForStrategy(BufferAccessStrategy strategy); extern IOContext IOContextForStrategy(BufferAccessStrategy strategy);