Whamcloud - gitweb
LU-2139 osc: Track and limit "unstable" pages
[fs/lustre-release.git] / lustre / llite / lproc_llite.c
index 4b86d48..5f995af 100644 (file)
@@ -293,10 +293,10 @@ static int ll_wr_max_readahead_mb(struct file *file, const char *buffer,
        if (rc)
                return rc;
 
-       if (pages_number < 0 || pages_number > num_physpages / 2) {
+       if (pages_number < 0 || pages_number > totalram_pages / 2) {
                /* 1/2 of RAM */
                CERROR("can't set file readahead more than %lu MB\n",
-                      num_physpages >> (20 - PAGE_CACHE_SHIFT + 1));
+                      totalram_pages >> (20 - PAGE_CACHE_SHIFT + 1));
                return -ERANGE;
        }
 
@@ -439,10 +439,10 @@ static int ll_wr_max_cached_mb(struct file *file, const char *buffer,
        if (rc)
                RETURN(rc);
 
-       if (pages_number < 0 || pages_number > num_physpages) {
+       if (pages_number < 0 || pages_number > totalram_pages) {
                CERROR("%s: can't set max cache more than %lu MB\n",
                       ll_get_fsname(sb, NULL, 0),
-                      num_physpages >> (20 - PAGE_CACHE_SHIFT));
+                      totalram_pages >> (20 - PAGE_CACHE_SHIFT));
                RETURN(-ERANGE);
        }
 
@@ -776,6 +776,23 @@ static int ll_rd_sbi_flags(char *page, char **start, off_t off,
        return rc;
 }
 
+static int ll_rd_unstable_stats(char *page, char **start, off_t off,
+                             int count, int *eof, void *data)
+{
+       struct super_block      *sb    = data;
+       struct ll_sb_info       *sbi   = ll_s2sbi(sb);
+       struct cl_client_cache  *cache = &sbi->ll_cache;
+       int pages, mb, rc;
+
+       pages = cfs_atomic_read(&cache->ccc_unstable_nr);
+       mb    = (pages * PAGE_CACHE_SIZE) >> 20;
+
+       rc = snprintf(page, count, "unstable_pages: %8d\n"
+                                  "unstable_mb:    %8d\n", pages, mb);
+
+       return rc;
+}
+
 static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
         { "uuid",         ll_rd_sb_uuid,          0, 0 },
         //{ "mntpt_path",   ll_rd_path,             0, 0 },
@@ -808,6 +825,7 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
         { "max_easize",       ll_rd_maxea_size, 0, 0 },
        { "sbi_flags",        ll_rd_sbi_flags, 0, 0 },
        { "xattr_cache",      ll_rd_xattr_cache, ll_wr_xattr_cache, 0 },
+       { "unstable_stats",   ll_rd_unstable_stats, 0, 0},
         { 0 }
 };