Whamcloud - gitweb
r=adilger,nic
[fs/lustre-release.git] / lustre / osc / lproc_osc.c
index 9216ec0..89ec9ba 100644 (file)
@@ -59,7 +59,7 @@ int osc_wr_max_pages_per_rpc(struct file *file, const char *buffer,
         if (rc)
                 return rc;
 
-        if (val < 1 || val > PTL_MD_MAX_PAGES)
+        if (val < 1 || val > PTLRPC_MAX_BRW_PAGES)
                 return -ERANGE;
 
         spin_lock(&cli->cl_loi_list_lock);
@@ -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,7 @@ 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 / 4)
                 return -ERANGE;
 
         spin_lock(&cli->cl_loi_list_lock);
@@ -166,76 +165,25 @@ 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;
-        struct obd_export *exp;
-
-        if (obd == NULL || list_empty(&obd->obd_exports))
-                return 0;
-
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        spin_unlock(&obd->obd_dev_lock);
-
-        return snprintf(page, count, "%d\n",
-                        exp->exp_osc_data.oed_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;
-        struct obd_export *exp;
-        int val, rc;
-
-        if (obd == NULL || list_empty(&obd->obd_exports))
-                return 0;
-
-        rc = lprocfs_write_helper(buffer, count, &val);
-        if (rc)
-                return rc;
-
-        if (val < 0)
-                return -ERANGE;
-
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        exp->exp_osc_data.oed_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)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        spin_unlock(&obd->obd_dev_lock);
-
         return snprintf(page, count, "%d\n",
-                        exp->exp_osc_data.oed_oscc.oscc_grow_count);
+                        obd->u.cli.cl_oscc.oscc_grow_count);
 }
 
 int osc_wr_create_count(struct file *file, const char *buffer,
                         unsigned long count, void *data)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
         int val, rc;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
         rc = lprocfs_write_helper(buffer, count, &val);
@@ -244,12 +192,10 @@ int osc_wr_create_count(struct file *file, const char *buffer,
 
         if (val < 0)
                 return -ERANGE;
+        if (val > OST_MAX_PRECREATE)
+                return -ERANGE;
 
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        exp->exp_osc_data.oed_oscc.oscc_grow_count = val;
-        spin_unlock(&obd->obd_dev_lock);
+        obd->u.cli.cl_oscc.oscc_grow_count = val;
 
         return count;
 }
@@ -258,36 +204,24 @@ int osc_rd_prealloc_next_id(char *page, char **start, off_t off, int count,
                             int *eof, void *data)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        spin_unlock(&obd->obd_dev_lock);
-
         return snprintf(page, count, LPU64"\n",
-                        exp->exp_osc_data.oed_oscc.oscc_next_id);
+                        obd->u.cli.cl_oscc.oscc_next_id);
 }
 
 int osc_rd_prealloc_last_id(char *page, char **start, off_t off, int count,
                             int *eof, void *data)
 {
         struct obd_device *obd = data;
-        struct obd_export *exp;
 
-        if (obd == NULL || list_empty(&obd->obd_exports))
+        if (obd == NULL)
                 return 0;
 
-        spin_lock(&obd->obd_dev_lock);
-        exp = list_entry(obd->obd_exports.next, struct obd_export,
-                         exp_obd_chain);
-        spin_unlock(&obd->obd_dev_lock);
-
         return snprintf(page, count, LPU64"\n",
-                        exp->exp_osc_data.oed_oscc.oscc_last_id);
+                        obd->u.cli.cl_oscc.oscc_last_id);
 }
 
 static struct lprocfs_vars lprocfs_obd_vars[] = {
@@ -308,7 +242,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 },
@@ -329,21 +262,22 @@ 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",
                    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 %% |");
@@ -359,9 +293,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)
@@ -382,9 +316,9 @@ 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)
@@ -423,7 +357,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;
@@ -448,6 +382,7 @@ static ssize_t osc_rpc_stats_seq_write(struct file *file, const char *buf,
 }
 
 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,
@@ -457,10 +392,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)