1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/fld/lproc_fld.c
5 * FLD (FIDs Location Database)
7 * Copyright (c) 2006 Cluster File Systems, Inc.
8 * Author: Yury Umanets <umka@clusterfs.com>
10 * This file is part of the Lustre file system, http://www.lustre.org
11 * Lustre is a trademark of Cluster File Systems, Inc.
13 * You may have signed or agreed to another license before downloading
14 * this software. If so, you are bound by the terms and conditions
15 * of that agreement, and the following does not apply to you. See the
16 * LICENSE file included with this distribution for more information.
18 * If you did not agree to a different license, then this copy of Lustre
19 * is open source software; you can redistribute it and/or modify it
20 * under the terms of version 2 of the GNU General Public License as
21 * published by the Free Software Foundation.
23 * In either case, Lustre is distributed in the hope that it will be
24 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
25 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * license text for more details.
30 # define EXPORT_SYMTAB
32 #define DEBUG_SUBSYSTEM S_FLD
35 # include <libcfs/libcfs.h>
36 # include <linux/module.h>
37 #else /* __KERNEL__ */
38 # include <liblustre.h>
42 #include <obd_class.h>
43 #include <dt_object.h>
44 #include <md_object.h>
45 #include <obd_support.h>
46 #include <lustre_req_layout.h>
47 #include <lustre_fld.h>
48 #include "fld_internal.h"
52 fld_proc_read_targets(char *page, char **start, off_t off,
53 int count, int *eof, void *data)
55 struct lu_client_fld *fld = (struct lu_client_fld *)data;
56 struct lu_fld_target *target;
62 spin_lock(&fld->lcf_lock);
63 list_for_each_entry(target,
64 &fld->lcf_targets, ft_chain)
66 rc = snprintf(page, count, "%s\n",
67 fld_target_name(target));
74 spin_unlock(&fld->lcf_lock);
79 fld_proc_read_hash(char *page, char **start, off_t off,
80 int count, int *eof, void *data)
82 struct lu_client_fld *fld = (struct lu_client_fld *)data;
88 spin_lock(&fld->lcf_lock);
89 rc = snprintf(page, count, "%s\n",
90 fld->lcf_hash->fh_name);
91 spin_unlock(&fld->lcf_lock);
97 fld_proc_write_hash(struct file *file, const char *buffer,
98 unsigned long count, void *data)
100 struct lu_client_fld *fld = (struct lu_client_fld *)data;
101 struct lu_fld_hash *hash = NULL;
105 LASSERT(fld != NULL);
107 for (i = 0; fld_hash[i].fh_name != NULL; i++) {
108 if (count != strlen(fld_hash[i].fh_name))
111 if (!strncmp(fld_hash[i].fh_name, buffer, count)) {
118 spin_lock(&fld->lcf_lock);
119 fld->lcf_hash = hash;
120 spin_unlock(&fld->lcf_lock);
122 CDEBUG(D_INFO, "%s: Changed hash to \"%s\"\n",
123 fld->lcf_name, hash->fh_name);
130 fld_proc_write_cache_flush(struct file *file, const char *buffer,
131 unsigned long count, void *data)
133 struct lu_client_fld *fld = (struct lu_client_fld *)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 struct lprocfs_vars fld_server_proc_list[] = {
148 struct lprocfs_vars fld_client_proc_list[] = {
149 { "targets", fld_proc_read_targets, NULL, NULL },
150 { "hash", fld_proc_read_hash, fld_proc_write_hash, NULL },
151 { "cache_flush", NULL, fld_proc_write_cache_flush, NULL },