X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmdd%2Fmdd_lproc.c;h=baf3d7ce670d3c63621a747e5d5763a830bd099f;hp=7bf5e335f0def9cf6ecdad85b48c6f2a5b497450;hb=3442db6faf685fbdbd092bdfdc8d273e4990a141;hpb=95bf473ced0ef87c565d1d972e5ed0d8771cfbcd diff --git a/lustre/mdd/mdd_lproc.c b/lustre/mdd/mdd_lproc.c index 7bf5e33..baf3d7c 100644 --- a/lustre/mdd/mdd_lproc.c +++ b/lustre/mdd/mdd_lproc.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, 2014, Intel Corporation. + * Copyright (c) 2012, 2016, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -50,7 +46,7 @@ #include "mdd_internal.h" static ssize_t -mdd_atime_diff_seq_write(struct file *file, const char *buffer, +mdd_atime_diff_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct seq_file *m = file->private_data; @@ -78,7 +74,8 @@ static int mdd_atime_diff_seq_show(struct seq_file *m, void *data) { struct mdd_device *mdd = m->private; - return seq_printf(m, "%lu\n", mdd->mdd_atime_diff); + seq_printf(m, "%lu\n", mdd->mdd_atime_diff); + return 0; } LPROC_SEQ_FOPS(mdd_atime_diff); @@ -93,11 +90,12 @@ static int mdd_changelog_mask_seq_show(struct seq_file *m, void *data) seq_printf(m, "%s ", changelog_type2str(i)); i++; } + seq_putc(m, '\n'); return 0; } static ssize_t -mdd_changelog_mask_seq_write(struct file *file, const char *buffer, +mdd_changelog_mask_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct seq_file *m = file->private_data; @@ -106,9 +104,9 @@ mdd_changelog_mask_seq_write(struct file *file, const char *buffer, int rc; ENTRY; - if (count >= PAGE_CACHE_SIZE) + if (count >= PAGE_SIZE) RETURN(-EINVAL); - OBD_ALLOC(kernbuf, PAGE_CACHE_SIZE); + OBD_ALLOC(kernbuf, PAGE_SIZE); if (kernbuf == NULL) RETURN(-ENOMEM); if (copy_from_user(kernbuf, buffer, count)) @@ -120,7 +118,7 @@ mdd_changelog_mask_seq_write(struct file *file, const char *buffer, if (rc == 0) rc = count; out: - OBD_FREE(kernbuf, PAGE_CACHE_SIZE); + OBD_FREE(kernbuf, PAGE_SIZE); return rc; } LPROC_SEQ_FOPS(mdd_changelog_mask); @@ -136,8 +134,9 @@ static int lprocfs_changelog_users_cb(const struct lu_env *env, rec = (struct llog_changelog_user_rec *)hdr; - seq_printf(m, CHANGELOG_USER_PREFIX"%-3d "LPU64"\n", - rec->cur_id, rec->cur_endrec); + seq_printf(m, CHANGELOG_USER_PREFIX"%-3d %llu (%u)\n", + rec->cur_id, rec->cur_endrec, (__u32)get_seconds() - + rec->cur_time); return 0; } @@ -165,8 +164,8 @@ static int mdd_changelog_users_seq_show(struct seq_file *m, void *data) cur = mdd->mdd_cl.mc_index; spin_unlock(&mdd->mdd_cl.mc_lock); - seq_printf(m, "current index: "LPU64"\n", cur); - seq_printf(m, "%-5s %s\n", "ID", "index"); + seq_printf(m, "current index: %llu\n", cur); + seq_printf(m, "%-5s %s %s\n", "ID", "index", "(idle seconds)"); llog_cat_process(&env, ctxt->loc_handle, lprocfs_changelog_users_cb, m, 0, 0); @@ -177,29 +176,250 @@ static int mdd_changelog_users_seq_show(struct seq_file *m, void *data) } LPROC_SEQ_FOPS_RO(mdd_changelog_users); +static int mdd_changelog_size_ctxt(const struct lu_env *env, + struct mdd_device *mdd, + int index, __u64 *val) +{ + struct llog_ctxt *ctxt; + + ctxt = llog_get_context(mdd2obd_dev(mdd), + index); + if (ctxt == NULL) + return -ENXIO; + + if (!(ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)) { + CERROR("%s: ChangeLog has wrong flags: rc = %d\n", + ctxt->loc_obd->obd_name, -EINVAL); + llog_ctxt_put(ctxt); + return -EINVAL; + } + + *val += llog_cat_size(env, ctxt->loc_handle); + + llog_ctxt_put(ctxt); + + return 0; +} + +static int mdd_changelog_size_seq_show(struct seq_file *m, void *data) +{ + struct lu_env env; + struct mdd_device *mdd = m->private; + __u64 tmp = 0; + int rc; + + rc = lu_env_init(&env, LCT_LOCAL); + if (rc) + return rc; + + rc = mdd_changelog_size_ctxt(&env, mdd, LLOG_CHANGELOG_ORIG_CTXT, &tmp); + if (rc) { + lu_env_fini(&env); + return rc; + } + + rc = mdd_changelog_size_ctxt(&env, mdd, LLOG_CHANGELOG_USER_ORIG_CTXT, + &tmp); + + seq_printf(m, "%llu\n", tmp); + lu_env_fini(&env); + return rc; +} +LPROC_SEQ_FOPS_RO(mdd_changelog_size); + +static int mdd_changelog_gc_seq_show(struct seq_file *m, void *data) +{ + struct mdd_device *mdd = m->private; + + LASSERT(mdd != NULL); + seq_printf(m, "%u\n", mdd->mdd_changelog_gc); + return 0; +} + +static ssize_t +mdd_changelog_gc_seq_write(struct file *file, const char __user *buffer, + size_t count, loff_t *off) +{ + struct seq_file *m = file->private_data; + struct mdd_device *mdd = m->private; + int rc; + __s64 val; + + LASSERT(mdd != NULL); + rc = lprocfs_str_to_s64(buffer, count, &val); + if (rc) + return rc; + + mdd->mdd_changelog_gc = !!val; + + return count; +} +LPROC_SEQ_FOPS(mdd_changelog_gc); + +static int mdd_changelog_max_idle_time_seq_show(struct seq_file *m, void *data) +{ + struct mdd_device *mdd = m->private; + + LASSERT(mdd != NULL); + seq_printf(m, "%u\n", mdd->mdd_changelog_max_idle_time); + return 0; +} + +static ssize_t +mdd_changelog_max_idle_time_seq_write(struct file *file, + const char __user *buffer, size_t count, + loff_t *off) +{ + struct seq_file *m = file->private_data; + struct mdd_device *mdd = m->private; + int rc; + __s64 val; + + LASSERT(mdd != NULL); + rc = lprocfs_str_to_s64(buffer, count, &val); + if (rc) + return rc; + + /* XXX may need to limit with reasonable elapsed/idle times */ + if (val < 1 || val > INT_MAX) + return -ERANGE; + + mdd->mdd_changelog_max_idle_time = val; + + return count; +} +LPROC_SEQ_FOPS(mdd_changelog_max_idle_time); + +static int mdd_changelog_max_idle_indexes_seq_show(struct seq_file *m, + void *data) +{ + struct mdd_device *mdd = m->private; + + LASSERT(mdd != NULL); + seq_printf(m, "%lu\n", mdd->mdd_changelog_max_idle_indexes); + return 0; +} + +static ssize_t +mdd_changelog_max_idle_indexes_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) +{ + struct seq_file *m = file->private_data; + struct mdd_device *mdd = m->private; + int rc; + __s64 val; + + LASSERT(mdd != NULL); + rc = lprocfs_str_to_s64(buffer, count, &val); + if (rc) + return rc; + + /* XXX may need to limit/check with reasonable elapsed/idle indexes */ + /* XXX may better allow to specify a % of full ChangeLogs */ + + mdd->mdd_changelog_max_idle_indexes = val; + + return count; +} +LPROC_SEQ_FOPS(mdd_changelog_max_idle_indexes); + +static int mdd_changelog_min_gc_interval_seq_show(struct seq_file *m, + void *data) +{ + struct mdd_device *mdd = m->private; + + LASSERT(mdd != NULL); + seq_printf(m, "%u\n", mdd->mdd_changelog_min_gc_interval); + return 0; +} + +static ssize_t +mdd_changelog_min_gc_interval_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) +{ + struct seq_file *m = file->private_data; + struct mdd_device *mdd = m->private; + int rc; + __s64 val; + + LASSERT(mdd != NULL); + rc = lprocfs_str_to_s64(buffer, count, &val); + if (rc) + return rc; + + /* XXX may need to limit with reasonable elapsed/interval times */ + if (val < 1 || val > UINT_MAX) + return -ERANGE; + + mdd->mdd_changelog_min_gc_interval = val; + + return count; +} +LPROC_SEQ_FOPS(mdd_changelog_min_gc_interval); + +static int mdd_changelog_min_free_cat_entries_seq_show(struct seq_file *m, + void *data) +{ + struct mdd_device *mdd = m->private; + + LASSERT(mdd != NULL); + seq_printf(m, "%u\n", mdd->mdd_changelog_min_free_cat_entries); + return 0; +} + +static ssize_t +mdd_changelog_min_free_cat_entries_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) +{ + struct seq_file *m = file->private_data; + struct mdd_device *mdd = m->private; + int rc; + __s64 val; + + LASSERT(mdd != NULL); + rc = lprocfs_str_to_s64(buffer, count, &val); + if (rc) + return rc; + + /* XXX may need to limit with more reasonable number of free entries */ + if (val < 1 || (__u64)val > UINT_MAX) + return -ERANGE; + + mdd->mdd_changelog_min_free_cat_entries = val; + + return count; +} +LPROC_SEQ_FOPS(mdd_changelog_min_free_cat_entries); + static int mdd_sync_perm_seq_show(struct seq_file *m, void *data) { struct mdd_device *mdd = m->private; LASSERT(mdd != NULL); - return seq_printf(m, "%d\n", mdd->mdd_sync_permission); + seq_printf(m, "%d\n", mdd->mdd_sync_permission); + return 0; } static ssize_t -mdd_sync_perm_seq_write(struct file *file, const char *buffer, +mdd_sync_perm_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct seq_file *m = file->private_data; struct mdd_device *mdd = m->private; - int val, rc; + int rc; + __s64 val; - LASSERT(mdd != NULL); - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; + LASSERT(mdd != NULL); + rc = lprocfs_str_to_s64(buffer, count, &val); + if (rc) + return rc; - mdd->mdd_sync_permission = !!val; - return count; + mdd->mdd_sync_permission = !!val; + + return count; } LPROC_SEQ_FOPS(mdd_sync_perm); @@ -212,18 +432,20 @@ static int mdd_lfsck_speed_limit_seq_show(struct seq_file *m, void *data) } static ssize_t -mdd_lfsck_speed_limit_seq_write(struct file *file, const char *buffer, +mdd_lfsck_speed_limit_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct seq_file *m = file->private_data; struct mdd_device *mdd = m->private; - __u32 val; + __s64 val; int rc; LASSERT(mdd != NULL); - rc = lprocfs_write_helper(buffer, count, &val); + rc = lprocfs_str_to_s64(buffer, count, &val); if (rc != 0) return rc; + if (val < 0 || val > INT_MAX) + return -ERANGE; rc = lfsck_set_speed(mdd->mdd_bottom, val); return rc != 0 ? rc : count; @@ -239,18 +461,22 @@ static int mdd_lfsck_async_windows_seq_show(struct seq_file *m, void *data) } static ssize_t -mdd_lfsck_async_windows_seq_write(struct file *file, const char *buffer, +mdd_lfsck_async_windows_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct seq_file *m = file->private_data; struct mdd_device *mdd = m->private; - __u32 val; + __s64 val; int rc; LASSERT(mdd != NULL); - rc = lprocfs_write_helper(buffer, count, &val); - if (rc == 0) - rc = lfsck_set_windows(mdd->mdd_bottom, val); + rc = lprocfs_str_to_s64(buffer, count, &val); + if (rc) + return rc; + if (val < 0 || val > INT_MAX) + return -ERANGE; + + rc = lfsck_set_windows(mdd->mdd_bottom, val); return rc != 0 ? rc : count; } @@ -283,6 +509,18 @@ static struct lprocfs_vars lprocfs_mdd_obd_vars[] = { .fops = &mdd_changelog_mask_fops }, { .name = "changelog_users", .fops = &mdd_changelog_users_fops }, + { .name = "changelog_size", + .fops = &mdd_changelog_size_fops }, + { .name = "changelog_gc", + .fops = &mdd_changelog_gc_fops }, + { .name = "changelog_max_idle_time", + .fops = &mdd_changelog_max_idle_time_fops }, + { .name = "changelog_max_idle_indexes", + .fops = &mdd_changelog_max_idle_indexes_fops }, + { .name = "changelog_min_gc_interval", + .fops = &mdd_changelog_min_gc_interval_fops }, + { .name = "changelog_min_free_cat_entries", + .fops = &mdd_changelog_min_free_cat_entries_fops }, { .name = "sync_permission", .fops = &mdd_sync_perm_fops }, { .name = "lfsck_speed_limit",