From 46f347899188a1491d8f3f43cb47495766aa839a Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Fri, 3 Sep 2010 14:05:49 +1200 Subject: [PATCH] yaffs Add stats tracking and control for background gc instrumentation This allows us to track the impact of background gc. Signed-off-by: Charles Manning --- yaffs_fs.c | 7 +++++-- yaffs_guts.c | 2 ++ yaffs_guts.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/yaffs_fs.c b/yaffs_fs.c index c3f11f4..dfb5461 100644 --- a/yaffs_fs.c +++ b/yaffs_fs.c @@ -158,6 +158,7 @@ unsigned int yaffs_traceMask = YAFFS_TRACE_BAD_BLOCKS | YAFFS_TRACE_ALWAYS; unsigned int yaffs_wr_attempts = YAFFS_WR_ATTEMPTS; unsigned int yaffs_auto_checkpoint = 1; unsigned int yaffs_gc_control = 1; +unsigned int yaffs_bg_enable = 1; /* Module Parameters */ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) @@ -165,6 +166,7 @@ module_param(yaffs_traceMask, uint, 0644); module_param(yaffs_wr_attempts, uint, 0644); module_param(yaffs_auto_checkpoint, uint, 0644); module_param(yaffs_gc_control, uint, 0644); +module_param(yaffs_bg_enable, uint, 0644); #else MODULE_PARM(yaffs_traceMask, "i"); MODULE_PARM(yaffs_wr_attempts, "i"); @@ -2314,12 +2316,12 @@ static int yaffs_BackgroundThread(void *data) now = jiffies; - if(time_after(now, next_dir_update)){ + if(time_after(now, next_dir_update) && yaffs_bg_enable){ yaffs_UpdateDirtyDirectories(dev); next_dir_update = now + HZ; } - if(time_after(now,next_gc)){ + if(time_after(now,next_gc) && yaffs_bg_enable){ if(!dev->isCheckpointed){ urgency = yaffs_bg_gc_urgency(dev); gcResult = yaffs_BackgroundGarbageCollect(dev, urgency); @@ -3188,6 +3190,7 @@ static char *yaffs_dump_dev_part1(char *buf, yaffs_Device * dev) buf += sprintf(buf, "allGCs............. %u\n", dev->allGCs); buf += sprintf(buf, "passiveGCs......... %u\n", dev->passiveGCs); buf += sprintf(buf, "oldestDirtyGCs..... %u\n", dev->oldestDirtyGCs); + buf += sprintf(buf, "nGCBlocks.......... %u\n", dev->nGCBlocks); buf += sprintf(buf, "backgroundGCs...... %u\n", dev->backgroundGCs); buf += sprintf(buf, "nRetriedWrites..... %u\n", dev->nRetriedWrites); buf += sprintf(buf, "nRetireBlocks...... %u\n", dev->nRetiredBlocks); diff --git a/yaffs_guts.c b/yaffs_guts.c index a1782e7..389a57c 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -2500,8 +2500,10 @@ static unsigned yaffs_FindBlockForGarbageCollection(yaffs_Device *dev, dev->param.nChunksPerBlock - dev->gcPagesInUse, prioritised)); + dev->nGCBlocks++; if(background) dev->backgroundGCs++; + dev->gcDirtiest = 0; dev->gcPagesInUse = 0; dev->gcNotDone = 0; diff --git a/yaffs_guts.h b/yaffs_guts.h index 6d4ae46..f9b5ac1 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -759,6 +759,7 @@ struct yaffs_DeviceStruct { __u32 allGCs; __u32 passiveGCs; __u32 oldestDirtyGCs; + __u32 nGCBlocks; __u32 backgroundGCs; __u32 nRetriedWrites; __u32 nRetiredBlocks; -- 2.30.2