Whamcloud - gitweb
LU-13309 osd: use per-cpu counters for brw_stats
[fs/lustre-release.git] / lustre / osp / lproc_osp.c
index c0fc78d..f0eb765 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/osp/lproc_osp.c
  *
@@ -80,7 +79,7 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct lu_device *lu = dt2lu_dev(dt);
        struct obd_device *obd = lu->ld_obd;
-       struct obd_import *imp;
+       struct obd_import *imp, *imp0;
        bool val;
        int rc;
 
@@ -88,15 +87,18 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
        if (rc)
                return rc;
 
-       with_imp_locked(obd, imp, rc) {
-               /* opposite senses */
-               if (obd->u.cli.cl_import->imp_deactive == val)
-                       rc = ptlrpc_set_import_active(imp, val);
-               else
-                       CDEBUG(D_CONFIG,
-                              "activate %u: ignoring repeat request\n",
-                              (unsigned int)val);
-       }
+       with_imp_locked(obd, imp0, rc)
+               imp = class_import_get(imp0);
+       if (rc)
+               return rc;
+       /* opposite senses */
+       if (imp->imp_deactive == val)
+               rc = ptlrpc_set_import_active(imp, val);
+       else
+               CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
+                      (unsigned int)val);
+
+       class_import_put(imp);
 
        return rc ?: count;
 }
@@ -191,6 +193,37 @@ static ssize_t sync_changes_store(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_RW_ATTR(sync_changes);
 
+static ssize_t max_sync_changes_show(struct kobject *kobj,
+               struct attribute *attr, char *buf)
+{
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osp_device *osp = dt2osp_dev(dt);
+
+       return sprintf(buf, "%u\n", osp->opd_sync_max_changes);
+}
+
+
+static ssize_t max_sync_changes_store(struct kobject *kobj,
+               struct attribute *attr, const char *buffer, size_t count)
+{
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osp_device *osp = dt2osp_dev(dt);
+       int val;
+       int rc;
+
+       rc = kstrtoint(buffer, 0, &val);
+       if (rc)
+               return rc;
+       if (val <= 0)
+               return -ERANGE;
+       osp->opd_sync_max_changes = val;
+       return count;
+}
+
+LUSTRE_RW_ATTR(max_sync_changes);
+
 /**
  * Show maximum number of RPCs in flight allowed
  *
@@ -335,12 +368,11 @@ static ssize_t create_count_store(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct osp_device *osp = dt2osp_dev(dt);
        unsigned int val;
-       int rc, i;
+       int rc;
 
        if (!osp->opd_pre)
                return -EINVAL;
 
-
        rc = kstrtouint(buffer, 0, &val);
        if (rc)
                return rc;
@@ -351,18 +383,24 @@ static ssize_t create_count_store(struct kobject *kobj, struct attribute *attr,
         * that is the maximum possible number of objects that will
         * ever be handled by MDT->OST recovery processing.
         *
+        * The OSP enforces the pre_create_count to amaximum of
+        * one half of opd_pre_max_create_count.
+        *
         * If the OST ever gets a request to delete more orphans,
         * this implies that something has gone badly on the MDT
         * and the OST will refuse to delete so much data from the
-        * filesystem as a safety measure. */
-       if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE)
-               return -ERANGE;
-       if (val > osp->opd_pre_max_create_count)
+        * filesystem as a safety measure.
+        */
+       if (val < OST_MIN_PRECREATE)
                return -ERANGE;
+       if (val > osp->opd_pre_max_create_count / 2)
+               val = osp->opd_pre_max_create_count / 2;
 
-       for (i = 1; (i << 1) <= val; i <<= 1)
-               ;
-       osp->opd_pre_create_count = i;
+       /* set to largest value <= 32, 64, 128 or a multiple of 256 */
+       if (val > 256)
+               osp->opd_pre_create_count = val & 0xffffff00;
+       else
+               osp->opd_pre_create_count = rounddown_pow_of_two(val);
 
        return count;
 }
@@ -758,11 +796,9 @@ ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct lu_device *lu = dt2lu_dev(dt);
        struct obd_device *obd = lu->ld_obd;
-       struct obd_import *imp;
        int rc;
 
-       with_imp_locked(obd, imp, rc)
-               rc = ptlrpc_obd_ping(obd);
+       rc = ptlrpc_obd_ping(obd);
 
        return rc;
 }
@@ -797,7 +833,7 @@ LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, connect_flags);
 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, server_uuid);
 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, timeouts);
 
-LPROC_SEQ_FOPS_RW_TYPE(osp, import);
+LDEBUGFS_SEQ_FOPS_RW_TYPE(osp, import);
 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, state);
 
 /**
@@ -955,7 +991,7 @@ static ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_WO_ATTR(force_sync);
 
-static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
+static struct ldebugfs_vars ldebugfs_osp_obd_vars[] = {
        { .name =       "connect_flags",
          .fops =       &osp_connect_flags_fops         },
        { .name =       "ost_server_uuid",
@@ -973,7 +1009,7 @@ static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
        { NULL }
 };
 
-static struct lprocfs_vars lprocfs_osp_md_vars[] = {
+static struct ldebugfs_vars ldebugfs_osp_md_vars[] = {
        { .name =       "connect_flags",
          .fops =       &osp_connect_flags_fops         },
        { .name =       "mdt_server_uuid",
@@ -1006,6 +1042,7 @@ static struct attribute *osp_obd_attrs[] = {
        &lustre_attr_sync_in_flight.attr,
        &lustre_attr_sync_in_progress.attr,
        &lustre_attr_sync_changes.attr,
+       &lustre_attr_max_sync_changes.attr,
        &lustre_attr_force_sync.attr,
        &lustre_attr_old_sync_processed.attr,
        &lustre_attr_create_count.attr,
@@ -1062,10 +1099,10 @@ void osp_tunables_init(struct osp_device *osp)
 
        if (osp->opd_connect_mdt) {
                osp->opd_dt_dev.dd_ktype.default_attrs = osp_md_attrs;
-               obd->obd_vars = lprocfs_osp_md_vars;
+               obd->obd_debugfs_vars = ldebugfs_osp_md_vars;
        } else {
                osp->opd_dt_dev.dd_ktype.default_attrs = osp_obd_attrs;
-               obd->obd_vars = lprocfs_osp_obd_vars;
+               obd->obd_debugfs_vars = ldebugfs_osp_obd_vars;
        }
 
        rc = dt_tunables_init(&osp->opd_dt_dev, obd->obd_type, obd->obd_name,
@@ -1079,18 +1116,9 @@ void osp_tunables_init(struct osp_device *osp)
        /* Since we register the obd device with ptlrpc / sptlrpc we
         * have to register debugfs with obd_device
         */
-       obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
-                                                  obd->obd_type->typ_debugfs_entry,
-                                                  obd->obd_vars, obd);
-       if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
-               rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
-                                           : -ENOMEM;
-               CERROR("%s: error %d setting up debugfs\n",
-                      obd->obd_name, rc);
-               obd->obd_debugfs_entry = NULL;
-               dt_tunables_fini(&osp->opd_dt_dev);
-               return;
-       }
+       obd->obd_debugfs_entry = debugfs_create_dir(
+               obd->obd_name, obd->obd_type->typ_debugfs_entry);
+       ldebugfs_add_vars(obd->obd_debugfs_entry, obd->obd_debugfs_vars, obd);
 
        sptlrpc_lprocfs_cliobd_attach(obd);
        ptlrpc_lprocfs_register_obd(obd);