staging: lustre: void function return statements are not generally useful.
[deliverable/linux.git] / drivers / staging / lustre / lustre / fld / lproc_fld.c
CommitLineData
d7e09d03
PT
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.sun.com/software/products/lustre/docs/GPLv2.pdf
19 *
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
22 * have any questions.
23 *
24 * GPL HEADER END
25 */
26/*
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
29 *
30 * Copyright (c) 2012, 2013, Intel Corporation.
31 */
32/*
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
35 *
36 * lustre/fld/lproc_fld.c
37 *
38 * FLD (FIDs Location Database)
39 *
40 * Author: Yury Umanets <umka@clusterfs.com>
41 * Di Wang <di.wang@whamcloud.com>
42 */
43
44#define DEBUG_SUBSYSTEM S_FLD
45
9fdaf8c0 46#include "../../include/linux/libcfs/libcfs.h"
0e9ad0ef 47#include <linux/module.h>
d7e09d03 48
0e9ad0ef
GKH
49#include "../include/obd.h"
50#include "../include/obd_class.h"
51#include "../include/dt_object.h"
0e9ad0ef
GKH
52#include "../include/obd_support.h"
53#include "../include/lustre_req_layout.h"
54#include "../include/lustre_fld.h"
55#include "../include/lustre_fid.h"
d7e09d03
PT
56#include "fld_internal.h"
57
d7e09d03 58static int
73bb1da6 59fld_proc_targets_seq_show(struct seq_file *m, void *unused)
d7e09d03 60{
73bb1da6 61 struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
d7e09d03 62 struct lu_fld_target *target;
d7e09d03
PT
63
64 LASSERT(fld != NULL);
65
66 spin_lock(&fld->lcf_lock);
67 list_for_each_entry(target,
68 &fld->lcf_targets, ft_chain)
73bb1da6 69 seq_printf(m, "%s\n", fld_target_name(target));
d7e09d03 70 spin_unlock(&fld->lcf_lock);
73bb1da6 71
0a3bdb00 72 return 0;
d7e09d03
PT
73}
74
75static int
73bb1da6 76fld_proc_hash_seq_show(struct seq_file *m, void *unused)
d7e09d03 77{
73bb1da6 78 struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
d7e09d03
PT
79
80 LASSERT(fld != NULL);
81
82 spin_lock(&fld->lcf_lock);
73bb1da6 83 seq_printf(m, "%s\n", fld->lcf_hash->fh_name);
d7e09d03
PT
84 spin_unlock(&fld->lcf_lock);
85
0a3bdb00 86 return 0;
d7e09d03
PT
87}
88
73bb1da6 89static ssize_t
e84962e3
TL
90fld_proc_hash_seq_write(struct file *file,
91 const char __user *buffer,
92 size_t count, loff_t *off)
d7e09d03 93{
48f46e74 94 struct lu_client_fld *fld;
d7e09d03 95 struct lu_fld_hash *hash = NULL;
41dff7ac 96 char fh_name[8];
d7e09d03 97 int i;
d7e09d03 98
41dff7ac 99 if (count > sizeof(fh_name))
e84962e3
TL
100 return -ENAMETOOLONG;
101
41dff7ac 102 if (copy_from_user(fh_name, buffer, count) != 0)
e84962e3
TL
103 return -EFAULT;
104
48f46e74 105 fld = ((struct seq_file *)file->private_data)->private;
d7e09d03
PT
106 LASSERT(fld != NULL);
107
108 for (i = 0; fld_hash[i].fh_name != NULL; i++) {
109 if (count != strlen(fld_hash[i].fh_name))
110 continue;
111
41dff7ac 112 if (!strncmp(fld_hash[i].fh_name, fh_name, count)) {
d7e09d03
PT
113 hash = &fld_hash[i];
114 break;
115 }
116 }
117
118 if (hash != NULL) {
119 spin_lock(&fld->lcf_lock);
120 fld->lcf_hash = hash;
121 spin_unlock(&fld->lcf_lock);
122
123 CDEBUG(D_INFO, "%s: Changed hash to \"%s\"\n",
124 fld->lcf_name, hash->fh_name);
125 }
126
0a3bdb00 127 return count;
d7e09d03
PT
128}
129
73bb1da6
PT
130static ssize_t
131fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
132 size_t count, loff_t *pos)
d7e09d03 133{
73bb1da6 134 struct lu_client_fld *fld = file->private_data;
d7e09d03
PT
135
136 LASSERT(fld != NULL);
137
138 fld_cache_flush(fld->lcf_cache);
139
140 CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name);
141
0a3bdb00 142 return count;
d7e09d03
PT
143}
144
73bb1da6
PT
145static int fld_proc_cache_flush_open(struct inode *inode, struct file *file)
146{
147 file->private_data = PDE_DATA(inode);
148 return 0;
149}
150
151static int fld_proc_cache_flush_release(struct inode *inode, struct file *file)
152{
153 file->private_data = NULL;
154 return 0;
155}
156
02a7b843 157static struct file_operations fld_proc_cache_flush_fops = {
73bb1da6
PT
158 .owner = THIS_MODULE,
159 .open = fld_proc_cache_flush_open,
160 .write = fld_proc_cache_flush_write,
161 .release = fld_proc_cache_flush_release,
162};
163
73bb1da6
PT
164LPROC_SEQ_FOPS_RO(fld_proc_targets);
165LPROC_SEQ_FOPS(fld_proc_hash);
166
d7e09d03 167struct lprocfs_vars fld_client_proc_list[] = {
73bb1da6
PT
168 { "targets", &fld_proc_targets_fops },
169 { "hash", &fld_proc_hash_fops },
170 { "cache_flush", &fld_proc_cache_flush_fops },
d7e09d03 171 { NULL }};
This page took 0.234059 seconds and 5 git commands to generate.