aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lustre/fld
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/lustre/lustre/fld')
-rw-r--r--drivers/staging/lustre/lustre/fld/Makefile2
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_cache.c45
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_handler.c447
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_index.c426
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_internal.h31
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_request.c90
-rw-r--r--drivers/staging/lustre/lustre/fld/lproc_fld.c217
7 files changed, 71 insertions, 1187 deletions
diff --git a/drivers/staging/lustre/lustre/fld/Makefile b/drivers/staging/lustre/lustre/fld/Makefile
index e7f2881a1d9e..90d46d84fbbb 100644
--- a/drivers/staging/lustre/lustre/fld/Makefile
+++ b/drivers/staging/lustre/lustre/fld/Makefile
@@ -1,5 +1,5 @@
obj-$(CONFIG_LUSTRE_FS) += fld.o
-fld-y := fld_handler.o fld_request.o fld_cache.o fld_index.o lproc_fld.o
+fld-y := fld_request.o fld_cache.o lproc_fld.o
ccflags-y := -I$(src)/../include
diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c
index 347f2ae83bc8..25099cbe37eb 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -45,7 +45,6 @@
# include <linux/libcfs/libcfs.h>
# include <linux/module.h>
-# include <linux/jbd.h>
# include <asm/div64.h>
#include <obd.h>
@@ -67,14 +66,13 @@ struct fld_cache *fld_cache_init(const char *name,
int cache_size, int cache_threshold)
{
struct fld_cache *cache;
- ENTRY;
LASSERT(name != NULL);
LASSERT(cache_threshold < cache_size);
OBD_ALLOC_PTR(cache);
if (cache == NULL)
- RETURN(ERR_PTR(-ENOMEM));
+ return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&cache->fci_entries_head);
INIT_LIST_HEAD(&cache->fci_lru);
@@ -94,7 +92,7 @@ struct fld_cache *fld_cache_init(const char *name,
CDEBUG(D_INFO, "%s: FLD cache - Size: %d, Threshold: %d\n",
cache->fci_name, cache_size, cache_threshold);
- RETURN(cache);
+ return cache;
}
/**
@@ -103,7 +101,6 @@ struct fld_cache *fld_cache_init(const char *name,
void fld_cache_fini(struct fld_cache *cache)
{
__u64 pct;
- ENTRY;
LASSERT(cache != NULL);
fld_cache_flush(cache);
@@ -121,8 +118,6 @@ void fld_cache_fini(struct fld_cache *cache)
CDEBUG(D_INFO, " Cache hits: "LPU64"%%\n", pct);
OBD_FREE_PTR(cache);
-
- EXIT;
}
/**
@@ -147,7 +142,6 @@ static void fld_fix_new_list(struct fld_cache *cache)
struct lu_seq_range *c_range;
struct lu_seq_range *n_range;
struct list_head *head = &cache->fci_entries_head;
- ENTRY;
restart_fixup:
@@ -200,8 +194,6 @@ restart_fixup:
c_range->lsr_end == n_range->lsr_end)
fld_cache_entry_delete(cache, f_curr);
}
-
- EXIT;
}
/**
@@ -227,12 +219,11 @@ static int fld_cache_shrink(struct fld_cache *cache)
struct fld_cache_entry *flde;
struct list_head *curr;
int num = 0;
- ENTRY;
LASSERT(cache != NULL);
if (cache->fci_cache_count < cache->fci_cache_size)
- RETURN(0);
+ return 0;
curr = cache->fci_lru.prev;
@@ -248,7 +239,7 @@ static int fld_cache_shrink(struct fld_cache *cache)
CDEBUG(D_INFO, "%s: FLD cache - Shrunk by "
"%d entries\n", cache->fci_name, num);
- RETURN(0);
+ return 0;
}
/**
@@ -256,14 +247,10 @@ static int fld_cache_shrink(struct fld_cache *cache)
*/
void fld_cache_flush(struct fld_cache *cache)
{
- ENTRY;
-
write_lock(&cache->fci_lock);
cache->fci_cache_size = 0;
fld_cache_shrink(cache);
write_unlock(&cache->fci_lock);
-
- EXIT;
}
/**
@@ -280,11 +267,9 @@ void fld_cache_punch_hole(struct fld_cache *cache,
const seqno_t new_end = range->lsr_end;
struct fld_cache_entry *fldt;
- ENTRY;
OBD_ALLOC_GFP(fldt, sizeof *fldt, GFP_ATOMIC);
if (!fldt) {
OBD_FREE_PTR(f_new);
- EXIT;
/* overlap is not allowed, so dont mess up list. */
return;
}
@@ -307,7 +292,6 @@ void fld_cache_punch_hole(struct fld_cache *cache,
fld_cache_entry_add(cache, fldt, &f_new->fce_list);
/* no need to fixup */
- EXIT;
}
/**
@@ -383,10 +367,10 @@ struct fld_cache_entry
OBD_ALLOC_PTR(f_new);
if (!f_new)
- RETURN(ERR_PTR(-ENOMEM));
+ return ERR_PTR(-ENOMEM);
f_new->fce_range = *range;
- RETURN(f_new);
+ return f_new;
}
/**
@@ -405,7 +389,6 @@ int fld_cache_insert_nolock(struct fld_cache *cache,
const seqno_t new_start = f_new->fce_range.lsr_start;
const seqno_t new_end = f_new->fce_range.lsr_end;
__u32 new_flags = f_new->fce_range.lsr_flags;
- ENTRY;
/*
* Duplicate entries are eliminated in insert op.
@@ -441,7 +424,7 @@ int fld_cache_insert_nolock(struct fld_cache *cache,
/* Add new entry to cache and lru list. */
fld_cache_entry_add(cache, f_new, prev);
out:
- RETURN(0);
+ return 0;
}
int fld_cache_insert(struct fld_cache *cache,
@@ -452,7 +435,7 @@ int fld_cache_insert(struct fld_cache *cache,
flde = fld_cache_entry_create(range);
if (IS_ERR(flde))
- RETURN(PTR_ERR(flde));
+ return PTR_ERR(flde);
write_lock(&cache->fci_lock);
rc = fld_cache_insert_nolock(cache, flde);
@@ -460,7 +443,7 @@ int fld_cache_insert(struct fld_cache *cache,
if (rc)
OBD_FREE_PTR(flde);
- RETURN(rc);
+ return rc;
}
void fld_cache_delete_nolock(struct fld_cache *cache,
@@ -512,7 +495,7 @@ struct fld_cache_entry
}
}
- RETURN(got);
+ return got;
}
/**
@@ -522,12 +505,11 @@ struct fld_cache_entry
*fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range)
{
struct fld_cache_entry *got = NULL;
- ENTRY;
read_lock(&cache->fci_lock);
got = fld_cache_entry_lookup_nolock(cache, range);
read_unlock(&cache->fci_lock);
- RETURN(got);
+ return got;
}
/**
@@ -539,7 +521,6 @@ int fld_cache_lookup(struct fld_cache *cache,
struct fld_cache_entry *flde;
struct fld_cache_entry *prev = NULL;
struct list_head *head;
- ENTRY;
read_lock(&cache->fci_lock);
head = &cache->fci_entries_head;
@@ -558,9 +539,9 @@ int fld_cache_lookup(struct fld_cache *cache,
cache->fci_stat.fst_cache++;
read_unlock(&cache->fci_lock);
- RETURN(0);
+ return 0;
}
}
read_unlock(&cache->fci_lock);
- RETURN(-ENOENT);
+ return -ENOENT;
}
diff --git a/drivers/staging/lustre/lustre/fld/fld_handler.c b/drivers/staging/lustre/lustre/fld/fld_handler.c
deleted file mode 100644
index d2707ae4ad57..000000000000
--- a/drivers/staging/lustre/lustre/fld/fld_handler.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program 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 GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2013, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/fld/fld_handler.c
- *
- * FLD (Fids Location Database)
- *
- * Author: Yury Umanets <umka@clusterfs.com>
- * Author: WangDi <wangdi@clusterfs.com>
- * Author: Pravin Shelar <pravin.shelar@sun.com>
- */
-
-#define DEBUG_SUBSYSTEM S_FLD
-
-# include <linux/libcfs/libcfs.h>
-# include <linux/module.h>
-# include <linux/jbd.h>
-# include <asm/div64.h>
-
-#include <obd.h>
-#include <obd_class.h>
-#include <lustre_ver.h>
-#include <obd_support.h>
-#include <lprocfs_status.h>
-
-#include <md_object.h>
-#include <lustre_fid.h>
-#include <lustre_req_layout.h>
-#include "fld_internal.h"
-#include <lustre_fid.h>
-
-
-/* context key constructor/destructor: fld_key_init, fld_key_fini */
-LU_KEY_INIT_FINI(fld, struct fld_thread_info);
-
-/* context key: fld_thread_key */
-LU_CONTEXT_KEY_DEFINE(fld, LCT_MD_THREAD | LCT_DT_THREAD | LCT_MG_THREAD);
-
-proc_dir_entry_t *fld_type_proc_dir = NULL;
-
-static int __init fld_mod_init(void)
-{
- fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME,
- proc_lustre_root,
- NULL, NULL);
- if (IS_ERR(fld_type_proc_dir))
- return PTR_ERR(fld_type_proc_dir);
-
- LU_CONTEXT_KEY_INIT(&fld_thread_key);
- lu_context_key_register(&fld_thread_key);
- return 0;
-}
-
-static void __exit fld_mod_exit(void)
-{
- lu_context_key_degister(&fld_thread_key);
- if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) {
- lprocfs_remove(&fld_type_proc_dir);
- fld_type_proc_dir = NULL;
- }
-}
-
-int fld_declare_server_create(const struct lu_env *env,
- struct lu_server_fld *fld,
- struct lu_seq_range *range,
- struct thandle *th)
-{
- int rc;
-
- rc = fld_declare_index_create(env, fld, range, th);
- RETURN(rc);
-}
-EXPORT_SYMBOL(fld_declare_server_create);
-
-/**
- * Insert FLD index entry and update FLD cache.
- *
- * This function is called from the sequence allocator when a super-sequence
- * is granted to a server.
- */
-int fld_server_create(const struct lu_env *env, struct lu_server_fld *fld,
- struct lu_seq_range *range, struct thandle *th)
-{
- int rc;
-
- mutex_lock(&fld->lsf_lock);
- rc = fld_index_create(env, fld, range, th);
- mutex_unlock(&fld->lsf_lock);
-
- RETURN(rc);
-}
-EXPORT_SYMBOL(fld_server_create);
-
-/**
- * Lookup mds by seq, returns a range for given seq.
- *
- * If that entry is not cached in fld cache, request is sent to super
- * sequence controller node (MDT0). All other MDT[1...N] and client
- * cache fld entries, but this cache is not persistent.
- */
-int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld,
- seqno_t seq, struct lu_seq_range *range)
-{
- struct lu_seq_range *erange;
- struct fld_thread_info *info;
- int rc;
- ENTRY;
-
- info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
- LASSERT(info != NULL);
- erange = &info->fti_lrange;
-
- /* Lookup it in the cache. */
- rc = fld_cache_lookup(fld->lsf_cache, seq, erange);
- if (rc == 0) {
- if (unlikely(fld_range_type(erange) != fld_range_type(range) &&
- !fld_range_is_any(range))) {
- CERROR("%s: FLD cache range "DRANGE" does not match"
- "requested flag %x: rc = %d\n", fld->lsf_name,
- PRANGE(erange), range->lsr_flags, -EIO);
- RETURN(-EIO);
- }
- *range = *erange;
- RETURN(0);
- }
-
- if (fld->lsf_obj) {
- /* On server side, all entries should be in cache.
- * If we can not find it in cache, just return error */
- CERROR("%s: Cannot find sequence "LPX64": rc = %d\n",
- fld->lsf_name, seq, -EIO);
- RETURN(-EIO);
- } else {
- LASSERT(fld->lsf_control_exp);
- /* send request to mdt0 i.e. super seq. controller.
- * This is temporary solution, long term solution is fld
- * replication on all mdt servers.
- */
- range->lsr_start = seq;
- rc = fld_client_rpc(fld->lsf_control_exp,
- range, FLD_LOOKUP);
- if (rc == 0)
- fld_cache_insert(fld->lsf_cache, range);
- }
- RETURN(rc);
-}
-EXPORT_SYMBOL(fld_server_lookup);
-
-/**
- * All MDT server handle fld lookup operation. But only MDT0 has fld index.
- * if entry is not found in cache we need to forward lookup request to MDT0
- */
-
-static int fld_server_handle(struct lu_server_fld *fld,
- const struct lu_env *env,
- __u32 opc, struct lu_seq_range *range,
- struct fld_thread_info *info)
-{
- int rc;
- ENTRY;
-
- switch (opc) {
- case FLD_LOOKUP:
- rc = fld_server_lookup(env, fld, range->lsr_start, range);
- break;
- default:
- rc = -EINVAL;
- break;
- }
-
- CDEBUG(D_INFO, "%s: FLD req handle: error %d (opc: %d, range: "
- DRANGE"\n", fld->lsf_name, rc, opc, PRANGE(range));
-
- RETURN(rc);
-
-}
-
-static int fld_req_handle(struct ptlrpc_request *req,
- struct fld_thread_info *info)
-{
- struct obd_export *exp = req->rq_export;
- struct lu_site *site = exp->exp_obd->obd_lu_dev->ld_site;
- struct lu_seq_range *in;
- struct lu_seq_range *out;
- int rc;
- __u32 *opc;
- ENTRY;
-
- rc = req_capsule_server_pack(info->fti_pill);
- if (rc)
- RETURN(err_serious(rc));
-
- opc = req_capsule_client_get(info->fti_pill, &RMF_FLD_OPC);
- if (opc != NULL) {
- in = req_capsule_client_get(info->fti_pill, &RMF_FLD_MDFLD);
- if (in == NULL)
- RETURN(err_serious(-EPROTO));
- out = req_capsule_server_get(info->fti_pill, &RMF_FLD_MDFLD);
- if (out == NULL)
- RETURN(err_serious(-EPROTO));
- *out = *in;
-
- /* For old 2.0 client, the 'lsr_flags' is uninitialized.
- * Set it as 'LU_SEQ_RANGE_MDT' by default. */
- if (!(exp_connect_flags(exp) & OBD_CONNECT_64BITHASH) &&
- !(exp_connect_flags(exp) & OBD_CONNECT_MDS_MDS) &&
- !(exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) &&
- !exp->exp_libclient)
- fld_range_set_mdt(out);
-
- rc = fld_server_handle(lu_site2seq(site)->ss_server_fld,
- req->rq_svc_thread->t_env,
- *opc, out, info);
- } else {
- rc = err_serious(-EPROTO);
- }
-
- RETURN(rc);
-}
-
-static void fld_thread_info_init(struct ptlrpc_request *req,
- struct fld_thread_info *info)
-{
- info->fti_pill = &req->rq_pill;
- /* Init request capsule. */
- req_capsule_init(info->fti_pill, req, RCL_SERVER);
- req_capsule_set(info->fti_pill, &RQF_FLD_QUERY);
-}
-
-static void fld_thread_info_fini(struct fld_thread_info *info)
-{
- req_capsule_fini(info->fti_pill);
-}
-
-static int fld_handle(struct ptlrpc_request *req)
-{
- struct fld_thread_info *info;
- const struct lu_env *env;
- int rc;
-
- env = req->rq_svc_thread->t_env;
- LASSERT(env != NULL);
-
- info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
- LASSERT(info != NULL);
-
- fld_thread_info_init(req, info);
- rc = fld_req_handle(req, info);
- fld_thread_info_fini(info);
-
- return rc;
-}
-
-/*
- * Entry point for handling FLD RPCs called from MDT.
- */
-int fld_query(struct com_thread_info *info)
-{
- return fld_handle(info->cti_pill->rc_req);
-}
-EXPORT_SYMBOL(fld_query);
-
-/*
- * Returns true, if fid is local to this server node.
- *
- * WARNING: this function is *not* guaranteed to return false if fid is
- * remote: it makes an educated conservative guess only.
- *
- * fid_is_local() is supposed to be used in assertion checks only.
- */
-int fid_is_local(const struct lu_env *env,
- struct lu_site *site, const struct lu_fid *fid)
-{
- int result;
- struct seq_server_site *ss_site;
- struct lu_seq_range *range;
- struct fld_thread_info *info;
- ENTRY;
-
- info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
- range = &info->fti_lrange;
-
- result = 1; /* conservatively assume fid is local */
- ss_site = lu_site2seq(site);
- if (ss_site->ss_client_fld != NULL) {
- int rc;
-
- rc = fld_cache_lookup(ss_site->ss_client_fld->lcf_cache,
- fid_seq(fid), range);
- if (rc == 0)
- result = (range->lsr_index == ss_site->ss_node_id);
- }
- return result;
-}
-EXPORT_SYMBOL(fid_is_local);
-
-static void fld_server_proc_fini(struct lu_server_fld *fld);
-
-#ifdef LPROCFS
-static int fld_server_proc_init(struct lu_server_fld *fld)
-{
- int rc = 0;
- ENTRY;
-
- fld->lsf_proc_dir = lprocfs_register(fld->lsf_name,
- fld_type_proc_dir,
- fld_server_proc_list, fld);
- if (IS_ERR(fld->lsf_proc_dir)) {
- rc = PTR_ERR(fld->lsf_proc_dir);
- RETURN(rc);
- }
-
- rc = lprocfs_seq_create(fld->lsf_proc_dir, "fldb", 0444,
- &fld_proc_seq_fops, fld);
- if (rc) {
- lprocfs_remove(&fld->lsf_proc_dir);
- fld->lsf_proc_dir = NULL;
- }
-
- RETURN(rc);
-}
-
-static void fld_server_proc_fini(struct lu_server_fld *fld)
-{
- ENTRY;
- if (fld->lsf_proc_dir != NULL) {
- if (!IS_ERR(fld->lsf_proc_dir))
- lprocfs_remove(&fld->lsf_proc_dir);
- fld->lsf_proc_dir = NULL;
- }
- EXIT;
-}
-#else
-static int fld_server_proc_init(struct lu_server_fld *fld)
-{
- return 0;
-}
-
-static void fld_server_proc_fini(struct lu_server_fld *fld)
-{
- return;
-}
-#endif
-
-int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld,
- struct dt_device *dt, const char *prefix, int mds_node_id,
- int type)
-{
- int cache_size, cache_threshold;
- int rc;
- ENTRY;
-
- snprintf(fld->lsf_name, sizeof(fld->lsf_name),
- "srv-%s", prefix);
-
- cache_size = FLD_SERVER_CACHE_SIZE /
- sizeof(struct fld_cache_entry);
-
- cache_threshold = cache_size *
- FLD_SERVER_CACHE_THRESHOLD / 100;
-
- mutex_init(&fld->lsf_lock);
- fld->lsf_cache = fld_cache_init(fld->lsf_name,
- cache_size, cache_threshold);
- if (IS_ERR(fld->lsf_cache)) {
- rc = PTR_ERR(fld->lsf_cache);
- fld->lsf_cache = NULL;
- GOTO(out, rc);
- }
-
- if (!mds_node_id && type == LU_SEQ_RANGE_MDT) {
- rc = fld_index_init(env, fld, dt);
- if (rc)
- GOTO(out, rc);
- } else {
- fld->lsf_obj = NULL;
- }
-
- rc = fld_server_proc_init(fld);
- if (rc)
- GOTO(out, rc);
-
- fld->lsf_control_exp = NULL;
-
- GOTO(out, rc);
-
-out:
- if (rc)
- fld_server_fini(env, fld);
- return rc;
-}
-EXPORT_SYMBOL(fld_server_init);
-
-void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld)
-{
- ENTRY;
-
- fld_server_proc_fini(fld);
- fld_index_fini(env, fld);
-
- if (fld->lsf_cache != NULL) {
- if (!IS_ERR(fld->lsf_cache))
- fld_cache_fini(fld->lsf_cache);
- fld->lsf_cache = NULL;
- }
-
- EXIT;
-}
-EXPORT_SYMBOL(fld_server_fini);
-
-MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("Lustre FLD");
-MODULE_LICENSE("GPL");
-
-cfs_module(mdd, "0.1.0", fld_mod_init, fld_mod_exit);
diff --git a/drivers/staging/lustre/lustre/fld/fld_index.c b/drivers/staging/lustre/lustre/fld/fld_index.c
deleted file mode 100644
index ec68a54c23bd..000000000000
--- a/drivers/staging/lustre/lustre/fld/fld_index.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program 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 GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2013, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/fld/fld_index.c
- *
- * Author: WangDi <wangdi@clusterfs.com>
- * Author: Yury Umanets <umka@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_FLD
-
-# include <linux/libcfs/libcfs.h>
-# include <linux/module.h>
-# include <linux/jbd.h>
-
-#include <obd.h>
-#include <obd_class.h>
-#include <lustre_ver.h>
-#include <obd_support.h>
-#include <lprocfs_status.h>
-
-#include <dt_object.h>
-#include <md_object.h>
-#include <lustre_mdc.h>
-#include <lustre_fid.h>
-#include <lustre_fld.h>
-#include "fld_internal.h"
-
-const char fld_index_name[] = "fld";
-
-static const struct lu_seq_range IGIF_FLD_RANGE = {
- .lsr_start = FID_SEQ_IGIF,
- .lsr_end = FID_SEQ_IGIF_MAX + 1,
- .lsr_index = 0,
- .lsr_flags = LU_SEQ_RANGE_MDT
-};
-
-static const struct lu_seq_range DOT_LUSTRE_FLD_RANGE = {
- .lsr_start = FID_SEQ_DOT_LUSTRE,
- .lsr_end = FID_SEQ_DOT_LUSTRE + 1,
- .lsr_index = 0,
- .lsr_flags = LU_SEQ_RANGE_MDT
-};
-
-static const struct lu_seq_range ROOT_FLD_RANGE = {
- .lsr_start = FID_SEQ_ROOT,
- .lsr_end = FID_SEQ_ROOT + 1,
- .lsr_index = 0,
- .lsr_flags = LU_SEQ_RANGE_MDT
-};
-
-const struct dt_index_features fld_index_features = {
- .dif_flags = DT_IND_UPDATE,
- .dif_keysize_min = sizeof(seqno_t),
- .dif_keysize_max = sizeof(seqno_t),
- .dif_recsize_min = sizeof(struct lu_seq_range),
- .dif_recsize_max = sizeof(struct lu_seq_range),
- .dif_ptrsize = 4
-};
-
-extern struct lu_context_key fld_thread_key;
-
-int fld_declare_index_create(const struct lu_env *env,
- struct lu_server_fld *fld,
- const struct lu_seq_range *new_range,
- struct thandle *th)
-{
- struct lu_seq_range *tmp;
- struct lu_seq_range *range;
- struct fld_thread_info *info;
- int rc = 0;
-
- ENTRY;
-
- info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
- range = &info->fti_lrange;
- tmp = &info->fti_irange;
- memset(range, 0, sizeof(*range));
-
- rc = fld_index_lookup(env, fld, new_range->lsr_start, range);
- if (rc == 0) {
- /* In case of duplicate entry, the location must be same */
- LASSERT((range_compare_loc(new_range, range) == 0));
- GOTO(out, rc = -EEXIST);
- }
-
- if (rc != -ENOENT) {
- CERROR("%s: lookup range "DRANGE" error: rc = %d\n",
- fld->lsf_name, PRANGE(range), rc);
- GOTO(out, rc);
- }
-
- /* Check for merge case, since the fld entry can only be increamental,
- * so we will only check whether it can be merged from the left. */
- if (new_range->lsr_start == range->lsr_end && range->lsr_end != 0 &&
- range_compare_loc(new_range, range) == 0) {
- range_cpu_to_be(tmp, range);
- rc = dt_declare_delete(env, fld->lsf_obj,
- (struct dt_key *)&tmp->lsr_start, th);
- if (rc) {
- CERROR("%s: declare record "DRANGE" failed: rc = %d\n",
- fld->lsf_name, PRANGE(range), rc);
- GOTO(out, rc);
- }
- memcpy(tmp, new_range, sizeof(*new_range));
- tmp->lsr_start = range->lsr_start;
- } else {
- memcpy(tmp, new_range, sizeof(*new_range));
- }
-
- range_cpu_to_be(tmp, tmp);
- rc = dt_declare_insert(env, fld->lsf_obj, (struct dt_rec *)tmp,
- (struct dt_key *)&tmp->lsr_start, th);
-out:
- RETURN(rc);
-}
-
-/**
- * insert range in fld store.
- *
- * \param range range to be inserted
- * \param th transaction for this operation as it could compound
- * transaction.
- *
- * \retval 0 success
- * \retval -ve error
- *
- * The whole fld index insertion is protected by seq->lss_mutex (see
- * seq_server_alloc_super), i.e. only one thread will access fldb each
- * time, so we do not need worry the fld file and cache will being
- * changed between declare and create.
- * Because the fld entry can only be increamental, so we will only check
- * whether it can be merged from the left.
- **/
-int fld_index_create(const struct lu_env *env, struct lu_server_fld *fld,
- const struct lu_seq_range *new_range, struct thandle *th)
-{
- struct lu_seq_range *range;
- struct lu_seq_range *tmp;
- struct fld_thread_info *info;
- int rc = 0;
- int deleted = 0;
- struct fld_cache_entry *flde;
- ENTRY;
-
- info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
-
- LASSERT(mutex_is_locked(&fld->lsf_lock));
-
- range = &info->fti_lrange;
- memset(range, 0, sizeof(*range));
- tmp = &info->fti_irange;
- rc = fld_index_lookup(env, fld, new_range->lsr_start, range);
- if (rc != -ENOENT) {
- rc = rc == 0 ? -EEXIST : rc;
- GOTO(out, rc);
- }
-
- if (new_range->lsr_start == range->lsr_end && range->lsr_end != 0 &&
- range_compare_loc(new_range, range) == 0) {
- range_cpu_to_be(tmp, range);
- rc = dt_delete(env, fld->lsf_obj,
- (struct dt_key *)&tmp->lsr_start, th,
- BYPASS_CAPA);
- if (rc != 0)
- GOTO(out, rc);
- memcpy(tmp, new_range, sizeof(*new_range));
- tmp->lsr_start = range->lsr_start;
- deleted = 1;
- } else {
- memcpy(tmp, new_range, sizeof(*new_range));
- }
-
- range_cpu_to_be(tmp, tmp);
- rc = dt_insert(env, fld->lsf_obj, (struct dt_rec *)tmp,
- (struct dt_key *)&tmp->lsr_start, th, BYPASS_CAPA, 1);
- if (rc != 0) {
- CERROR("%s: insert range "DRANGE" failed: rc = %d\n",
- fld->lsf_name, PRANGE(new_range), rc);
- GOTO(out, rc);
- }
-
- flde = fld_cache_entry_create(new_range);
- if (IS_ERR(flde))
- GOTO(out, rc = PTR_ERR(flde));
-
- write_lock(&fld->lsf_cache->fci_lock);
- if (deleted)
- fld_cache_delete_nolock(fld->lsf_cache, new_range);
- rc = fld_cache_insert_nolock(fld->lsf_cache, flde);
- write_unlock(&fld->lsf_cache->fci_lock);
- if (rc)
- OBD_FREE_PTR(flde);
-out:
- RETURN(rc);
-}
-
-/**
- * lookup range for a seq passed. note here we only care about the start/end,
- * caller should handle the attached location data (flags, index).
- *
- * \param seq seq for lookup.
- * \param range result of lookup.
- *
- * \retval 0 found, \a range is the matched range;
- * \retval -ENOENT not found, \a range is the left-side range;
- * \retval -ve other error;
- */
-int fld_index_lookup(const struct lu_env *env, struct lu_server_fld *fld,
- seqno_t seq, struct lu_seq_range *range)
-{
- struct lu_seq_range *fld_rec;
- struct fld_thread_info *info;
- int rc;
-
- ENTRY;
-
- info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
- fld_rec = &info->fti_rec;
-
- rc = fld_cache_lookup(fld->lsf_cache, seq, fld_rec);
- if (rc == 0) {
- *range = *fld_rec;
- if (range_within(range, seq))
- rc = 0;
- else
- rc = -ENOENT;
- }
-
- CDEBUG(D_INFO, "%s: lookup seq = "LPX64" range : "DRANGE" rc = %d\n",
- fld->lsf_name, seq, PRANGE(range), rc);
-
- RETURN(rc);
-}
-
-int fld_insert_entry(const struct lu_env *env,
- struct lu_server_fld *fld,
- const struct lu_seq_range *range)
-{
- struct thandle *th;
- int rc;
- ENTRY;
-
- th = dt_trans_create(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev));
- if (IS_ERR(th))
- RETURN(PTR_ERR(th));
-
- rc = fld_declare_index_create(env, fld, range, th);
- if (rc != 0) {
- if (rc == -EEXIST)
- rc = 0;
- GOTO(out, rc);
- }
-
- rc = dt_trans_start_local(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev),
- th);
- if (rc)
- GOTO(out, rc);
-
- rc = fld_index_create(env, fld, range, th);
- if (rc == -EEXIST)
- rc = 0;
-out:
- dt_trans_stop(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev), th);
- RETURN(rc);
-}
-EXPORT_SYMBOL(fld_insert_entry);
-
-static int fld_insert_special_entries(const struct lu_env *env,
- struct lu_server_fld *fld)
-{
- int rc;
-
- rc = fld_insert_entry(env, fld, &IGIF_FLD_RANGE);
- if (rc != 0)
- RETURN(rc);
-
- rc = fld_insert_entry(env, fld, &DOT_LUSTRE_FLD_RANGE);
- if (rc != 0)
- RETURN(rc);
-
- rc = fld_insert_entry(env, fld, &ROOT_FLD_RANGE);
-
- RETURN(rc);
-}
-
-int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld,
- struct dt_device *dt)
-{
- struct dt_object *dt_obj = NULL;
- struct lu_fid fid;
- struct lu_attr *attr = NULL;
- struct lu_seq_range *range = NULL;
- struct fld_thread_info *info;
- struct dt_object_format dof;
- struct dt_it *it;
- const struct dt_it_ops *iops;
- int rc;
- ENTRY;
-
- info = lu_context_key_get(&env->le_ctx, &fld_thread_key);
- LASSERT(info != NULL);
-
- lu_local_obj_fid(&fid, FLD_INDEX_OID);
- OBD_ALLOC_PTR(attr);
- if (attr == NULL)
- RETURN(-ENOMEM);
-
- memset(attr, 0, sizeof(*attr));
- attr->la_valid = LA_MODE;
- attr->la_mode = S_IFREG | 0666;
- dof.dof_type = DFT_INDEX;
- dof.u.dof_idx.di_feat = &fld_index_features;
-
- dt_obj = dt_find_or_create(env, dt, &fid, &dof, attr);
- if (IS_ERR(dt_obj)) {
- rc = PTR_ERR(dt_obj);
- CERROR("%s: Can't find \"%s\" obj %d\n", fld->lsf_name,
- fld_index_name, rc);
- dt_obj = NULL;
- GOTO(out, rc);
- }
-
- fld->lsf_obj = dt_obj;
- rc = dt_obj->do_ops->do_index_try(env, dt_obj, &fld_index_features);
- if (rc != 0) {
- CERROR("%s: File \"%s\" is not an index: rc = %d!\n",
- fld->lsf_name, fld_index_name, rc);
- GOTO(out, rc);
- }
-
- range = &info->fti_rec;
- /* Load fld entry to cache */
- iops = &dt_obj->do_index_ops->dio_it;
- it = iops->init(env, dt_obj, 0, NULL);
- if (IS_ERR(it))
- GOTO(out, rc = PTR_ERR(it));
-
- rc = iops->load(env, it, 0);
- if (rc < 0)
- GOTO(out_it_fini, rc);
-
- if (rc > 0) {
- /* Load FLD entry into server cache */
- do {
- rc = iops->rec(env, it, (struct dt_rec *)range, 0);
- if (rc != 0)
- GOTO(out_it_put, rc);
- LASSERT(range != NULL);
- range_be_to_cpu(range, range);
- rc = fld_cache_insert(fld->lsf_cache, range);
- if (rc != 0)
- GOTO(out_it_put, rc);
- rc = iops->next(env, it);
- } while (rc == 0);
- }
-
- /* Note: fld_insert_entry will detect whether these
- * special entries already exist inside FLDB */
- mutex_lock(&fld->lsf_lock);
- rc = fld_insert_special_entries(env, fld);
- mutex_unlock(&fld->lsf_lock);
- if (rc != 0) {
- CERROR("%s: insert special entries failed!: rc = %d\n",
- fld->lsf_name, rc);
- GOTO(out_it_put, rc);
- }
-
-out_it_put:
- iops->put(env, it);
-out_it_fini:
- iops->fini(env, it);
-out:
- if (attr != NULL)
- OBD_FREE_PTR(attr);
-
- if (rc != 0) {
- if (dt_obj != NULL)
- lu_object_put(env, &dt_obj->do_lu);
- fld->lsf_obj = NULL;
- }
- RETURN(rc);
-}
-
-void fld_index_fini(const struct lu_env *env, struct lu_server_fld *fld)
-{
- ENTRY;
- if (fld->lsf_obj != NULL) {
- if (!IS_ERR(fld->lsf_obj))
- lu_object_put(env, &fld->lsf_obj->do_lu);
- fld->lsf_obj = NULL;
- }
- EXIT;
-}
diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h
index 9fa9e01cdb67..56686b138ac1 100644
--- a/drivers/staging/lustre/lustre/fld/fld_internal.h
+++ b/drivers/staging/lustre/lustre/fld/fld_internal.h
@@ -139,38 +139,10 @@ enum {
extern struct lu_fld_hash fld_hash[];
-
-struct fld_thread_info {
- struct req_capsule *fti_pill;
- __u64 fti_key;
- struct lu_seq_range fti_rec;
- struct lu_seq_range fti_lrange;
- struct lu_seq_range fti_irange;
-};
-
-extern struct lu_context_key fld_thread_key;
-
-int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld,
- struct dt_device *dt);
-
-void fld_index_fini(const struct lu_env *env, struct lu_server_fld *fld);
-
-int fld_declare_index_create(const struct lu_env *env,
- struct lu_server_fld *fld,
- const struct lu_seq_range *new,
- struct thandle *th);
-
-int fld_index_create(const struct lu_env *env, struct lu_server_fld *fld,
- const struct lu_seq_range *new, struct thandle *th);
-
-int fld_index_lookup(const struct lu_env *env, struct lu_server_fld *fld,
- seqno_t seq, struct lu_seq_range *range);
-
int fld_client_rpc(struct obd_export *exp,
struct lu_seq_range *range, __u32 fld_op);
#ifdef LPROCFS
-extern struct lprocfs_vars fld_server_proc_list[];
extern struct lprocfs_vars fld_client_proc_list[];
#endif
@@ -218,6 +190,5 @@ fld_target_name(struct lu_fld_target *tar)
return (const char *)tar->ft_exp->exp_obd->obd_name;
}
-extern proc_dir_entry_t *fld_type_proc_dir;
-extern struct file_operations fld_proc_seq_fops;
+extern struct proc_dir_entry *fld_type_proc_dir;
#endif /* __FLD_INTERNAL_H */
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c
index e9f07398b68a..078e98bda684 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -44,7 +44,6 @@
# include <linux/libcfs/libcfs.h>
# include <linux/module.h>
-# include <linux/jbd.h>
# include <asm/div64.h>
#include <obd.h>
@@ -60,16 +59,18 @@
#include <lustre_mdc.h>
#include "fld_internal.h"
+struct lu_context_key fld_thread_key;
+
/* TODO: these 3 functions are copies of flow-control code from mdc_lib.c
* It should be common thing. The same about mdc RPC lock */
static int fld_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw)
{
int rc;
- ENTRY;
+
client_obd_list_lock(&cli->cl_loi_list_lock);
rc = list_empty(&mcw->mcw_entry);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- RETURN(rc);
+ return rc;
};
static void fld_enter_request(struct client_obd *cli)
@@ -123,7 +124,6 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq)
{
struct lu_fld_target *target;
int hash;
- ENTRY;
/* Because almost all of special sequence located in MDT0,
* it should go to index 0 directly, instead of calculating
@@ -137,7 +137,7 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq)
list_for_each_entry(target, &fld->lcf_targets, ft_chain) {
if (target->ft_idx == hash)
- RETURN(target);
+ return target;
}
CERROR("%s: Can't find target by hash %d (seq "LPX64"). "
@@ -161,7 +161,7 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq)
* LBUG() to catch this situation.
*/
LBUG();
- RETURN(NULL);
+ return NULL;
}
struct lu_fld_hash fld_hash[] = {
@@ -179,7 +179,6 @@ static struct lu_fld_target *
fld_client_get_target(struct lu_client_fld *fld, seqno_t seq)
{
struct lu_fld_target *target;
- ENTRY;
LASSERT(fld->lcf_hash != NULL);
@@ -193,7 +192,7 @@ fld_client_get_target(struct lu_client_fld *fld, seqno_t seq)
target->ft_idx, seq);
}
- RETURN(target);
+ return target;
}
/*
@@ -205,7 +204,6 @@ int fld_client_add_target(struct lu_client_fld *fld,
{
const char *name;
struct lu_fld_target *target, *tmp;
- ENTRY;
LASSERT(tar != NULL);
name = fld_target_name(tar);
@@ -216,7 +214,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
CERROR("%s: Attempt to add target %s (idx "LPU64") "
"on fly - skip it\n", fld->lcf_name, name,
tar->ft_idx);
- RETURN(0);
+ return 0;
} else {
CDEBUG(D_INFO, "%s: Adding target %s (idx "
LPU64")\n", fld->lcf_name, name, tar->ft_idx);
@@ -224,7 +222,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
OBD_ALLOC_PTR(target);
if (target == NULL)
- RETURN(-ENOMEM);
+ return -ENOMEM;
spin_lock(&fld->lcf_lock);
list_for_each_entry(tmp, &fld->lcf_targets, ft_chain) {
@@ -233,7 +231,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
OBD_FREE_PTR(target);
CERROR("Target %s exists in FLD and known as %s:#"LPU64"\n",
name, fld_target_name(tmp), tmp->ft_idx);
- RETURN(-EEXIST);
+ return -EEXIST;
}
}
@@ -249,7 +247,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
fld->lcf_count++;
spin_unlock(&fld->lcf_lock);
- RETURN(0);
+ return 0;
}
EXPORT_SYMBOL(fld_client_add_target);
@@ -257,7 +255,6 @@ EXPORT_SYMBOL(fld_client_add_target);
int fld_client_del_target(struct lu_client_fld *fld, __u64 idx)
{
struct lu_fld_target *target, *tmp;
- ENTRY;
spin_lock(&fld->lcf_lock);
list_for_each_entry_safe(target, tmp,
@@ -271,19 +268,20 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx)
class_export_put(target->ft_exp);
OBD_FREE_PTR(target);
- RETURN(0);
+ return 0;
}
}
spin_unlock(&fld->lcf_lock);
- RETURN(-ENOENT);
+ return -ENOENT;
}
EXPORT_SYMBOL(fld_client_del_target);
#ifdef LPROCFS
+struct proc_dir_entry *fld_type_proc_dir = NULL;
+
static int fld_client_proc_init(struct lu_client_fld *fld)
{
int rc;
- ENTRY;
fld->lcf_proc_dir = lprocfs_register(fld->lcf_name,
fld_type_proc_dir,
@@ -293,7 +291,7 @@ static int fld_client_proc_init(struct lu_client_fld *fld)
CERROR("%s: LProcFS failed in fld-init\n",
fld->lcf_name);
rc = PTR_ERR(fld->lcf_proc_dir);
- RETURN(rc);
+ return rc;
}
rc = lprocfs_add_vars(fld->lcf_proc_dir,
@@ -304,7 +302,7 @@ static int fld_client_proc_init(struct lu_client_fld *fld)
GOTO(out_cleanup, rc);
}
- RETURN(0);
+ return 0;
out_cleanup:
fld_client_proc_fini(fld);
@@ -313,13 +311,11 @@ out_cleanup:
void fld_client_proc_fini(struct lu_client_fld *fld)
{
- ENTRY;
if (fld->lcf_proc_dir) {
if (!IS_ERR(fld->lcf_proc_dir))
lprocfs_remove(&fld->lcf_proc_dir);
fld->lcf_proc_dir = NULL;
}
- EXIT;
}
#else
static int fld_client_proc_init(struct lu_client_fld *fld)
@@ -345,7 +341,6 @@ int fld_client_init(struct lu_client_fld *fld,
{
int cache_size, cache_threshold;
int rc;
- ENTRY;
LASSERT(fld != NULL);
@@ -355,7 +350,7 @@ int fld_client_init(struct lu_client_fld *fld,
if (!hash_is_sane(hash)) {
CERROR("%s: Wrong hash function %#x\n",
fld->lcf_name, hash);
- RETURN(-EINVAL);
+ return -EINVAL;
}
fld->lcf_count = 0;
@@ -381,7 +376,6 @@ int fld_client_init(struct lu_client_fld *fld,
rc = fld_client_proc_init(fld);
if (rc)
GOTO(out, rc);
- EXIT;
out:
if (rc)
fld_client_fini(fld);
@@ -395,7 +389,6 @@ EXPORT_SYMBOL(fld_client_init);
void fld_client_fini(struct lu_client_fld *fld)
{
struct lu_fld_target *target, *tmp;
- ENTRY;
spin_lock(&fld->lcf_lock);
list_for_each_entry_safe(target, tmp,
@@ -413,8 +406,6 @@ void fld_client_fini(struct lu_client_fld *fld)
fld_cache_fini(fld->lcf_cache);
fld->lcf_cache = NULL;
}
-
- EXIT;
}
EXPORT_SYMBOL(fld_client_fini);
@@ -426,7 +417,6 @@ int fld_client_rpc(struct obd_export *exp,
__u32 *op;
int rc;
struct obd_import *imp;
- ENTRY;
LASSERT(exp != NULL);
@@ -434,7 +424,7 @@ int fld_client_rpc(struct obd_export *exp,
req = ptlrpc_request_alloc_pack(imp, &RQF_FLD_QUERY, LUSTRE_MDS_VERSION,
FLD_QUERY);
if (req == NULL)
- RETURN(-ENOMEM);
+ return -ENOMEM;
op = req_capsule_client_get(&req->rq_pill, &RMF_FLD_OPC);
*op = fld_op;
@@ -464,7 +454,6 @@ int fld_client_rpc(struct obd_export *exp,
if (prange == NULL)
GOTO(out_req, rc = -EFAULT);
*range = *prange;
- EXIT;
out_req:
ptlrpc_req_finished(req);
return rc;
@@ -476,14 +465,13 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds,
struct lu_seq_range res = { 0 };
struct lu_fld_target *target;
int rc;
- ENTRY;
fld->lcf_flags |= LUSTRE_FLD_RUN;
rc = fld_cache_lookup(fld->lcf_cache, seq, &res);
if (rc == 0) {
*mds = res.lsr_index;
- RETURN(0);
+ return 0;
}
/* Can not find it in the cache */
@@ -496,19 +484,14 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds,
res.lsr_start = seq;
fld_range_set_type(&res, flags);
- if (target->ft_srv != NULL) {
- LASSERT(env != NULL);
- rc = fld_server_lookup(env, target->ft_srv, seq, &res);
- } else {
- rc = fld_client_rpc(target->ft_exp, &res, FLD_LOOKUP);
- }
+ rc = fld_client_rpc(target->ft_exp, &res, FLD_LOOKUP);
if (rc == 0) {
*mds = res.lsr_index;
fld_cache_insert(fld->lcf_cache, &res);
}
- RETURN(rc);
+ return rc;
}
EXPORT_SYMBOL(fld_client_lookup);
@@ -517,3 +500,32 @@ void fld_client_flush(struct lu_client_fld *fld)
fld_cache_flush(fld->lcf_cache);
}
EXPORT_SYMBOL(fld_client_flush);
+
+static int __init fld_mod_init(void)
+{
+ fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME,
+ proc_lustre_root,
+ NULL, NULL);
+ if (IS_ERR(fld_type_proc_dir))
+ return PTR_ERR(fld_type_proc_dir);
+
+ LU_CONTEXT_KEY_INIT(&fld_thread_key);
+ lu_context_key_register(&fld_thread_key);
+ return 0;
+}
+
+static void __exit fld_mod_exit(void)
+{
+ lu_context_key_degister(&fld_thread_key);
+ if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) {
+ lprocfs_remove(&fld_type_proc_dir);
+ fld_type_proc_dir = NULL;
+ }
+}
+
+MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
+MODULE_DESCRIPTION("Lustre FLD");
+MODULE_LICENSE("GPL");
+
+module_init(fld_mod_init)
+module_exit(fld_mod_exit)
diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index c1bd80339e67..052f7d51a07c 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -62,7 +62,6 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
struct lu_fld_target *target;
- ENTRY;
LASSERT(fld != NULL);
@@ -72,14 +71,13 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused)
seq_printf(m, "%s\n", fld_target_name(target));
spin_unlock(&fld->lcf_lock);
- RETURN(0);
+ return 0;
}
static int
fld_proc_hash_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
- ENTRY;
LASSERT(fld != NULL);
@@ -87,7 +85,7 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused)
seq_printf(m, "%s\n", fld->lcf_hash->fh_name);
spin_unlock(&fld->lcf_lock);
- RETURN(0);
+ return 0;
}
static ssize_t
@@ -97,7 +95,6 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer,
struct lu_client_fld *fld = ((struct seq_file *)file->private_data)->private;
struct lu_fld_hash *hash = NULL;
int i;
- ENTRY;
LASSERT(fld != NULL);
@@ -120,7 +117,7 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer,
fld->lcf_name, hash->fh_name);
}
- RETURN(count);
+ return count;
}
static ssize_t
@@ -128,7 +125,6 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
size_t count, loff_t *pos)
{
struct lu_client_fld *fld = file->private_data;
- ENTRY;
LASSERT(fld != NULL);
@@ -136,7 +132,7 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name);
- RETURN(count);
+ return count;
}
static int fld_proc_cache_flush_open(struct inode *inode, struct file *file)
@@ -158,202 +154,6 @@ struct file_operations fld_proc_cache_flush_fops = {
.release = fld_proc_cache_flush_release,
};
-struct fld_seq_param {
- struct lu_env fsp_env;
- struct dt_it *fsp_it;
- struct lu_server_fld *fsp_fld;
- unsigned int fsp_stop:1;
-};
-
-static void *fldb_seq_start(struct seq_file *p, loff_t *pos)
-{
- struct fld_seq_param *param = p->private;
- struct lu_server_fld *fld;
- struct dt_object *obj;
- const struct dt_it_ops *iops;
-
- if (param == NULL || param->fsp_stop)
- return NULL;
-
- fld = param->fsp_fld;
- obj = fld->lsf_obj;
- LASSERT(obj != NULL);
- iops = &obj->do_index_ops->dio_it;
-
- iops->load(&param->fsp_env, param->fsp_it, *pos);
-
- *pos = be64_to_cpu(*(__u64 *)iops->key(&param->fsp_env, param->fsp_it));
- return param;
-}
-
-static void fldb_seq_stop(struct seq_file *p, void *v)
-{
- struct fld_seq_param *param = p->private;
- const struct dt_it_ops *iops;
- struct lu_server_fld *fld;
- struct dt_object *obj;
-
- if (param == NULL)
- return;
-
- fld = param->fsp_fld;
- obj = fld->lsf_obj;
- LASSERT(obj != NULL);
- iops = &obj->do_index_ops->dio_it;
-
- iops->put(&param->fsp_env, param->fsp_it);
-}
-
-static void *fldb_seq_next(struct seq_file *p, void *v, loff_t *pos)
-{
- struct fld_seq_param *param = p->private;
- struct lu_server_fld *fld;
- struct dt_object *obj;
- const struct dt_it_ops *iops;
- int rc;
-
- if (param == NULL || param->fsp_stop)
- return NULL;
-
- fld = param->fsp_fld;
- obj = fld->lsf_obj;
- LASSERT(obj != NULL);
- iops = &obj->do_index_ops->dio_it;
-
- rc = iops->next(&param->fsp_env, param->fsp_it);
- if (rc > 0) {
- param->fsp_stop = 1;
- return NULL;
- }
-
- *pos = be64_to_cpu(*(__u64 *)iops->key(&param->fsp_env, param->fsp_it));
- return param;
-}
-
-static int fldb_seq_show(struct seq_file *p, void *v)
-{
- struct fld_seq_param *param = p->private;
- struct lu_server_fld *fld;
- struct dt_object *obj;
- const struct dt_it_ops *iops;
- struct fld_thread_info *info;
- struct lu_seq_range *fld_rec;
- int rc;
-
- if (param == NULL || param->fsp_stop)
- return 0;
-
- fld = param->fsp_fld;
- obj = fld->lsf_obj;
- LASSERT(obj != NULL);
- iops = &obj->do_index_ops->dio_it;
-
- info = lu_context_key_get(&param->fsp_env.le_ctx,
- &fld_thread_key);
- fld_rec = &info->fti_rec;
- rc = iops->rec(&param->fsp_env, param->fsp_it,
- (struct dt_rec *)fld_rec, 0);
- if (rc != 0) {
- CERROR("%s:read record error: rc %d\n",
- fld->lsf_name, rc);
- } else if (fld_rec->lsr_start != 0) {
- range_be_to_cpu(fld_rec, fld_rec);
- rc = seq_printf(p, DRANGE"\n", PRANGE(fld_rec));
- }
-
- return rc;
-}
-
-struct seq_operations fldb_sops = {
- .start = fldb_seq_start,
- .stop = fldb_seq_stop,
- .next = fldb_seq_next,
- .show = fldb_seq_show,
-};
-
-static int fldb_seq_open(struct inode *inode, struct file *file)
-{
- struct seq_file *seq;
- struct lu_server_fld *fld = (struct lu_server_fld *)PDE_DATA(inode);
- struct dt_object *obj;
- const struct dt_it_ops *iops;
- struct fld_seq_param *param = NULL;
- int env_init = 0;
- int rc;
-
- rc = seq_open(file, &fldb_sops);
- if (rc)
- GOTO(out, rc);
-
- obj = fld->lsf_obj;
- if (obj == NULL) {
- seq = file->private_data;
- seq->private = NULL;
- return 0;
- }
-
- OBD_ALLOC_PTR(param);
- if (param == NULL)
- GOTO(out, rc = -ENOMEM);
-
- rc = lu_env_init(&param->fsp_env, LCT_MD_THREAD);
- if (rc != 0)
- GOTO(out, rc);
-
- env_init = 1;
- iops = &obj->do_index_ops->dio_it;
- param->fsp_it = iops->init(&param->fsp_env, obj, 0, NULL);
- if (IS_ERR(param->fsp_it))
- GOTO(out, rc = PTR_ERR(param->fsp_it));
-
- param->fsp_fld = fld;
- param->fsp_stop = 0;
-
- seq = file->private_data;
- seq->private = param;
-out:
- if (rc != 0) {
- if (env_init == 1)
- lu_env_fini(&param->fsp_env);
- if (param != NULL)
- OBD_FREE_PTR(param);
- }
- return rc;
-}
-
-static int fldb_seq_release(struct inode *inode, struct file *file)
-{
- struct seq_file *seq = file->private_data;
- struct fld_seq_param *param;
- struct lu_server_fld *fld;
- struct dt_object *obj;
- const struct dt_it_ops *iops;
-
- param = seq->private;
- if (param == NULL) {
- lprocfs_seq_release(inode, file);
- return 0;
- }
-
- fld = param->fsp_fld;
- obj = fld->lsf_obj;
- LASSERT(obj != NULL);
- iops = &obj->do_index_ops->dio_it;
-
- LASSERT(iops != NULL);
- LASSERT(obj != NULL);
- LASSERT(param->fsp_it != NULL);
- iops->fini(&param->fsp_env, param->fsp_it);
- lu_env_fini(&param->fsp_env);
- OBD_FREE_PTR(param);
- lprocfs_seq_release(inode, file);
-
- return 0;
-}
-
-struct lprocfs_vars fld_server_proc_list[] = {
- { NULL }};
-
LPROC_SEQ_FOPS_RO(fld_proc_targets);
LPROC_SEQ_FOPS(fld_proc_hash);
@@ -363,11 +163,4 @@ struct lprocfs_vars fld_client_proc_list[] = {
{ "cache_flush", &fld_proc_cache_flush_fops },
{ NULL }};
-struct file_operations fld_proc_seq_fops = {
- .owner = THIS_MODULE,
- .open = fldb_seq_open,
- .read = seq_read,
- .release = fldb_seq_release,
-};
-
-#endif
+#endif /* LPROCFS */