From: Liu Xuezhao Date: Fri, 15 Mar 2013 00:01:06 +0000 (-0500) Subject: LU-1330 fld: prepare FLD module for client server split X-Git-Tag: 2.4.51~1 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c50a9e2ae39df781598696dae4f33d60199a84dd LU-1330 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: Liu Xuezhao Signed-off-by: John L. Hammond Change-Id: I60a43934f9aa391689e376f68d249b7244645713 Reviewed-on: http://review.whamcloud.com/2675 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Nathaniel Clark Reviewed-by: Andreas Dilger --- diff --git a/lustre/fld/Makefile.in b/lustre/fld/Makefile.in index 2887277..e869668 100644 --- a/lustre/fld/Makefile.in +++ b/lustre/fld/Makefile.in @@ -1,6 +1,7 @@ -MODULES := fld -fld-objs := fld_handler.o fld_request.o fld_cache.o fld_index.o lproc_fld.o +MODULES := fld +fld-objs := fld_request.o fld_cache.o lproc_fld.o +@SERVER_TRUE@fld-objs += fld_handler.o fld_index.o -EXTRA_PRE_CFLAGS := -I@LUSTRE@ -I@LUSTRE@/ldiskfs +EXTRA_PRE_CFLAGS := -I@LUSTRE@ @INCLUDE_RULES@ diff --git a/lustre/fld/autoMakefile.am b/lustre/fld/autoMakefile.am index aaadac6..a8aa63a 100644 --- a/lustre/fld/autoMakefile.am +++ b/lustre/fld/autoMakefile.am @@ -36,7 +36,7 @@ if LIBLUSTRE noinst_LIBRARIES = libfld.a -libfld_a_SOURCES = fld_handler.c fld_request.c fld_cache.c lproc_fld.c fld_internal.h +libfld_a_SOURCES = fld_request.c fld_cache.c lproc_fld.c fld_internal.h libfld_a_CPPFLAGS = $(LLCPPFLAGS) libfld_a_CFLAGS = $(LLCFLAGS) endif @@ -45,5 +45,5 @@ if MODULES modulefs_DATA = fld$(KMODEXT) endif -MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ +MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ EXTRA_DIST := $(fld-objs:%.o=%.c) fld_internal.h diff --git a/lustre/fld/fld_cache.c b/lustre/fld/fld_cache.c index 632efea..2b6a4e4 100644 --- a/lustre/fld/fld_cache.c +++ b/lustre/fld/fld_cache.c @@ -46,22 +46,13 @@ #ifdef __KERNEL__ # include # include -# include # include #else /* __KERNEL__ */ # include # include #endif -#include -#include -#include #include -#include - -#include -#include -#include #include #include "fld_internal.h" @@ -276,9 +267,9 @@ void fld_cache_flush(struct fld_cache *cache) * entry accordingly. */ -void fld_cache_punch_hole(struct fld_cache *cache, - struct fld_cache_entry *f_curr, - struct fld_cache_entry *f_new) +static void fld_cache_punch_hole(struct fld_cache *cache, + struct fld_cache_entry *f_curr, + struct fld_cache_entry *f_new) { const struct lu_seq_range *range = &f_new->fce_range; const seqno_t new_start = range->lsr_start; @@ -499,9 +490,9 @@ void fld_cache_delete(struct fld_cache *cache, write_unlock(&cache->fci_lock); } -struct fld_cache_entry -*fld_cache_entry_lookup_nolock(struct fld_cache *cache, - struct lu_seq_range *range) +struct fld_cache_entry * +fld_cache_entry_lookup_nolock(struct fld_cache *cache, + const struct lu_seq_range *range) { struct fld_cache_entry *flde; struct fld_cache_entry *got = NULL; @@ -523,8 +514,9 @@ struct fld_cache_entry /** * lookup \a seq sequence for range in fld cache. */ -struct fld_cache_entry -*fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range) +struct fld_cache_entry * +fld_cache_entry_lookup(struct fld_cache *cache, + const struct lu_seq_range *range) { struct fld_cache_entry *got = NULL; ENTRY; @@ -532,6 +524,7 @@ struct fld_cache_entry read_lock(&cache->fci_lock); got = fld_cache_entry_lookup_nolock(cache, range); read_unlock(&cache->fci_lock); + RETURN(got); } @@ -569,4 +562,3 @@ int fld_cache_lookup(struct fld_cache *cache, read_unlock(&cache->fci_lock); RETURN(-ENOENT); } - diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 84d90ce..9d6d138 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -44,29 +44,17 @@ #define DEBUG_SUBSYSTEM S_FLD -#ifdef __KERNEL__ -# include -# include -# include -# include -#else /* __KERNEL__ */ -# include -# include -#endif +#include +#include #include -#include -#include #include -#include - -#include #include +#include +#include /* err_serious() */ #include +#include #include "fld_internal.h" -#include - -#ifdef __KERNEL__ /* context key constructor/destructor: fld_key_init, fld_key_fini */ LU_KEY_INIT_FINI(fld, struct fld_thread_info); @@ -74,33 +62,20 @@ 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); -cfs_proc_dir_entry_t *fld_type_proc_dir = NULL; - -static int __init fld_mod_init(void) +int fld_server_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; + LU_CONTEXT_KEY_INIT(&fld_thread_key); + return lu_context_key_register(&fld_thread_key); } -static void __exit fld_mod_exit(void) +void fld_server_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; - } + lu_context_key_degister(&fld_thread_key); } int fld_declare_server_create(const struct lu_env *env, struct lu_server_fld *fld, - struct lu_seq_range *range, + const struct lu_seq_range *range, struct thandle *th) { int rc; @@ -117,7 +92,7 @@ EXPORT_SYMBOL(fld_declare_server_create); * 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) + const struct lu_seq_range *range, struct thandle *th) { int rc; @@ -445,10 +420,3 @@ void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld) EXIT; } EXPORT_SYMBOL(fld_server_fini); - -MODULE_AUTHOR("Sun Microsystems, Inc. "); -MODULE_DESCRIPTION("Lustre FLD"); -MODULE_LICENSE("GPL"); - -cfs_module(mdd, "0.1.0", fld_mod_init, fld_mod_exit); -#endif diff --git a/lustre/fld/fld_index.c b/lustre/fld/fld_index.c index 577d388..c9a3546 100644 --- a/lustre/fld/fld_index.c +++ b/lustre/fld/fld_index.c @@ -44,25 +44,17 @@ #ifdef __KERNEL__ # include # include -# include #else /* __KERNEL__ */ # include #endif -#include -#include -#include #include -#include - #include -#include -#include #include #include #include "fld_internal.h" -const char fld_index_name[] = "fld"; +static const char fld_index_name[] = "fld"; static const struct lu_seq_range IGIF_FLD_RANGE = { .lsr_start = FID_SEQ_IGIF, @@ -85,7 +77,7 @@ static const struct lu_seq_range ROOT_FLD_RANGE = { .lsr_flags = LU_SEQ_RANGE_MDT }; -const struct dt_index_features fld_index_features = { +static 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), @@ -138,10 +130,10 @@ int fld_declare_index_create(const struct lu_env *env, fld->lsf_name, PRANGE(range), rc); GOTO(out, rc); } - memcpy(tmp, new_range, sizeof(*new_range)); + *tmp = *new_range; tmp->lsr_start = range->lsr_start; } else { - memcpy(tmp, new_range, sizeof(*new_range)); + *tmp = *new_range; } range_cpu_to_be(tmp, tmp); @@ -200,11 +192,11 @@ int fld_index_create(const struct lu_env *env, struct lu_server_fld *fld, BYPASS_CAPA); if (rc != 0) GOTO(out, rc); - memcpy(tmp, new_range, sizeof(*new_range)); + *tmp = *new_range; tmp->lsr_start = range->lsr_start; deleted = 1; } else { - memcpy(tmp, new_range, sizeof(*new_range)); + *tmp = *new_range; } range_cpu_to_be(tmp, tmp); diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index fbb050a..e95ad9f 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -41,11 +41,9 @@ #ifndef __FLD_INTERNAL_H #define __FLD_INTERNAL_H +#include #include -#include - #include -#include #include enum { @@ -56,7 +54,6 @@ enum { struct fld_stats { __u64 fst_count; __u64 fst_cache; - __u64 fst_inflight; }; typedef int (*fld_hash_func_t) (struct lu_client_fld *, __u64); @@ -141,16 +138,23 @@ extern struct lu_fld_hash fld_hash[]; #ifdef __KERNEL__ +# ifdef LPROCFS +extern struct proc_dir_entry *fld_type_proc_dir; +extern struct lprocfs_vars fld_client_proc_list[]; +# endif + +# ifdef HAVE_SERVER_SUPPORT +struct req_capsule; 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; + struct req_capsule *fti_pill; + 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; +struct dt_device; int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld, struct dt_device *dt); @@ -158,24 +162,30 @@ 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, + const struct lu_seq_range *new_range, 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); + const struct lu_seq_range *new_range, 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); +int fld_server_mod_init(void); -#ifdef LPROCFS +void fld_server_mod_exit(void); + +# ifdef LPROCFS +extern const struct file_operations fld_proc_seq_fops; extern struct lprocfs_vars fld_server_proc_list[]; -extern struct lprocfs_vars fld_client_proc_list[]; -#endif +# endif -#endif +# endif /* HAVE_SERVER_SUPPORT */ + +int fld_client_rpc(struct obd_export *exp, + struct lu_seq_range *range, __u32 fld_op); + +#endif /* __KERNEL__ */ struct fld_cache *fld_cache_init(const char *name, int cache_size, int cache_threshold); @@ -199,27 +209,26 @@ void fld_cache_delete_nolock(struct fld_cache *cache, int fld_cache_lookup(struct fld_cache *cache, const seqno_t seq, struct lu_seq_range *range); -struct fld_cache_entry* -fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range); +struct fld_cache_entry * +fld_cache_entry_lookup(struct fld_cache *cache, + const struct lu_seq_range *range); + void fld_cache_entry_delete(struct fld_cache *cache, struct fld_cache_entry *node); -void fld_dump_cache_entries(struct fld_cache *cache); -struct fld_cache_entry -*fld_cache_entry_lookup_nolock(struct fld_cache *cache, - struct lu_seq_range *range); -int fld_write_range(const struct lu_env *env, struct dt_object *dt, - const struct lu_seq_range *range, struct thandle *th); +struct fld_cache_entry * +fld_cache_entry_lookup_nolock(struct fld_cache *cache, + const struct lu_seq_range *range); static inline const char * -fld_target_name(struct lu_fld_target *tar) +fld_target_name(const struct lu_fld_target *tar) { - if (tar->ft_srv != NULL) - return tar->ft_srv->lsf_name; +#ifdef HAVE_SERVER_SUPPORT + if (tar->ft_srv != NULL) + return tar->ft_srv->lsf_name; +#endif - return (const char *)tar->ft_exp->exp_obd->obd_name; + return tar->ft_exp->exp_obd->obd_name; } -extern cfs_proc_dir_entry_t *fld_type_proc_dir; -extern struct file_operations fld_proc_seq_fops; #endif /* __FLD_INTERNAL_H */ diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index 995581a..d9f2237 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -45,7 +45,6 @@ #ifdef __KERNEL__ # include # include -# include # include #else /* __KERNEL__ */ # include @@ -54,12 +53,8 @@ #include #include -#include #include #include - -#include -#include #include #include #include @@ -501,22 +496,22 @@ 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); -#ifdef __KERNEL__ + +#if defined(__KERNEL__) && defined(HAVE_SERVER_SUPPORT) if (target->ft_srv != NULL) { LASSERT(env != NULL); rc = fld_server_lookup(env, target->ft_srv, seq, &res); - } else { + } else #endif + { rc = fld_client_rpc(target->ft_exp, &res, FLD_LOOKUP); -#ifdef __KERNEL__ } -#endif if (rc == 0) { *mds = res.lsr_index; - fld_cache_insert(fld->lcf_cache, &res); } + RETURN(rc); } EXPORT_SYMBOL(fld_client_lookup); @@ -526,3 +521,41 @@ void fld_client_flush(struct lu_client_fld *fld) fld_cache_flush(fld->lcf_cache); } EXPORT_SYMBOL(fld_client_flush); + +#ifdef __KERNEL__ + +struct proc_dir_entry *fld_type_proc_dir; + +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); + +#ifdef HAVE_SERVER_SUPPORT + fld_server_mod_init(); +#endif + + return 0; +} + +static void __exit fld_mod_exit(void) +{ +#ifdef HAVE_SERVER_SUPPORT + fld_server_mod_exit(); +#endif + + 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. "); +MODULE_DESCRIPTION("Lustre FLD"); +MODULE_LICENSE("GPL"); + +cfs_module(mdd, LUSTRE_VERSION_STRING, fld_mod_init, fld_mod_exit); +#endif /* __KERNEL__ */ diff --git a/lustre/fld/lproc_fld.c b/lustre/fld/lproc_fld.c index c68f3c4..97bd3d5 100644 --- a/lustre/fld/lproc_fld.c +++ b/lustre/fld/lproc_fld.c @@ -50,12 +50,8 @@ # include #endif -#include -#include #include -#include #include -#include #include #include #include "fld_internal.h" @@ -161,6 +157,14 @@ struct fld_seq_param { unsigned int fsp_stop:1; }; +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 } +}; + +# ifdef HAVE_SERVER_SUPPORT static void *fldb_seq_start(struct seq_file *p, loff_t *pos) { struct fld_seq_param *param = p->private; @@ -350,20 +354,17 @@ static int fldb_seq_release(struct inode *inode, struct file *file) return 0; } -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 }}; - -struct file_operations fld_proc_seq_fops = { +const struct file_operations fld_proc_seq_fops = { .owner = THIS_MODULE, .open = fldb_seq_open, .read = seq_read, .release = fldb_seq_release, }; -#endif +struct lprocfs_vars fld_server_proc_list[] = { + { NULL } +}; + +# endif /* HAVE_SERVER_SUPPORT */ + +#endif /* LPROCFS */ diff --git a/lustre/include/lustre_fld.h b/lustre/include/lustre_fld.h index c6784c5..e9f35a1 100644 --- a/lustre/include/lustre_fld.h +++ b/lustre/include/lustre_fld.h @@ -43,18 +43,16 @@ */ #include -#include -#include - #include +struct lu_env; struct lu_client_fld; struct lu_server_fld; struct lu_fld_hash; struct fld_cache; - -extern const struct dt_index_features fld_index_features; -extern const char fld_index_name[]; +struct thandle; +struct dt_device; +struct dt_object; /* * FLD (Fid Location Database) interface. @@ -64,12 +62,11 @@ enum { LUSTRE_CLI_FLD_HASH_RRB }; - struct lu_fld_target { - cfs_list_t ft_chain; - struct obd_export *ft_exp; - struct lu_server_fld *ft_srv; - __u64 ft_idx; + cfs_list_t ft_chain; + struct obd_export *ft_exp; + struct lu_server_fld *ft_srv; + __u64 ft_idx; }; struct lu_server_fld { @@ -129,21 +126,10 @@ 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 lcf_flags; }; +struct com_thread_info; int fld_query(struct com_thread_info *info); /* Server methods */ @@ -155,12 +141,12 @@ 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, + const struct lu_seq_range *range, struct thandle *th); int fld_server_create(const struct lu_env *env, struct lu_server_fld *fld, - struct lu_seq_range *add_range, + const struct lu_seq_range *add_range, struct thandle *th); int fld_insert_entry(const struct lu_env *env, diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 0f72f8e..4537c7b 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -64,13 +64,6 @@ struct md_object; struct obd_export; enum { - UCRED_INVALID = -1, - UCRED_INIT = 0, - UCRED_OLD = 1, - UCRED_NEW = 2 -}; - -enum { MD_CAPAINFO_MAX = 5 }; @@ -858,6 +851,13 @@ int lustre_buf2som(void *buf, int rc, struct md_som_data *msd); int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh); void lustre_hsm2buf(void *buf, struct md_hsm *mh); +enum { + UCRED_INVALID = -1, + UCRED_INIT = 0, + UCRED_OLD = 1, + UCRED_NEW = 2, +}; + struct lu_ucred { __u32 uc_valid; __u32 uc_o_uid; diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index e459c44..5437f71 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c index 273daee..7516ba5 100644 --- a/lustre/lfsck/lfsck_namespace.c +++ b/lustre/lfsck/lfsck_namespace.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 446c7c9..0597b6c 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 503a8bf..a956f62 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c index ebd5c1b..35bbed0 100644 --- a/lustre/osd-zfs/osd_handler.c +++ b/lustre/osd-zfs/osd_handler.c @@ -57,6 +57,7 @@ #include #include #include +#include #include "osd_internal.h" diff --git a/lustre/quota/qmt_internal.h b/lustre/quota/qmt_internal.h index d83ff83..277f4c9 100644 --- a/lustre/quota/qmt_internal.h +++ b/lustre/quota/qmt_internal.h @@ -25,11 +25,12 @@ * Use is subject to license terms. */ -#include "lquota_internal.h" - #ifndef _QMT_INTERNAL_H #define _QMT_INTERNAL_H +#include /* err_serious() */ +#include "lquota_internal.h" + /* * The Quota Master Target Device. * The qmt is responsible for: