4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2012, 2013, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/fld/lproc_fld.c
38 * FLD (FIDs Location Database)
40 * Author: Yury Umanets <umka@clusterfs.com>
41 * Di Wang <di.wang@whamcloud.com>
44 #define DEBUG_SUBSYSTEM S_FLD
46 #include "../../include/linux/libcfs/libcfs.h"
47 #include <linux/module.h>
49 #include "../include/obd.h"
50 #include "../include/obd_class.h"
51 #include "../include/dt_object.h"
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"
56 #include "fld_internal.h"
59 fld_proc_targets_seq_show(struct seq_file *m, void *unused)
61 struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
62 struct lu_fld_target *target;
66 spin_lock(&fld->lcf_lock);
67 list_for_each_entry(target,
68 &fld->lcf_targets, ft_chain)
69 seq_printf(m, "%s\n", fld_target_name(target));
70 spin_unlock(&fld->lcf_lock);
76 fld_proc_hash_seq_show(struct seq_file *m, void *unused)
78 struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
82 spin_lock(&fld->lcf_lock);
83 seq_printf(m, "%s\n", fld->lcf_hash->fh_name);
84 spin_unlock(&fld->lcf_lock);
90 fld_proc_hash_seq_write(struct file *file,
91 const char __user *buffer,
92 size_t count, loff_t *off)
94 struct lu_client_fld *fld;
95 struct lu_fld_hash *hash = NULL;
99 if (count > sizeof(fh_name))
100 return -ENAMETOOLONG;
102 if (copy_from_user(fh_name, buffer, count) != 0)
105 fld = ((struct seq_file *)file->private_data)->private;
106 LASSERT(fld != NULL);
108 for (i = 0; fld_hash[i].fh_name != NULL; i++) {
109 if (count != strlen(fld_hash[i].fh_name))
112 if (!strncmp(fld_hash[i].fh_name, fh_name, count)) {
119 spin_lock(&fld->lcf_lock);
120 fld->lcf_hash = hash;
121 spin_unlock(&fld->lcf_lock);
123 CDEBUG(D_INFO, "%s: Changed hash to \"%s\"\n",
124 fld->lcf_name, hash->fh_name);
131 fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
132 size_t count, loff_t *pos)
134 struct lu_client_fld *fld = file->private_data;
136 LASSERT(fld != NULL);
138 fld_cache_flush(fld->lcf_cache);
140 CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name);
145 static int fld_proc_cache_flush_open(struct inode *inode, struct file *file)
147 file->private_data = PDE_DATA(inode);
151 static int fld_proc_cache_flush_release(struct inode *inode, struct file *file)
153 file->private_data = NULL;
157 static struct file_operations fld_proc_cache_flush_fops = {
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,
164 LPROC_SEQ_FOPS_RO(fld_proc_targets);
165 LPROC_SEQ_FOPS(fld_proc_hash);
167 struct lprocfs_vars fld_client_proc_list[] = {
168 { "targets", &fld_proc_targets_fops },
169 { "hash", &fld_proc_hash_fops },
170 { "cache_flush", &fld_proc_cache_flush_fops },