Whamcloud - gitweb
LU-2358 procfs: Implement /proc/fs/lustre/mgs/MGS/fstype as symlink
[fs/lustre-release.git] / lustre / ofd / lproc_ofd.c
index 3fbfd1e..414e7f2 100644 (file)
@@ -41,7 +41,6 @@
 #include <obd.h>
 #include <lprocfs_status.h>
 #include <linux/seq_file.h>
-#include <lquota.h>
 
 #include "ofd_internal.h"
 
@@ -135,9 +134,41 @@ static int lprocfs_ofd_wr_grant_ratio(struct file *file, const char *buffer,
                      "a huge part of the free space is now reserved for "
                      "grants\n", obd->obd_name);
 
-       cfs_spin_lock(&ofd->ofd_grant_lock);
+       spin_lock(&ofd->ofd_grant_lock);
        ofd->ofd_grant_ratio = ofd_grant_ratio_conv(val);
-       cfs_spin_unlock(&ofd->ofd_grant_lock);
+       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;
+
+       spin_lock(&ofd->ofd_objid_lock);
+       ofd->ofd_precreate_batch = val;
+       spin_unlock(&ofd->ofd_objid_lock);
        return count;
 }
 
@@ -286,9 +317,9 @@ int lprocfs_ofd_wr_degraded(struct file *file, const char *buffer,
        if (rc)
                return rc;
 
-       cfs_spin_lock(&ofd->ofd_flags_lock);
+       spin_lock(&ofd->ofd_flags_lock);
        ofd->ofd_raid_degraded = !!val;
-       cfs_spin_unlock(&ofd->ofd_flags_lock);
+       spin_unlock(&ofd->ofd_flags_lock);
 
        return count;
 }
@@ -332,10 +363,10 @@ int lprocfs_ofd_wr_syncjournal(struct file *file, const char *buffer,
        if (val < 0)
                return -EINVAL;
 
-       cfs_spin_lock(&ofd->ofd_flags_lock);
+       spin_lock(&ofd->ofd_flags_lock);
        ofd->ofd_syncjournal = !!val;
        ofd_slc_set(ofd);
-       cfs_spin_unlock(&ofd->ofd_flags_lock);
+       spin_unlock(&ofd->ofd_flags_lock);
 
        return count;
 }
@@ -382,9 +413,9 @@ int lprocfs_ofd_wr_sync_lock_cancel(struct file *file, const char *buffer,
        if (val < 0 || val > 2)
                return -EINVAL;
 
-       cfs_spin_lock(&ofd->ofd_flags_lock);
+       spin_lock(&ofd->ofd_flags_lock);
        ofd->ofd_sync_lock_cancel = val;
-       cfs_spin_unlock(&ofd->ofd_flags_lock);
+       spin_unlock(&ofd->ofd_flags_lock);
        return count;
 }
 
@@ -414,9 +445,9 @@ int lprocfs_ofd_wr_grant_compat_disable(struct file *file, const char *buffer,
        if (val < 0)
                return -EINVAL;
 
-       cfs_spin_lock(&ofd->ofd_flags_lock);
+       spin_lock(&ofd->ofd_flags_lock);
        ofd->ofd_grant_compat_disable = !!val;
-       cfs_spin_unlock(&ofd->ofd_flags_lock);
+       spin_unlock(&ofd->ofd_flags_lock);
 
        return count;
 }
@@ -438,6 +469,8 @@ static struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
        { "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},
@@ -464,6 +497,8 @@ static struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
        { "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 }
 };
 
@@ -618,4 +653,19 @@ static ssize_t ofd_per_nid_stats_seq_write(struct file *file, const char *buf,
 }
 
 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 */