Whamcloud - gitweb
LU-2948 osc: keep trying to shrink more LRU slots
[fs/lustre-release.git] / lustre / ofd / lproc_ofd.c
index c40774b..272aba7 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #include <obd.h>
 #include <lprocfs_status.h>
 #include <linux/seq_file.h>
-#include <lquota.h>
 
 #include "ofd_internal.h"
 
 #ifdef LPROCFS
 
-static int lprocfs_ofd_rd_groups(char *page, char **start, off_t off,
-                                int count, int *eof, void *data)
+static int lprocfs_ofd_rd_seqs(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);
 
        *eof = 1;
-       return snprintf(page, count, "%u\n", ofd->ofd_max_group);
+       return snprintf(page, count, "%u\n", ofd->ofd_seq_count);
 }
 
 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);
+       struct ofd_device *ofd;
 
        LASSERT(obd != NULL);
+       ofd = ofd_dev(obd->obd_lu_dev);
        *eof = 1;
        return snprintf(page, count, LPU64"\n", ofd->ofd_tot_dirty);
 }
@@ -72,9 +72,10 @@ 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);
+       struct ofd_device *ofd;
 
        LASSERT(obd != NULL);
+       ofd = ofd_dev(obd->obd_lu_dev);
        *eof = 1;
        return snprintf(page, count, LPU64"\n", ofd->ofd_tot_granted);
 }
@@ -83,9 +84,10 @@ 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);
+       struct ofd_device *ofd;
 
        LASSERT(obd != NULL);
+       ofd = ofd_dev(obd->obd_lu_dev);
        *eof = 1;
        return snprintf(page, count, LPU64"\n", ofd->ofd_tot_pending);
 }
@@ -105,9 +107,10 @@ 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);
+       struct ofd_device *ofd;
 
        LASSERT(obd != NULL);
+       ofd = ofd_dev(obd->obd_lu_dev);
        *eof = 1;
        return snprintf(page, count, "%d%%\n",
                        (int) ofd_grant_reserved(ofd, 100));
@@ -135,9 +138,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_batch_lock);
+       ofd->ofd_precreate_batch = val;
+       spin_unlock(&ofd->ofd_batch_lock);
        return count;
 }
 
@@ -145,14 +180,19 @@ static int lprocfs_ofd_rd_last_id(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                      retval = 0, rc, i;
+       struct ofd_device       *ofd;
+       struct ofd_seq          *oseq = NULL;
+       int                     retval = 0, rc;
 
        if (obd == NULL)
                return 0;
 
-       for (i = FID_SEQ_OST_MDT0; i <= ofd->ofd_max_group; i++) {
-               rc = snprintf(page, count, LPU64"\n", ofd_last_id(ofd, i));
+       ofd = ofd_dev(obd->obd_lu_dev);
+
+       read_lock(&ofd->ofd_seq_list_lock);
+       cfs_list_for_each_entry(oseq, &ofd->ofd_seq_list, os_list) {
+               rc = snprintf(page, count, LPX64": "LPX64"\n",
+                             oseq->os_seq, ofd_seq_last_oid(oseq));
                if (rc < 0) {
                        retval = rc;
                        break;
@@ -161,6 +201,7 @@ static int lprocfs_ofd_rd_last_id(char *page, char **start, off_t off,
                count -= rc;
                retval += rc;
        }
+       read_unlock(&ofd->ofd_seq_list_lock);
        return retval;
 }
 
@@ -286,9 +327,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 +373,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 +423,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 +455,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;
 }
@@ -429,7 +470,7 @@ static struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
        { "kbytesavail",         lprocfs_rd_kbytesavail, 0, 0 },
        { "filestotal",          lprocfs_rd_filestotal, 0, 0 },
        { "filesfree",           lprocfs_rd_filesfree, 0, 0 },
-       { "filegroups",          lprocfs_ofd_rd_groups, 0, 0 },
+       { "seqs_allocated",      lprocfs_ofd_rd_seqs, 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 },
@@ -438,6 +479,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},
@@ -585,7 +628,7 @@ LPROC_SEQ_FOPS(ofd_brw_stats);
 
 int lproc_ofd_attach_seqstat(struct obd_device *dev)
 {
-       return lprocfs_obd_seq_create(dev, "brw_stats", 0444,
+       return lprocfs_obd_seq_create(dev, "brw_stats", 0644,
                                      &ofd_brw_stats_fops, dev);
 }