Whamcloud - gitweb
- name switch: "light" --> "lite"
authorbraam <braam>
Mon, 8 Apr 2002 18:28:50 +0000 (18:28 +0000)
committerbraam <braam>
Mon, 8 Apr 2002 18:28:50 +0000 (18:28 +0000)
                "/mnt/obd" --> "/mnt/lustre"
- small changes to RPC code to handle request packet freeing later,
  separate connection initialization and connect.
- rename event handlers and queues, add separate request_out and
  reply_out queue

34 files changed:
lustre/doc/Makefile.am
lustre/include/linux/lustre_ha.h [new file with mode: 0644]
lustre/include/linux/lustre_lite.h [moved from lustre/include/linux/lustre_light.h with 98% similarity]
lustre/include/linux/lustre_net.h
lustre/ldlm/ldlm_lockd.c
lustre/llite/Makefile.am
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_ha.c [new file with mode: 0644]
lustre/llite/namei.c
lustre/llite/rw.c
lustre/llite/super.c
lustre/llite/symlink.c
lustre/mdc/mdc_request.c
lustre/obdfs/namei.c
lustre/osc/osc_request.c
lustre/ptlrpc/client.c
lustre/ptlrpc/events.c
lustre/ptlrpc/niobuf.c
lustre/ptlrpc/service.c
lustre/tests/common.sh
lustre/tests/llext3.sh
lustre/tests/lllocalmount.sh
lustre/tests/llmount-client.sh
lustre/tests/llmount.sh
lustre/tests/llmountcleanup.sh
lustre/tests/llrext3.sh
lustre/tests/llrmount.sh
lustre/tests/mdcreqcleanup.sh
lustre/tests/rundbench
lustre/tests/runfailure-mds
lustre/tests/runfailure-net
lustre/tests/runiozone
lustre/tests/runtests

index a0c5952..34895bf 100644 (file)
@@ -25,4 +25,3 @@ dist-hook:
        rm -rf $(distdir)/figs/CVS
 
 include $(top_srcdir)/Rules
-
diff --git a/lustre/include/linux/lustre_ha.h b/lustre/include/linux/lustre_ha.h
new file mode 100644 (file)
index 0000000..715055b
--- /dev/null
@@ -0,0 +1,22 @@
+
+#define MGR_STOPPING   1
+#define MGR_RUNNING    2
+#define MGR_STOPPED    4
+#define MGR_KILLED     8
+#define MGR_EVENT      16
+#define MGR_RECOVERING 32
+#define MGR_SIGNAL     64
+
+struct lustre_ha_mgr {
+        __u32               mgr_flags; 
+        struct task_struct *mgr_thread;
+        wait_queue_head_t   mgr_waitq;
+        wait_queue_head_t   mgr_ctl_waitq;
+        spinlock_t          mgr_lock;
+};
+
+struct lustre_ha_thread { 
+        char                 *name;
+        struct lustre_ha_mgr *mgr; 
+        struct obd_device    *dev;
+}; 
similarity index 98%
rename from lustre/include/linux/lustre_light.h
rename to lustre/include/linux/lustre_lite.h
index 80d2bd8..80dc7cd 100644 (file)
@@ -3,10 +3,10 @@
  * This code is issued under the GNU General Public License.
  * See the file COPYING in this distribution
  * 
- * Copyright (C), 1999, Stelias Computing Inc
  *
  *
- */
+ *
+
 
 
 #ifndef _LL_H
@@ -18,6 +18,8 @@
 #include <linux/lustre_mds.h>
 #include <linux/obdo.h>
 
