Whamcloud - gitweb
LU-1330 fld: prepare FLD module for client server split
[fs/lustre-release.git] / lustre / fld / fld_request.c
index 55e93cb..d9f2237 100644 (file)
@@ -45,7 +45,6 @@
 #ifdef __KERNEL__
 # include <libcfs/libcfs.h>
 # include <linux/module.h>
-# include <linux/jbd.h>
 # include <asm/div64.h>
 #else /* __KERNEL__ */
 # include <liblustre.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_req_layout.h>
 #include <lustre_fld.h>
 #include <lustre_mdc.h>
@@ -476,12 +471,12 @@ out_req:
 }
 
 int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds,
-                      __u32 flags, const struct lu_env *env)
+                     __u32 flags, const struct lu_env *env)
 {
-        struct lu_seq_range res;
-        struct lu_fld_target *target;
-        int rc;
-        ENTRY;
+       struct lu_seq_range res = { 0 };
+       struct lu_fld_target *target;
+       int rc;
+       ENTRY;
 
         fld->lcf_flags |= LUSTRE_FLD_RUN;
 
@@ -499,26 +494,25 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds,
                "target %s (idx "LPU64")\n", fld->lcf_name, seq,
                fld_target_name(target), target->ft_idx);
 
-        res.lsr_start = seq;
-        res.lsr_flags = flags;
-#ifdef __KERNEL__
-        if (target->ft_srv != NULL) {
+       res.lsr_start = seq;
+       fld_range_set_type(&res, flags);
+
+#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;
+       {
+               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);
 
@@ -527,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. <http://www.lustre.org/>");
+MODULE_DESCRIPTION("Lustre FLD");
+MODULE_LICENSE("GPL");
+
+cfs_module(mdd, LUSTRE_VERSION_STRING, fld_mod_init, fld_mod_exit);
+#endif /* __KERNEL__ */