4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2012, Whamcloud, Inc.
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 #define BUFLEN (UUID_MAX + 4)
73 static int lprocfs_mds_wr_evict_client(struct file *file, const char *buffer,
74 unsigned long count, void *data)
76 struct ptlrpc_request_set *set;
77 struct obd_device *obd = data;
78 struct mds_obd *mds = &obd->u.mds;
83 OBD_ALLOC(kbuf, BUFLEN);
88 * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
89 * bytes into kbuf, to ensure that the string is NUL-terminated.
90 * UUID_MAX should include a trailing NUL already.
92 if (cfs_copy_from_user(kbuf, buffer,
93 min_t(unsigned long, BUFLEN - 1, count))) {
97 tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
99 if (strncmp(tmpbuf, "nid:", 4) != 0) {
100 count = lprocfs_wr_evict_client(file, buffer, count, data);
104 set = ptlrpc_prep_set();
110 if (obd->u.mds.mds_evict_ost_nids) {
111 rc = obd_set_info_async(NULL, mds->mds_lov_exp,
112 sizeof(KEY_EVICT_BY_NID),
113 KEY_EVICT_BY_NID, strlen(tmpbuf + 4) + 1,
116 CERROR("Failed to evict nid %s from OSTs: rc %d\n",
119 ptlrpc_check_set(NULL, set);
122 /* See the comments in function lprocfs_wr_evict_client()
123 * in ptlrpc/lproc_ptlrpc.c for details. - jay */
124 class_incref(obd, __FUNCTION__, cfs_current());
127 obd_export_evict_by_nid(obd, tmpbuf + 4);
130 rc = ptlrpc_set_wait(set);
132 CERROR("Failed to evict nid %s from OSTs: rc %d\n", tmpbuf + 4,
136 class_decref(obd, __FUNCTION__, cfs_current());
138 ptlrpc_set_destroy(set);
140 OBD_FREE(kbuf, BUFLEN);
146 static int lprocfs_wr_atime_diff(struct file *file, const char *buffer,
147 unsigned long count, void *data)
149 struct obd_device *obd = data;
150 struct mds_obd *mds = &obd->u.mds;
151 char kernbuf[20], *end;
152 unsigned long diff = 0;
154 if (count > (sizeof(kernbuf) - 1))
157 if (cfs_copy_from_user(kernbuf, buffer, count))
160 kernbuf[count] = '\0';
162 diff = simple_strtoul(kernbuf, &end, 0);
166 mds->mds_atime_diff = diff;
170 static int lprocfs_rd_atime_diff(char *page, char **start, off_t off,
171 int count, int *eof, void *data)
173 struct obd_device *obd = data;
174 struct mds_obd *mds = &obd->u.mds;
177 return snprintf(page, count, "%lu\n", mds->mds_atime_diff);
180 struct lprocfs_vars lprocfs_mds_obd_vars[] = {
181 { "uuid", lprocfs_rd_uuid, 0, 0 },
182 { "blocksize", lprocfs_rd_blksize, 0, 0 },
183 { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
184 { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
185 { "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
186 { "filestotal", lprocfs_rd_filestotal, 0, 0 },
187 { "filesfree", lprocfs_rd_filesfree, 0, 0 },
188 { "fstype", lprocfs_rd_fstype, 0, 0 },
189 { "mntdev", lprocfs_obd_rd_mntdev, 0, 0 },
190 { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
191 { "hash_stats", lprocfs_obd_rd_hash, 0, 0 },
192 { "evict_client", 0, lprocfs_mds_wr_evict_client, 0 },
193 { "evict_ost_nids", lprocfs_mds_rd_evictostnids,
194 lprocfs_mds_wr_evictostnids, 0 },
195 { "num_exports", lprocfs_rd_num_exports, 0, 0 },
196 { "atime_diff", lprocfs_rd_atime_diff, lprocfs_wr_atime_diff, 0 },
200 struct lprocfs_vars lprocfs_mds_module_vars[] = {
201 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
205 struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
206 { "uuid", lprocfs_rd_uuid, 0, 0 },
210 void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars)
212 lvars->module_vars = lprocfs_mds_module_vars;
213 lvars->obd_vars = lprocfs_mds_obd_vars;