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:
parent
322875597c
commit
52676dc2e0
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user