summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-03-15 00:27:20 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-03-15 00:27:20 +0100
commitb50c419c9b8f59b459d488d7bf11654d56f35511 (patch)
tree2ef2123f9f80f9d8c37ed526183408188d3b6ea3
parentfa8c83d2fd17e507f305ccc2ddfb39341c8dee99 (diff)
ext2fs: Fix adding blocks to free blocks cache
* ext2fs/pager.c (disk_cache_info_free_push): Add prototype. (disk_pager_notify_evict): When dropping DC_INCORE flag, if the block becomes free (no reference and no DC_DONT_REUSE flags), call disk_cache_info_free_push. (disk_cache_block_deref): Only call disk_cache_info_free_push if the flags of the block do not contain DC_DONT_REUSE flags.
-rw-r--r--ext2fs/pager.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ext2fs/pager.c b/ext2fs/pager.c
index 458b822d..d3954722 100644
--- a/ext2fs/pager.c
+++ b/ext2fs/pager.c
@@ -79,6 +79,9 @@ do { pthread_spin_lock (&ext2s_pager_stats.lock); \
#else /* !STATS */
#define STAT_INC(field) /* nop */0
#endif /* STATS */
+
+static void
+disk_cache_info_free_push (struct disk_cache_info *p);
#define FREE_PAGE_BUFS 24
@@ -538,6 +541,9 @@ disk_pager_notify_evict (vm_offset_t page)
pthread_mutex_lock (&disk_cache_lock);
disk_cache_info[index].flags &= ~DC_INCORE;
+ if (disk_cache_info[index].ref_count == 0 &&
+ !(disk_cache_info[index].flags & DC_DONT_REUSE))
+ disk_cache_info_free_push (&disk_cache_info[index]);
pthread_mutex_unlock (&disk_cache_lock);
}
@@ -1196,7 +1202,8 @@ disk_cache_block_deref (void *ptr)
assert (! (disk_cache_info[index].flags & DC_UNTOUCHED));
assert (disk_cache_info[index].ref_count >= 1);
disk_cache_info[index].ref_count--;
- if (disk_cache_info[index].ref_count == 0)
+ if (disk_cache_info[index].ref_count == 0 &&
+ !(disk_cache_info[index].flags & DC_DONT_REUSE))
disk_cache_info_free_push (&disk_cache_info[index]);
pthread_mutex_unlock (&disk_cache_lock);
}