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>
42 # define EXPORT_SYMTAB
44 #define DEBUG_SUBSYSTEM S_FLD
47 # include <libcfs/libcfs.h>
48 # include <linux/module.h>
49 #else /* __KERNEL__ */
50 # include <liblustre.h>
54 #include <obd_class.h>
55 #include <dt_object.h>
56 #include <md_object.h>
57 #include <obd_support.h>
58 #include <lustre_req_layout.h>
59 #include <lustre_fld.h>
60 #include "fld_internal.h"
64 fld_proc_read_targets(char *page, char **start, off_t off,
65 int count, int *eof, void *data)
67 struct lu_client_fld *fld = (struct lu_client_fld *)data;
68 struct lu_fld_target *target;
74 cfs_spin_lock(&fld->lcf_lock);
75 cfs_list_for_each_entry(target,
76 &fld->lcf_targets, ft_chain)
78 rc = snprintf(page, count, "%s\n",
79 fld_target_name(target));
86 cfs_spin_unlock(&fld->lcf_lock);
91 fld_proc_read_hash(char *page, char **start, off_t off,
92 int count, int *eof, void *data)
94 struct lu_client_fld *fld = (struct lu_client_fld *)data;
100 cfs_spin_lock(&fld->lcf_lock);
101 rc = snprintf(page, count, "%s\n",
102 fld->lcf_hash->fh_name);
103 cfs_spin_unlock(&fld->lcf_lock);
109 fld_proc_write_hash(struct file *file, const char *buffer,
110 unsigned long count, void *data)
112 struct lu_client_fld *fld = (struct lu_client_fld *)data;
113 struct lu_fld_hash *hash = NULL;
117 LASSERT(fld != NULL);
119 for (i = 0; fld_hash[i].fh_name != NULL; i++) {
120 if (count != strlen(fld_hash[i].fh_name))
123 if (!strncmp(fld_hash[i].fh_name, buffer, count)) {
130 cfs_spin_lock(&fld->lcf_lock);
131 fld->lcf_hash = hash;
132 cfs_spin_unlock(&fld->lcf_lock);
134 CDEBUG(D_INFO, "%s: Changed hash to \"%s\"\n",
135 fld->lcf_name, hash->fh_name);
142 fld_proc_write_cache_flush(struct file *file, const char *buffer,
143 unsigned long count, void *data)
145 struct lu_client_fld *fld = (struct lu_client_fld *)data;
148 LASSERT(fld != NULL);
150 fld_cache_flush(fld->lcf_cache);
152 CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name);
157 struct lprocfs_vars fld_server_proc_list[] = {
160 struct lprocfs_vars fld_client_proc_list[] = {
161 { "targets", fld_proc_read_targets, NULL, NULL },
162 { "hash", fld_proc_read_hash, fld_proc_write_hash, NULL },
163 { "cache_flush", NULL, fld_proc_write_cache_flush, NULL },