From 42b75235a537bae856b9ec8b763b5ea5369d7b22 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 15 Oct 2008 10:30:39 -0400 Subject: copyright year tweak --- cache.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cache.cxx') diff --git a/cache.cxx b/cache.cxx index 19334114..ce57e2d0 100644 --- a/cache.cxx +++ b/cache.cxx @@ -1,5 +1,5 @@ // systemtap cache manager -// Copyright (C) 2006-2007 Red Hat Inc. +// Copyright (C) 2006-2008 Red Hat Inc. // // This file is part of systemtap, and is free software. You can // redistribute it and/or modify it under the terms of the GNU General -- cgit From fffd8e13b84c121be4657a91042d050094fbfb99 Mon Sep 17 00:00:00 2001 From: Kent Sebastian Date: Fri, 17 Oct 2008 14:39:33 -0400 Subject: Minor changes to cache.cxx (cache_clean). --- cache.cxx | 47 +++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) (limited to 'cache.cxx') diff --git a/cache.cxx b/cache.cxx index ce57e2d0..750e2309 100644 --- a/cache.cxx +++ b/cache.cxx @@ -149,32 +149,22 @@ clean_cache(systemtap_session& s) string cache_max_filename = s.cache_path + "/"; cache_max_filename += SYSTEMTAP_CACHE_MAX_FILENAME; ifstream cache_max_file(cache_max_filename.c_str(), ios::in); + unsigned long cache_mb_max; if (cache_max_file.is_open()) { - cache_max_file >> s.cache_max; + cache_max_file >> cache_mb_max; cache_max_file.close(); - s.cache_max *= 1024 * 1024; //convert to bytes - - //bad content in the file? - if (s.cache_max < 0) - s.cache_max = 0; } else { //file doesnt exist or error - s.cache_max = 0; - } - - if (s.cache_max == 0) - { if (s.verbose > 1) clog << "Missing cache limit file " << s.cache_path << "/" << SYSTEMTAP_CACHE_MAX_FILENAME << ", I/O error or invalid content." << endl; return; } - //glob for all kernel modules in the cache dir glob_t cache_glob; string glob_str = s.cache_path + "/*/*.ko"; @@ -182,7 +172,7 @@ clean_cache(systemtap_session& s) set cache_contents; - long cache_size = 0; + unsigned long cache_size_b = 0; //grab info for each cache entry (.ko and .c) for (unsigned int i = 0; i < cache_glob.gl_pathc; i++) @@ -197,7 +187,7 @@ clean_cache(systemtap_session& s) cur_size = get_cache_file_size(cache_ent_path); cur_info.size = cur_size; - cache_size += cur_size; + cache_size_b += cur_size; if (cur_info.size != 0 && cur_info.weight != 0) { @@ -208,35 +198,28 @@ clean_cache(systemtap_session& s) globfree(&cache_glob); set::iterator i; - long r_cache_size = cache_size; + unsigned long r_cache_size = cache_size_b; string removed_dirs = ""; //unlink .ko and .c until the cache size is under the limit for (i = cache_contents.begin(); i != cache_contents.end(); ++i) { - if (r_cache_size < s.cache_max) + if ( (r_cache_size / 1024 / 1024) < cache_mb_max) //convert r_cache_size to MiB break; - //delete this (*i) cache_entry, add to removed list - r_cache_size -= (*i).size; - unlink_cache_entry((*i).path); - removed_dirs += (*i).path + ", "; + //remove this (*i) cache_entry, add to removed list + r_cache_size -= i->size; + unlink_cache_entry(i->path); + removed_dirs += i->path + ", "; } cache_contents.clear(); - if (s.verbose > 1) + if (s.verbose > 1 && removed_dirs != "") { - if (removed_dirs == "") - { - clog << "Cache size under limit, no entries removed." << endl; - } - else - { - //remove trailing ", " - removed_dirs = removed_dirs.substr(0, removed_dirs.length() - 2); - clog << "Cache cleaning successful, removed entries: " << removed_dirs << endl; - } + //remove trailing ", " + removed_dirs = removed_dirs.substr(0, removed_dirs.length() - 2); + clog << "Cache cleaning successful, removed entries: " << removed_dirs << endl; } } else @@ -268,7 +251,7 @@ get_cache_file_size(const string &cache_ent_path) cache_ent_size += file_info.st_size; - return cache_ent_size; + return cache_ent_size; // / 1024 / 1024; //convert to MiB } //Assign a weight to this cache entry. A lower weight -- cgit From f604f54a6df38a064787a381852ceb98e229f9e9 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 17 Oct 2008 17:28:46 -0400 Subject: Added creation of a default cache limit file if it doesn't exist. --- cache.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'cache.cxx') diff --git a/cache.cxx b/cache.cxx index 750e2309..acab0b84 100644 --- a/cache.cxx +++ b/cache.cxx @@ -158,11 +158,13 @@ clean_cache(systemtap_session& s) } else { - //file doesnt exist or error - if (s.verbose > 1) - clog << "Missing cache limit file " << s.cache_path << "/" << SYSTEMTAP_CACHE_MAX_FILENAME << ", I/O error or invalid content." << endl; + //file doesnt exist, create a default size + ofstream default_cache_max(cache_max_filename.c_str(), ios::out); + default_cache_max << SYSTEMTAP_CACHE_DEFAULT_MB << endl; + cache_mb_max = SYSTEMTAP_CACHE_DEFAULT_MB; - return; + if (s.verbose > 1) + clog << "Cache limit file " << s.cache_path << "/" << SYSTEMTAP_CACHE_MAX_FILENAME << " missing, creating default." << endl; } //glob for all kernel modules in the cache dir -- cgit