Whamcloud - gitweb
Branch b1_8
authortianzy <tianzy>
Wed, 29 Apr 2009 00:58:53 +0000 (00:58 +0000)
committertianzy <tianzy>
Wed, 29 Apr 2009 00:58:53 +0000 (00:58 +0000)
add lcounter_read_positive() so that it always returns positive integer
b=17098
i=shadow
i=jay

lustre/include/linux/lustre_lite.h
lustre/llite/lproc_llite.c
lustre/llite/rw.c

index 1857aac..2b64bb1 100644 (file)
@@ -65,6 +65,7 @@
 
 typedef struct percpu_counter lcounter_t;
 
+#define lcounter_read_positive(counter) percpu_counter_read_positive(counter)
 #define lcounter_read(counter)          (int)percpu_counter_read(counter)
 #define lcounter_inc(counter)           percpu_counter_inc(counter)
 #define lcounter_dec(counter)           percpu_counter_dec(counter)
@@ -81,6 +82,7 @@ typedef struct percpu_counter lcounter_t;
 typedef struct { atomic_t count; } lcounter_t;
 
 #define lcounter_read(counter)          atomic_read(&counter->count)
+#define lcounter_read_positive(counter) lcounter_read(counter)
 #define lcounter_inc(counter)           atomic_inc(&counter->count)
 #define lcounter_dec(counter)           atomic_dec(&counter->count)
 #define lcounter_init(counter)          atomic_set(&counter->count, 0)
index 1b62f7d..9daf6d4 100644 (file)
@@ -372,7 +372,8 @@ static int ll_wr_max_cached_mb(struct file *file, const char *buffer,
                 LL_PGLIST_DATA_CPU(sbi, cpu)->llpd_budget = budget;
         spin_unlock(&sbi->ll_async_page_reblnc_lock);
 
-        if (lcounter_read(&sbi->ll_async_page_count) >= sbi->ll_async_page_max)
+        if (lcounter_read_positive(&sbi->ll_async_page_count) >=
+            sbi->ll_async_page_max)
                 llap_shrink_cache(sbi, -1);
 
         return count;
index 6a61cb4..087169b 100644 (file)
@@ -641,7 +641,7 @@ int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction)
         unsigned long total, want, percpu_want, count = 0;
         int cpu, nr_cpus;
 
-        total = lcounter_read(&sbi->ll_async_page_count);
+        total = lcounter_read_positive(&sbi->ll_async_page_count);
         if (total == 0)
                 return 0;
 
@@ -690,7 +690,7 @@ int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction)
                count, want, total);
 
 #ifdef HAVE_SHRINKER_CACHE
-        return lcounter_read(&sbi->ll_async_page_count);
+        return lcounter_read_positive(&sbi->ll_async_page_count);
 #else
         return count;
 #endif