+static int mdc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
+{
+ struct obd_device *dev = m->private;
+ struct client_obd *cli = &dev->u.cli;
+ long val;
+ int mult;
+
+ spin_lock(&cli->cl_loi_list_lock);
+ val = cli->cl_dirty_max_pages;
+ spin_unlock(&cli->cl_loi_list_lock);
+
+ mult = 1 << (20 - PAGE_SHIFT);
+ return lprocfs_seq_read_frac_helper(m, val, mult);
+}
+
+static ssize_t mdc_max_dirty_mb_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
+{
+ struct seq_file *sfl = file->private_data;
+ struct obd_device *dev = sfl->private;
+ struct client_obd *cli = &dev->u.cli;
+ __s64 pages_number;
+ int rc;
+
+ rc = lprocfs_str_with_units_to_s64(buffer, count, &pages_number, 'M');
+ if (rc)
+ return rc;
+
+ pages_number >>= PAGE_SHIFT;
+
+ if (pages_number <= 0 ||
+ pages_number >= OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_SHIFT) ||
+ pages_number > totalram_pages / 4) /* 1/4 of RAM */
+ return -ERANGE;
+
+ spin_lock(&cli->cl_loi_list_lock);
+ cli->cl_dirty_max_pages = pages_number;
+ osc_wake_cache_waiters(cli);
+ spin_unlock(&cli->cl_loi_list_lock);
+
+ return count;
+}
+LPROC_SEQ_FOPS(mdc_max_dirty_mb);
+
+static int mdc_cached_mb_seq_show(struct seq_file *m, void *v)
+{
+ struct obd_device *dev = m->private;
+ struct client_obd *cli = &dev->u.cli;
+ int shift = 20 - PAGE_SHIFT;
+
+ seq_printf(m, "used_mb: %ld\n"
+ "busy_cnt: %ld\n"
+ "reclaim: %llu\n",
+ (atomic_long_read(&cli->cl_lru_in_list) +
+ atomic_long_read(&cli->cl_lru_busy)) >> shift,
+ atomic_long_read(&cli->cl_lru_busy),
+ cli->cl_lru_reclaim);
+
+ return 0;
+}
+
+/* shrink the number of caching pages to a specific number */
+static ssize_t
+mdc_cached_mb_seq_write(struct file *file, const char __user *buffer,
+ size_t count, loff_t *off)
+{
+ struct seq_file *sfl = file->private_data;
+ struct obd_device *dev = sfl->private;
+ struct client_obd *cli = &dev->u.cli;
+ __s64 pages_number;
+ long rc;
+ char kernbuf[128];
+
+ if (count >= sizeof(kernbuf))
+ return -EINVAL;
+
+ if (copy_from_user(kernbuf, buffer, count))
+ return -EFAULT;
+ kernbuf[count] = 0;
+
+ buffer += lprocfs_find_named_value(kernbuf, "used_mb:", &count) -
+ kernbuf;
+ rc = lprocfs_str_with_units_to_s64(buffer, count, &pages_number, 'M');
+ if (rc)
+ return rc;
+
+ pages_number >>= PAGE_SHIFT;
+
+ if (pages_number < 0)
+ return -ERANGE;
+
+ rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number;
+ if (rc > 0) {
+ struct lu_env *env;
+ __u16 refcheck;
+
+ env = cl_env_get(&refcheck);
+ if (!IS_ERR(env)) {
+ (void)osc_lru_shrink(env, cli, rc, true);
+ cl_env_put(env, &refcheck);
+ }
+ }
+
+ return count;
+}
+LPROC_SEQ_FOPS(mdc_cached_mb);
+
+static int mdc_contention_seconds_seq_show(struct seq_file *m, void *v)
+{
+ struct obd_device *obd = m->private;
+ struct osc_device *od = obd2osc_dev(obd);
+
+ seq_printf(m, "%u\n", od->od_contention_time);
+ return 0;
+}
+
+static ssize_t mdc_contention_seconds_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
+{
+ struct seq_file *sfl = file->private_data;
+ struct obd_device *obd = sfl->private;
+ struct osc_device *od = obd2osc_dev(obd);
+ int rc;
+ __s64 val;
+
+ rc = lprocfs_str_to_s64(buffer, count, &val);
+ if (rc)
+ return rc;
+ if (val < 0 || val > INT_MAX)
+ return -ERANGE;
+
+ od->od_contention_time = val;
+
+ return count;
+}
+LPROC_SEQ_FOPS(mdc_contention_seconds);
+
+static int mdc_unstable_stats_seq_show(struct seq_file *m, void *v)
+{
+ struct obd_device *dev = m->private;
+ struct client_obd *cli = &dev->u.cli;
+ long pages;
+ int mb;
+
+ pages = atomic_long_read(&cli->cl_unstable_count);
+ mb = (pages * PAGE_SIZE) >> 20;
+
+ seq_printf(m, "unstable_pages: %20ld\n"
+ "unstable_mb: %10d\n", pages, mb);
+ return 0;
+}
+LPROC_SEQ_FOPS_RO(mdc_unstable_stats);
+