/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * * lustre/fld/lproc_fld.c * FLD (FIDs Location Database) * * Copyright (c) 2006 Cluster File Systems, Inc. * Author: Yury Umanets * * This file is part of the Lustre file system, http://www.lustre.org * Lustre is a trademark of Cluster File Systems, Inc. * * You may have signed or agreed to another license before downloading * this software. If so, you are bound by the terms and conditions * of that agreement, and the following does not apply to you. See the * LICENSE file included with this distribution for more information. * * If you did not agree to a different license, then this copy of Lustre * is open source software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * In either case, Lustre is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * license text for more details. */ #ifndef EXPORT_SYMTAB # define EXPORT_SYMTAB #endif #define DEBUG_SUBSYSTEM S_FLD #ifdef __KERNEL__ # include # include #else /* __KERNEL__ */ # include #endif #include #include #include #include #include #include #include #include "fld_internal.h" #ifdef LPROCFS static int fld_proc_read_targets(char *page, char **start, off_t off, int count, int *eof, void *data) { struct lu_client_fld *fld = (struct lu_client_fld *)data; struct lu_fld_target *target; int total = 0, rc; ENTRY; LASSERT(fld != NULL); spin_lock(&fld->lcf_lock); list_for_each_entry(target, &fld->lcf_targets, ft_chain) { rc = snprintf(page, count, "%s\n", fld_target_name(target)); page += rc; count -= rc; total += rc; if (count == 0) break; } spin_unlock(&fld->lcf_lock); RETURN(total); } static int fld_proc_read_hash(char *page, char **start, off_t off, int count, int *eof, void *data) { struct lu_client_fld *fld = (struct lu_client_fld *)data; int rc; ENTRY; LASSERT(fld != NULL); spin_lock(&fld->lcf_lock); rc = snprintf(page, count, "%s\n", fld->lcf_hash->fh_name); spin_unlock(&fld->lcf_lock); RETURN(rc); } static int fld_proc_write_hash(struct file *file, const char *buffer, unsigned long count, void *data) { struct lu_client_fld *fld = (struct lu_client_fld *)data; struct lu_fld_hash *hash = NULL; int i; ENTRY; LASSERT(fld != NULL); for (i = 0; fld_hash[i].fh_name != NULL; i++) { if (count != strlen(fld_hash[i].fh_name)) continue; if (!strncmp(fld_hash[i].fh_name, buffer, count)) { hash = &fld_hash[i]; break; } } if (hash != NULL) { spin_lock(&fld->lcf_lock); fld->lcf_hash = hash; spin_unlock(&fld->lcf_lock); CDEBUG(D_INFO, "%s: Changed hash to \"%s\"\n", fld->lcf_name, hash->fh_name); } RETURN(count); } static int fld_proc_write_cache_flush(struct file *file, const char *buffer, unsigned long count, void *data) { struct lu_client_fld *fld = (struct lu_client_fld *)data; ENTRY; LASSERT(fld != NULL); fld_cache_flush(fld->lcf_cache); CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name); RETURN(count); } struct lprocfs_vars fld_server_proc_list[] = { { NULL }}; struct lprocfs_vars fld_client_proc_list[] = { { "targets", fld_proc_read_targets, NULL, NULL }, { "hash", fld_proc_read_hash, fld_proc_write_hash, NULL }, { "cache_flush", NULL, fld_proc_write_cache_flush, NULL }, { NULL }}; #endif