diff options
author | Robert Haas <rhaas@postgresql.org> | 2014-01-27 11:07:44 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2014-01-27 11:07:44 -0500 |
commit | ea9df812d8502fff74e7bc37d61bdc7d66d77a7f (patch) | |
tree | 7e138cbe713ccbf24c3be5603bcc84cae1f3079e /src/include/storage/buf_internals.h | |
parent | f62eba204f367acbfea7e63991524bf981b307f8 (diff) | |
download | postgresql-ea9df812d8502fff74e7bc37d61bdc7d66d77a7f.tar.gz postgresql-ea9df812d8502fff74e7bc37d61bdc7d66d77a7f.zip |
Relax the requirement that all lwlocks be stored in a single array.
This makes it possible to store lwlocks as part of some other data
structure in the main shared memory segment, or in a dynamic shared
memory segment. There is still a main LWLock array and this patch does
not move anything out of it, but it provides necessary infrastructure
for doing that in the future.
This change is likely to increase the size of LWLockPadded on some
platforms, especially 32-bit platforms where it was previously only
16 bytes.
Patch by me. Review by Andres Freund and KaiGai Kohei.
Diffstat (limited to 'src/include/storage/buf_internals.h')
-rw-r--r-- | src/include/storage/buf_internals.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h index 457390fc879..93a0030c3ee 100644 --- a/src/include/storage/buf_internals.h +++ b/src/include/storage/buf_internals.h @@ -104,7 +104,10 @@ typedef struct buftag #define BufTableHashPartition(hashcode) \ ((hashcode) % NUM_BUFFER_PARTITIONS) #define BufMappingPartitionLock(hashcode) \ - ((LWLockId) (FirstBufMappingLock + BufTableHashPartition(hashcode))) + (&MainLWLockArray[BUFFER_MAPPING_LWLOCK_OFFSET + \ + BufTableHashPartition(hashcode)].lock) +#define BufMappingPartitionLockByIndex(i) \ + (&MainLWLockArray[BUFFER_MAPPING_LWLOCK_OFFSET + (i)].lock) /* * BufferDesc -- shared descriptor/state data for a single shared buffer. @@ -144,8 +147,8 @@ typedef struct sbufdesc int buf_id; /* buffer's index number (from 0) */ int freeNext; /* link in freelist chain */ - LWLockId io_in_progress_lock; /* to wait for I/O to complete */ - LWLockId content_lock; /* to lock access to buffer contents */ + LWLock *io_in_progress_lock; /* to wait for I/O to complete */ + LWLock *content_lock; /* to lock access to buffer contents */ } BufferDesc; #define BufferDescriptorGetBuffer(bdesc) ((bdesc)->buf_id + 1) |