1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002, 2003 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_OST
24 #include <linux/obd_class.h>
25 #include <linux/lprocfs_status.h>
26 #include <linux/seq_file.h>
29 static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
30 static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
32 static struct lprocfs_vars lprocfs_obd_vars[] = {
33 { "uuid", lprocfs_rd_uuid, 0, 0 },
37 static struct lprocfs_vars lprocfs_module_vars[] = {
38 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
42 #define PRINTF_STIME(stime) (unsigned long)(stime)->st_num, \
43 lprocfs_stime_avg_ms(stime), lprocfs_stime_avg_us(stime)
45 static int ost_stimes_seq_show(struct seq_file *seq, void *v)
48 struct obd_device *dev = seq->private;
49 struct ost_obd *ost = &dev->u.ost;
51 do_gettimeofday(&now);
53 spin_lock(&ost->ost_lock);
55 seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
56 now.tv_sec, now.tv_usec);
58 seq_printf(seq, "\nread rpc service time: (rpcs, average ms)\n");
59 seq_printf(seq, "\tprep\t%lu\t%lu.%04lu\n",
60 PRINTF_STIME(&ost->ost_stimes[0]));
61 seq_printf(seq, "\tbulk\t%lu\t%lu.%04lu\n\n",
62 PRINTF_STIME(&ost->ost_stimes[1]));
63 seq_printf(seq, "\tcommit\t%lu\t%lu.%04lu\n\n",
64 PRINTF_STIME(&ost->ost_stimes[2]));
66 seq_printf(seq, "\nwrite rpc service time: (rpcs, average ms)\n");
67 seq_printf(seq, "\tprep\t%lu\t%lu.%04lu\n",
68 PRINTF_STIME(&ost->ost_stimes[3]));
69 seq_printf(seq, "\tbulk\t%lu\t%lu.%04lu\n\n",
70 PRINTF_STIME(&ost->ost_stimes[4]));
71 seq_printf(seq, "\tcommit\t%lu\t%lu.%04lu\n\n",
72 PRINTF_STIME(&ost->ost_stimes[5]));
74 spin_unlock(&ost->ost_lock);
79 static void *ost_stimes_seq_start(struct seq_file *p, loff_t *pos)
85 static void *ost_stimes_seq_next(struct seq_file *p, void *v, loff_t *pos)
90 static void ost_stimes_seq_stop(struct seq_file *p, void *v)
93 struct seq_operations ost_stimes_seq_sops = {
94 .start = ost_stimes_seq_start,
95 .stop = ost_stimes_seq_stop,
96 .next = ost_stimes_seq_next,
97 .show = ost_stimes_seq_show,
100 static int ost_stimes_seq_open(struct inode *inode, struct file *file)
102 struct proc_dir_entry *dp = PDE(inode);
103 struct seq_file *seq;
106 rc = seq_open(file, &ost_stimes_seq_sops);
109 seq = file->private_data;
110 seq->private = dp->data;
114 static ssize_t ost_stimes_seq_write(struct file *file, const char *buf,
115 size_t len, loff_t *off)
117 struct seq_file *seq = file->private_data;
118 struct obd_device *dev = seq->private;
119 struct ost_obd *ost = &dev->u.ost;
121 spin_lock(&ost->ost_lock);
122 memset(&ost->ost_stimes, 0, sizeof(ost->ost_stimes));
123 spin_unlock(&ost->ost_lock);
128 struct file_operations ost_stimes_fops = {
129 .owner = THIS_MODULE,
130 .open = ost_stimes_seq_open,
132 .write = ost_stimes_seq_write,
134 .release = seq_release,
138 LPROCFS_INIT_VARS(ost, lprocfs_module_vars, lprocfs_obd_vars)