Whamcloud - gitweb
LU-1330 fld: prepare FLD module for client server split
[fs/lustre-release.git] / lustre / fld / fld_request.c
index 995581a..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>
@@ -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. <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__ */