-/* -*- 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.
* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include "mds_internal.h"
#ifdef LPROCFS
-static int lprocfs_mds_rd_mntdev(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct obd_device* obd = (struct obd_device *)data;
-
- LASSERT(obd != NULL);
- LASSERT(obd->u.mds.mds_vfsmnt->mnt_devname);
- *eof = 1;
-
- return snprintf(page, count, "%s\n",obd->u.mds.mds_vfsmnt->mnt_devname);
-}
-
static int lprocfs_mds_rd_evictostnids(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
return count;
}
+#define BUFLEN (UUID_MAX + 4)
+
static int lprocfs_mds_wr_evict_client(struct file *file, const char *buffer,
unsigned long count, void *data)
{
- struct obd_device *obd = data;
- struct mds_obd *mds = &obd->u.mds;
- char tmpbuf[sizeof(struct obd_uuid)];
struct ptlrpc_request_set *set;
- int rc;
+ struct obd_device *obd = data;
+ struct mds_obd *mds = &obd->u.mds;
+ char *kbuf;
+ char *tmpbuf;
+ int rc;
+
+ OBD_ALLOC(kbuf, BUFLEN);
+ if (kbuf == NULL)
+ return -ENOMEM;
- sscanf(buffer, "%40s", tmpbuf);
+ /*
+ * 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;
+ }
set = ptlrpc_prep_set();
- if (!set)
- return -ENOMEM;
+ if (set == NULL) {
+ count = -ENOMEM;
+ goto out;
+ }
if (obd->u.mds.mds_evict_ost_nids) {
- rc = obd_set_info_async(mds->mds_lov_exp,
+ rc = obd_set_info_async(NULL, mds->mds_lov_exp,
sizeof(KEY_EVICT_BY_NID),
KEY_EVICT_BY_NID, strlen(tmpbuf + 4) + 1,
tmpbuf + 4, set);
class_incref(obd, __FUNCTION__, cfs_current());
LPROCFS_EXIT();
- obd_export_evict_by_nid(obd, tmpbuf+4);
+ obd_export_evict_by_nid(obd, tmpbuf + 4);
rc = ptlrpc_set_wait(set);
class_decref(obd, __FUNCTION__, cfs_current());
ptlrpc_set_destroy(set);
+out:
+ OBD_FREE(kbuf, BUFLEN);
return count;
}
+#undef BUFLEN
+
static int lprocfs_wr_atime_diff(struct file *file, const char *buffer,
unsigned long count, void *data)
{
{ "filestotal", lprocfs_rd_filestotal, 0, 0 },
{ "filesfree", lprocfs_rd_filesfree, 0, 0 },
{ "fstype", lprocfs_rd_fstype, 0, 0 },
- { "mntdev", lprocfs_mds_rd_mntdev, 0, 0 },
+ { "mntdev", lprocfs_obd_rd_mntdev, 0, 0 },
{ "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
{ "hash_stats", lprocfs_obd_rd_hash, 0, 0 },
{ "evict_client", 0, lprocfs_mds_wr_evict_client, 0 },
{ 0 }
};
-struct lprocfs_vars lprocfs_mdt_module_vars[] = {
- { "num_refs", lprocfs_rd_numrefs, 0, 0 },
- { 0 }
-};
-
-void mds_counter_incr(struct obd_export *exp, int opcode)
-{
- if (exp->exp_obd && exp->exp_obd->obd_stats)
- lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode);
- if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)
- lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode);
-
-}
-
-void mds_stats_counter_init(struct lprocfs_stats *stats)
-{
- lprocfs_counter_init(stats, LPROC_MDS_OPEN, 0, "open", "reqs");
- lprocfs_counter_init(stats, LPROC_MDS_CLOSE, 0, "close", "reqs");
- lprocfs_counter_init(stats, LPROC_MDS_MKNOD, 0, "mknod", "reqs");
- lprocfs_counter_init(stats, LPROC_MDS_LINK, 0, "link", "reqs");
- lprocfs_counter_init(stats, LPROC_MDS_UNLINK, 0, "unlink", "reqs");
- lprocfs_counter_init(stats, LPROC_MDS_MKDIR, 0, "mkdir", "reqs");
- lprocfs_counter_init(stats, LPROC_MDS_RMDIR, 0, "rmdir", "reqs");
- lprocfs_counter_init(stats, LPROC_MDS_RENAME, 0, "rename", "reqs");
- lprocfs_counter_init(stats, LPROC_MDS_GETXATTR, 0, "getxattr", "reqs");
- lprocfs_counter_init(stats, LPROC_MDS_SETXATTR, 0, "setxattr", "reqs");
-}
-
void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars)
{
lvars->module_vars = lprocfs_mds_module_vars;
lvars->obd_vars = lprocfs_mds_obd_vars;
}
-void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars)
-{
- lvars->module_vars = lprocfs_mdt_module_vars;
- lvars->obd_vars = lprocfs_mdt_obd_vars;
-}
#endif