Whamcloud - gitweb
LU-6032 ldlm: don't disable softirq for exp_rpc_lock
[fs/lustre-release.git] / lustre / lod / lproc_lod.c
index ea17bac..b7621f1 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2016, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  * \retval 0           on success
  * \retval negative    error code if failed
  */
+static int lod_dom_stripesize_seq_show(struct seq_file *m, void *v)
+{
+       struct obd_device *dev = m->private;
+       struct lod_device *lod;
+
+       LASSERT(dev != NULL);
+       lod = lu2lod_dev(dev->obd_lu_dev);
+       seq_printf(m, "%u\n", lod->lod_dom_max_stripesize);
+       return 0;
+}
+
+/**
+ * Set default stripe size.
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string containing the maximum number of bytes stored in
+ *                     each object before moving to the next object in the
+ *                     layout (if any)
+ * \param[in] count    @buffer length
+ * \param[in] off      unused for single entry
+ *
+ * \retval @count      on success
+ * \retval negative    error code if failed
+ */
+static ssize_t
+lod_dom_stripesize_seq_write(struct file *file, const char __user *buffer,
+                             size_t count, loff_t *off)
+{
+       struct seq_file *m = file->private_data;
+       struct obd_device *dev = m->private;
+       struct lod_device *lod;
+       s64 val;
+       int rc;
+
+       LASSERT(dev != NULL);
+       lod = lu2lod_dev(dev->obd_lu_dev);
+       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
+       if (rc)
+               return rc;
+       if (val < 0)
+               return -ERANGE;
+
+       /* 1GB is the limit */
+       if (val > (1ULL << 30))
+               return -ERANGE;
+       else if (val > 0)
+               lod_fix_desc_stripe_size(&val);
+
+       lod->lod_dom_max_stripesize = val;
+
+       return count;
+}
+LPROC_SEQ_FOPS(lod_dom_stripesize);
+
+/**
+ * Show default stripe size.
+ *
+ * \param[in] m                seq file
+ * \param[in] v                unused for single entry
+ *
+ * \retval 0           on success
+ * \retval negative    error code if failed
+ */
 static int lod_stripesize_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *dev = m->private;
@@ -86,7 +149,7 @@ lod_stripesize_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
-       __s64 val;
+       s64 val;
        int rc;
 
        LASSERT(dev != NULL);
@@ -145,15 +208,15 @@ lod_stripeoffset_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
-       __s64 val;
+       long val;
        int rc;
 
        LASSERT(dev != NULL);
        lod  = lu2lod_dev(dev->obd_lu_dev);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtol_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < -1)
+       if (val < -1 || val > LOV_MAX_STRIPE_COUNT)
                return -ERANGE;
 
        lod->lod_desc.ld_default_stripe_offset = val;
@@ -201,19 +264,15 @@ lod_stripetype_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
+       u32 pattern;
        int rc;
-       __u32 pattern;
-       __s64 val;
 
        LASSERT(dev != NULL);
        lod  = lu2lod_dev(dev->obd_lu_dev);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &pattern);
        if (rc)
                return rc;
-       if (val < 0)
-               return -ERANGE;
 
-       pattern = val;
        lod_fix_desc_pattern(&pattern);
        lod->lod_desc.ld_pattern = pattern;
 
@@ -261,19 +320,15 @@ lod_stripecount_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
+       u32 stripe_count;
        int rc;
-       __s64 val;
-       __u32 stripe_count;
 
        LASSERT(dev != NULL);
-       lod  = lu2lod_dev(dev->obd_lu_dev);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       lod = lu2lod_dev(dev->obd_lu_dev);
+       rc = kstrtouint_from_user(buffer, count, 0, &stripe_count);
        if (rc)
                return rc;
-       if (val < -1)
-               return -ERANGE;
 
-       stripe_count = val;
        lod_fix_desc_stripe_count(&stripe_count);
        lod->lod_desc.ld_default_stripe_count = stripe_count;
 
@@ -392,17 +447,17 @@ lod_qos_priofree_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
+       unsigned int val;
        int rc;
