Whamcloud - gitweb
LU-2139 osc: Track and limit "unstable" pages
[fs/lustre-release.git] / lustre / llite / lproc_llite.c
index 90dbfef..5f995af 100644 (file)
@@ -218,6 +218,40 @@ static int ll_rd_sb_uuid(char *page, char **start, off_t off, int count,
         return snprintf(page, count, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
 }
 
+static int ll_rd_xattr_cache(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       struct super_block *sb = (struct super_block *)data;
+       struct ll_sb_info *sbi = ll_s2sbi(sb);
+       int rc;
+
+       rc = snprintf(page, count, "%u\n", sbi->ll_xattr_cache_enabled);
+
+       return rc;
+}
+
+static int ll_wr_xattr_cache(struct file *file, const char *buffer,
+                               unsigned long count, void *data)
+{
+       struct super_block *sb = (struct super_block *)data;
+       struct ll_sb_info *sbi = ll_s2sbi(sb);
+       int val, rc;
+
+       rc = lprocfs_write_helper(buffer, count, &val);
+       if (rc)
+               return rc;
+
+       if (val != 0 && val != 1)
+               return -ERANGE;
+
+       if (val == 1 && !(sbi->ll_flags & LL_SBI_XATTR_CACHE))
+               return -ENOTSUPP;
+
+       sbi->ll_xattr_cache_enabled = val;
+
+       return count;
+}
+
 static int ll_rd_site_stats(char *page, char **start, off_t off,
                             int count, int *eof, void *data)
 {
@@ -259,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;
        }
 
@@ -405,15 +439,15 @@ 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);
        }
 
-       if (sbi->ll_dt_exp == NULL)
-               RETURN(-ENODEV);
+       if (sbi->ll_dt_exp == NULL) /* being initialized */
+               GOTO(out, rc = 0);
 
        spin_lock(&sbi->ll_lock);
        diff = pages_number - cache->ccc_lru_max;
@@ -742,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 },
@@ -773,6 +824,8 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
         { "lazystatfs",       ll_rd_lazystatfs, ll_wr_lazystatfs, 0 },
         { "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 }
 };
 
@@ -824,6 +877,7 @@ struct llite_file_opcode {
         { LPROC_LL_ALLOC_INODE,    LPROCFS_TYPE_REGS, "alloc_inode" },
         { LPROC_LL_SETXATTR,       LPROCFS_TYPE_REGS, "setxattr" },
         { LPROC_LL_GETXATTR,       LPROCFS_TYPE_REGS, "getxattr" },
+       { LPROC_LL_GETXATTR_HITS,  LPROCFS_TYPE_REGS, "getxattr_hits" },
         { LPROC_LL_LISTXATTR,      LPROCFS_TYPE_REGS, "listxattr" },
         { LPROC_LL_REMOVEXATTR,    LPROCFS_TYPE_REGS, "removexattr" },
         { LPROC_LL_INODE_PERM,     LPROCFS_TYPE_REGS, "inode_permission" },
@@ -841,9 +895,9 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count)
         else if (sbi->ll_stats_track_type == STATS_TRACK_PPID &&
                  sbi->ll_stats_track_id == current->parent->pid)
                 lprocfs_counter_add(sbi->ll_stats, op, count);
-        else if (sbi->ll_stats_track_type == STATS_TRACK_GID &&
-                 sbi->ll_stats_track_id == cfs_curproc_gid())
-                lprocfs_counter_add(sbi->ll_stats, op, count);
+       else if (sbi->ll_stats_track_type == STATS_TRACK_GID &&
+                sbi->ll_stats_track_id == current_gid())
+               lprocfs_counter_add(sbi->ll_stats, op, count);
 }
 EXPORT_SYMBOL(ll_stats_ops_tally);
 
@@ -1065,12 +1119,12 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v)
         struct timeval now;
         struct ll_sb_info *sbi = seq->private;
         struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
-        int k;
+       int k;
 
-        cfs_gettimeofday(&now);
+       do_gettimeofday(&now);
 
-        if (!sbi->ll_rw_stats_on) {
-                seq_printf(seq, "disabled\n"
+       if (!sbi->ll_rw_stats_on) {
+               seq_printf(seq, "disabled\n"
                                 "write anything in this file to activate, "
                                 "then 0 or \"[D/d]isabled\" to deactivate\n");
                 return 0;
@@ -1127,13 +1181,13 @@ LPROC_SEQ_FOPS(ll_rw_extents_stats_pp);
 
 static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v)
 {
-        struct timeval now;
-        struct ll_sb_info *sbi = seq->private;
-        struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
+       struct timeval now;
+       struct ll_sb_info *sbi = seq->private;
+       struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
 
-        cfs_gettimeofday(&now);
+       do_gettimeofday(&now);
 
-        if (!sbi->ll_rw_stats_on) {
+       if (!sbi->ll_rw_stats_on) {
                 seq_printf(seq, "disabled\n"
                                 "write anything in this file to activate, "
                                 "then 0 or \"[D/d]isabled\" to deactivate\n");
@@ -1293,11 +1347,11 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v)
         struct ll_sb_info *sbi = seq->private;
         struct ll_rw_process_info *offset = sbi->ll_rw_offset_info;
         struct ll_rw_process_info *process = sbi->ll_rw_process_info;
-        int i;
+       int i;
 
-        cfs_gettimeofday(&now);
+       do_gettimeofday(&now);
 
-        if (!sbi->ll_rw_stats_on) {
+       if (!sbi->ll_rw_stats_on) {
                 seq_printf(seq, "disabled\n"
                                 "write anything in this file to activate, "
                                 "then 0 or \"[D/d]isabled\" to deactivate\n");