Whamcloud - gitweb
LU-3321 osc: Adjustment on osc LRU for performance
[fs/lustre-release.git] / lustre / osc / lproc_osc.c
index 1ee6d60..e765e48 100644 (file)
@@ -134,28 +134,28 @@ static int osc_rd_max_dirty_mb(char *page, char **start, off_t off, int count,
 }
 
 static int osc_wr_max_dirty_mb(struct file *file, const char *buffer,
-                               unsigned long count, void *data)
+                              unsigned long count, void *data)
 {
-        struct obd_device *dev = data;
-        struct client_obd *cli = &dev->u.cli;
-        int pages_number, mult, rc;
+       struct obd_device *dev = data;
+       struct client_obd *cli = &dev->u.cli;
+       int pages_number, mult, rc;
 
-        mult = 1 << (20 - CFS_PAGE_SHIFT);
-        rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
-        if (rc)
-                return rc;
+       mult = 1 << (20 - PAGE_CACHE_SHIFT);
+       rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+       if (rc)
+               return rc;
 
-        if (pages_number <= 0 ||
-            pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - CFS_PAGE_SHIFT) ||
-            pages_number > cfs_num_physpages / 4) /* 1/4 of RAM */
-                return -ERANGE;
+       if (pages_number <= 0 ||
+           pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) ||
+           pages_number > totalram_pages / 4) /* 1/4 of RAM */
+               return -ERANGE;
 
-        client_obd_list_lock(&cli->cl_loi_list_lock);
-        cli->cl_dirty_max = (obd_count)(pages_number << CFS_PAGE_SHIFT);
-        osc_wake_cache_waiters(cli);
-        client_obd_list_unlock(&cli->cl_loi_list_lock);
+       client_obd_list_lock(&cli->cl_loi_list_lock);
+       cli->cl_dirty_max = (obd_count)(pages_number << PAGE_CACHE_SHIFT);
+       osc_wake_cache_waiters(cli);
+       client_obd_list_unlock(&cli->cl_loi_list_lock);
 
