Whamcloud - gitweb
LU-1406 ofd: grant support
[fs/lustre-release.git] / lustre / ofd / lproc_ofd.c
index e806a61..28f5ab4 100644 (file)
@@ -56,6 +56,90 @@ static int lprocfs_ofd_rd_groups(char *page, char **start, off_t off,
        return snprintf(page, count, "%u\n", ofd->ofd_max_group);
 }
 
+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;
+}
+
 static int lprocfs_ofd_rd_last_id(char *page, char **start, off_t off,
                                  int count, int *eof, void *data)
 {
@@ -79,6 +163,66 @@ static int lprocfs_ofd_rd_last_id(char *page, char **start, off_t off,
        return retval;
 }
 
+int lprocfs_ofd_rd_fmd_max_num(char *page, char **start, off_t off,
+                              int count, int *eof, void *data)
+{
+       struct obd_device       *obd = data;
+       struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
+       int                      rc;
+
+       rc = snprintf(page, count, "%u\n", ofd->ofd_fmd_max_num);
+       return rc;
+}
+
+int lprocfs_ofd_wr_fmd_max_num(struct file *file, const char *buffer,
+                              unsigned long count, void *data)
+{
+       struct obd_device       *obd = 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 > 65536 || val < 1)
+               return -EINVAL;
+
+       ofd->ofd_fmd_max_num = val;
+       return count;
+}
+
+int lprocfs_ofd_rd_fmd_max_age(char *page, char **start, off_t off,
+                              int count, int *eof, void *data)
+{
+       struct obd_device       *obd = data;
+       struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
+       int                      rc;
+
+       rc = snprintf(page, count, "%ld\n", ofd->ofd_fmd_max_age / CFS_HZ);
+       return rc;
+}
+
+int lprocfs_ofd_wr_fmd_max_age(struct file *file, const char *buffer,
+                              unsigned long count, void *data)
+{
+       struct obd_device       *obd = 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 > 65536 || val < 1)
+               return -EINVAL;
+
+       ofd->ofd_fmd_max_age = val * CFS_HZ;
+       return count;
+}
+
 static int lprocfs_ofd_rd_capa(char *page, char **start, off_t off,
                               int count, int *eof, void *data)
 {
@@ -243,6 +387,39 @@ int lprocfs_ofd_wr_sync_lock_cancel(struct file *file, const char *buffer,
        return count;
 }
 
+int lprocfs_ofd_rd_grant_compat_disable(char *page, char **start, off_t off,
+                                       int count, int *eof, void *data)
+{
+       struct obd_device       *obd = data;
+       struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
+       int                      rc;
+
+       rc = snprintf(page, count, "%u\n", ofd->ofd_grant_compat_disable);
+       return rc;
+}
+
+int lprocfs_ofd_wr_grant_compat_disable(struct file *file, const char *buffer,
+                                       unsigned long count, void *data)
+{
+       struct obd_device       *obd = 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 < 0)
+               return -EINVAL;
+
+       cfs_spin_lock(&ofd->ofd_flags_lock);
+       ofd->ofd_grant_compat_disable = !!val;
+       cfs_spin_unlock(&ofd->ofd_flags_lock);
+
+       return count;
+}
+
 static struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
        { "uuid",                lprocfs_rd_uuid, 0, 0 },
        { "blocksize",           lprocfs_rd_blksize, 0, 0 },
@@ -254,6 +431,12 @@ static struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
        { "filegroups",          lprocfs_ofd_rd_groups, 0, 0 },
        { "fstype",              lprocfs_ofd_rd_fstype, 0, 0 },
        { "last_id",             lprocfs_ofd_rd_last_id, 0, 0 },
+       { "tot_dirty",           lprocfs_ofd_rd_tot_dirty,   0, 0 },
+       { "tot_pending",         lprocfs_ofd_rd_tot_pending, 0, 0 },
+       { "tot_granted",         lprocfs_ofd_rd_tot_granted, 0, 0 },
+       { "grant_precreate",     lprocfs_ofd_rd_grant_precreate, 0, 0 },
+       { "grant_ratio",         lprocfs_ofd_rd_grant_ratio,
+                                lprocfs_ofd_wr_grant_ratio, 0, 0 },
        { "recovery_status",     lprocfs_obd_rd_recovery_status, 0, 0 },
        { "recovery_time_soft",  lprocfs_obd_rd_recovery_time_soft,
                                 lprocfs_obd_wr_recovery_time_soft, 0},
@@ -271,6 +454,12 @@ static struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
        { "instance",            lprocfs_target_rd_instance, 0 },
        { "ir_factor",           lprocfs_obd_rd_ir_factor,
                                 lprocfs_obd_wr_ir_factor, 0},
+       { "grant_compat_disable", lprocfs_ofd_rd_grant_compat_disable,
+                                 lprocfs_ofd_wr_grant_compat_disable, 0 },
+       { "client_cache_count",  lprocfs_ofd_rd_fmd_max_num,
+                                lprocfs_ofd_wr_fmd_max_num, 0 },
+       { "client_cache_seconds", lprocfs_ofd_rd_fmd_max_age,
+                                 lprocfs_ofd_wr_fmd_max_age, 0 },
        { "capa",                lprocfs_ofd_rd_capa,
                                 lprocfs_ofd_wr_capa, 0 },
        { "capa_count",          lprocfs_ofd_rd_capa_count, 0, 0 },