+#define LUSTRE_LITE_NAME "llite"
+
 extern kmem_cache_t *ll_file_data_slab;
 struct ll_file_data { 
         __u64 fd_mdshandle; 
index 2384685..c211ec1 100644 (file)
 struct ptlrpc_client {
         struct lustre_peer cli_server;
         struct obd_device *cli_obd;
+        struct list_head cli_sending_head;
+        struct list_head cli_sent_head;
         __u32 cli_request_portal;
         __u32 cli_reply_portal;
 
         spinlock_t cli_lock;
         __u32 cli_xid;
+        __u32 cli_generation;  /* changes upon new connection */
+        __u32 cli_epoch;       /* changes when peer changes */
+        __u32 cli_bootcount;   /* peer's boot count */ 
         struct semaphore cli_rpc_sem;
 };
 
@@ -122,6 +127,7 @@ struct ptlrpc_request {
         __u32 rq_req_portal;
 
         struct lustre_peer rq_peer;
+        struct ptlrpc_client *rq_client;
 };
 
 struct ptlrpc_bulk_desc {
@@ -194,8 +200,9 @@ int ptl_send_rpc(struct ptlrpc_request *request, struct ptlrpc_client *cl);
 void ptlrpc_link_svc_me(struct ptlrpc_service *service, int i);
 
 /* rpc/client.c */
-int ptlrpc_connect_client(int dev, char *uuid, int req_portal, int rep_portal,
-                          struct ptlrpc_client *cl);
+void ptlrpc_init_client(int dev, int req_portal, int rep_portal,
+                       struct ptlrpc_client *cl);
+int ptlrpc_connect_client(int dev, char *uuid, struct ptlrpc_client *cl);
 int ptlrpc_queue_wait(struct ptlrpc_client *cl, struct ptlrpc_request *req);
 int ptlrpc_queue_req(struct ptlrpc_client *peer, struct ptlrpc_request *req);
 struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl, int opcode,
index b2359eb..4f384f1 100644 (file)
@@ -155,9 +155,8 @@ static int ldlm_iocontrol(int cmd, struct obd_conn *conn, int len, void *karg,
                 return -EINVAL;
         }
 
-        err = ptlrpc_connect_client(-1, "ldlm",
-                                    LDLM_REQUEST_PORTAL, LDLM_REPLY_PORTAL,
-                                    &cl);
+        ptlrpc_init_client(-1, LDLM_REQUEST_PORTAL, LDLM_REPLY_PORTAL, &cl);
+        err = ptlrpc_connect_client(-1, "ldlm", &cl);
         if (err) {
                 CERROR("cannot create client\n");
                 RETURN(-EINVAL);
index 2d095b4..acf6597 100644 (file)
@@ -5,16 +5,16 @@
 
 DEFS:= 
 
-MODULE = llight
-modulefs_DATA = llight.o
-EXTRA_PROGRAMS = llight
+MODULE = llite
+modulefs_DATA = llite.o
+EXTRA_PROGRAMS = llite
 
 page.c: 
        -ln -s ../lib/page.c
 
 
 LINX=page.c
-llight_SOURCES =  page.c super.c rw.c file.c dir.c sysctl.c namei.c symlink.c
+llite_SOURCES =  llite_ha.c page.c super.c rw.c file.c dir.c sysctl.c namei.c symlink.c
 
 dist-hook:
        list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done
index 97468c3..93d17d7 100644 (file)
 #include <linux/locks.h>
 #include <asm/uaccess.h>
 
-#define DEBUG_SUBSYSTEM S_LLIGHT
+#define DEBUG_SUBSYSTEM S_LLITE
 
 #include <linux/obd_support.h>
 #include <linux/obd_class.h>
 #include <linux/lustre_lib.h>
 #include <linux/lustre_idl.h>
 #include <linux/lustre_mds.h>
-#include <linux/lustre_light.h>
+#include <linux/lustre_lite.h>
 
 typedef struct ext2_dir_entry_2 ext2_dirent;
 
index 71d2b95..2eb2829 100644 (file)
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 
-#define DEBUG_SUBSYSTEM S_LLIGHT
+#define DEBUG_SUBSYSTEM S_LLITE
 
 #include <linux/obd_support.h>
-#include <linux/lustre_light.h>
+#include <linux/lustre_lite.h>
 
 int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc);
 extern int ll_setattr(struct dentry *de, struct iattr *attr);
diff --git a/lustre/llite/llite_ha.c b/lustre/llite/llite_ha.c
new file mode 100644 (file)
index 0000000..2657d33
--- /dev/null
@@ -0,0 +1,143 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  linux/mds/handler.c
+ *
+ *  Lustre Metadata Server (mds) request handler
+ *
+ *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
+ *
+ *  This code is issued under the GNU General Public License.
+ *  See the file COPYING in this distribution
+ *
+ *  by Peter Braam <braam@clusterfs.com>
+ *
+ *  This server is single threaded at present (but can easily be multi threaded)
+ *
+ */
+
+#define EXPORT_SYMTAB
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/stat.h>
+#include <linux/locks.h>
+#include <linux/quotaops.h>
+#include <asm/unistd.h>
+#include <asm/uaccess.h>
+
+#define DEBUG_SUBSYSTEM S_LLITE
+
+#include <linux/lustre_lite.h>
+#include <linux/lustre_ha.h>
+#include <linux/lustre_lib.h>
+#include <linux/lustre_net.h>
+
+static int lustre_ha_check_event(struct lustre_ha_mgr *mgr)
+{
+
+        
+        return 1;
+}
+
+
+static int llite_ha_main(void *arg)
+{
+        struct lustre_ha_thread *data = (struct lustre_ha_thread *)arg;
+        struct lustre_ha_mgr *mgr = data->mgr;
+
+        ENTRY;
+
+        lock_kernel();
+        daemonize();
+        spin_lock_irq(&current->sigmask_lock);
+        sigfillset(&current->blocked);
+        recalc_sigpending(current);
+        spin_unlock_irq(&current->sigmask_lock);
+
+        sprintf(current->comm, data->name);
+
+        /* Record that the  thread is running */
+        mgr->mgr_thread = current;
+        mgr->mgr_flags = MGR_RUNNING;
+        wake_up(&mgr->mgr_ctl_waitq);
+
+        /* And now, loop forever on requests */
+        while (1) {
+                wait_event_interruptible(mgr->mgr_waitq, 
+                                         lustre_ha_check_event(mgr));
+
+                spin_lock(&mgr->mgr_lock);
+                schedule_timeout(5 * HZ); 
+                if (mgr->mgr_flags & MGR_SIGNAL) {
+                        spin_unlock(&mgr->mgr_lock);
+                        EXIT;
+                        break;
+                }
+
+                if (mgr->mgr_flags & MGR_STOPPING) {
+                        spin_unlock(&mgr->mgr_lock);
+                        EXIT;
+                        break;
+                }
+
+                if (mgr->mgr_flags & MGR_EVENT) {
+                        mgr->mgr_flags = MGR_RUNNING;
+
+                        /* FIXME: If we move to an event-driven model,
+                         * we should put the request on the stack of
+                         * mds_handle instead. */
+                        CERROR("MGR event\n"); 
+                        continue;
+                }
+
+                CERROR("unknown break in service");
+                spin_unlock(&mgr->mgr_lock);
+                EXIT;
+                break;
+        }
+
+        mgr->mgr_thread = NULL;
+        mgr->mgr_flags = MGR_STOPPED;
+        wake_up(&mgr->mgr_ctl_waitq);
+        CDEBUG(D_NET, "mgr exiting process %d\n", current->pid);
+        return 0;
+}
+
+
+int llite_ha_setup(struct obd_device *dev, struct lustre_ha_mgr *mgr,
+                   char *name)
+{
+        struct lustre_ha_thread d;
+        int rc;
+        ENTRY;
+
+        d.dev = dev;
+        d.mgr = mgr;
+        d.name = name;
+
+        init_waitqueue_head(&mgr->mgr_waitq);
+
+        init_waitqueue_head(&mgr->mgr_ctl_waitq);
+        rc = kernel_thread(llite_ha_main, (void *) &d,
+                           CLONE_VM | CLONE_FS | CLONE_FILES);
+        if (rc < 0) {
+                CERROR("cannot start thread\n");
+                RETURN(-EINVAL);
+        }
+        wait_event(mgr->mgr_ctl_waitq, mgr->mgr_flags & MGR_RUNNING);
+
+        RETURN(0);
+}
+
+
+int llite_ha_cleanup(struct lustre_ha_mgr *mgr)
+{
+        mgr->mgr_flags = MGR_STOPPING;
+
+        wake_up(&mgr->mgr_waitq);
+        wait_event_interruptible(mgr->mgr_ctl_waitq,
+                                 (mgr->mgr_flags & MGR_STOPPED));
+        return 0;
+}
index 00c62bd..ce2cdaa 100644 (file)
 #include <linux/locks.h>
 #include <linux/quotaops.h>
 
-#define DEBUG_SUBSYSTEM S_LLIGHT
+#define DEBUG_SUBSYSTEM S_LLITE
 
 #include <linux/obd_support.h>
-#include <linux/lustre_light.h>
+#include <linux/lustre_lite.h>
 extern struct address_space_operations ll_aops;
 
 /* from super.c */
index 9fedc5d..0021f31 100644 (file)
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 
-#define DEBUG_SUBSYSTEM S_LLIGHT
+#define DEBUG_SUBSYSTEM S_LLITE
 
 #include <linux/obd_support.h>
 #include <linux/obd_class.h>
 #include <linux/lustre_lib.h>
 #include <linux/lustre_idl.h>
 #include <linux/lustre_mds.h>
-#include <linux/lustre_light.h>
+#include <linux/lustre_lite.h>
 
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10))
index 3bf4d37..3e5a65d 100644 (file)
@@ -32,9 +32,9 @@
 #include <asm/uaccess.h>
 #include <asm/segment.h>
 
-#define DEBUG_SUBSYSTEM S_LLIGHT
+#define DEBUG_SUBSYSTEM S_LLITE
 
-#include <linux/lustre_light.h>
+#include <linux/lustre_lite.h>
 
 kmem_cache_t *ll_file_data_slab;
 extern struct address_space_operations ll_aops;
@@ -134,14 +134,14 @@ static struct super_block * ll_read_super(struct super_block *sb,
         }
 
         /* the first parameter should become an mds device no */
-        err = ptlrpc_connect_client(-1, "mds",
-                                    MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL,
-                                    &sbi->ll_mds_client);
-
+        ptlrpc_init_client(-1, MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL,
+                           &sbi->ll_mds_client);
+        err = ptlrpc_connect_client(-1, "mds", &sbi->ll_mds_client);
         if (err) {
                 CERROR("cannot find MDS\n");
                 GOTO(out_disc, sb = NULL);
         }
+
         sbi->ll_super = sb;
         sbi->ll_rootino = 2;
 
@@ -164,7 +164,7 @@ static struct super_block * ll_read_super(struct super_block *sb,
         if (root) {
                 sb->s_root = d_alloc_root(root);
         } else {
-                CERROR("lustre_light: bad iget4 for root\n");
+                CERROR("lustre_lite: bad iget4 for root\n");
                 GOTO(out_req, sb = NULL);
         }
 
@@ -177,8 +177,10 @@ out_free:
                 MOD_DEC_USE_COUNT;
                 OBD_FREE(sbi, sizeof(*sbi));
         }
-        OBD_FREE(device, strlen(device) + 1);
-        OBD_FREE(version, strlen(version) + 1);
+        if (device) 
+                OBD_FREE(device, strlen(device) + 1);
+        if (version)
+                OBD_FREE(version, strlen(version) + 1);
 
         RETURN(sb);
 } /* ll_read_super */
@@ -382,31 +384,51 @@ struct super_operations ll_super_operations =
         // statfs: ll_statfs
 };
 
