1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 #define DEBUG_SUBSYSTEM S_CLASS
38 #include <linux/version.h>
39 #include <asm/statfs.h>
41 #include <obd_class.h>
42 #include <lprocfs_status.h>
43 #include "mds_internal.h"
46 static int lprocfs_mds_rd_evictostnids(char *page, char **start, off_t off,
47 int count, int *eof, void *data)
49 struct obd_device* obd = (struct obd_device *)data;
53 return snprintf(page, count, "%d\n", obd->u.mds.mds_evict_ost_nids);
56 static int lprocfs_mds_wr_evictostnids(struct file *file, const char *buffer,
57 unsigned long count, void *data)
59 struct obd_device *obd = data;
62 rc = lprocfs_write_helper(buffer, count, &val);
66 obd->u.mds.mds_evict_ost_nids = !!val;
71 static int lprocfs_mds_wr_evict_client(struct file *file, const char *buffer,
72 unsigned long count, void *data)
74 struct obd_device *obd = data;
75 struct mds_obd *mds = &obd->u.mds;
76 char tmpbuf[sizeof(struct obd_uuid)];
77 struct ptlrpc_request_set *set;
80 sscanf(buffer, "%40s", tmpbuf);
82 if (strncmp(tmpbuf, "nid:", 4) != 0)
83 return lprocfs_wr_evict_client(file, buffer, count, data);
85 set = ptlrpc_prep_set();
89 if (obd->u.mds.mds_evict_ost_nids) {
90 rc = obd_set_info_async(mds->mds_lov_exp,
91 sizeof(KEY_EVICT_BY_NID),
92 KEY_EVICT_BY_NID, strlen(tmpbuf + 4) + 1,
95 CERROR("Failed to evict nid %s from OSTs: rc %d\n",
98 ptlrpc_check_set(NULL, set);
101 /* See the comments in function lprocfs_wr_evict_client()
102 * in ptlrpc/lproc_ptlrpc.c for details. - jay */
103 class_incref(obd, __FUNCTION__, cfs_current());
106 obd_export_evict_by_nid(obd, tmpbuf+4);
109 rc = ptlrpc_set_wait(set);
111 CERROR("Failed to evict nid %s from OSTs: rc %d\n", tmpbuf + 4,
115 class_decref(obd, __FUNCTION__, cfs_current());
117 ptlrpc_set_destroy(set);
121 static int lprocfs_wr_atime_diff(struct file *file, const char *buffer,
122 unsigned long count, void *data)
124 struct obd_device *obd = data;
125 struct mds_obd *mds = &obd->u.mds;
126 char kernbuf[20], *end;
127 unsigned long diff = 0;
129 if (count > (sizeof(kernbuf) - 1))
132 if (cfs_copy_from_user(kernbuf, buffer, count))
135 kernbuf[count] = '\0';
137 diff = simple_strtoul(kernbuf, &end, 0);
141 mds->mds_atime_diff = diff;
145 static int lprocfs_rd_atime_diff(char *page, char **start, off_t off,
146 int count, int *eof, void *data)
148 struct obd_device *obd = data;
149 struct mds_obd *mds = &obd->u.mds;
152 return snprintf(page, count, "%lu\n", mds->mds_atime_diff);
155 struct lprocfs_vars lprocfs_mds_obd_vars[] = {
156 { "uuid", lprocfs_rd_uuid, 0, 0 },
157 { "blocksize", lprocfs_rd_blksize, 0, 0 },
158 { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
159 { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
160 { "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
161 { "filestotal", lprocfs_rd_filestotal, 0, 0 },
162 { "filesfree", lprocfs_rd_filesfree, 0, 0 },
163 { "fstype", lprocfs_rd_fstype, 0, 0 },
164 { "mntdev", lprocfs_obd_rd_mntdev, 0, 0 },
165 { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
166 { "hash_stats", lprocfs_obd_rd_hash, 0, 0 },
167 { "evict_client", 0, lprocfs_mds_wr_evict_client, 0 },
168 { "evict_ost_nids", lprocfs_mds_rd_evictostnids,
169 lprocfs_mds_wr_evictostnids, 0 },
170 { "num_exports", lprocfs_rd_num_exports, 0, 0 },
171 { "atime_diff", lprocfs_rd_atime_diff, lprocfs_wr_atime_diff, 0 },
175 struct lprocfs_vars lprocfs_mds_module_vars[] = {
176 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
180 struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
181 { "uuid", lprocfs_rd_uuid, 0, 0 },
185 void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars)
187 lvars->module_vars = lprocfs_mds_module_vars;
188 lvars->obd_vars = lprocfs_mds_obd_vars;