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 2008 Sun Microsystems, Inc. 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 <linux/vfs.h>
40 #include <obd_class.h>
41 #include <lprocfs_status.h>
42 #include <lustre_log.h>
46 static int mdc_rd_max_rpcs_in_flight(char *page, char **start, off_t off,
47 int count, int *eof, void *data)
49 struct obd_device *dev = data;
50 struct client_obd *cli = &dev->u.cli;
53 client_obd_list_lock(&cli->cl_loi_list_lock);
54 rc = snprintf(page, count, "%u\n", cli->cl_max_rpcs_in_flight);
55 client_obd_list_unlock(&cli->cl_loi_list_lock);
59 static int mdc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
60 unsigned long count, void *data)
62 struct obd_device *dev = data;
63 struct client_obd *cli = &dev->u.cli;
66 rc = lprocfs_write_helper(buffer, count, &val);
70 if (val < 1 || val > MDC_MAX_RIF_MAX)
73 client_obd_list_lock(&cli->cl_loi_list_lock);
74 cli->cl_max_rpcs_in_flight = val;
75 client_obd_list_unlock(&cli->cl_loi_list_lock);
80 static int mdc_changelog_seq_release(struct inode *inode, struct file *file)
82 struct seq_file *seq = file->private_data;
83 struct changelog_seq_iter *csi = seq->private;
85 if (csi && csi->csi_llh)
86 llog_cat_put(csi->csi_llh);
87 if (csi && csi->csi_ctxt)
88 llog_ctxt_put(csi->csi_ctxt);
90 return (changelog_seq_release(inode, file));
93 static int mdc_changelog_seq_open(struct inode *inode, struct file *file)
95 struct changelog_seq_iter *csi;
99 rc = changelog_seq_open(inode, file, &csi);
103 /* Set up the remote catalog handle */
104 /* Note the proc file is set up with obd in data, not mdc_device */
105 csi->csi_ctxt = llog_get_context((struct obd_device *)csi->csi_dev,
106 LLOG_CHANGELOG_REPL_CTXT);
107 if (csi->csi_ctxt == NULL)
108 GOTO(out, rc = -ENOENT);
109 rc = llog_create(csi->csi_ctxt, &csi->csi_llh, NULL, CHANGELOG_CATALOG);
111 CERROR("llog_create() failed %d\n", rc);
114 rc = llog_init_handle(csi->csi_llh, LLOG_F_IS_CAT, NULL);
116 CERROR("llog_init_handle failed %d\n", rc);
122 mdc_changelog_seq_release(inode, file);
126 static struct file_operations mdc_changelog_fops = {
127 .owner = THIS_MODULE,
128 .open = mdc_changelog_seq_open,
130 .llseek = changelog_seq_lseek,
131 .release = mdc_changelog_seq_release,
135 static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
136 { "uuid", lprocfs_rd_uuid, 0, 0 },
137 { "ping", 0, lprocfs_wr_ping, 0, 0, 0222 },
138 { "connect_flags", lprocfs_rd_connect_flags, 0, 0 },
139 { "blocksize", lprocfs_rd_blksize, 0, 0 },
140 { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
141 { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
142 { "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
143 { "filestotal", lprocfs_rd_filestotal, 0, 0 },
144 { "filesfree", lprocfs_rd_filesfree, 0, 0 },
145 /*{ "filegroups", lprocfs_rd_filegroups, 0, 0 },*/
146 { "mds_server_uuid", lprocfs_rd_server_uuid, 0, 0 },
147 { "mds_conn_uuid", lprocfs_rd_conn_uuid, 0, 0 },
148 { "max_rpcs_in_flight", mdc_rd_max_rpcs_in_flight,
149 mdc_wr_max_rpcs_in_flight, 0 },
150 { "timeouts", lprocfs_rd_timeouts, 0, 0 },
151 { "import", lprocfs_rd_import, 0, 0 },
152 { "state", lprocfs_rd_state, 0, 0 },
153 { "changelog", 0, 0, 0, &mdc_changelog_fops, 0400 },
157 static struct lprocfs_vars lprocfs_mdc_module_vars[] = {
158 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
162 void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
164 lvars->module_vars = lprocfs_mdc_module_vars;
165 lvars->obd_vars = lprocfs_mdc_obd_vars;