-struct file_system_type lustre_light_fs_type = {
-        "lustre_light", 0, ll_read_super, NULL
+struct file_system_type lustre_lite_fs_type = {
+        "lustre_lite", 0, ll_read_super, NULL
+};
+
+static int llite_setup(struct obd_device *dev, obd_count len, void *buf)
+{
+        MOD_INC_USE_COUNT;
+        return 0;
+}
+
+static int llite_cleanup(struct obd_device *dev)
+{
+        MOD_DEC_USE_COUNT;
+        return 0;
+}
+
+/* use obd ops to offer management infrastructure */
+static struct obd_ops llite_obd_ops = {
+        o_setup:       llite_setup,
+        o_cleanup:     llite_cleanup,
 };
 
-static int __init init_lustre_light(void)
+static int __init init_lustre_lite(void)
 {
-        printk(KERN_INFO "Lustre Light 0.0.1, braam@clusterfs.com\n");
+        printk(KERN_INFO "Lustre Lite 0.0.1, braam@clusterfs.com\n");
+        obd_register_type(&llite_obd_ops, LUSTRE_LITE_NAME);
         ll_file_data_slab = kmem_cache_create("ll_file_data",
                                               sizeof(struct ll_file_data), 0,
                                                SLAB_HWCACHE_ALIGN, NULL, NULL);
         if (ll_file_data_slab == NULL)
                 return -ENOMEM;
 
-        return register_filesystem(&lustre_light_fs_type);
+        return register_filesystem(&lustre_lite_fs_type);
 }
 
-static void __exit exit_lustre_light(void)
+static void __exit exit_lustre_lite(void)
 {
-        unregister_filesystem(&lustre_light_fs_type);
         kmem_cache_destroy(ll_file_data_slab);
+        unregister_filesystem(&lustre_lite_fs_type);
+        obd_unregister_type(LUSTRE_LITE_NAME);
 }
 
 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
-MODULE_DESCRIPTION("Lustre Light Client File System v1.0");
+MODULE_DESCRIPTION("Lustre Lite Client File System v1.0");
 MODULE_LICENSE("GPL");
 
-module_init(init_lustre_light);
-module_exit(exit_lustre_light);
+module_init(init_lustre_lite);
+module_exit(exit_lustre_lite);
index 83c41f4..5f54913 100644 (file)
@@ -9,10 +9,6 @@
  * Laboratoire MASI - Institut Blaise Pascal
  * Universite Pierre et Marie Curie (Paris VI)
  *
- *  from
- *
- *  linux/fs/minix/symlink.c
- *
  *  Copyright (C) 1991, 1992  Linus Torvalds
  *
  *  ext2 symlink handling code
 #include <linux/stat.h>
 #include <linux/locks.h>
 
-#define DEBUG_SUBSYSTEM S_LLIGHT
+#define DEBUG_SUBSYSTEM S_LLITE
 
 #include <linux/obd_support.h> /* for ENTRY and EXIT only */
-#include <linux/lustre_light.h>
+#include <linux/lustre_lite.h>
 
 static int ll_fast_readlink(struct dentry *dentry, char *buffer, int buflen)
 {
@@ -47,6 +43,6 @@ extern int ll_setattr(struct dentry *de, struct iattr *attr);
 struct inode_operations ll_fast_symlink_inode_operations = {
         readlink:       ll_fast_readlink,
         follow_link:    ll_fast_follow_link,
-       setattr:        ll_setattr
+        setattr:        ll_setattr
 };
 
index 4a04ffe..ec567e8 100644 (file)
 
 extern int mds_queue_req(struct ptlrpc_request *);
 
+int mdc_connect(struct ptlrpc_client *cl, ino_t ino, int type, int valid,
+                struct ptlrpc_request **request)
+{
+        struct ptlrpc_request *req;
+        struct mds_body *body;
+        int rc, size = sizeof(*body);
+        ENTRY;
+
+        req = ptlrpc_prep_req(cl, MDS_GETATTR, 1, &size, NULL);
+        if (!req)
+                GOTO(out, rc = -ENOMEM);
+
+        body = lustre_msg_buf(req->rq_reqmsg, 0);
+        ll_ino2fid(&body->fid1, ino, 0, type);
+        body->valid = valid;
+
+        req->rq_replen = lustre_msg_size(1, &size);
+
+        rc = ptlrpc_queue_wait(cl, req);
+        rc = ptlrpc_check_status(req, rc);
+
+        if (!rc) {
+                mds_unpack_body(req);
+                body = lustre_msg_buf(req->rq_repmsg, 0);
+                CDEBUG(D_NET, "mode: %o\n", body->mode);
+        }
+
+        EXIT;
+ out:
+        *request = req;
+        return rc;
+}
+
+
 int mdc_getattr(struct ptlrpc_client *cl, ino_t ino, int type, int valid,
                 struct ptlrpc_request **request)
 {
@@ -225,8 +259,8 @@ static int request_ioctl(struct inode *inode, struct file *file,
                 RETURN(-EINVAL);
         }
 
-        err = ptlrpc_connect_client(-1, "mds",
-                                    MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL, &cl);
+        ptlrpc_init_client(-1, MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL, &cl);
+        err = ptlrpc_connect_client(-1, "mds", &cl);
         if (err) {
                 CERROR("cannot create client\n");
                 RETURN(-EINVAL);
index b575b2f..340f4a5 100644 (file)
@@ -34,7 +34,7 @@
 #define DEBUG_SUBSYSTEM S_OBDFS
 
 #include <linux/obdfs.h>
-#include <linux/lustre_light.h>
+#include <linux/lustre_lite.h>
 extern struct address_space_operations obdfs_aops;
 
 /* from super.c */
@@ -46,76 +46,76 @@ extern int ext2_add_link (struct dentry *dentry, struct inode *inode);
 ino_t obdfs_inode_by_name(struct inode * dir, struct dentry *dentry, int *typ);
 int ext2_make_empty(struct inode *inode, struct inode *parent);
 struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
-                  struct dentry *dentry, struct page ** res_page);
+                   struct dentry *dentry, struct page ** res_page);
 int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page );
 int ext2_empty_dir (struct inode * inode);
 struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p);
 void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
-                  struct page *page, struct inode *inode);
+                   struct page *page, struct inode *inode);
 
 /*
  * Couple of helper functions - make the code slightly cleaner.
  */
 static inline void ext2_inc_count(struct inode *inode)
 {
-       inode->i_nlink++;
-       obdfs_change_inode(inode);
+        inode->i_nlink++;
+        obdfs_change_inode(inode);
 }
 
 /* postpone the disk update until the inode really goes away */ 
 static inline void ext2_dec_count(struct inode *inode)
 {
-       inode->i_nlink--;
-       if (inode->i_nlink > 0) 
-               obdfs_change_inode(inode);
+        inode->i_nlink--;
+        if (inode->i_nlink > 0) 
+                obdfs_change_inode(inode);
 }
 
 static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
 {
-       int err;
-       err = ext2_add_link(dentry, inode);
-       if (!err) {
-               d_instantiate(dentry, inode);
-               return 0;
-       }
-       ext2_dec_count(inode);
-       iput(inode);
-       return err;
+        int err;
+        err = ext2_add_link(dentry, inode);
+        if (!err) {
+                d_instantiate(dentry, inode);
+                return 0;
+        }
+        ext2_dec_count(inode);
+        iput(inode);
+        return err;
 }
 
 /* methods */
 static struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry)
 {
         struct obdo *oa;
-       struct inode * inode = NULL;
-       int type;
-       ino_t ino;
-       
+        struct inode * inode = NULL;
+        int type;
+        ino_t ino;
+        
         ENTRY;
-       if (dentry->d_name.len > EXT2_NAME_LEN)
-               return ERR_PTR(-ENAMETOOLONG);
+        if (dentry->d_name.len > EXT2_NAME_LEN)
+                return ERR_PTR(-ENAMETOOLONG);
 
-       ino = obdfs_inode_by_name(dir, dentry, &type);
-       if (!ino)
-               goto negative;
+        ino = obdfs_inode_by_name(dir, dentry, &type);
+        if (!ino)
+                goto negative;
 
         oa = obdo_fromid(IID(dir), ino, type, 
-                        OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS);
+                         OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS);
         if ( IS_ERR(oa) ) {
                 CERROR("obdo_fromid failed\n");
                 EXIT;
                 return ERR_PTR(-EACCES); 
         }
 
-       inode = iget4(dir->i_sb, ino, NULL, oa);
+        inode = iget4(dir->i_sb, ino, NULL, oa);
         obdo_free(oa);
 
-       if (!inode) 
-               return ERR_PTR(-EACCES);
+        if (!inode) 
+                return ERR_PTR(-EACCES);
 
  negative:
-       d_add(dentry, inode);
-       return NULL;
+        d_add(dentry, inode);
+        return NULL;
 }
 
 
@@ -151,9 +151,9 @@ static struct inode *obdfs_new_inode(struct inode *dir, int mode)
         /* Send a hint to the create method on the type of file to create */
         oa->o_mode = mode;
         oa->o_valid |= OBD_MD_FLMODE;
-       CDEBUG(D_INODE, "\n");
+        CDEBUG(D_INODE, "\n");
         err = obd_create(IID(dir), oa);
-       CDEBUG(D_INODE, "\n");
+        CDEBUG(D_INODE, "\n");
 
         if ( err ) {
                 CERROR("new_inode - fatal: err %d\n", err);
@@ -161,15 +161,15 @@ static struct inode *obdfs_new_inode(struct inode *dir, int mode)
                 EXIT;
                 return ERR_PTR(err);
         }
-       CDEBUG(D_INODE, "obdo mode %o\n", oa->o_mode);
+        CDEBUG(D_INODE, "obdo mode %o\n", oa->o_mode);
 
         inode = iget4(dir->i_sb, (ino_t)oa->o_id, NULL, oa);
-       CDEBUG(D_INODE, "\n");
+        CDEBUG(D_INODE, "\n");
 
         if (!inode) {
                 CERROR("new_inode -fatal:  %ld\n", (long)oa->o_id);
                 obd_destroy(IID(dir), oa);
-               obdo_free(oa);
+                obdo_free(oa);
                 EXIT;
                 return ERR_PTR(-EIO);
         }
@@ -177,9 +177,9 @@ static struct inode *obdfs_new_inode(struct inode *dir, int mode)
 
         if (!list_empty(&inode->i_dentry)) {
                 CERROR("new_inode -fatal: aliases %ld, ct %d lnk %d\n", 
-                      (long)oa->o_id,
-                      atomic_read(&inode->i_count), 
-                      inode->i_nlink);
+                       (long)oa->o_id,
+                       atomic_read(&inode->i_count), 
+                       inode->i_nlink);
                 obd_destroy(IID(dir), oa);
                 iput(inode);
                 EXIT;
@@ -201,266 +201,266 @@ static struct inode *obdfs_new_inode(struct inode *dir, int mode)
  */
 static int obdfs_create (struct inode * dir, struct dentry * dentry, int mode)
 {
-       struct inode * inode = obdfs_new_inode (dir, mode);
-       int err = PTR_ERR(inode);
-       if (!IS_ERR(inode)) {
-               inode->i_op = &obdfs_file_inode_operations;
-               inode->i_fop = &obdfs_file_operations;
-               inode->i_mapping->a_ops = &obdfs_aops;
-               err = ext2_add_nondir(dentry, inode);
-       }
-       return err;
+        struct inode * inode = obdfs_new_inode (dir, mode);
+        int err = PTR_ERR(inode);
+        if (!IS_ERR(inode)) {
+                inode->i_op = &obdfs_file_inode_operations;
+                inode->i_fop = &obdfs_file_operations;
+                inode->i_mapping->a_ops = &obdfs_aops;
+                err = ext2_add_nondir(dentry, inode);
+        }
+        return err;
 } /* obdfs_create */
 
 
 static int obdfs_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev)
 {
-       struct inode * inode = obdfs_new_inode (dir, mode);
-       int err = PTR_ERR(inode);
-       if (!IS_ERR(inode)) {
-               init_special_inode(inode, mode, rdev);
-               obdfs_change_inode(inode);
-               err = ext2_add_nondir(dentry, inode);
-       }
-       return err;
+        struct inode * inode = obdfs_new_inode (dir, mode);
+        int err = PTR_ERR(inode);
+        if (!IS_ERR(inode)) {
+                init_special_inode(inode, mode, rdev);
+                obdfs_change_inode(inode);
+                err = ext2_add_nondir(dentry, inode);
+        }
+        return err;
 }
 
 static int obdfs_symlink (struct inode * dir, struct dentry * dentry,
-       const char * symname)
+        const char * symname)
 {
-       struct super_block * sb = dir->i_sb;
-       int err = -ENAMETOOLONG;
-       unsigned l = strlen(symname)+1;
-       struct inode * inode;
+        struct super_block * sb = dir->i_sb;
+        int err = -ENAMETOOLONG;
+        unsigned l = strlen(symname)+1;
+        struct inode * inode;
         struct obdfs_inode_info *oinfo;
 
-       if (l > sb->s_blocksize)
-               goto out;
+        if (l > sb->s_blocksize)
+                goto out;
 
-       inode = obdfs_new_inode (dir, S_IFLNK | S_IRWXUGO);
-       err = PTR_ERR(inode);
-       if (IS_ERR(inode))
-               goto out;
+        inode = obdfs_new_inode (dir, S_IFLNK | S_IRWXUGO);
+        err = PTR_ERR(inode);
+        if (IS_ERR(inode))
+                goto out;
 
         oinfo = obdfs_i2info(inode);
         if (l >= sizeof(oinfo->oi_inline)) {
-               /* slow symlink */
-               inode->i_op = &page_symlink_inode_operations;
-               inode->i_mapping->a_ops = &obdfs_aops;
-               err = block_symlink(inode, symname, l);
-               if (err)
-                       goto out_fail;
-       } else {
-               /* fast symlink */
-               inode->i_op = &obdfs_fast_symlink_inode_operations;
-               memcpy(oinfo->oi_inline, symname, l);
-               inode->i_size = l-1;
-       }
-       obdfs_change_inode(inode);
-
-       err = ext2_add_nondir(dentry, inode);
+                /* slow symlink */
+                inode->i_op = &page_symlink_inode_operations;
+                inode->i_mapping->a_ops = &obdfs_aops;
+                err = block_symlink(inode, symname, l);
+                if (err)
+                        goto out_fail;
+        } else {
+                /* fast symlink */
+                inode->i_op = &obdfs_fast_symlink_inode_operations;
+                memcpy(oinfo->oi_inline, symname, l);
+                inode->i_size = l-1;
+        }
+        obdfs_change_inode(inode);
+
+        err = ext2_add_nondir(dentry, inode);
 out:
-       return err;
+        return err;
 
 out_fail:
