Whamcloud - gitweb
re-organize the layout under liblustre
authornfshp <nfshp>
Fri, 4 Apr 2003 14:27:33 +0000 (14:27 +0000)
committernfshp <nfshp>
Fri, 4 Apr 2003 14:27:33 +0000 (14:27 +0000)
lustre/liblustre/llite_lib.c [new file with mode: 0644]
lustre/liblustre/llite_lib.h
lustre/liblustre/super.c

diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c
new file mode 100644 (file)
index 0000000..176e610
--- /dev/null
@@ -0,0 +1,169 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Lustre Light Super operations
+ *
+ *  Copyright (c) 2002, 2003 Cluster File Systems, Inc.
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Lustre 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 for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Lustre; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define DEBUG_SUBSYSTEM S_LLITE
+
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/queue.h>
+
+#include <sysio.h>
+#include <fs.h>
+#include <mount.h>
+#include <inode.h>
+#include <file.h>
+
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+
+#include <portals/api-support.h> /* needed for ptpctl.h */
+#include <portals/ptlctl.h>    /* needed for parse_dump */
+
+#include "llite_lib.h"
+
+
+ptl_handle_ni_t         tcpnal_ni;
+struct task_struct *current;
+struct obd_class_user_state ocus;
+
+/* portals interfaces */
+ptl_handle_ni_t *
+kportal_get_ni (int nal)
+{
+        return &tcpnal_ni;
+}
+
+inline void
+kportal_put_ni (int nal)
+{
+        return;
+}
+
+struct ldlm_namespace;
+struct ldlm_res_id;
+struct obd_import;
+
+extern int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, struct ldlm_res_id *res_id, int flags);
+extern int ldlm_namespace_cleanup(struct ldlm_namespace *ns, int local_only);
+extern int ldlm_replay_locks(struct obd_import *imp);
+
+void *inter_module_get(char *arg)
+{
+        if (!strcmp(arg, "tcpnal_ni"))
+                return &tcpnal_ni;
+        else if (!strcmp(arg, "ldlm_cli_cancel_unused"))
+                return ldlm_cli_cancel_unused;
+        else if (!strcmp(arg, "ldlm_namespace_cleanup"))
+                return ldlm_namespace_cleanup;
+        else if (!strcmp(arg, "ldlm_replay_locks"))
+                return ldlm_replay_locks;
+        else
+                return NULL;
+}
+
+void init_current(char *comm)
+{ 
+        current = malloc(sizeof(*current));
+        current->fs = malloc(sizeof(*current->fs));
+        strncpy(current->comm, comm, sizeof(current->comm));
+        current->pid = getpid();
+        current->fsuid = 0;
+        current->fsgid = 0;
+        current->cap_effective = 0;
+        memset(&current->pending, 0, sizeof(current->pending));
+}
+
+ptl_nid_t tcpnal_mynid;
+
+int init_lib_portals()
+{
+        int rc;
+
+        PtlInit();
+        rc = PtlNIInit(procbridge_interface, 0, 0, 0, &tcpnal_ni);
+        if (rc != 0) {
+                CERROR("ksocknal: PtlNIInit failed: error %d\n", rc);
+                PtlFini();
+                RETURN (rc);
+        }
+        PtlNIDebug(tcpnal_ni, ~0);
+        return rc;
+}
+
+extern int class_handle_ioctl(struct obd_class_user_state *ocus, unsigned int cmd, unsigned long arg);
+
+int lib_ioctl(int dev_id, int opc, void * ptr)
+{
+        int rc;
+
+       if (dev_id == OBD_DEV_ID) {
+                struct obd_ioctl_data *ioc = ptr;
+               rc = class_handle_ioctl(&ocus, opc, (unsigned long)ptr);
+
+               /* you _may_ need to call obd_ioctl_unpack or some
+                  other verification function if you want to use ioc
+                  directly here */
+               printf ("processing ioctl cmd: %x buf len: %d, rc %d\n", 
+                       opc,  ioc->ioc_len, rc);
+
+                if (rc)
+                        return rc;
+       }
+       return (0);
+}
+
+int lllib_init(char *arg)
+{
+       tcpnal_mynid = ntohl(inet_addr(arg));
+        INIT_LIST_HEAD(&ocus.ocus_conns);
+
+        init_current("dummy");
+        if (init_obdclass() ||
+            init_lib_portals() ||
+            ptlrpc_init() ||
+            ldlm_init() ||
+            mdc_init() ||
+            lov_init() ||
+            osc_init())
+                return -1;
+
+       if (parse_dump("/tmp/DUMP_FILE", lib_ioctl))
+                return -1;
+
+        return _sysio_fssw_register("llite", &llu_fssw_ops);
+}
+
+/* FIXME */
+void generate_random_uuid(unsigned char uuid_out[16])
+{
+        int *arr = (int*)uuid_out;
+        int i;
+
+        for (i = 0; i < sizeof(uuid_out)/sizeof(int); i++)
+                arr[i] = rand();
+}
+
index dbd4f3e..561789a 100644 (file)
@@ -86,6 +86,10 @@ static inline struct lustre_handle *llu_i2obdconn(struct inode *inode)
         return &(llu_i2info(inode)->lli_sbi->ll_osc_conn);
 }
 
+
+/* llite_lib.c */
+void generate_random_uuid(unsigned char uuid_out[16]);
+
 /* super.c */
 void llu_update_inode(struct inode *inode, struct mds_body *body,
                       struct lov_mds_md *lmm);
