Whamcloud - gitweb
- landing b_fid.
[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/obd_class.h>
25 #include <linux/lprocfs_status.h>
26
27 #ifndef LPROCFS
28 static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
29 static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
30 #else
31 /* Common STATUS namespace */
32 static int cobd_rd_target(char *page, char **start, off_t off, int count,
33                           int *eof, void *data)
34 {
35         struct obd_device *cobd = (struct obd_device *)data;
36         int    rc;
37
38         LASSERT(cobd != NULL);
39
40         if (!cobd->obd_set_up) {
41                 rc = snprintf(page, count, "not set up\n");
42         } else {
43                 struct obd_device *tgt =
44                         class_exp2obd(cobd->u.cobd.master_exp);
45                 LASSERT(tgt != NULL);
46                 rc = snprintf(page, count, "%s\n", tgt->obd_uuid.uuid);
47         }
48         return rc;
49 }
50
51 static int cobd_rd_cache(char *page, char **start, off_t off, int count,
52                          int *eof, void *data)
53 {
54         struct obd_device *cobd = (struct obd_device*)data;
55         int    rc;
56
57         LASSERT(cobd != NULL);
58
59         if (!cobd->obd_set_up) {
60                 rc = snprintf(page, count, "not set up\n");
61         } else {
62                 struct obd_device *cache =
63                         class_exp2obd(cobd->u.cobd.cache_exp);
64                 LASSERT(cache != NULL);
65                 rc = snprintf(page, count, "%s\n", cache->obd_uuid.uuid);
66         }
67         return rc;
68 }
69
70 static struct lprocfs_vars lprocfs_obd_vars[] = {
71         { "uuid",         lprocfs_rd_uuid,        0, 0 },
72         { "target_uuid",  cobd_rd_target,         0, 0 },
73         { "cache_uuid",   cobd_rd_cache,          0, 0 },
74         { 0 }
75 };
76
77 struct lprocfs_vars lprocfs_module_vars[] = {
78         { "num_refs",     lprocfs_rd_numrefs,     0, 0 },
79         { 0 }
80 };
81 #endif /* LPROCFS */
82
83 LPROCFS_INIT_VARS(cobd, lprocfs_module_vars, lprocfs_obd_vars)