X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdd%2Fmdd_lproc.c;h=de379b3ca05ad148d6c0fc8d00e6aa2b544c7987;hb=8abb5a19e4375f194f3f7d304ad46ec7120e733f;hp=1ca8cfc7f171bbbebc280db5ac11a3efad6322fc;hpb=5165cdd4b063d523e5ae261f47818b5ba2bbc7cc;p=fs%2Flustre-release.git diff --git a/lustre/mdd/mdd_lproc.c b/lustre/mdd/mdd_lproc.c index 1ca8cfc..de379b3 100644 --- a/lustre/mdd/mdd_lproc.c +++ b/lustre/mdd/mdd_lproc.c @@ -26,6 +26,8 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2012, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -44,14 +46,9 @@ #include #include #include -#include #include - #include "mdd_internal.h" -static const char *mdd_counter_names[LPROC_MDD_NR] = { -}; - int mdd_procfs_init(struct mdd_device *mdd, const char *name) { struct lprocfs_static_vars lvars; @@ -78,9 +75,7 @@ int mdd_procfs_init(struct mdd_device *mdd, const char *name) GOTO(out, rc); } - rc = lu_time_init(&mdd->mdd_stats, - mdd->mdd_proc_entry, - mdd_counter_names, ARRAY_SIZE(mdd_counter_names)); + rc = 0; EXIT; out: @@ -91,9 +86,6 @@ out: int mdd_procfs_fini(struct mdd_device *mdd) { - if (mdd->mdd_stats) - lu_time_fini(&mdd->mdd_stats); - if (mdd->mdd_proc_entry) { lprocfs_remove(&mdd->mdd_proc_entry); mdd->mdd_proc_entry = NULL; @@ -101,17 +93,6 @@ int mdd_procfs_fini(struct mdd_device *mdd) RETURN(0); } -void mdd_lprocfs_time_start(const struct lu_env *env) -{ - lu_lprocfs_time_start(env); -} - -void mdd_lprocfs_time_end(const struct lu_env *env, struct mdd_device *mdd, - int idx) -{ - lu_lprocfs_time_end(env, mdd->mdd_stats, idx); -} - static int lprocfs_wr_atime_diff(struct file *file, const char *buffer, unsigned long count, void *data) { @@ -122,7 +103,7 @@ static int lprocfs_wr_atime_diff(struct file *file, const char *buffer, if (count > (sizeof(kernbuf) - 1)) return -EINVAL; - if (cfs_copy_from_user(kernbuf, buffer, count)) + if (copy_from_user(kernbuf, buffer, count)) return -EFAULT; kernbuf[count] = '\0'; @@ -163,29 +144,29 @@ static int lprocfs_rd_changelog_mask(char *page, char **start, off_t off, } static int lprocfs_wr_changelog_mask(struct file *file, const char *buffer, - unsigned long count, void *data) + unsigned long count, void *data) { - struct mdd_device *mdd = data; - char *kernbuf; - int rc; - ENTRY; - - if (count >= CFS_PAGE_SIZE) - RETURN(-EINVAL); - OBD_ALLOC(kernbuf, CFS_PAGE_SIZE); - if (kernbuf == NULL) - RETURN(-ENOMEM); - if (cfs_copy_from_user(kernbuf, buffer, count)) - GOTO(out, rc = -EFAULT); - kernbuf[count] = 0; - - rc = cfs_str2mask(kernbuf, changelog_type2str, &mdd->mdd_cl.mc_mask, - CHANGELOG_MINMASK, CHANGELOG_ALLMASK); - if (rc == 0) - rc = count; + struct mdd_device *mdd = data; + char *kernbuf; + int rc; + ENTRY; + + if (count >= PAGE_CACHE_SIZE) + RETURN(-EINVAL); + OBD_ALLOC(kernbuf, PAGE_CACHE_SIZE); + if (kernbuf == NULL) + RETURN(-ENOMEM); + if (copy_from_user(kernbuf, buffer, count)) + GOTO(out, rc = -EFAULT); + kernbuf[count] = 0; + + rc = cfs_str2mask(kernbuf, changelog_type2str, &mdd->mdd_cl.mc_mask, + CHANGELOG_MINMASK, CHANGELOG_ALLMASK); + if (rc == 0) + rc = count; out: - OBD_FREE(kernbuf, CFS_PAGE_SIZE); - return rc; + OBD_FREE(kernbuf, PAGE_CACHE_SIZE); + return rc; } struct cucb_data { @@ -217,21 +198,30 @@ static int lprocfs_changelog_users_cb(const struct lu_env *env, static int lprocfs_rd_changelog_users(char *page, char **start, off_t off, int count, int *eof, void *data) { - struct mdd_device *mdd = data; - struct llog_ctxt *ctxt; - struct cucb_data cucb; - __u64 cur; + struct lu_env env; + struct mdd_device *mdd = data; + struct llog_ctxt *ctxt; + struct cucb_data cucb; + __u64 cur; + int rc; *eof = 1; - ctxt = llog_get_context(mdd2obd_dev(mdd),LLOG_CHANGELOG_USER_ORIG_CTXT); + ctxt = llog_get_context(mdd2obd_dev(mdd), + LLOG_CHANGELOG_USER_ORIG_CTXT); if (ctxt == NULL) return -ENXIO; LASSERT(ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT); - cfs_spin_lock(&mdd->mdd_cl.mc_lock); - cur = mdd->mdd_cl.mc_index; - cfs_spin_unlock(&mdd->mdd_cl.mc_lock); + rc = lu_env_init(&env, LCT_LOCAL); + if (rc) { + llog_ctxt_put(ctxt); + return rc; + } + + spin_lock(&mdd->mdd_cl.mc_lock); + cur = mdd->mdd_cl.mc_index; + spin_unlock(&mdd->mdd_cl.mc_lock); cucb.count = count; cucb.page = page; @@ -243,11 +233,12 @@ static int lprocfs_rd_changelog_users(char *page, char **start, off_t off, cucb.idx += snprintf(cucb.page + cucb.idx, cucb.count - cucb.idx, "%-5s %s\n", "ID", "index"); - llog_cat_process(NULL, ctxt->loc_handle, lprocfs_changelog_users_cb, + llog_cat_process(&env, ctxt->loc_handle, lprocfs_changelog_users_cb, &cucb, 0, 0); - llog_ctxt_put(ctxt); - return cucb.idx; + lu_env_fini(&env); + llog_ctxt_put(ctxt); + return cucb.idx; } static int lprocfs_rd_sync_perm(char *page, char **start, off_t off, @@ -281,26 +272,77 @@ static int lprocfs_rd_lfsck_speed_limit(char *page, char **start, off_t off, LASSERT(mdd != NULL); *eof = 1; - return snprintf(page, count, "%u\n", mdd->mdd_lfsck.ml_speed_limit); + + return lfsck_get_speed(mdd->mdd_bottom, page, count); } static int lprocfs_wr_lfsck_speed_limit(struct file *file, const char *buffer, unsigned long count, void *data) { struct mdd_device *mdd = data; - struct md_lfsck *lfsck; __u32 val; int rc; LASSERT(mdd != NULL); rc = lprocfs_write_helper(buffer, count, &val); - if (rc) + if (rc != 0) return rc; - lfsck = &mdd->mdd_lfsck; - if (val != lfsck->ml_speed_limit) - mdd_lfsck_set_speed(lfsck, val); - return count; + rc = lfsck_set_speed(mdd->mdd_bottom, val); + return rc != 0 ? rc : count; +} + +static int lprocfs_rd_lfsck_async_windows(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct mdd_device *mdd = data; + int rc; + + LASSERT(mdd != NULL); + *eof = 1; + + rc = lfsck_get_windows(mdd->mdd_bottom, page, count); + + return rc != 0 ? rc : count; +} + +static int lprocfs_wr_lfsck_async_windows(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct mdd_device *mdd = data; + __u32 val; + int rc; + + LASSERT(mdd != NULL); + rc = lprocfs_write_helper(buffer, count, &val); + if (rc == 0) + rc = lfsck_set_windows(mdd->mdd_bottom, val); + + return rc != 0 ? rc : count; +} + +static int lprocfs_rd_lfsck_namespace(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct mdd_device *mdd = data; + int rc; + + LASSERT(mdd != NULL); + *eof = 1; + + rc = lfsck_dump(mdd->mdd_bottom, page, count, LT_NAMESPACE); + return rc; +} + +static int lprocfs_rd_lfsck_layout(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct mdd_device *mdd = data; + + LASSERT(mdd != NULL); + *eof = 1; + + return lfsck_dump(mdd->mdd_bottom, page, count, LT_LAYOUT); } static struct lprocfs_vars lprocfs_mdd_obd_vars[] = { @@ -311,6 +353,10 @@ static struct lprocfs_vars lprocfs_mdd_obd_vars[] = { { "sync_permission", lprocfs_rd_sync_perm, lprocfs_wr_sync_perm, 0 }, { "lfsck_speed_limit", lprocfs_rd_lfsck_speed_limit, lprocfs_wr_lfsck_speed_limit, 0 }, + { "lfsck_async_windows", lprocfs_rd_lfsck_async_windows, + lprocfs_wr_lfsck_async_windows, 0 }, + { "lfsck_namespace", lprocfs_rd_lfsck_namespace, 0, 0 }, + { "lfsck_layout", lprocfs_rd_lfsck_layout, 0, 0 }, { 0 } };