-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011 Whamcloud, Inc.
- *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Author: Fan Yong <fanyong@clusterfs.com>
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
#define DEBUG_SUBSYSTEM S_MDS
#include <linux/version.h>
}
void mdt_rename_counter_tally(struct mdt_thread_info *info,
- struct mdt_device *mdt,
- struct obd_export *exp,
- struct mdt_object *src,
- struct mdt_object *tgt)
+ struct mdt_device *mdt,
+ struct ptlrpc_request *req,
+ struct mdt_object *src,
+ struct mdt_object *tgt)
{
struct md_attr *ma = &info->mti_attr;
struct rename_stats *rstats = &mdt->mdt_rename_stats;
rc = mo_attr_get(info->mti_env, mdt_object_child(src), ma);
if (rc) {
CERROR("%s: "DFID" attr_get, rc = %d\n",
- exp->exp_obd->obd_name, PFID(mdt_object_fid(src)), rc);
+ req->rq_export->exp_obd->obd_name,
+ PFID(mdt_object_fid(src)), rc);
return;
}
if (src == tgt) {
- mdt_counter_incr(exp, LPROC_MDT_SAMEDIR_RENAME);
+ mdt_counter_incr(req, LPROC_MDT_SAMEDIR_RENAME);
lprocfs_oh_tally_log2(&rstats->hist[RENAME_SAMEDIR_SIZE],
(unsigned int)ma->ma_attr.la_size);
return;
}
- mdt_counter_incr(exp, LPROC_MDT_CROSSDIR_RENAME);
+ mdt_counter_incr(req, LPROC_MDT_CROSSDIR_RENAME);
lprocfs_oh_tally_log2(&rstats->hist[RENAME_CROSSDIR_SRC_SIZE],
(unsigned int)ma->ma_attr.la_size);
rc = mo_attr_get(info->mti_env, mdt_object_child(tgt), ma);
if (rc) {
CERROR("%s: "DFID" attr_get, rc = %d\n",
- exp->exp_obd->obd_name, PFID(mdt_object_fid(tgt)), rc);
+ req->rq_export->exp_obd->obd_name,
+ PFID(mdt_object_fid(tgt)), rc);
return;
}
"clear", lprocfs_nid_stats_clear_read,
lprocfs_nid_stats_clear_write, obd, NULL);
rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST);
- if (rc == 0)
- mdt_stats_counter_init(obd->md_stats);
+ if (rc)
+ return rc;
+ mdt_stats_counter_init(obd->md_stats);
+
+ rc = lprocfs_job_stats_init(obd, LPROC_MDT_LAST,
+ mdt_stats_counter_init);
rc = lproc_mdt_attach_rename_seqstat(mdt);
if (rc)
struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
struct obd_device *obd = ld->ld_obd;
+ lprocfs_job_stats_fini(obd);
+
if (obd->obd_proc_exports_entry) {
lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
obd->obd_proc_exports_entry = NULL;
return count;
}
+#define BUFLEN (UUID_MAX + 4)
+
static int lprocfs_mdt_wr_evict_client(struct file *file, const char *buffer,
unsigned long count, void *data)
{
- char tmpbuf[sizeof(struct obd_uuid)];
+ char *kbuf;
+ char *tmpbuf;
- sscanf(buffer, "%40s", tmpbuf);
+ OBD_ALLOC(kbuf, BUFLEN);
+ if (kbuf == NULL)
+ return -ENOMEM;
+
+ /*
+ * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
+ * bytes into kbuf, to ensure that the string is NUL-terminated.
+ * UUID_MAX should include a trailing NUL already.
+ */
+ if (cfs_copy_from_user(kbuf, buffer,
+ min_t(unsigned long, BUFLEN - 1, count))) {
+ count = -EFAULT;
+ goto out;
+ }
+ tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
- if (strncmp(tmpbuf, "nid:", 4) != 0)
- return lprocfs_wr_evict_client(file, buffer, count, data);
+ if (strncmp(tmpbuf, "nid:", 4) != 0) {
+ count = lprocfs_wr_evict_client(file, buffer, count, data);
+ goto out;
+ }
CERROR("NOT implement evict client by nid %s\n", tmpbuf);
+out:
+ OBD_FREE(kbuf, BUFLEN);
return count;
}
+#undef BUFLEN
+
static int lprocfs_rd_sec_level(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
{
struct obd_device *obd = data;
struct obd_export *exp = NULL;
- struct obd_uuid uuid;
- char tmpbuf[sizeof(struct obd_uuid)];
+ struct obd_uuid *uuid;
+ char *kbuf;
+ char *tmpbuf;
+
+ OBD_ALLOC(kbuf, UUID_MAX);
+ if (kbuf == NULL)
+ return -ENOMEM;
- sscanf(buffer, "%40s", tmpbuf);
+ /*
+ * OBD_ALLOC() will zero kbuf, but we only copy UUID_MAX - 1
+ * bytes into kbuf, to ensure that the string is NUL-terminated.
+ * UUID_MAX should include a trailing NUL already.
+ */
+ if (cfs_copy_from_user(kbuf, buffer,
+ min_t(unsigned long, UUID_MAX - 1, count))) {
+ count = -EFAULT;
+ goto out;
+ }
+ tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, UUID_MAX - 1, count));
+
+ OBD_ALLOC(uuid, UUID_MAX);
+ if (uuid == NULL) {
+ count = -ENOMEM;
+ goto out;
+ }
- obd_str2uuid(&uuid, tmpbuf);
- exp = cfs_hash_lookup(obd->obd_uuid_hash, &uuid);
+ obd_str2uuid(uuid, tmpbuf);
+ exp = cfs_hash_lookup(obd->obd_uuid_hash, uuid);
if (exp == NULL) {
CERROR("%s: no export %s found\n",
- obd->obd_name, obd_uuid2str(&uuid));
+ obd->obd_name, obd_uuid2str(uuid));
} else {
mdt_hsm_copytool_send(exp);
class_export_put(exp);
}
+ OBD_FREE(uuid, UUID_MAX);
+out:
+ OBD_FREE(kbuf, UUID_MAX);
return count;
}
{ "instance", lprocfs_target_rd_instance, 0 },
{ "ir_factor", lprocfs_obd_rd_ir_factor,
lprocfs_obd_wr_ir_factor, 0 },
+ { "job_cleanup_interval", lprocfs_rd_job_interval,
+ lprocfs_wr_job_interval, 0 },
{ 0 }
};
lvars->obd_vars = lprocfs_mdt_obd_vars;
}
-void mdt_counter_incr(struct obd_export *exp, int opcode)
+void mdt_counter_incr(struct ptlrpc_request *req, int opcode)
{
- if (exp->exp_obd && exp->exp_obd->md_stats)
- lprocfs_counter_incr(exp->exp_obd->md_stats, opcode);
- if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)
- lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode);
-
+ struct obd_export *exp = req->rq_export;
+
+ if (exp->exp_obd && exp->exp_obd->md_stats)
+ lprocfs_counter_incr(exp->exp_obd->md_stats, opcode);
+ if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)
+ lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode);
+ if (exp->exp_obd && exp->exp_obd->u.obt.obt_jobstats.ojs_hash &&
+ (exp->exp_connect_flags & OBD_CONNECT_JOBSTATS))
+ lprocfs_job_stats_log(exp->exp_obd,
+ lustre_msg_get_jobid(req->rq_reqmsg),
+ opcode, 1);
}
void mdt_stats_counter_init(struct lprocfs_stats *stats)