Convert SharedFileSet->refcnt to an atomic variable.

Currently, this variable is an int protected by a spinlock.  By
converting it to an atomic variable, we can remove the spinlock.
Detaching becomes an atomic subtract, and attaching becomes a
compare-and-exchange loop, since it must not resurrect a fileset
whose reference count has already reached zero.

Reviewed-by: Zsolt Parragi <[email protected]>
Tested-by: solai v <[email protected]>
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/09a579abaca86bcd85ebc49b247d2ec58bdc6d3b

Modified Files
--------------
src/backend/storage/file/sharedfileset.c | 33 ++++++++++++++------------------
src/include/storage/sharedfileset.h      |  5 ++---
2 files changed, 16 insertions(+), 22 deletions(-)

Reply via email to