Whamcloud - gitweb
LU-5549 llite: make default_easize writeable in /proc 12/13112/7
authorNed Bass <bass6@llnl.gov>
Wed, 17 Dec 2014 00:03:10 +0000 (16:03 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 11 Feb 2015 17:58:48 +0000 (17:58 +0000)
Allow default_easize to be tuned via /proc. A system administrator
might want this if a rare access to widely striped files drives up the
value on a filesystem where narrowly striped files are the more common
case. In practice, however, this is wanted primarily to facilitate
a test case for LU-5549.

- Plumb the necessary interfaces through the LMV and MDC layers
  to expose write access to this value by higher layers.

- Add block comments to modified functions.

- Correct misspelling of "default" in /proc handler function names
  in lustre/llite/lproc_llite.c. The file names in /proc were already
  spelled correctly so there are no issues with backward
  compatibility.

- Convert remaining space-indented lines in lmv_set_info_async()
  to tabs.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Change-Id: Iae2c8d0ca28cccf12af9372b1a10a0f9d170fddf
Reviewed-on: http://review.whamcloud.com/13112
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/lproc_llite.c
lustre/lmv/lmv_obd.c
lustre/mdc/mdc_request.c

index fc9f234..baa47ba 100644 (file)
@@ -920,6 +920,7 @@ void lustre_dump_dentry(struct dentry *, int recur);
 int ll_obd_statfs(struct inode *inode, void __user *arg);
 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
 int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize);
+int ll_set_default_mdsize(struct ll_sb_info *sbi, int default_mdsize);
 int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *max_cookiesize);
 int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *default_cookiesize);
 int ll_process_config(struct lustre_cfg *lcfg);
index fca1a7d..f0ee6b0 100644 (file)
@@ -653,6 +653,17 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize)
        RETURN(rc);
 }
 
+/**
+ * Get the value of the default_easize parameter.
+ *
+ * \see client_obd::cl_default_mds_easize
+ *
+ * \param[in] sbi      superblock info for this filesystem
+ * \param[out] lmmsize pointer to storage location for value
+ *
+ * \retval 0           on success
+ * \retval negative    negated errno on failure
+ */
 int ll_get_default_mdsize(struct ll_sb_info *sbi, int *lmmsize)
 {
        int size, rc;
@@ -666,6 +677,31 @@ int ll_get_default_mdsize(struct ll_sb_info *sbi, int *lmmsize)
        RETURN(rc);
 }
 
+/**
+ * Set the default_easize parameter to the given value.
+ *
+ * \see client_obd::cl_default_mds_easize
+ *
+ * \param[in] sbi      superblock info for this filesystem
+ * \param[in] lmmsize  the size to set
+ *
+ * \retval 0           on success
+ * \retval negative    negated errno on failure
+ */
+int ll_set_default_mdsize(struct ll_sb_info *sbi, int lmmsize)
+{
+       int rc;
+
+       if (lmmsize < sizeof(struct lov_mds_md) || lmmsize > PAGE_CACHE_SIZE)
+               return -EINVAL;
+
+       rc = obd_set_info_async(NULL, sbi->ll_md_exp,
+                               sizeof(KEY_DEFAULT_EASIZE), KEY_DEFAULT_EASIZE,
+                               sizeof(int), &lmmsize, NULL);
+
+       RETURN(rc);
+}
+
 int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *lmmsize)
 {
        int size, rc;
index a3d0b2b..e4241e4 100644 (file)
@@ -783,7 +783,18 @@ static int ll_max_easize_seq_show(struct seq_file *m, void *v)
 }
 LPROC_SEQ_FOPS_RO(ll_max_easize);
 
-static int ll_defult_easize_seq_show(struct seq_file *m, void *v)
+/**
+ * Get default_easize.
+ *
+ * \see client_obd::cl_default_mds_easize
+ *
+ * \param[in] m                seq_file handle
+ * \param[in] v                unused for single entry
+ *
+ * \retval 0           on success
+ * \retval negative    negated errno on failure
+ */
+static int ll_default_easize_seq_show(struct seq_file *m, void *v)
 {
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
@@ -796,7 +807,47 @@ static int ll_defult_easize_seq_show(struct seq_file *m, void *v)
 
        return seq_printf(m, "%u\n", ealen);
 }
-LPROC_SEQ_FOPS_RO(ll_defult_easize);
+
+/**
+ * Set default_easize.
+ *
+ * Range checking on the passed value is handled by
+ * ll_set_default_mdsize().
+ *
+ * \see client_obd::cl_default_mds_easize
+ *
+ * \param[in] file     proc file
+ * \param[in] buffer   string passed from user space
+ * \param[in] count    \a buffer length
+ * \param[in] off      unused for single entry
+ *
+ * \retval positive    \a count on success
+ * \retval negative    negated errno on failure
+ */
+static ssize_t ll_default_easize_seq_write(struct file *file,
+                                          const char __user *buffer,
+                                          size_t count, loff_t *unused)
+{
+       struct seq_file         *seq = file->private_data;
+       struct super_block      *sb = (struct super_block *)seq->private;
+       struct ll_sb_info       *sbi = ll_s2sbi(sb);
+       int                      val;
+       int                      rc;
+
+       if (count == 0)
+               return 0;
+
+       rc = lprocfs_write_helper(buffer, count, &val);
+       if (rc < 0)
+               return rc;
+
+       rc = ll_set_default_mdsize(sbi, val);
+       if (rc)
+               return rc;
+
+       return count;
+}
+LPROC_SEQ_FOPS(ll_default_easize);
 
 static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v)
 {
@@ -813,7 +864,7 @@ static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v)
 }
 LPROC_SEQ_FOPS_RO(ll_max_cookiesize);
 
-static int ll_defult_cookiesize_seq_show(struct seq_file *m, void *v)
+static int ll_default_cookiesize_seq_show(struct seq_file *m, void *v)
 {
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
@@ -826,7 +877,7 @@ static int ll_defult_cookiesize_seq_show(struct seq_file *m, void *v)
 
        return seq_printf(m, "%u\n", cookielen);
 }
-LPROC_SEQ_FOPS_RO(ll_defult_cookiesize);
+LPROC_SEQ_FOPS_RO(ll_default_cookiesize);
 
 static int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
 {
@@ -977,7 +1028,7 @@ struct lprocfs_vars lprocfs_llite_obd_vars[] = {
        { .name =       "blocksize",
          .fops =       &ll_blksize_fops                        },
        { .name =       "kbytestotal",
-         .fops =       &ll_kbytestotal_fops                    },
+         .fops =       &ll_kbytestotal_fops                    },
        { .name =       "kbytesfree",
          .fops =       &ll_kbytesfree_fops                     },
        { .name =       "kbytesavail",
@@ -1013,17 +1064,17 @@ struct lprocfs_vars lprocfs_llite_obd_vars[] = {
        { .name =       "statahead_stats",
          .fops =       &ll_statahead_stats_fops                },
        { .name =       "lazystatfs",
-         .fops =       &ll_lazystatfs_fops                     },
+         .fops =       &ll_lazystatfs_fops                     },
        { .name =       "max_easize",
-         .fops =       &ll_max_easize_fops                     },
+         .fops =       &ll_max_easize_fops                     },
        { .name =       "default_easize",
-         .fops =       &ll_defult_easize_fops                  },
+         .fops =       &ll_default_easize_fops                 },
        { .name =       "max_cookiesize",
-         .fops =       &ll_max_cookiesize_fops                 },
+         .fops =       &ll_max_cookiesize_fops                 },
        { .name =       "default_cookiesize",
-         .fops =       &ll_defult_cookiesize_fops              },
+         .fops =       &ll_default_cookiesize_fops             },
        { .name =       "sbi_flags",
-         .fops =       &ll_sbi_flags_fops                      },
+         .fops =       &ll_sbi_flags_fops                      },
        { .name =       "xattr_cache",
          .fops =       &ll_xattr_cache_fops                    },
        { .name =       "unstable_stats",
index c13e91a..64b6f15 100644 (file)
@@ -2745,6 +2745,22 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
         RETURN(rc);
 }
 
+/**
+ * Get by key a value associated with a LMV device.
+ *
+ * Dispatch request to lower-layer devices as needed.
+ *
+ * \param[in] env              execution environment for this thread
+ * \param[in] exp              export for the LMV device
+ * \param[in] keylen           length of key identifier
+ * \param[in] key              identifier of key to get value for
+ * \param[in] vallen           size of \a val
+ * \param[out] val             pointer to storage location for value
+ * \param[in] lsm              optional striping metadata of object
+ *
+ * \retval 0           on success
+ * \retval negative    negated errno on failure
+ */
 static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
                         __u32 keylen, void *key, __u32 *vallen, void *val,
                         struct lov_stripe_md *lsm)
@@ -2810,26 +2826,43 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
         RETURN(-EINVAL);
 }
 
+/**
+ * Asynchronously set by key a value associated with a LMV device.
+ *
+ * Dispatch request to lower-layer devices as needed.
+ *
+ * \param[in] env      execution environment for this thread
+ * \param[in] exp      export for the LMV device
+ * \param[in] keylen   length of key identifier
+ * \param[in] key      identifier of key to store value for
+ * \param[in] vallen   size of value to store
+ * \param[in] val      pointer to data to be stored
+ * \param[in] set      optional list of related ptlrpc requests
+ *
+ * \retval 0           on success
+ * \retval negative    negated errno on failure
+ */
 int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp,
-                       obd_count keylen, void *key, obd_count vallen,
-                       void *val, struct ptlrpc_request_set *set)
+                      obd_count keylen, void *key, obd_count vallen,
+                      void *val, struct ptlrpc_request_set *set)
 {
-       struct lmv_tgt_desc    *tgt = NULL;
-        struct obd_device      *obd;
-        struct lmv_obd         *lmv;
-        int rc = 0;
-        ENTRY;
+       struct lmv_tgt_desc     *tgt = NULL;
+       struct obd_device       *obd;
+       struct lmv_obd          *lmv;
+       int rc = 0;
+       ENTRY;
 
-        obd = class_exp2obd(exp);
-        if (obd == NULL) {
-                CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
-                       exp->exp_handle.h_cookie);
-                RETURN(-EINVAL);
-        }
-        lmv = &obd->u.lmv;
+       obd = class_exp2obd(exp);
+       if (obd == NULL) {
+               CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
+                      exp->exp_handle.h_cookie);
+               RETURN(-EINVAL);
+       }
+       lmv = &obd->u.lmv;
 
-        if (KEY_IS(KEY_READ_ONLY) || KEY_IS(KEY_FLUSH_CTX)) {
-                int i, err = 0;
+       if (KEY_IS(KEY_READ_ONLY) || KEY_IS(KEY_FLUSH_CTX) ||
+           KEY_IS(KEY_DEFAULT_EASIZE)) {
+               int i, err = 0;
 
                for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
                        tgt = lmv->tgts[i];
@@ -2837,16 +2870,16 @@ int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp,
                        if (tgt == NULL || tgt->ltd_exp == NULL)
                                continue;
 
-                        err = obd_set_info_async(env, tgt->ltd_exp,
-                                                 keylen, key, vallen, val, set);
-                        if (err && rc == 0)
-                                rc = err;
-                }
+                       err = obd_set_info_async(env, tgt->ltd_exp,
+                                                keylen, key, vallen, val, set);
+                       if (err && rc == 0)
+                               rc = err;
+               }
 
-                RETURN(rc);
-        }
+               RETURN(rc);
+       }
 
-        RETURN(-EINVAL);
+       RETURN(-EINVAL);
 }
 
 static int lmv_pack_md_v1(const struct lmv_stripe_md *lsm,
index 55fbdef..dc22bff 100644 (file)
@@ -2626,6 +2626,13 @@ static int mdc_set_info_async(const struct lu_env *env,
                 RETURN(rc);
         }
 
+       if (KEY_IS(KEY_DEFAULT_EASIZE)) {
+               __u32 *default_easize = val;
+
+               exp->exp_obd->u.cli.cl_default_mds_easize = *default_easize;
+               RETURN(0);
+       }
+
        CERROR("Unknown key %s\n", (char *)key);
        RETURN(-EINVAL);
 }