From af624dc18cabfe34d7df9256508715bb636bb9ec Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 23 Oct 1999 18:09:28 +0000 Subject: 1999-10-23 Roland McGrath * sync-interval.c (periodic_sync): With diskfs_fsys_lock reader lock held, check _diskfs_diskdirty and don't sync if not dirty. --- libdiskfs/sync-interval.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libdiskfs/sync-interval.c b/libdiskfs/sync-interval.c index f2cb8570..8167fc4a 100644 --- a/libdiskfs/sync-interval.c +++ b/libdiskfs/sync-interval.c @@ -112,8 +112,14 @@ periodic_sync (int interval) if (! diskfs_readonly) { rwlock_reader_lock (&diskfs_fsys_lock); - diskfs_sync_everything (0); - diskfs_set_hypermetadata (0, 0); + /* Only sync if we need to, to avoid clearing the clean flag + when it's just been set. Any other thread doing a sync + will have held the lock while it did its work. */ + if (_diskfs_diskdirty) + { + diskfs_sync_everything (0); + diskfs_set_hypermetadata (0, 0); + } rwlock_reader_unlock (&diskfs_fsys_lock); } ports_end_rpc (pi, &link); -- cgit v1.2.3