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.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * lustre/fld/lproc_fld.c
36 * FLD (FIDs Location Database)
38 * Author: Yury Umanets <umka@clusterfs.com>
41 #define DEBUG_SUBSYSTEM S_FLD
44 # include <libcfs/libcfs.h>
45 # include <linux/module.h>
46 #else /* __KERNEL__ */
47 # include <liblustre.h>
51 #include <obd_class.h>
52 #include <dt_object.h>
53 #include <md_object.h>
54 #include <obd_support.h>
55 #include <lustre_req_layout.h>
56 #include <lustre_fld.h>
57 #include "fld_internal.h"
61 fld_proc_read_targets(char *page, char **start, off_t off,
62 int count, int *eof, void *data)
64 struct lu_client_fld *fld = (struct lu_client_fld *)data;
65 struct lu_fld_target *target;
71 cfs_spin_lock(&fld->lcf_lock);
72 cfs_list_for_each_entry(target,
73 &fld->lcf_targets, ft_chain)
75 rc = snprintf(page, count, "%s\n",
76 fld_target_name(target));
83 cfs_spin_unlock(&fld->lcf_lock);
88 fld_proc_read_hash(char *page, char **start, off_t off,
89 int count, int *eof, void *data)
91 struct lu_client_fld *fld = (struct lu_client_fld *)data;
97 cfs_spin_lock(&fld->lcf_lock);
98 rc = snprintf(page, count, "%s\n",
99 fld->lcf_hash->fh_name);
100 cfs_spin_unlock(&fld->lcf_lock);
106 fld_proc_write_hash(struct file *file, const char *buffer,
107 unsigned long count, void *data)
109 struct lu_client_fld *fld = (struct lu_client_fld *)data;
110 struct lu_fld_hash *hash = NULL;
114 LASSERT(fld != NULL);
116 for (i = 0; fld_hash[i].fh_name != NULL; i++) {
117 if (count != strlen(fld_hash[i].fh_name))
120 if (!strncmp(fld_hash[i].fh_name, buffer, count)) {
127 cfs_spin_lock(&fld->lcf_lock);
128 fld->lcf_hash = hash;
129 cfs_spin_unlock(&fld->lcf_lock);
131 CDEBUG(D_INFO, "%s: Changed hash to \"%s\"\n",
132 fld->lcf_name, hash->fh_name);
139 fld_proc_write_cache_flush(struct file *file, const char *buffer,
140 unsigned long count, void *data)
142 struct lu_client_fld *fld = (struct lu_client_fld *)data;
145 LASSERT(fld != NULL);
147 fld_cache_flush(fld->lcf_cache);
149 CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name);
154 struct lprocfs_vars fld_server_proc_list[] = {
157 struct lprocfs_vars fld_client_proc_list[] = {
158 { "targets", fld_proc_read_targets, NULL, NULL },
159 { "hash", fld_proc_read_hash, fld_proc_write_hash, NULL },
160 { "cache_flush", NULL, fld_proc_write_cache_flush, NULL },