-       __s64 val;
 
        LASSERT(dev != NULL);
        lod = lu2lod_dev(dev->obd_lu_dev);
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 0 || val > 100)
+       if (val > 100)
                return -EINVAL;
        lod->lod_qos.lq_prio_free = (val << 8) / 100;
        lod->lod_qos.lq_dirty = 1;
@@ -522,12 +577,12 @@ lod_qos_maxage_seq_write(struct file *file, const char __user *buffer,
        char str[32];
        unsigned int i;
        int rc;
-       __s64 val;
+       u32 val;
 
        LASSERT(dev != NULL);
        lod = lu2lod_dev(dev->obd_lu_dev);
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -539,7 +594,7 @@ lod_qos_maxage_seq_write(struct file *file, const char __user *buffer,
         * propogate the value down to OSPs
         */
        lustre_cfg_bufs_reset(&bufs, NULL);
-       snprintf(str, 32, "%smaxage=%u", PARAM_OSP, (__u32)val);
+       snprintf(str, 32, "%smaxage=%u", PARAM_OSP, val);
        lustre_cfg_bufs_set_string(&bufs, 1, str);
        OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
        if (lcfg == NULL)
@@ -718,17 +773,17 @@ lod_lmv_failout_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
-       __s64 val = 0;
+       bool val = 0;
        int rc;
 
        LASSERT(dev != NULL);
        lod = lu2lod_dev(dev->obd_lu_dev);
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       lod->lod_lmv_failout = !!val;
+       lod->lod_lmv_failout = val;
 
        return count;
 }
@@ -757,6 +812,10 @@ static struct lprocfs_vars lprocfs_lod_obd_vars[] = {
          .fops =       &lod_qos_maxage_fops    },
        { .name =       "lmv_failout",
          .fops =       &lod_lmv_failout_fops   },
+       {
+         .name = "dom_stripesize",
+         .fops = &lod_dom_stripesize_fops
+       },
        { NULL }
 };
 
@@ -788,10 +847,11 @@ static const struct file_operations lod_proc_target_fops = {
  */
 int lod_procfs_init(struct lod_device *lod)
 {
-       struct obd_device       *obd = lod2obd(lod);
-       struct proc_dir_entry   *lov_proc_dir = NULL;
-       struct obd_type         *type;
-       int                      rc;
+       struct obd_device *obd = lod2obd(lod);
+       struct proc_dir_entry *lov_proc_dir;
+       struct obd_type *type;
+       struct kobject *lov;
+       int rc;
 
        obd->obd_vars = lprocfs_lod_obd_vars;
        rc = lprocfs_obd_setup(obd, true);
@@ -828,6 +888,19 @@ int lod_procfs_init(struct lod_device *lod)
                GOTO(out, rc);
        }
 
+       lov = kset_find_obj(lustre_kset, "lov");
+       if (lov) {
+               rc = sysfs_create_link(lov, &obd->obd_kset.kobj,
+                                      obd->obd_name);
+               kobject_put(lov);
+       }
+
+       lod->lod_debugfs = ldebugfs_add_symlink(obd->obd_name, "lov",
+                                               "../lod/%s", obd->obd_name);
+       if (!lod->lod_debugfs)
+               CERROR("%s: failed to create LOV debugfs symlink\n",
+                      obd->obd_name);
+
        /* If the real LOV is present which is the case for setups
         * with both server and clients on the same node then use
         * the LOV's proc root */
@@ -862,17 +935,22 @@ out:
 void lod_procfs_fini(struct lod_device *lod)
 {
        struct obd_device *obd = lod2obd(lod);
+       struct kobject *lov;
 
        if (lod->lod_symlink != NULL) {
                lprocfs_remove(&lod->lod_symlink);
                lod->lod_symlink = NULL;
        }
 
-       if (lod->lod_pool_proc_entry != NULL) {
-               lprocfs_remove(&lod->lod_pool_proc_entry);
-               lod->lod_pool_proc_entry = NULL;
+       lov = kset_find_obj(lustre_kset, "lov");
+       if (lov) {
+               sysfs_remove_link(lov, obd->obd_name);
+               kobject_put(lov);
        }
 
+       if (!IS_ERR_OR_NULL(lod->lod_debugfs))
+               ldebugfs_remove(&lod->lod_debugfs);
+
        lprocfs_obd_cleanup(obd);
 }