@@ -93,6 +97,8 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid);
 void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid);
 struct inode* llu_new_inode(struct filesys *fs, ino_t ino, mode_t mode);
 
+extern struct fssw_ops llu_fssw_ops;
+
 /* file.c */
 int llu_create(struct inode *dir, struct pnode_base *pnode, int mode);
 int llu_iop_open(struct pnode *pnode, int flags, mode_t mode);
index 48bcd62..7b82410 100644 (file)
 #include <inode.h>
 #include <file.h>
 
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-
-#include <portals/api-support.h> /* needed for ptpctl.h */
-#include <portals/ptlctl.h>    /* needed for parse_dump */
-
 #include "llite_lib.h"
 
-
-ptl_handle_ni_t         tcpnal_ni;
-struct task_struct *current;
-struct obd_class_user_state ocus;
-
-/* portals interfaces */
-ptl_handle_ni_t *
-kportal_get_ni (int nal)
-{
-        return &tcpnal_ni;
-}
-
-inline void
-kportal_put_ni (int nal)
-{
-        return;
-}
-
-struct ldlm_namespace;
-struct ldlm_res_id;
-struct obd_import;
-
-extern int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, struct ldlm_res_id *res_id, int flags);
-extern int ldlm_namespace_cleanup(struct ldlm_namespace *ns, int local_only);
-extern int ldlm_replay_locks(struct obd_import *imp);
-
-void *inter_module_get(char *arg)
-{
-        if (!strcmp(arg, "tcpnal_ni"))
-                return &tcpnal_ni;
-        else if (!strcmp(arg, "ldlm_cli_cancel_unused"))
-                return ldlm_cli_cancel_unused;
-        else if (!strcmp(arg, "ldlm_namespace_cleanup"))
-                return ldlm_namespace_cleanup;
-        else if (!strcmp(arg, "ldlm_replay_locks"))
-                return ldlm_replay_locks;
-        else
-                return NULL;
-}
-
-void init_current(char *comm)
-{ 
-        current = malloc(sizeof(*current));
-        current->fs = malloc(sizeof(*current->fs));
-        strncpy(current->comm, comm, sizeof(current->comm));
-        current->pid = getpid();
-        current->fsuid = 0;
-        current->fsgid = 0;
-        current->cap_effective = 0;
-        memset(&current->pending, 0, sizeof(current->pending));
-}
-
-ptl_nid_t tcpnal_mynid;
-
-int init_lib_portals()
-{
-        int rc;
-
-        PtlInit();
-        rc = PtlNIInit(procbridge_interface, 0, 0, 0, &tcpnal_ni);
-        if (rc != 0) {
-                CERROR("ksocknal: PtlNIInit failed: error %d\n", rc);
-                PtlFini();
-                RETURN (rc);
-        }
-        PtlNIDebug(tcpnal_ni, ~0);
-        return rc;
-}
-
 static void llu_fsop_gone(struct filesys *fs)
 {
         /* FIXME */
@@ -387,16 +311,6 @@ struct filesys_ops llu_filesys_ops =
         fsop_gone: llu_fsop_gone,
 };
 
-/* FIXME */
-void generate_random_uuid(unsigned char uuid_out[16])
-{
-        int *arr = (int*)uuid_out;
-        int i;
-
-        for (i = 0; i < sizeof(uuid_out)/sizeof(int); i++)
-                arr[i] = rand();
-}
-
 
 static struct inode_ops llu_inode_ops = {
         inop_lookup:    llu_iop_lookup,
@@ -429,7 +343,6 @@ llu_fsswop_mount(const char *source,
         class_uuid_t uuid;
         struct obd_device *obd;
         char *osc="lov1_UUID";
-//        char *mdc="57f5ded574_MDC_lov1_mds1_a8c55ce8f1"; /* FIXME */
         char *mdc="853fe49c56_MDC_lov1_mds1_704cccf8fd";
         int err = -EINVAL;
 
@@ -550,51 +463,7 @@ out_free:
         return err;
 }
 
-static struct fssw_ops llu_fssw_ops = {
+struct fssw_ops llu_fssw_ops = {
         llu_fsswop_mount
 };
 
-extern int class_handle_ioctl(struct obd_class_user_state *ocus, unsigned int cmd, unsigned long arg);
-
-
-int lib_ioctl(int dev_id, int opc, void * ptr)
-{
-        int rc;
-
-       if (dev_id == OBD_DEV_ID) {
-                struct obd_ioctl_data *ioc = ptr;
-               rc = class_handle_ioctl(&ocus, opc, (unsigned long)ptr);
-
-               /* you _may_ need to call obd_ioctl_unpack or some
-                  other verification function if you want to use ioc
-                  directly here */
-               printf ("processing ioctl cmd: %x buf len: %d, rc %d\n", 
-                       opc,  ioc->ioc_len, rc);
-
-                if (rc)
-                        return rc;
-       }
-       return (0);
-}
-
-int lllib_init(char *arg)
-{
-       tcpnal_mynid = ntohl(inet_addr(arg));
-        INIT_LIST_HEAD(&ocus.ocus_conns);
-
-        init_current("dummy");
-        if (init_obdclass() ||
-            init_lib_portals() ||
-            ptlrpc_init() ||
-            ldlm_init() ||
-            mdc_init() ||
-            lov_init() ||
-            osc_init())
-                return -1;
-
-       if (parse_dump("/tmp/DUMP_FILE", lib_ioctl))
-                return -1;
-
-        return _sysio_fssw_register("llite", &llu_fssw_ops);
-}
-