-       ext2_dec_count(inode);
-       iput (inode);
-       goto out;
+        ext2_dec_count(inode);
+        iput (inode);
+        goto out;
 }
 
 
 
 static int obdfs_link (struct dentry * old_dentry, struct inode * dir,
-       struct dentry *dentry)
+        struct dentry *dentry)
 {
-       struct inode *inode = old_dentry->d_inode;
+        struct inode *inode = old_dentry->d_inode;
 
-       if (S_ISDIR(inode->i_mode))
-               return -EPERM;
+        if (S_ISDIR(inode->i_mode))
+                return -EPERM;
 
-       if (inode->i_nlink >= EXT2_LINK_MAX)
-               return -EMLINK;
+        if (inode->i_nlink >= EXT2_LINK_MAX)
+                return -EMLINK;
 
-       inode->i_ctime = CURRENT_TIME;
-       ext2_inc_count(inode);
-       atomic_inc(&inode->i_count);
+        inode->i_ctime = CURRENT_TIME;
+        ext2_inc_count(inode);
+        atomic_inc(&inode->i_count);
 
-       return ext2_add_nondir(dentry, inode);
+        return ext2_add_nondir(dentry, inode);
 }
 
 
 static int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
 {
-       struct inode * inode;
-       int err = -EMLINK;
-       ENTRY;
+        struct inode * inode;
+        int err = -EMLINK;
+        ENTRY;
 
-       if (dir->i_nlink >= EXT2_LINK_MAX)
-               goto out;
+        if (dir->i_nlink >= EXT2_LINK_MAX)
+                goto out;
 
-       ext2_inc_count(dir);
+        ext2_inc_count(dir);
 
-       inode = obdfs_new_inode (dir, S_IFDIR | mode);
-       err = PTR_ERR(inode);
-       if (IS_ERR(inode))
-               goto out_dir;
+        inode = obdfs_new_inode (dir, S_IFDIR | mode);
+        err = PTR_ERR(inode);
+        if (IS_ERR(inode))
+                goto out_dir;
 
-       inode->i_op = &obdfs_dir_inode_operations;
-       inode->i_fop = &obdfs_dir_operations;
-       inode->i_mapping->a_ops = &obdfs_aops;
+        inode->i_op = &obdfs_dir_inode_operations;
+        inode->i_fop = &obdfs_dir_operations;
+        inode->i_mapping->a_ops = &obdfs_aops;
 
-       ext2_inc_count(inode);
+        ext2_inc_count(inode);
 
-       err = ext2_make_empty(inode, dir);
-       if (err)
-               goto out_fail;
+        err = ext2_make_empty(inode, dir);
+        if (err)
+                goto out_fail;
 
-       err = ext2_add_link(dentry, inode);
-       if (err)
-               goto out_fail;
+        err = ext2_add_link(dentry, inode);
+        if (err)
+                goto out_fail;
 
-       d_instantiate(dentry, inode);
+        d_instantiate(dentry, inode);
 out:
-       EXIT;
-       return err;
+        EXIT;
+        return err;
 
 out_fail:
-       ext2_dec_count(inode);
-       ext2_dec_count(inode);
-       iput(inode);
-       EXIT;
+        ext2_dec_count(inode);
+        ext2_dec_count(inode);
+        iput(inode);
+        EXIT;
 out_dir:
-       ext2_dec_count(dir);
-       EXIT;
-       goto out;
+        ext2_dec_count(dir);
+        EXIT;
+        goto out;
 }
 
 static int obdfs_unlink(struct inode * dir, struct dentry *dentry)
 {
-       struct inode * inode = dentry->d_inode;
-       struct ext2_dir_entry_2 * de;
-       struct page * page;
-       int err = -ENOENT;
-
-       de = ext2_find_entry (dir, dentry, &page);
-       if (!de)
-               goto out;
-
-       err = ext2_delete_entry (de, page);
-       if (err)
-               goto out;
-
-       inode->i_ctime = dir->i_ctime;
-       ext2_dec_count(inode);
-       err = 0;
+        struct inode * inode = dentry->d_inode;
+        struct ext2_dir_entry_2 * de;
+        struct page * page;
+        int err = -ENOENT;
+
+        de = ext2_find_entry (dir, dentry, &page);
+        if (!de)
+                goto out;
+
+        err = ext2_delete_entry (de, page);
+        if (err)
+                goto out;
+
+        inode->i_ctime = dir->i_ctime;
+        ext2_dec_count(inode);
+        err = 0;
 out:
-       return err;
+        return err;
 }
 
 
 static int obdfs_rmdir (struct inode * dir, struct dentry *dentry)
 {
-       struct inode * inode = dentry->d_inode;
-       int err = -ENOTEMPTY;
-
-       if (ext2_empty_dir(inode)) {
-               err = obdfs_unlink(dir, dentry);
-               if (!err) {
-                       inode->i_size = 0;
-                       ext2_dec_count(inode);
-                       ext2_dec_count(dir);
-               }
-       }
-       return err;
+        struct inode * inode = dentry->d_inode;
+        int err = -ENOTEMPTY;
+
+        if (ext2_empty_dir(inode)) {
+                err = obdfs_unlink(dir, dentry);
+                if (!err) {
+                        inode->i_size = 0;
+                        ext2_dec_count(inode);
+                        ext2_dec_count(dir);
+                }
+        }
+        return err;
 }
 
 static int obdfs_rename (struct inode * old_dir, struct dentry * old_dentry,
-       struct inode * new_dir, struct dentry * new_dentry )
+        struct inode * new_dir, struct dentry * new_dentry )
 {
-       struct inode * old_inode = old_dentry->d_inode;
-       struct inode * new_inode = new_dentry->d_inode;
-       struct page * dir_page = NULL;
-       struct ext2_dir_entry_2 * dir_de = NULL;
-       struct page * old_page;
-       struct ext2_dir_entry_2 * old_de;
-       int err = -ENOENT;
-
-       old_de = ext2_find_entry (old_dir, old_dentry, &old_page);
-       if (!old_de)
-               goto out;
-
-       if (S_ISDIR(old_inode->i_mode)) {
-               err = -EIO;
-               dir_de = ext2_dotdot(old_inode, &dir_page);
-               if (!dir_de)
-                       goto out_old;
-       }
-
-       if (new_inode) {
-               struct page *new_page;
-               struct ext2_dir_entry_2 *new_de;
-
-               err = -ENOTEMPTY;
-               if (dir_de && !ext2_empty_dir (new_inode))
-                       goto out_dir;
-
-               err = -ENOENT;
-               new_de = ext2_find_entry (new_dir, new_dentry, &new_page);
-               if (!new_de)
-                       goto out_dir;
-               ext2_inc_count(old_inode);
-               ext2_set_link(new_dir, new_de, new_page, old_inode);
-               new_inode->i_ctime = CURRENT_TIME;
-               if (dir_de)
-                       new_inode->i_nlink--;
-               ext2_dec_count(new_inode);
-       } else {
-               if (dir_de) {
-                       err = -EMLINK;
-                       if (new_dir->i_nlink >= EXT2_LINK_MAX)
-                               goto out_dir;
-               }
-               ext2_inc_count(old_inode);
-               err = ext2_add_link(new_dentry, old_inode);
-               if (err) {
-                       ext2_dec_count(old_inode);
-                       goto out_dir;
-               }
-               if (dir_de)
-                       ext2_inc_count(new_dir);
-       }
-
-       ext2_delete_entry (old_de, old_page);
-       ext2_dec_count(old_inode);
-
-       if (dir_de) {
-               ext2_set_link(old_inode, dir_de, dir_page, new_dir);
-               ext2_dec_count(old_dir);
-       }
-       return 0;
+        struct inode * old_inode = old_dentry->d_inode;
+        struct inode * new_inode = new_dentry->d_inode;
+        struct page * dir_page = NULL;
+        struct ext2_dir_entry_2 * dir_de = NULL;
+        struct page * old_page;
+        struct ext2_dir_entry_2 * old_de;
+        int err = -ENOENT;
+
+        old_de = ext2_find_entry (old_dir, old_dentry, &old_page);
+        if (!old_de)
+                goto out;
+
+        if (S_ISDIR(old_inode->i_mode)) {
+                err = -EIO;
+                dir_de = ext2_dotdot(old_inode, &dir_page);
+                if (!dir_de)
+                        goto out_old;
+        }
+
+        if (new_inode) {
+                struct page *new_page;
+                struct ext2_dir_entry_2 *new_de;
+
+                err = -ENOTEMPTY;
+                if (dir_de && !ext2_empty_dir (new_inode))
+                        goto out_dir;
+
+                err = -ENOENT;
+                new_de = ext2_find_entry (new_dir, new_dentry, &new_page);
+                if (!new_de)
+                        goto out_dir;
+                ext2_inc_count(old_inode);
+                ext2_set_link(new_dir, new_de, new_page, old_inode);
+                new_inode->i_ctime = CURRENT_TIME;
+                if (dir_de)
+                        new_inode->i_nlink--;
+                ext2_dec_count(new_inode);
+        } else {
+                if (dir_de) {
+                        err = -EMLINK;
+                        if (new_dir->i_nlink >= EXT2_LINK_MAX)
+                                goto out_dir;
+                }
+                ext2_inc_count(old_inode);
+                err = ext2_add_link(new_dentry, old_inode);
+                if (err) {
+                        ext2_dec_count(old_inode);
+                        goto out_dir;
+                }
+                if (dir_de)
+                        ext2_inc_count(new_dir);
+        }
+
+        ext2_delete_entry (old_de, old_page);
+        ext2_dec_count(old_inode);
+
+        if (dir_de) {
+                ext2_set_link(old_inode, dir_de, dir_page, new_dir);
+                ext2_dec_count(old_dir);
+        }
+        return 0;
 
 
 out_dir:
-       if (dir_de) {
-               kunmap(dir_page);
-               page_cache_release(dir_page);
-       }
+        if (dir_de) {
+                kunmap(dir_page);
+                page_cache_release(dir_page);
+        }
 out_old:
-       kunmap(old_page);
-       page_cache_release(old_page);
+        kunmap(old_page);
+        page_cache_release(old_page);
 out:
-       return err;
+        return err;
 }
 
 struct inode_operations obdfs_dir_inode_operations = {
-       create:         obdfs_create,
-       lookup:         obdfs_lookup,
-       link:           obdfs_link,
-       unlink:         obdfs_unlink,
-       symlink:        obdfs_symlink,
-       mkdir:          obdfs_mkdir,
-       rmdir:          obdfs_rmdir,
-       mknod:          obdfs_mknod,
-       rename:         obdfs_rename,
-       setattr:        obdfs_setattr
+        create:         obdfs_create,
+        lookup:         obdfs_lookup,
+        link:           obdfs_link,
+        unlink:         obdfs_unlink,
+        symlink:        obdfs_symlink,
+        mkdir:          obdfs_mkdir,
+        rmdir:          obdfs_rmdir,
+        mknod:          obdfs_mknod,
+        rename:         obdfs_rename,
+        setattr:        obdfs_setattr
 };
