From b5014aa1d82ff142a3a0e9dc49220446f083856b Mon Sep 17 00:00:00 2001 From: nfshp Date: Fri, 4 Apr 2003 14:27:33 +0000 Subject: [PATCH] re-organize the layout under liblustre --- lustre/liblustre/llite_lib.c | 169 +++++++++++++++++++++++++++++++++++++++++++ lustre/liblustre/llite_lib.h | 6 ++ lustre/liblustre/super.c | 133 +--------------------------------- 3 files changed, 176 insertions(+), 132 deletions(-) create mode 100644 lustre/liblustre/llite_lib.c diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c new file mode 100644 index 0000000..176e610 --- /dev/null +++ b/lustre/liblustre/llite_lib.c @@ -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 +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include /* needed for ptpctl.h */ +#include /* 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(¤t->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(); +} + diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h index dbd4f3e..561789a 100644 --- a/lustre/liblustre/llite_lib.h +++ b/lustre/liblustre/llite_lib.h @@ -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); diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 48bcd62..7b82410 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -36,84 +36,8 @@ #include #include -#include -#include -#include - -#include /* needed for ptpctl.h */ -#include /* 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(¤t->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); -} - -- 1.8.3.1