From 9d9db87afc80ed3e98e1fc05b3ad97a89ebf577a Mon Sep 17 00:00:00 2001 From: Ned Bass Date: Tue, 16 Dec 2014 16:03:10 -0800 Subject: [PATCH] LU-5549 llite: make default_easize writeable in /proc 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 Change-Id: Iae2c8d0ca28cccf12af9372b1a10a0f9d170fddf Reviewed-on: http://review.whamcloud.com/13112 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao --- lustre/llite/llite_internal.h | 1 + lustre/llite/llite_lib.c | 36 +++++++++++++++++++ lustre/llite/lproc_llite.c | 73 ++++++++++++++++++++++++++++++++------ lustre/lmv/lmv_obd.c | 81 ++++++++++++++++++++++++++++++------------- lustre/mdc/mdc_request.c | 7 ++++ 5 files changed, 163 insertions(+), 35 deletions(-) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index fc9f234..baa47ba 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -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); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index fca1a7d..f0ee6b0 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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; diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index a3d0b2b..e4241e4 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -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", diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index c13e91a..64b6f15 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -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, diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 55fbdef..dc22bff 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -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); } -- 1.8.3.1