1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #define DEBUG_SUBSYSTEM S_CLASS
24 #include <linux/version.h>
25 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
26 #include <asm/statfs.h>
28 #include <linux/obd.h>
29 #include <linux/obd_class.h>
30 #include <linux/lprocfs_status.h>
33 struct lprocfs_vars lprocfs_mds_obd_vars[] = { {0} };
34 struct lprocfs_vars lprocfs_mds_module_vars[] = { {0} };
35 struct lprocfs_vars lprocfs_mdt_obd_vars[] = { {0} };
36 struct lprocfs_vars lprocfs_mdt_module_vars[] = { {0} };
40 static int lprocfs_mds_rd_mntdev(char *page, char **start, off_t off, int count,
43 struct obd_device* obd = (struct obd_device *)data;
46 LASSERT(obd->u.mds.mds_vfsmnt->mnt_devname);
49 return snprintf(page, count, "%s\n",obd->u.mds.mds_vfsmnt->mnt_devname);
52 static int lprocfs_mds_rd_recovery_status(char *page, char **start, off_t off,
53 int count, int *eof, void *data)
55 struct obd_device *obd = data;
57 connected = obd->obd_connected_clients,
58 max_recoverable = obd->obd_max_recoverable_clients,
59 recoverable = obd->obd_recoverable_clients,
60 completed = max_recoverable - recoverable,
61 queue_len = obd->obd_requests_queued_for_recovery,
62 replayed = obd->obd_replayed_requests;
63 __u64 next_transno = obd->obd_next_recovery_transno;
68 n = snprintf(page, count, "status: ");
69 page += n; len += n; count -= n;
70 if (obd->obd_max_recoverable_clients == 0) {
71 n = snprintf(page, count, "INACTIVE\n");
75 if (obd->obd_recoverable_clients == 0) {
76 n = snprintf(page, count, "COMPLETE\n");
77 page += n; len += n; count -= n;
78 n = snprintf(page, count, "recovered_clients: %d\n",
80 page += n; len += n; count -= n;
81 n = snprintf(page, count, "last_transno: "LPD64"\n",
83 page += n; len += n; count -= n;
84 n = snprintf(page, count, "replayed_requests: %d\n", replayed);
88 /* sampled unlocked, but really... */
89 if (obd->obd_recovering == 0) {
90 n = snprintf(page, count, "ABORTED\n");
94 n = snprintf(page, count, "RECOVERING\n");
95 page += n; len += n; count -= n;
96 n = snprintf(page, count, "connected_clients: %d/%d\n",
97 connected, max_recoverable);
98 page += n; len += n; count -= n;
99 n = snprintf(page, count, "completed_clients: %d/%d\n",
100 completed, max_recoverable);
101 page += n; len += n; count -= n;
102 n = snprintf(page, count, "replayed_requests: %d/??\n", replayed);
103 page += n; len += n; count -= n;
104 n = snprintf(page, count, "queued_requests: %d\n", queue_len);
105 page += n; len += n; count -= n;
106 n = snprintf(page, count, "next_transno: "LPD64"\n", next_transno);
110 static int lprocfs_mds_wr_evict_client(struct file *file, const char *buffer,
111 unsigned long count, void *data)
113 struct obd_device *obd = data;
114 struct obd_export *doomed_exp = NULL;
115 struct obd_uuid doomed;
117 char tmpbuf[sizeof(doomed)];
119 sscanf(buffer, "%40s", tmpbuf);
120 obd_str2uuid(&doomed, tmpbuf);
122 spin_lock(&obd->obd_dev_lock);
123 list_for_each(p, &obd->obd_exports) {
124 doomed_exp = list_entry(p, struct obd_export, exp_obd_chain);
125 if (obd_uuid_equals(&doomed, &doomed_exp->exp_client_uuid)) {
126 class_export_get(doomed_exp);
131 spin_unlock(&obd->obd_dev_lock);
133 if (doomed_exp == NULL) {
134 CERROR("can't disconnect %s: no export found\n",
137 CERROR("evicting %s at adminstrative request\n",
139 ptlrpc_fail_export(doomed_exp);
140 class_export_put(doomed_exp);
145 struct lprocfs_vars lprocfs_mds_obd_vars[] = {
146 { "uuid", lprocfs_rd_uuid, 0, 0 },
147 { "blocksize", lprocfs_rd_blksize, 0, 0 },
148 { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
149 { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
150 { "fstype", lprocfs_rd_fstype, 0, 0 },
151 { "filestotal", lprocfs_rd_filestotal, 0, 0 },
152 { "filesfree", lprocfs_rd_filesfree, 0, 0 },
153 //{ "filegroups", lprocfs_rd_filegroups, 0, 0 },
154 { "mntdev", lprocfs_mds_rd_mntdev, 0, 0 },
155 { "recovery_status", lprocfs_mds_rd_recovery_status, 0, 0 },
156 { "evict_client", 0, lprocfs_mds_wr_evict_client, 0 },
160 struct lprocfs_vars lprocfs_mds_module_vars[] = {
161 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
165 struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
166 { "uuid", lprocfs_rd_uuid, 0, 0 },
170 struct lprocfs_vars lprocfs_mdt_module_vars[] = {
171 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
176 struct lprocfs_static_vars lprocfs_array_vars[] = { {lprocfs_mds_module_vars,
177 lprocfs_mds_obd_vars},
178 {lprocfs_mdt_module_vars,
179 lprocfs_mdt_obd_vars}};
181 LPROCFS_INIT_MULTI_VARS(lprocfs_array_vars,
182 (sizeof(lprocfs_array_vars) /
183 sizeof(struct lprocfs_static_vars)))