Whamcloud - gitweb
LU-15317 libcfs: Remove D_TTY
[fs/lustre-release.git] / lustre / osp / lproc_osp.c
index 08ec720..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;
 }
@@ -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,