Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / osc / lproc_osc.c
index 93b4276..4f0035d 100644 (file)
@@ -108,14 +108,13 @@ int osc_rd_max_dirty_mb(char *page, char **start, off_t off, int count,
 {
         struct obd_device *dev = data;
         struct client_obd *cli = &dev->u.cli;
-        int val;
-        int rc;
+        unsigned val;
 
         spin_lock(&cli->cl_loi_list_lock);
         val = cli->cl_dirty_max >> 20;
-        rc = snprintf(page, count, "%d\n", val);
         spin_unlock(&cli->cl_loi_list_lock);
-        return rc;
+
+        return snprintf(page, count, "%u\n", val);
 }
 
 int osc_wr_max_dirty_mb(struct file *file, const char *buffer,
@@ -129,7 +128,8 @@ int osc_wr_max_dirty_mb(struct file *file, const char *buffer,
         if (rc)
                 return rc;
 
-        if (val < 0 || val > OSC_MAX_DIRTY_MB_MAX)
+        if (val < 0 || val > OSC_MAX_DIRTY_MB_MAX ||
+            val > num_physpages >> (20 - PAGE_SHIFT - 2)) /* 1/4 of RAM */
                 return -ERANGE;
 
         spin_lock(&cli->cl_loi_list_lock);
@@ -166,41 +166,6 @@ int osc_rd_cur_grant_bytes(char *page, char **start, off_t off, int count,
         return rc;
 }
 
-int osc_rd_create_low_wm(char *page, char **start, off_t off, int count,
-                         int *eof, void *data)
-{
-        struct obd_device *obd = data;
-
-        if (obd == NULL)
-                return 0;
-
-        return snprintf(page, count, "%d\n",
-                        obd->u.cli.cl_oscc.oscc_kick_barrier);
-}
-
-int osc_wr_create_low_wm(struct file *file, const char *buffer,
-                         unsigned long count, void *data)
-{
-        struct obd_device *obd = data;
-        int val, rc;
-
-        if (obd == NULL)
-                return 0;
-
-        rc = lprocfs_write_helper(buffer, count, &val);
-        if (rc)
-                return rc;
-
-        if (val < 0)
-                return -ERANGE;
-
-        spin_lock(&obd->obd_dev_lock);
-        obd->u.cli.cl_oscc.oscc_kick_barrier = val;
-        spin_unlock(&obd->obd_dev_lock);
-
-        return count;
-}
-
 int osc_rd_create_count(char *page, char **start, off_t off, int count,
                         int *eof, void *data)
 {
@@ -276,7 +241,6 @@ static struct lprocfs_vars lprocfs_obd_vars[] = {
         { "max_dirty_mb", osc_rd_max_dirty_mb, osc_wr_max_dirty_mb, 0 },
         { "cur_dirty_bytes", osc_rd_cur_dirty_bytes, 0, 0 },
         { "cur_grant_bytes", osc_rd_cur_grant_bytes, 0, 0 },
-        {"create_low_watermark", osc_rd_create_low_wm, osc_wr_create_low_wm, 0},
         { "create_count", osc_rd_create_count, osc_wr_create_count, 0 },
         { "prealloc_next_id", osc_rd_prealloc_next_id, 0, 0 },
         { "prealloc_last_id", osc_rd_prealloc_last_id, 0, 0 },
@@ -290,6 +254,10 @@ static struct lprocfs_vars lprocfs_module_vars[] = {
 
 #define pct(a,b) (b ? a * 100 / b : 0)
 
+#define PRINTF_STIME(stime) (unsigned long)(stime)->st_num,     \
+        lprocfs_stime_avg_ms(stime), lprocfs_stime_avg_us(stime)
+
+
 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
 {
         struct timeval now;
@@ -297,21 +265,24 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
         struct client_obd *cli = &dev->u.cli;
         unsigned long flags;
         unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
-        int i, rpcs, r, w;
+        int i;
 
         do_gettimeofday(&now);
 
         spin_lock_irqsave(&cli->cl_loi_list_lock, flags);
 
-        rpcs = cli->cl_brw_in_flight;
-        r = cli->cl_pending_r_pages;
-        w = cli->cl_pending_w_pages;
-                                                                                
-        seq_printf(seq, "snapshot_time:         %lu:%lu (secs:usecs)\n",
+        seq_printf(seq, "snapshot_time:         %lu.%lu (secs.usecs)\n",
                    now.tv_sec, now.tv_usec);
-        seq_printf(seq, "RPCs in flight:        %d\n", rpcs);
-        seq_printf(seq, "pending write pages:   %d\n", w);
-        seq_printf(seq, "pending read pages:   %d\n", r);
+
+        seq_printf(seq, "read RPCs in flight:  %d\n",
+                   cli->cl_r_in_flight);
+        seq_printf(seq, "write RPCs in flight: %d\n",
+                   cli->cl_w_in_flight);
+        seq_printf(seq, "pending write pages:  %d\n",
+                   cli->cl_pending_w_pages);
+        seq_printf(seq, "pending read pages:   %d\n",
+                   cli->cl_pending_r_pages);
+
 
         seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
         seq_printf(seq, "pages per rpc         rpcs   %% cum %% |");
@@ -327,9 +298,9 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
                 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
                 read_cum += r;
                 write_cum += w;
-                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n", 
-                                 1 << i, r, pct(r, read_tot), 
-                                 pct(read_cum, read_tot), w, 
+                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
+                                 1 << i, r, pct(r, read_tot),
+                                 pct(read_cum, read_tot), w,
                                  pct(w, write_tot),
                                  pct(write_cum, write_tot));
                 if (read_cum == read_tot && write_cum == write_tot)
@@ -350,15 +321,25 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
                 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
                 read_cum += r;
                 write_cum += w;
-                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n", 
-                                 i, r, pct(r, read_tot), 
-                                 pct(read_cum, read_tot), w, 
+                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
+                                 i, r, pct(r, read_tot),
+                                 pct(read_cum, read_tot), w,
                                  pct(w, write_tot),
                                  pct(write_cum, write_tot));
                 if (read_cum == read_tot && write_cum == write_tot)
                         break;
         }
 
+        seq_printf(seq, "\nrpc service time: (rpcs, average ms)\n");
+        seq_printf(seq, "\tread\t%lu\t%lu.%04lu\n",
+                        PRINTF_STIME(&cli->cl_read_stime));
+        seq_printf(seq, "\twrite\t%lu\t%lu.%04lu\n\n",
+                        PRINTF_STIME(&cli->cl_write_stime));
+
+        seq_printf(seq, "app waiting: (num, average ms)\n");
+        seq_printf(seq, "\tenter cache\t%lu\t%lu.%04lu\n",
+                        PRINTF_STIME(&cli->cl_enter_stime));
+
         spin_unlock_irqrestore(&cli->cl_loi_list_lock, flags);
 
         return 0;
@@ -391,7 +372,7 @@ static int osc_rpc_stats_seq_open(struct inode *inode, struct file *file)
         struct proc_dir_entry *dp = PDE(inode);
         struct seq_file *seq;
         int rc;
+
         rc = seq_open(file, &osc_rpc_stats_seq_sops);
         if (rc)
                 return rc;
@@ -412,10 +393,15 @@ static ssize_t osc_rpc_stats_seq_write(struct file *file, const char *buf,
         lprocfs_oh_clear(&cli->cl_read_page_hist);
         lprocfs_oh_clear(&cli->cl_write_page_hist);
 
+        memset(&cli->cl_read_stime, 0, sizeof(cli->cl_read_stime));
+        memset(&cli->cl_write_stime, 0, sizeof(cli->cl_write_stime));
+        memset(&cli->cl_enter_stime, 0, sizeof(cli->cl_enter_stime));
+
         return len;
 }
 
 struct file_operations osc_rpc_stats_fops = {
+        .owner   = THIS_MODULE,
         .open    = osc_rpc_stats_seq_open,
         .read    = seq_read,
         .write   = osc_rpc_stats_seq_write,
@@ -425,10 +411,9 @@ struct file_operations osc_rpc_stats_fops = {
 
 int lproc_osc_attach_seqstat(struct obd_device *dev)
 {
-        return lprocfs_obd_seq_create(dev, "rpc_stats", 0444, 
+        return lprocfs_obd_seq_create(dev, "rpc_stats", 0444,
                                       &osc_rpc_stats_fops, dev);
 }
 
-
 #endif /* LPROCFS */
-LPROCFS_INIT_VARS(osc,lprocfs_module_vars, lprocfs_obd_vars)
+LPROCFS_INIT_VARS(osc, lprocfs_module_vars, lprocfs_obd_vars)