Whamcloud - gitweb
land 0.5.20.3 b_devel onto HEAD (b_devel will remain)
[fs/lustre-release.git] / lustre / cobd / lproc_cache.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
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.
11  *
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.
16  *
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.
20  *
21  */
22 #define DEBUG_SUBSYSTEM S_CLASS
23
24 #include <linux/lustre_lite.h>
25 #include <linux/lprocfs_status.h>
26
27 #ifndef LPROCFS
28 struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
29 struct lprocfs_vars lprocfs_module_vars[] = { {0} };
30 #else
31 /* Common STATUS namespace */
32 static int rd_target(char *page, char **start, off_t off, int count,
33                      int *eof, void *data)
34 {
35         struct obd_device    *dev = (struct obd_device*)data;
36         struct lustre_handle *conn;
37         struct obd_export    *exp;
38         int    rc;
39
40         LASSERT(dev != NULL);
41         conn = &dev->u.cobd.cobd_target;
42
43         if ((dev->obd_flags & OBD_SET_UP) == 0)
44                 rc = snprintf (page, count, "not set up\n");
45         else {
46                 exp = class_conn2export (conn);
47                 LASSERT(exp != NULL);
48                 rc = snprintf(page, count, "%s\n", 
49                               exp->exp_obd->obd_uuid.uuid);
50         }
51         return (rc);
52 }
53
54 static int rd_cache(char *page, char **start, off_t off, int count,
55                     int *eof, void *data)
56 {
57         struct obd_device    *dev = (struct obd_device*)data;
58         struct lustre_handle *conn;
59         struct obd_export    *exp;
60         int    rc;
61
62         LASSERT(dev != NULL);
63         conn = &dev->u.cobd.cobd_cache;
64
65         if ((dev->obd_flags & OBD_SET_UP) == 0)
66                 rc = snprintf (page, count, "not set up\n");
67         else {
68                 exp = class_conn2export (conn);
69                 LASSERT (exp != NULL);
70                 rc = snprintf(page, count, "%s\n", 
71                               exp->exp_obd->obd_uuid.uuid);
72         }
73         return (rc);
74 }
75
76 struct lprocfs_vars lprocfs_obd_vars[] = {
77         { "uuid",        lprocfs_rd_uuid,    0, 0 },
78         { "target_uuid", rd_target,          0, 0 },
79         { "cache_uuid",  rd_cache,           0, 0 },
80         { 0 }
81 };
82
83 struct lprocfs_vars lprocfs_module_vars[] = {
84         { "num_refs",    lprocfs_rd_numrefs, 0, 0 },
85         { 0 }
86 };
87 #endif /* LPROCFS */
88
89 LPROCFS_INIT_VARS(lprocfs_module_vars, lprocfs_obd_vars)