diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-17 22:01:51 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-17 22:01:51 +0000 |
commit | 4347cc2392a75dec1d5e83f8b60911597fc602d9 (patch) | |
tree | 291a95ed8fc4a81871ca98848ec69007e1078663 /src/backend/storage/buffer/bufmgr.c | |
parent | bdbe9c9f061439f180976b75e4be50f5ea64d07f (diff) |
Allow background writing to be shut down by setting limit values to zero.
This does not disable the bgwriter process: it still has to wake up often
enough to collect fsync requests from backends in a timely fashion. But
it responds to the recent gripe about not being able to prevent the disk
from being spun up constantly.
Diffstat (limited to 'src/backend/storage/buffer/bufmgr.c')
-rw-r--r-- | src/backend/storage/buffer/bufmgr.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index b9d8fc3ad53..c96c635d0a6 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.180 2004/10/16 18:57:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.181 2004/10/17 22:01:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -671,8 +671,10 @@ UnpinBuffer(BufferDesc *buf, bool fixOwner) * * This is called at checkpoint time to write out all dirty shared buffers, * and by the background writer process to write out some of the dirty blocks. - * percent/maxpages should be zero in the former case, and nonzero limit - * values in the latter. + * percent/maxpages should be -1 in the former case, and limit values (>= 0) + * in the latter. + * + * Returns the number of buffers written. */ int BufferSync(int percent, int maxpages) @@ -682,6 +684,10 @@ BufferSync(int percent, int maxpages) int num_buffer_dirty; int i; + /* If either limit is zero then we are disabled from doing anything... */ + if (percent == 0 || maxpages == 0) + return 0; + /* * Get a list of all currently dirty buffers and how many there are. * We do not flush buffers that get dirtied after we started. They |