staging/lustre: Replace sun.com GPLv2 URL with gnu.org one.
[deliverable/linux.git] / drivers / staging / lustre / lustre / fld / lproc_fld.c
... / ...
CommitLineData
1/*
2 * GPL HEADER START
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
19 *
20 * GPL HEADER END
21 */
22/*
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright (c) 2012, 2015, Intel Corporation.
27 */
28/*
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
31 *
32 * lustre/fld/lproc_fld.c
33 *
34 * FLD (FIDs Location Database)
35 *
36 * Author: Yury Umanets <umka@clusterfs.com>
37 * Di Wang <di.wang@whamcloud.com>
38 */
39
40#define DEBUG_SUBSYSTEM S_FLD
41
42#include "../../include/linux/libcfs/libcfs.h"
43#include <linux/module.h>
44
45#include "../include/obd.h"
46#include "../include/obd_class.h"
47#include "../include/obd_support.h"
48#include "../include/lustre_req_layout.h"
49#include "../include/lustre_fld.h"
50#include "../include/lustre_fid.h"
51#include "fld_internal.h"
52
53static int
54fld_debugfs_targets_seq_show(struct seq_file *m, void *unused)
55{
56 struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
57 struct lu_fld_target *target;
58
59 spin_lock(&fld->lcf_lock);
60 list_for_each_entry(target, &fld->lcf_targets, ft_chain)
61 seq_printf(m, "%s\n", fld_target_name(target));
62 spin_unlock(&fld->lcf_lock);
63
64 return 0;
65}
66
67static int
68fld_debugfs_hash_seq_show(struct seq_file *m, void *unused)
69{
70 struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
71
72 spin_lock(&fld->lcf_lock);
73 seq_printf(m, "%s\n", fld->lcf_hash->fh_name);
74 spin_unlock(&fld->lcf_lock);
75
76 return 0;
77}
78
79static ssize_t
80fld_debugfs_hash_seq_write(struct file *file,
81 const char __user *buffer,
82 size_t count, loff_t *off)
83{
84 struct lu_client_fld *fld;
85 struct lu_fld_hash *hash = NULL;
86 char fh_name[8];
87 int i;
88
89 if (count > sizeof(fh_name))
90 return -ENAMETOOLONG;
91
92 if (copy_from_user(fh_name, buffer, count) != 0)
93 return -EFAULT;
94
95 fld = ((struct seq_file *)file->private_data)->private;
96
97 for (i = 0; fld_hash[i].fh_name; i++) {
98 if (count != strlen(fld_hash[i].fh_name))
99 continue;
100
101 if (!strncmp(fld_hash[i].fh_name, fh_name, count)) {
102 hash = &fld_hash[i];
103 break;
104 }
105 }
106
107 if (hash) {
108 spin_lock(&fld->lcf_lock);
109 fld->lcf_hash = hash;
110 spin_unlock(&fld->lcf_lock);
111
112 CDEBUG(D_INFO, "%s: Changed hash to \"%s\"\n",
113 fld->lcf_name, hash->fh_name);
114 }
115
116 return count;
117}
118
119static ssize_t
120fld_debugfs_cache_flush_write(struct file *file, const char __user *buffer,
121 size_t count, loff_t *pos)
122{
123 struct lu_client_fld *fld = file->private_data;
124
125 fld_cache_flush(fld->lcf_cache);
126
127 CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name);
128
129 return count;
130}
131
132static int
133fld_debugfs_cache_flush_release(struct inode *inode, struct file *file)
134{
135 file->private_data = NULL;
136 return 0;
137}
138
139static struct file_operations fld_debugfs_cache_flush_fops = {
140 .owner = THIS_MODULE,
141 .open = simple_open,
142 .write = fld_debugfs_cache_flush_write,
143 .release = fld_debugfs_cache_flush_release,
144};
145
146LPROC_SEQ_FOPS_RO(fld_debugfs_targets);
147LPROC_SEQ_FOPS(fld_debugfs_hash);
148
149struct lprocfs_vars fld_client_debugfs_list[] = {
150 { "targets", &fld_debugfs_targets_fops },
151 { "hash", &fld_debugfs_hash_fops },
152 { "cache_flush", &fld_debugfs_cache_flush_fops },
153 { NULL }
154};
This page took 0.024116 seconds and 5 git commands to generate.