u64 generation;
u64 last_trans_committed;
u64 avg_delayed_ref_runtime;
+ u64 avg_delayed_ref_count;
+ u64 avg_delayed_ref_time;
/*
* this is updated to the current trans every time a full commit
fs_info->tree_mod_log = RB_ROOT;
fs_info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL;
fs_info->avg_delayed_ref_runtime = NSEC_PER_SEC >> 6; /* div by 64 */
+ fs_info->avg_delayed_ref_count = 64;
+ fs_info->avg_delayed_ref_time = NSEC_PER_SEC;
/* readahead state */
INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
spin_lock_init(&fs_info->reada_lock);
if (actual_count > 0) {
u64 runtime = ktime_to_ns(ktime_sub(ktime_get(), start));
u64 avg;
+ u64 time = 0;
+ u64 count = 0;
/*
* We weigh the current average higher than our current runtime
* to avoid large swings in the average.
*/
spin_lock(&delayed_refs->lock);
- avg = fs_info->avg_delayed_ref_runtime * 3 + runtime;
- fs_info->avg_delayed_ref_runtime = avg >> 2; /* div by 4 */
+ fs_info->avg_delayed_ref_count += actual_count;
+ fs_info->avg_delayed_ref_time += runtime;
+ avg = fs_info->avg_delayed_ref_time / fs_info->avg_delayed_ref_count;
+ if (fs_info->avg_delayed_ref_time >= NSEC_PER_SEC * 1000 && fs_info->avg_delayed_ref_count > 1000) {
+ fs_info->avg_delayed_ref_time = fs_info->avg_delayed_ref_time * 3 / 4;
+ fs_info->avg_delayed_ref_count = fs_info->avg_delayed_ref_count * 3 / 4;
+ time = fs_info->avg_delayed_ref_time;
+ count = fs_info->avg_delayed_ref_count;
+ }
+ fs_info->avg_delayed_ref_runtime = avg;
spin_unlock(&delayed_refs->lock);
+ if (time || count) {
+ printk(KERN_ERR "avg_delayed_ref_runtime = %llu, time = %llu, count = %llu\n", avg, time, count);
+ }
}
return 0;
}