-        return count;
+       return count;
 }
 
 static int osc_rd_cached_mb(char *page, char **start, off_t off, int count,
@@ -163,7 +163,7 @@ static int osc_rd_cached_mb(char *page, char **start, off_t off, int count,
 {
        struct obd_device *dev = data;
        struct client_obd *cli = &dev->u.cli;
-       int shift = 20 - CFS_PAGE_SHIFT;
+       int shift = 20 - PAGE_CACHE_SHIFT;
        int rc;
 
        rc = snprintf(page, count,
@@ -184,7 +184,7 @@ static int osc_wr_cached_mb(struct file *file, const char *buffer,
        struct client_obd *cli = &dev->u.cli;
        int pages_number, mult, rc;
 
-       mult = 1 << (20 - CFS_PAGE_SHIFT);
+       mult = 1 << (20 - PAGE_CACHE_SHIFT);
        buffer = lprocfs_find_named_value(buffer, "used_mb:", &count);
        rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
        if (rc)
@@ -195,7 +195,7 @@ static int osc_wr_cached_mb(struct file *file, const char *buffer,
 
        rc = cfs_atomic_read(&cli->cl_lru_in_list) - pages_number;
        if (rc > 0)
-               (void)osc_lru_shrink(cli, rc);
+               (void)osc_lru_shrink(cli, rc, true);
 
        return count;
 }
@@ -371,7 +371,7 @@ static int osc_wd_checksum_type(struct file *file, const char *buffer,
 
         if (count > sizeof(kernbuf) - 1)
                 return -EINVAL;
-        if (cfs_copy_from_user(kernbuf, buffer, count))
+       if (copy_from_user(kernbuf, buffer, count))
                 return -EFAULT;
         if (count > 0 && kernbuf[count - 1] == '\n')
                 kernbuf[count - 1] = '\0';
@@ -477,14 +477,14 @@ static int lprocfs_osc_wr_max_pages_per_rpc(struct file *file,
 
        /* if the max_pages is specified in bytes, convert to pages */
        if (val >= ONE_MB_BRW_SIZE)
-               val >>= CFS_PAGE_SHIFT;
+               val >>= PAGE_CACHE_SHIFT;
 
        LPROCFS_CLIMP_CHECK(dev);
 
-       chunk_mask = ~((1 << (cli->cl_chunkbits - CFS_PAGE_SHIFT)) - 1);
+       chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_CACHE_SHIFT)) - 1);
        /* max_pages_per_rpc must be chunk aligned */
        val = (val + ~chunk_mask) & chunk_mask;
-       if (val == 0 || val > ocd->ocd_brw_size >> CFS_PAGE_SHIFT) {
+       if (val == 0 || val > ocd->ocd_brw_size >> PAGE_CACHE_SHIFT) {
                LPROCFS_CLIMP_EXIT(dev);
                return -ERANGE;
        }
@@ -496,6 +496,22 @@ static int lprocfs_osc_wr_max_pages_per_rpc(struct file *file,
        return count;
 }
 
+static int osc_rd_unstable_stats(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       struct obd_device *dev = data;
+       struct client_obd *cli = &dev->u.cli;
+       int pages, mb;
+
+       pages = cfs_atomic_read(&cli->cl_unstable_count);
+       mb    = (pages * PAGE_CACHE_SIZE) >> 20;
+
+       return snprintf(page, count,
+                       "unstable_pages: %8d\n"
+                       "unstable_mb:    %8d\n",
+                       pages, mb);
+}
+
 static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
         { "uuid",            lprocfs_rd_uuid,        0, 0 },
         { "ping",            0, lprocfs_wr_ping,     0, 0, 0222 },
@@ -536,6 +552,8 @@ static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
         { "state",           lprocfs_rd_state,         0, 0 },
         { "pinger_recov",    lprocfs_rd_pinger_recov,
                              lprocfs_wr_pinger_recov,  0, 0 },
+        { "unstable_stats",  osc_rd_unstable_stats, 0, 0},
+
         { 0 }
 };
 
@@ -552,11 +570,11 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
         struct obd_device *dev = seq->private;
         struct client_obd *cli = &dev->u.cli;
         unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
-        int i;
+       int i;
 
-        cfs_gettimeofday(&now);
+       do_gettimeofday(&now);
 
-        client_obd_list_lock(&cli->cl_loi_list_lock);
+       client_obd_list_lock(&cli->cl_loi_list_lock);
 
         seq_printf(seq, "snapshot_time:         %lu.%lu (secs.usecs)\n",
                    now.tv_sec, now.tv_usec);
@@ -664,21 +682,21 @@ LPROC_SEQ_FOPS(osc_rpc_stats);
 
 static int osc_stats_seq_show(struct seq_file *seq, void *v)
 {
-        struct timeval now;
-        struct obd_device *dev = seq->private;
-        struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
-
-        cfs_gettimeofday(&now);
-
-        seq_printf(seq, "snapshot_time:         %lu.%lu (secs.usecs)\n",
-                   now.tv_sec, now.tv_usec);
-        seq_printf(seq, "lockless_write_bytes\t\t"LPU64"\n",
-                   stats->os_lockless_writes);
-        seq_printf(seq, "lockless_read_bytes\t\t"LPU64"\n",
-                   stats->os_lockless_reads);
-        seq_printf(seq, "lockless_truncate\t\t"LPU64"\n",
-                   stats->os_lockless_truncates);
-        return 0;
+       struct timeval now;
+       struct obd_device *dev = seq->private;
+       struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
+
+       do_gettimeofday(&now);
+
+       seq_printf(seq, "snapshot_time:         %lu.%lu (secs.usecs)\n",
+                  now.tv_sec, now.tv_usec);
+       seq_printf(seq, "lockless_write_bytes\t\t"LPU64"\n",
+                  stats->os_lockless_writes);
+       seq_printf(seq, "lockless_read_bytes\t\t"LPU64"\n",
+                  stats->os_lockless_reads);
+       seq_printf(seq, "lockless_truncate\t\t"LPU64"\n",
+                  stats->os_lockless_truncates);
+       return 0;
 }
 
 static ssize_t osc_stats_seq_write(struct file *file, const char *buf,