Commit e62e5d92 authored by Liu Xuezhao's avatar Liu Xuezhao Committed by Greg Kroah-Hartman

staging/lustre/fld: prepare FLD module for client server split

Split FLD server from client, fld_{handler,index}.c are not compliled
unless server support is enabled.  Do not include dt_object.h or
lustre_mdt.h in lustre_fld.h and fix the minor breakages caused by
this elsewhere.  Generally cleanup includes in lustre/fld.
Signed-off-by: default avatarLiu Xuezhao <xuezhao.liu@emc.com>
Signed-off-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1330
Lustre-change: http://review.whamcloud.com/2675Reviewed-by: default avatarNathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarPeng Tao <tao.peng@emc.com>
Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 02524b20
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
This diff is collapsed.
This diff is collapsed.
......@@ -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
......@@ -219,5 +191,4 @@ fld_target_name(struct lu_fld_target *tar)
}
extern proc_dir_entry_t *fld_type_proc_dir;
extern struct file_operations fld_proc_seq_fops;
#endif /* __FLD_INTERNAL_H */
......@@ -60,6 +60,8 @@
#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)
......@@ -280,6 +282,8 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx)
EXPORT_SYMBOL(fld_client_del_target);
#ifdef LPROCFS
proc_dir_entry_t *fld_type_proc_dir = NULL;
static int fld_client_proc_init(struct lu_client_fld *fld)
{
int rc;
......@@ -496,12 +500,7 @@ 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);
}
if (rc == 0) {
*mds = res.lsr_index;
......@@ -517,3 +516,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)
......@@ -158,202 +158,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 +167,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 */
......@@ -43,9 +43,6 @@
*/
#include <lustre/lustre_idl.h>
#include <lustre_mdt.h>
#include <dt_object.h>
#include <linux/libcfs/libcfs.h>
struct lu_client_fld;
......@@ -129,47 +126,9 @@ struct lu_client_fld {
* Client fld proc entry name. */
char lcf_name[80];
const struct lu_context *lcf_ctx;
int lcf_flags;
};
/**
* number of blocks to reserve for particular operations. Should be function of
* ... something. Stub for now.
*/
enum {
/* one insert operation can involve two delete and one insert */
FLD_TXN_INDEX_INSERT_CREDITS = 60,
FLD_TXN_INDEX_DELETE_CREDITS = 20,
};
int fld_query(struct com_thread_info *info);
/* Server methods */
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);
void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld);
int fld_declare_server_create(const struct lu_env *env,
struct lu_server_fld *fld,
struct lu_seq_range *new,
struct thandle *th);
int fld_server_create(const struct lu_env *env,
struct lu_server_fld *fld,
struct lu_seq_range *add_range,
struct thandle *th);
int fld_insert_entry(const struct lu_env *env,
struct lu_server_fld *fld,
const struct lu_seq_range *range);
int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld,
seqno_t seq, struct lu_seq_range *range);
/* Client methods */
int fld_client_init(struct lu_client_fld *fld,
const char *prefix, int hash);
......
/*
* 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.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*/
#ifndef __LINUX_MDT_H
#define __LINUX_MDT_H
/** \defgroup mdt mdt
*
* @{
*/
#include <lustre/lustre_idl.h>
#include <lustre_req_layout.h>
#include <md_object.h>
#include <dt_object.h>
#include <linux/libcfs/libcfs.h>
/*
* Common thread info for mdt, seq and fld
*/
struct com_thread_info {
/*
* for req-layout interface.
*/
struct req_capsule *cti_pill;
};
enum {
ESERIOUS = 0x0001000
};
static inline int err_serious(int rc)
{
LASSERT(rc < 0);
LASSERT(-rc < ESERIOUS);
return -(-rc | ESERIOUS);
}
static inline int clear_serious(int rc)
{
if (rc < 0)
rc = -(-rc & ~ESERIOUS);
return rc;
}
static inline int is_serious(int rc)
{
return (rc < 0 && -rc & ESERIOUS);
}
/** @} mdt */
#endif
......@@ -43,6 +43,7 @@
#include <lustre_debug.h>
#include <lprocfs_status.h>
#include <cl_object.h>
#include <md_object.h>
#include <lustre_fid.h>
#include <lustre_acl.h>
#include <lustre_net.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment