From acab1b0914e426d28789731f50f5964dd4d2f054 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 5 Apr 2023 18:57:29 -0700 Subject: Convert many uses of ReadBuffer[Extended](P_NEW) to ExtendBufferedRel() A few places are not converted. Some because they are tackled in later commits (e.g. hio.c, xlogutils.c), some because they are more complicated (e.g. brin_pageops.c). Having a few users of ReadBuffer(P_NEW) is good anyway, to ensure the backward compat path stays working. Discussion: https://postgr.es/m/20221029025420.eplyow6k7tgu6he3@awork3.anarazel.de --- src/backend/access/gist/gist.c | 4 ++-- src/backend/access/gist/gistutil.c | 13 ++----------- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'src/backend/access/gist') diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index c3a3d49bca0..b5c1754e788 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -134,8 +134,8 @@ gistbuildempty(Relation index) Buffer buffer; /* Initialize the root page */ - buffer = ReadBufferExtended(index, INIT_FORKNUM, P_NEW, RBM_NORMAL, NULL); - LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); + buffer = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL, + EB_SKIP_EXTENSION_LOCK | EB_LOCK_FIRST); /* Initialize and xlog buffer */ START_CRIT_SECTION(); diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index a607464b979..f9f51152b8e 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -824,7 +824,6 @@ Buffer gistNewBuffer(Relation r, Relation heaprel) { Buffer buffer; - bool needLock; /* First, try to get a page from FSM */ for (;;) @@ -878,16 +877,8 @@ gistNewBuffer(Relation r, Relation heaprel) } /* Must extend the file */ - needLock = !RELATION_IS_LOCAL(r); - - if (needLock) - LockRelationForExtension(r, ExclusiveLock); - - buffer = ReadBuffer(r, P_NEW); - LockBuffer(buffer, GIST_EXCLUSIVE); - - if (needLock) - UnlockRelationForExtension(r, ExclusiveLock); + buffer = ExtendBufferedRel(EB_REL(r), MAIN_FORKNUM, NULL, + EB_LOCK_FIRST); return buffer; } -- cgit v1.2.3