#include <obd.h>
#include <lprocfs_status.h>
#include <linux/seq_file.h>
+#include <lquota.h>
#include "ofd_internal.h"
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_precreate_batch(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", ofd->ofd_precreate_batch);
+}
+
+static int lprocfs_ofd_wr_precreate_batch(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 < 1)
+ return -EINVAL;
+
+ cfs_spin_lock(&ofd->ofd_objid_lock);
+ ofd->ofd_precreate_batch = val;
+ cfs_spin_unlock(&ofd->ofd_objid_lock);
+ return count;
+}
+
static int lprocfs_ofd_rd_last_id(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
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)
{
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 },
{ "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 },
+ { "precreate_batch", lprocfs_ofd_rd_precreate_batch,
+ lprocfs_ofd_wr_precreate_batch, 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},
{ "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 },
+ { "job_cleanup_interval", lprocfs_rd_job_interval,
+ lprocfs_wr_job_interval, 0},
{ 0 }
};
}
LPROC_SEQ_FOPS(ofd_per_nid_stats);
+
+void ofd_stats_counter_init(struct lprocfs_stats *stats)
+{
+ LASSERT(stats && stats->ls_num == LPROC_OFD_STATS_LAST);
+ lprocfs_counter_init(stats, LPROC_OFD_STATS_READ,
+ LPROCFS_CNTR_AVGMINMAX, "read", "bytes");
+ lprocfs_counter_init(stats, LPROC_OFD_STATS_WRITE,
+ LPROCFS_CNTR_AVGMINMAX, "write", "bytes");
+ lprocfs_counter_init(stats, LPROC_OFD_STATS_SETATTR,
+ 0, "setattr", "reqs");
+ lprocfs_counter_init(stats, LPROC_OFD_STATS_PUNCH,
+ 0, "punch", "reqs");
+ lprocfs_counter_init(stats, LPROC_OFD_STATS_SYNC,
+ 0, "sync", "reqs");
+}
#endif /* LPROCFS */