1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
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>
44 # define EXPORT_SYMTAB
46 #define DEBUG_SUBSYSTEM S_FLD
49 # include <libcfs/libcfs.h>
50 # include <linux/module.h>
51 #else /* __KERNEL__ */
52 # include <liblustre.h>
56 #include <obd_class.h>
57 #include <dt_object.h>
58 #include <md_object.h>
59 #include <obd_support.h>
60 #include <lustre_req_layout.h>
61 #include <lustre_fld.h>
62 #include "fld_internal.h"
66 fld_proc_read_targets(char *page, char **start, off_t off,
67 int count, int *eof, void *data)
69 struct lu_client_fld *fld = (struct lu_client_fld *)data;
70 struct lu_fld_target *target;
76 cfs_spin_lock(&fld->lcf_lock);
77 cfs_list_for_each_entry(target,
78 &fld->lcf_targets, ft_chain)
80 rc = snprintf(page, count, "%s\n",
81 fld_target_name(target));
88 cfs_spin_unlock(&fld->lcf_lock);
93 fld_proc_read_hash(char *page, char **start, off_t off,
94 int count, int *eof, void *data)
96 struct lu_client_fld *fld = (struct lu_client_fld *)data;
100 LASSERT(fld != NULL);
102 cfs_spin_lock(&fld->lcf_lock);
103 rc = snprintf(page, count, "%s\n",
104 fld->lcf_hash->fh_name);
105 cfs_spin_unlock(&fld->lcf_lock);
111 fld_proc_write_hash(struct file *file, const char *buffer,
112 unsigned long count, void *data)
114 struct lu_client_fld *fld = (struct lu_client_fld *)data;
115 struct lu_fld_hash *hash = NULL;
119 LASSERT(fld != NULL);
121 for (i = 0; fld_hash[i].fh_name != NULL; i++) {
122 if (count != strlen(fld_hash[i].fh_name))
125 if (!strncmp(fld_hash[i].fh_name, buffer, count)) {
132 cfs_spin_lock(&fld->lcf_lock);
133 fld->lcf_hash = hash;
134 cfs_spin_unlock(&fld->lcf_lock);
136 CDEBUG(D_INFO, "%s: Changed hash to \"%s\"\n",
137 fld->lcf_name, hash->fh_name);
144 fld_proc_write_cache_flush(struct file *file, const char *buffer,
145 unsigned long count, void *data)
147 struct lu_client_fld *fld = (struct lu_client_fld *)data;
150 LASSERT(fld != NULL);
152 fld_cache_flush(fld->lcf_cache);
154 CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name);
159 struct lprocfs_vars fld_server_proc_list[] = {
162 struct lprocfs_vars fld_client_proc_list[] = {
163 { "targets", fld_proc_read_targets, NULL, NULL },
164 { "hash", fld_proc_read_hash, fld_proc_write_hash, NULL },
165 { "cache_flush", NULL, fld_proc_write_cache_flush, NULL },