index bb2c613..b8869ba 100644 (file)
@@ -563,9 +563,9 @@ static int osc_setup(struct obd_device *obddev, obd_count len,
         if (osc->osc_client == NULL)
                 RETURN(-ENOMEM);
 
-        rc = ptlrpc_connect_client(dev, "ost",
-                                   OST_REQUEST_PORTAL, OSC_REPLY_PORTAL,
+        ptlrpc_init_client(dev, OST_REQUEST_PORTAL, OSC_REPLY_PORTAL,
                                    osc->osc_client);
+        rc = ptlrpc_connect_client(dev, "ost", osc->osc_client);
 
         if (rc == 0)
                 MOD_INC_USE_COUNT;
index 3e736af..a1322ac 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/list.h>
 
 #define DEBUG_SUBSYSTEM S_RPC
 
 #include <linux/obd_class.h>
 #include <linux/lustre_net.h>
 
-int ptlrpc_enqueue(struct ptlrpc_client *peer, struct ptlrpc_request *req)
-{
-        struct ptlrpc_request *srv_req;
-
-        if (!peer->cli_obd)
-                RETURN(-1);
-
-        OBD_ALLOC(srv_req, sizeof(*srv_req));
-        if (!srv_req)
-                RETURN(-ENOMEM);
-
-        CDEBUG(0, "peer obd minor %d, incoming req %p, srv_req %p\n",
-               peer->cli_obd->obd_minor, req, srv_req);
-
-        /* move the request buffer */
-        srv_req->rq_reqbuf = req->rq_reqbuf;
-        srv_req->rq_reqlen = req->rq_reqlen;
-        srv_req->rq_obd = peer->cli_obd;
-
-        /* remember where it came from */
-        srv_req->rq_reply_handle = req;
-
-        spin_lock(&peer->cli_lock);
-        list_add(&srv_req->rq_list, &peer->cli_obd->obd_req_list);
-        spin_unlock(&peer->cli_lock);
-        wake_up(&peer->cli_obd->obd_req_waitq);
-        return 0;
-}
-
-int ptlrpc_connect_client(int dev, char *uuid, int req_portal, int rep_portal,
+void ptlrpc_init_client(int dev, int req_portal, int rep_portal,
                           struct ptlrpc_client *cl)
 {
-        int err;
-
         memset(cl, 0, sizeof(*cl));
         spin_lock_init(&cl->cli_lock);
         cl->cli_xid = 1;
+        cl->cli_generation = 1;
+        cl->cli_epoch = 1;
+        cl->cli_bootcount = 0;
         cl->cli_obd = NULL;
         cl->cli_request_portal = req_portal;
         cl->cli_reply_portal = rep_portal;
+        INIT_LIST_HEAD(&cl->cli_sending_head);
+        INIT_LIST_HEAD(&cl->cli_sent_head);
         sema_init(&cl->cli_rpc_sem, 32);
+}
 
-        /* non networked client */
-        if (dev >= 0 && dev < MAX_OBD_DEVICES) {
-                struct obd_device *obd = &obd_dev[dev];
-
-                if ((!obd->obd_flags & OBD_ATTACHED) ||
-                    (!obd->obd_flags & OBD_SET_UP)) {
-                        CERROR("target device %d not att or setup\n", dev);
-                        return -EINVAL;
-                }
-                if (strcmp(obd->obd_type->typ_name, "ost") &&
-                    strcmp(obd->obd_type->typ_name, "mds"))
-                        return -EINVAL;
-
-                cl->cli_obd = &obd_dev[dev];
-                return 0;
-        }
+int ptlrpc_connect_client(int dev, char *uuid, struct ptlrpc_client *cl)
+{
+        int err;
 
-        /* networked */
+        cl->cli_epoch++;
         err = kportal_uuid_to_peer(uuid, &cl->cli_server);
         if (err != 0)
                 CERROR("cannot find peer %s!\n", uuid);
@@ -203,8 +166,15 @@ int ptlrpc_check_status(struct ptlrpc_request *req, int err)
         RETURN(0);
 }
 
+static void ptlrpc_cleanup_request_buf(struct ptlrpc_request *request)
+{
+        OBD_FREE(request->rq_reqbuf, request->rq_reqlen);
+        request->rq_reqbuf = NULL;
+        request->rq_reqlen = 0;
+}
+
 /* Abort this request and cleanup any resources associated with it. */
-int ptlrpc_abort(struct ptlrpc_request *request)
+static int ptlrpc_abort(struct ptlrpc_request *request)
 {
         /* First remove the ME for the reply; in theory, this means
          * that we can tear down the buffer safely. */
@@ -212,7 +182,6 @@ int ptlrpc_abort(struct ptlrpc_request *request)
         OBD_FREE(request->rq_reply_md.start, request->rq_replen);
         request->rq_repbuf = NULL;
         request->rq_replen = 0;
-
         return 0;
 }
 
@@ -223,18 +192,13 @@ int ptlrpc_queue_wait(struct ptlrpc_client *cl, struct ptlrpc_request *req)
 
         init_waitqueue_head(&req->rq_wait_for_rep);
 
-        if (cl->cli_obd) {
-                /* Local delivery */
-                down(&cl->cli_rpc_sem);
-                rc = ptlrpc_enqueue(cl, req);
-        } else {
-                /* Remote delivery via portals. */
-                req->rq_req_portal = cl->cli_request_portal;
-                req->rq_reply_portal = cl->cli_reply_portal;
-                rc = ptl_send_rpc(req, cl);
-        }
+        req->rq_client = cl;
+        req->rq_req_portal = cl->cli_request_portal;
+        req->rq_reply_portal = cl->cli_reply_portal;
+        rc = ptl_send_rpc(req, cl);
         if (rc) {
                 CERROR("error %d, opcode %d\n", rc, req->rq_reqmsg->opc);
+                ptlrpc_cleanup_request_buf(req);
                 up(&cl->cli_rpc_sem);
                 RETURN(-rc);
         }
@@ -242,6 +206,7 @@ int ptlrpc_queue_wait(struct ptlrpc_client *cl, struct ptlrpc_request *req)
         CDEBUG(D_OTHER, "-- sleeping\n");
         wait_event_interruptible(req->rq_wait_for_rep, ptlrpc_check_reply(req));
         CDEBUG(D_OTHER, "-- done\n");
+        ptlrpc_cleanup_request_buf(req);
         up(&cl->cli_rpc_sem);
         if (req->rq_flags == PTL_RPC_INTR) {
                 /* Clean up the dangling reply buffers */
index 17f1a1d..5cf37fb 100644 (file)
 #include <linux/obd_class.h>
 #include <linux/lustre_net.h>
 
-ptl_handle_eq_t sent_pkt_eq, rcvd_rep_eq, bulk_source_eq, bulk_sink_eq;
+ptl_handle_eq_t request_out_eq, 
+                reply_in_eq, 
+                reply_out_eq,
+                bulk_source_eq, 
+                bulk_sink_eq;
 static const ptl_handle_ni_t *socknal_nip = NULL, *qswnal_nip = NULL;
 
 /*
  *  Free the packet when it has gone out
  */
-static int sent_packet_callback(ptl_event_t *ev, void *data)
+static int request_out_callback(ptl_event_t *ev, void *data)
+{
+        struct ptlrpc_request *req = ev->mem_desc.user_ptr;
+        struct ptlrpc_client *cl = req->rq_client; 
+        
+        ENTRY;
+
+        if (ev->type == PTL_EVENT_SENT) {
+                list_del(&req->rq_list);
+                list_add(&req->rq_list, &cl->cli_sent_head);
+        } else { 
+                // XXX make sure we understand all events, including ACK's
+                CERROR("Unknown event %d\n", ev->type); 
+                LBUG();
+        }
+
+        RETURN(1);
+}
+
+
+/*
+ *  Free the packet when it has gone out
+ */
+static int reply_out_callback(ptl_event_t *ev, void *data)
 {
         ENTRY;
 
@@ -56,7 +83,7 @@ static int sent_packet_callback(ptl_event_t *ev, void *data)
 /*
  * Wake up the thread waiting for the reply once it comes in.
  */
-static int rcvd_reply_callback(ptl_event_t *ev, void *data)
+static int reply_in_callback(ptl_event_t *ev, void *data)
 {
         struct ptlrpc_request *rpc = ev->mem_desc.user_ptr;
         ENTRY;
@@ -74,7 +101,7 @@ static int rcvd_reply_callback(ptl_event_t *ev, void *data)
         RETURN(1);
 }
 
-int server_request_callback(ptl_event_t *ev, void *data)
+int request_in_callback(ptl_event_t *ev, void *data)
 {
         struct ptlrpc_service *service = data;
         int index;
@@ -184,11 +211,15 @@ int ptlrpc_init_portals(void)
         else
                 ni = *socknal_nip;
 
-        rc = PtlEQAlloc(ni, 128, sent_packet_callback, NULL, &sent_pkt_eq);
+        rc = PtlEQAlloc(ni, 128, request_out_callback, NULL, &request_out_eq);
+        if (rc != PTL_OK)
+                CERROR("PtlEQAlloc failed: %d\n", rc);
+
+        rc = PtlEQAlloc(ni, 128, reply_out_callback, NULL, &reply_out_eq);
         if (rc != PTL_OK)
                 CERROR("PtlEQAlloc failed: %d\n", rc);
 
-        rc = PtlEQAlloc(ni, 128, rcvd_reply_callback, NULL, &rcvd_rep_eq);
+        rc = PtlEQAlloc(ni, 128, reply_in_callback, NULL, &reply_in_eq);
         if (rc != PTL_OK)
                 CERROR("PtlEQAlloc failed: %d\n", rc);
 
@@ -205,8 +236,9 @@ int ptlrpc_init_portals(void)
 
 void ptlrpc_exit_portals(void)
 {
-        PtlEQFree(sent_pkt_eq);
-        PtlEQFree(rcvd_rep_eq);
+        PtlEQFree(request_out_eq);
+        PtlEQFree(reply_out_eq);
+        PtlEQFree(reply_in_eq);
         PtlEQFree(bulk_source_eq);
         PtlEQFree(bulk_sink_eq);
 
index c349cc9..7f68332 100644 (file)
 #include <linux/obd_class.h>
 #include <linux/lustre_net.h>
 
-extern ptl_handle_eq_t bulk_source_eq, sent_pkt_eq, rcvd_rep_eq, bulk_sink_eq;
+extern ptl_handle_eq_t request_out_eq, 
+        reply_in_eq, 
+        reply_out_eq,
+        bulk_source_eq, 
+        bulk_sink_eq;
 static ptl_process_id_t local_id = {PTL_ID_ANY, PTL_ID_ANY};
 
 
@@ -62,6 +66,8 @@ int ptl_send_buf(struct ptlrpc_request *request, struct lustre_peer *peer,
         ptl_handle_md_t md_h;
         ptl_ack_req_t ack;
 
+        request->rq_req_md.user_ptr = request;
+
         switch (request->rq_type) {
         case PTL_RPC_BULK:
                 request->rq_req_md.start = request->rq_bulkbuf;
@@ -73,14 +79,14 @@ int ptl_send_buf(struct ptlrpc_request *request, struct lustre_peer *peer,
         case PTL_RPC_REQUEST:
                 request->rq_req_md.start = request->rq_reqbuf;
                 request->rq_req_md.length = request->rq_reqlen;
-                request->rq_req_md.eventq = sent_pkt_eq;
+                request->rq_req_md.eventq = request_out_eq;
                 request->rq_req_md.threshold = 1;
                 ack = PTL_NOACK_REQ;
                 break;
         case PTL_RPC_REPLY:
                 request->rq_req_md.start = request->rq_repbuf;
                 request->rq_req_md.length = request->rq_replen;
-                request->rq_req_md.eventq = sent_pkt_eq;
+                request->rq_req_md.eventq = reply_out_eq;
                 request->rq_req_md.threshold = 1;
                 ack = PTL_NOACK_REQ;
                 break;
@@ -305,7 +311,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, struct ptlrpc_client *cl)
         request->rq_reply_md.threshold = 1;
         request->rq_reply_md.options = PTL_MD_OP_PUT;
         request->rq_reply_md.user_ptr = request;
-        request->rq_reply_md.eventq = rcvd_rep_eq;
+        request->rq_reply_md.eventq = reply_in_eq;
 
         rc = PtlMDAttach(request->rq_reply_me_h, request->rq_reply_md,
                          PTL_UNLINK, &request->rq_reply_md_h);
@@ -318,6 +324,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, struct ptlrpc_client *cl)
         CDEBUG(D_NET, "Setup reply buffer: %u bytes, xid %u, portal %u\n",
                request->rq_replen, request->rq_xid, request->rq_reply_portal);
 
+        list_add(&request->rq_list, &cl->cli_sending_head);
         rc = ptl_send_buf(request, &cl->cli_server, request->rq_req_portal);
         RETURN(rc);
 
index e783c70..0532837 100644 (file)
@@ -32,7 +32,7 @@
 #include <linux/obd_class.h>
 #include <linux/lustre_net.h>
 
-extern int server_request_callback(ptl_event_t *ev, void *data);
+extern int request_in_callback(ptl_event_t *ev, void *data);
 extern int ptl_handled_rpc(struct ptlrpc_service *service, void *start);
 
 static int ptlrpc_check_event(struct ptlrpc_service *svc)
@@ -119,7 +119,7 @@ ptlrpc_init_svc(__u32 bufsize, int req_portal, int rep_portal, char *uuid,
         service->srv_id.pid = PTL_ID_ANY;
 
         rc = PtlEQAlloc(service->srv_self.peer_ni, 128,
-                        server_request_callback,
+                        request_in_callback,
                         service, &(service->srv_eq_h));
 
         if (rc != PTL_OK) {
index 478a5ef..c8f7570 100644 (file)
@@ -117,11 +117,11 @@ setup() {
     insmod $SRCDIR/../../obd/obdecho/obdecho.o || exit -1
     insmod $SRCDIR/../../obd/mds/mds.o || exit -1
     insmod $SRCDIR/../../obd/mdc/mdc.o || exit -1
-    insmod $SRCDIR/../../obd/llight/llight.o || exit -1
+    insmod $SRCDIR/../../obd/llight/llite.o || exit -1
 
     list_mods
 
-    [ -d /mnt/obd ] || mkdir /mnt/obd
+    [ -d /mnt/lustre ] || mkdir /mnt/lustre
 }
 
 setup_portals() {
index 530ddce..7dcc034 100755 (executable)
@@ -35,4 +35,4 @@ setup -1
 quit
 EOF
 
-mount -t lustre_light -o device=3 none /mnt/obd
+mount -t lustre_lite -o device=3 none /mnt/lustre
index f60c7e7..723caa7 100755 (executable)
@@ -30,4 +30,4 @@ setup 2
 quit
 EOF
 
-# mount -t lustre_light -o device=3 none /mnt/obd
+# mount -t lustre_lite -o device=3 none /mnt/lustre
index 4f2bd50..46b3e1f 100644 (file)
@@ -19,5 +19,5 @@ setup -1
 quit
 EOF
 
-mkdir /mnt/obd
-mount -t lustre_light -o device=0 none /mnt/obd
+mkdir /mnt/lustre
+mount -t lustre_lite -o device=0 none /mnt/lustre
index 493d7cd..65adf4d 100755 (executable)
@@ -35,4 +35,4 @@ setup -1
 quit
 EOF
 
-mount -t lustre_light -o device=3 none /mnt/obd
+mount -t lustre_lite -o device=3 none /mnt/lustre
index 9f422d6..a7a62cb 100755 (executable)
@@ -3,10 +3,10 @@
 SRCDIR="`dirname $0`"
 . $SRCDIR/common.sh
 
-umount /mnt/obd
+umount /mnt/lustre
 
 killall acceptor
-rmmod llight
+rmmod llite
 rmmod mdc
 
 $OBDCTL <<EOF
index 4d55ef2..a958c8d 100755 (executable)
@@ -35,4 +35,4 @@ setup -1
 quit
 EOF
 
-mount -t lustre_light -o device=3 none /mnt/obd
+mount -t lustre_lite -o device=3 none /mnt/lustre
index 2a79f38..45e0b62 100755 (executable)
@@ -35,4 +35,4 @@ setup -1
 quit
 EOF
 
-mount -t lustre_light -o device=3 none /mnt/obd
+mount -t lustre_lite -o device=3 none /mnt/lustre
index 39258a4..141d1df 100755 (executable)
@@ -3,7 +3,7 @@
 SRCDIR="`dirname $0`"
 . $SRCDIR/common.sh
 
-rmmod llight
+rmmod llite
 rmmod mdc
 
 $OBDCTL <<EOF
index 4171e2d..0f6b66d 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 [ -e /proc/sys/portals/debug ] && echo 0 > /proc/sys/portals/debug 
-cd /mnt/obd
+cd /mnt/lustre
 cp /usr/src/obd/demos/dbench/client.txt .
 /usr/src/obd/demos/dbench/dbench $1
index 62e07c5..ce7a6e5 100755 (executable)
@@ -35,7 +35,7 @@ setup -1
 quit
 EOF
 
-MOUNT='mount -t lustre_light -o device=3 none /mnt/obd'
+MOUNT='mount -t lustre_lite -o device=3 none /mnt/lustre'
 $MOUNT
 
 test_fail() {
@@ -45,7 +45,7 @@ test_fail() {
        $* 
 
        echo "Cleaning up and restarting MDS"
-       umount /mnt/obd
+       umount /mnt/lustre
        $OBDCTL <<- EOF
        device 0
        cleanup
@@ -66,29 +66,29 @@ test_fail() {
 
 #set -vx
 
-touch /mnt/obd/foo
-chmod a+x /mnt/obd/foo
+touch /mnt/lusre/foo
+chmod a+x /mnt/lustre/foo
 sync
 
 # OBD_FAIL_MDS_REINT_SETATTR_WRITE - MDS will discard data from setattr
-test_fail 0x10a chmod 000 /mnt/obd/foo
-ls -l /mnt/obd/foo
-[ ! -x /mnt/obd/foo ] && echo "/mnt/obd/foo is not executable!" 1>&2 && exit -1
+test_fail 0x10a chmod 000 /mnt/lustre/foo
+ls -l /mnt/lustre/foo
+[ ! -x /mnt/lustre/foo ] && echo "/mnt/lustre/foo is not executable!" 1>&2 && exit -1
 
 # OBD_FAIL_MDS_REINT_CREATE_WRITE - MDS will not create the file
-test_fail 0x10c touch /mnt/obd/bar
-ls /mnt/obd/bar
-[ $? -eq 0 ] && echo "/mnt/obd/bar was created!" 1>&2 && exit -1
+test_fail 0x10c touch /mnt/lustre/bar
+ls /mnt/lustre/bar
+[ $? -eq 0 ] && echo "/mnt/lustre/bar was created!" 1>&2 && exit -1
 
 # OBD_FAIL_MDS_REINT_UNLINK_WRITE - MDS will discard data from unlink
-test_fail 0x10e rm /mnt/obd/foo
-ls /mnt/obd/foo
-[ $? -eq 1 ] && echo "/mnt/obd/foo has been removed!" 1>&2 && exit -1
+test_fail 0x10e rm /mnt/lustre/foo
+ls /mnt/lustre/foo
+[ $? -eq 1 ] && echo "/mnt/lustre/foo has been removed!" 1>&2 && exit -1
 
 # OBD_FAIL_MDS_REINT_RENAME_WRITE - MDS will discard data from rename
-test_fail 0x112 mv /mnt/obd/foo /mnt/obd/bar
-ls /mnt/obd/foo /mnt/obd/bar
-[ ! -f /mnt/obd/foo -o -f /mnt/obd/bar ] && \
-       echo "/mnt/obd/foo has been renamed to bar!" 1>&2 && exit -1
+test_fail 0x112 mv /mnt/lustre/foo /mnt/lustre/bar
+ls /mnt/lustre/foo /mnt/lustre/bar
+[ ! -f /mnt/lustre/foo -o -f /mnt/lustre/bar ] && \
+       echo "/mnt/lustre/foo has been renamed to bar!" 1>&2 && exit -1
 
 echo "Done."
index bd2d141..bb8c8dd 100755 (executable)
@@ -10,8 +10,8 @@ run() {
        kill -9 $!
 
         echo 0 > /proc/sys/lustre/fail_loc
-        umount /mnt/obd
-        mount -t lustre_light -o device=3 none /mnt/obd
+        umount /mnt/lustre
+        mount -t lustre_lite -o device=3 none /mnt/lustre
 }
 
 mknod /dev/request c 10 244
@@ -19,30 +19,30 @@ mknod /dev/request c 10 244
 sh llmount.sh
 
 # GETATTR_NET - ls will hang on the getattr
-run 0x102 ls -l /mnt/obd
+run 0x102 ls -l /mnt/lustre
 
 # READPAGE_NET - ls will hang reading in new pages (lost+found is not in cache)
-run 0x104 ls /mnt/obd
+run 0x104 ls /mnt/lustre
 
 sleep 1
 
 # REINT_NET - touch will hang on setattr
-run 0x107 touch /mnt/obd
+run 0x107 touch /mnt/lustre
 
 # REINT_NET - touch will hang on create
-run 0x107 touch /mnt/obd/tt
+run 0x107 touch /mnt/lustre/tt
 
 # REINT_NET - mv will hang on rename
-touch /mnt/obd/foo
-run 0x107 mv /mnt/obd/foo /mnt/obd/bar
+touch /mnt/lustre/foo
+run 0x107 mv /mnt/lustre/foo /mnt/lustre/bar
 
 # REINT_NET - rm will hang on unlink
-touch /mnt/obd/salmon
-run 0x107 rm /mnt/obd/salmon
+touch /mnt/lustre/salmon
+run 0x107 rm /mnt/lustre/salmon
 
 # OPEN_NET - touch will hang on open
-touch /mnt/obd/foo
-run 0x113 cat /mnt/obd/foo
+touch /mnt/lustre/foo
+run 0x113 cat /mnt/lustre/foo
 
 # CLOSE_NET - ls will hang on close
 run 0x115 ./testreq --close junk_file_handle
index 0dd52fb..f187ed6 100755 (executable)
@@ -4,7 +4,7 @@ COUNT=0
 rm -f endiozone
 while date; do
        echo "Test #$COUNT"
-       iozone -i 0 -i 1 -f /mnt/obd/test.$$ -s $SIZE 2>&1 || exit $?
+       iozone -i 0 -i 1 -f /mnt/lusre/test.$$ -s $SIZE 2>&1 || exit $?
        COUNT=`expr $COUNT + 1`
        [ -f endiozone ] && rm endiozone && exit 0
 done | tee /tmp/iozone.log
index 239aa50..5f24925 100755 (executable)
@@ -13,18 +13,18 @@ ERROR=
 llmount.sh || exit 1
 
 # let's start slowly here...
-touch /mnt/obd || exit 2
-cp /etc/hosts /mnt/obd || exit 3
-diff -u /etc/hosts /mnt/obd/hosts || exit 4
+touch /mnt/lustre || exit 2
+cp /etc/hosts /mnt/lustre || exit 3
+diff -u /etc/hosts /mnt/lustre/hosts || exit 4
 
 # ok, that hopefully worked, so let's do a little more
 FILES=`find /etc -type f`
-echo "copying files from /etc to /mnt/obd"
-tar cf - $FILES | tar xf - -C /mnt/obd || exit 10
+echo "copying files from /etc to /mnt/lustre"
+tar cf - $FILES | tar xf - -C /mnt/lustre || exit 10
 
 echo "comparing newly copied files"
 for f in $FILES; do
-       diff -q $f /mnt/obd/$f || ERROR=11
+       diff -q $f /mnt/lustre/$f || ERROR=11
 done
 
 [ "$ERROR" ] && exit $ERROR
@@ -33,16 +33,16 @@ llmountcleanup.sh
 
 llrmount.sh || exit 20
 echo "comparing previously copied files"
-diff -u /etc/hosts /mnt/obd/hosts || exit 21
+diff -u /etc/hosts /mnt/lustre/hosts || exit 21
 
 for f in $FILES; do
-       diff -q $f /mnt/obd/$f || ERROR=22
+       diff -q $f /mnt/lustre/$f || ERROR=22
 done
 
 [ "$ERROR" ] && exit $ERROR
 
-rm /mnt/obd/hosts || exit 23
+rm /mnt/lustre/hosts || exit 23
 
-rm -r /mnt/obd/etc || exit 24
+rm -r /mnt/lustre/etc || exit 24
 
 llmountcleanup.sh