+static int lprocfs_ofd_rd_tot_dirty(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+ LASSERT(obd != NULL);
+ *eof = 1;
+ return snprintf(page, count, LPU64"\n", ofd->ofd_tot_dirty);
+}
+
+static int lprocfs_ofd_rd_tot_granted(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+ LASSERT(obd != NULL);
+ *eof = 1;
+ return snprintf(page, count, LPU64"\n", ofd->ofd_tot_granted);
+}
+
+static int lprocfs_ofd_rd_tot_pending(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+ LASSERT(obd != NULL);
+ *eof = 1;
+ return snprintf(page, count, LPU64"\n", ofd->ofd_tot_pending);
+}
+
+static int lprocfs_ofd_rd_grant_precreate(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+
+ LASSERT(obd != NULL);
+ *eof = 1;
+ return snprintf(page, count, "%ld\n",
+ obd->obd_self_export->exp_filter_data.fed_grant);
+}
+
+static int lprocfs_ofd_rd_grant_ratio(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+ LASSERT(obd != NULL);
+ *eof = 1;
+ return snprintf(page, count, "%d%%\n",
+ (int) ofd_grant_reserved(ofd, 100));
+}
+
+static int lprocfs_ofd_wr_grant_ratio(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+ int val;
+ int rc;
+
+ rc = lprocfs_write_helper(buffer, count, &val);
+ if (rc)
+ return rc;
+
+ if (val > 100 || val < 0)
+ return -EINVAL;
+
+ if (val == 0)
+ CWARN("%s: disabling grant error margin\n", obd->obd_name);
+ if (val > 50)
+ CWARN("%s: setting grant error margin >50%%, be warned that "
+ "a huge part of the free space is now reserved for "
+ "grants\n", obd->obd_name);
+
+ cfs_spin_lock(&ofd->ofd_grant_lock);
+ ofd->ofd_grant_ratio = ofd_grant_ratio_conv(val);
+ cfs_spin_unlock(&ofd->ofd_grant_lock);
+ return count;
+}
+