Whamcloud - gitweb
Pass 1 of debugging and leak cleanup:
authorpschwan <pschwan>
Thu, 21 Feb 2002 23:15:18 +0000 (23:15 +0000)
committerpschwan <pschwan>
Thu, 21 Feb 2002 23:15:18 +0000 (23:15 +0000)
- use OBD_ALLOC/OBD_FREE everywhere
- fixed a few leaks
- cleaned up a few macros
- load obdclass.o before ptlrpc.o now, since obdclass exports the memory counter
- fixed broken strdup()
- made llmount.sh a little more robust

19 files changed:
lustre/include/linux/obd_support.h
lustre/lib/mds_pack.c
lustre/lib/mds_updates.c
lustre/lib/obd_pack.c
lustre/lib/page.c
lustre/llite/namei.c
lustre/llite/rw.c
lustre/llite/super.c
lustre/mdc/mdc_reint.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdfs/super.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/ptlrpc/rpc.c
lustre/tests/llmount.sh
lustre/tests/llmountcleanup.sh

index c091236..7d76129 100644 (file)
@@ -9,16 +9,15 @@
 
 #include <linux/autoconf.h>
 #include <linux/slab.h>
-#include <linux/vmalloc.h>
 
-
-
-#define obd_unlock_page(page)   do {    if (PageLocked(page)) { \
-                        UnlockPage(page);\
-                } else {\
-                        printk("file %s, line %d: expecting locked page\n",\
-                               __FILE__, __LINE__); \
-                }                       \
+#define obd_unlock_page(page)                                           \
+do {                                                                    \
+        if (PageLocked(page)) {                                         \
+                UnlockPage(page);                                       \
+        } else {                                                        \
+                printk("file %s, line %d: expecting locked page\n",     \
+                       __FILE__, __LINE__);                             \
+        }                                                               \
 } while(0)
 
 /*
@@ -160,31 +159,26 @@ static inline void obd_iput(struct inode *inode)
 
 #endif /* EXT2_OBD_DEBUG */
 
-
-
-#define OBD_ALLOC(ptr, cast, size)                                      \
-do {                                                                    \
-        ptr = kmalloc((unsigned long) size, GFP_KERNEL);        \
-        obd_memory += size;                                             \
-        CDEBUG(D_MALLOC, "kmalloced: %d at %x (tot %ld).\n",            \
-                       (int) size, (int) ptr, obd_memory);             \
-        if (ptr == 0) {                                                 \
-                printk("kernel malloc returns 0 at %s:%d\n",            \
-                       __FILE__, __LINE__);                             \
-        } else {                                                        \
-                memset(ptr, 0, size);                                   \
-        }                                                               \
+#define OBD_ALLOC(ptr, size)                                    \
+do {                                                            \
+        (ptr) = kmalloc((unsigned long)(size), GFP_KERNEL);     \
+        obd_memory += (size);                                   \
+        CDEBUG(D_MALLOC, "kmalloced: %ld at %x (tot %ld).\n",   \
+               (long)(size), (int)(ptr), obd_memory);           \
+        if (ptr == NULL) {                                      \
+                printk("kernel malloc failed at %s:%d\n",       \
+                       __FILE__, __LINE__);                     \
+        } else {                                                \
+                memset((ptr), 0, (size));                       \
+        }                                                       \
 } while (0)
 
-#define OBD_FREE(ptr,size)                                   \
+#define OBD_FREE(ptr, size)                                  \
 do {                                                         \
         kfree((ptr));                                        \
-        obd_memory -= size;                                  \
+        obd_memory -= (size);                                \
         CDEBUG(D_MALLOC, "kfreed: %d at %x (tot %ld).\n",    \
-               (int) size, (int) ptr, obd_memory);           \
+               (int)(size), (int)(ptr), obd_memory);         \
 } while (0)
 
-
-
 #endif
-
index 033e68a..0b4e38b 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/delay.h>
 #include <linux/skbuff.h>
 #include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/poll.h>
 #include <linux/init.h>
@@ -60,7 +59,7 @@ int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen,
        *len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) + 
                sizeof(**req); 
 
-       *buf = kmalloc(*len, GFP_KERNEL);
+       OBD_ALLOC(*buf, *len);
        if (!*buf) {
                EXIT;
                return -ENOMEM;
@@ -149,7 +148,7 @@ int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen,
        *len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) + 
                sizeof(**rep); 
 
-       *buf = kmalloc(*len, GFP_KERNEL);
+       OBD_ALLOC(*buf, *len);
        if (!*buf) {
                EXIT;
                return -ENOMEM;
index 45317b5..f5e5b7f 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <asm/uaccess.h>
-#include <linux/vmalloc.h>
 #include <linux/slab.h>
 #include <asm/segment.h>
 
index 47917ab..e787e26 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/delay.h>
 #include <linux/skbuff.h>
 #include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/poll.h>
 #include <linux/init.h>
@@ -61,7 +60,7 @@ int ost_pack_req(char *buf1, int buflen1, char *buf2, int buflen2,
        *len = sizeof(**hdr) + size_round(buflen1) + size_round(buflen2) + 
                sizeof(**req); 
 
-       *buf = kmalloc(*len, GFP_KERNEL);
+       OBD_ALLOC(*buf, *len);
        if (!*buf) {
                EXIT;
                return -ENOMEM;
@@ -137,7 +136,7 @@ int ost_pack_rep(void *buf1, __u32 buflen1, void *buf2, __u32 buflen2,
        *len = sizeof(**hdr) + size_round(buflen1) + size_round(buflen2) + 
                sizeof(**rep); 
 
-       *buf = kmalloc(*len, GFP_KERNEL);
+       OBD_ALLOC(*buf, *len);
        if (!*buf) {
                EXIT;
                return -ENOMEM;
index ee96147..28f9d8b 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <asm/uaccess.h>
-#include <linux/vmalloc.h>
 #include <asm/segment.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
index 99e5107..b746770 100644 (file)
@@ -104,7 +104,9 @@ static struct dentry *ll_lookup(struct inode * dir, struct dentry *dentry)
         }
 
        inode = iget4(dir->i_sb, ino, NULL, rep);
-       kfree(hdr); 
+
+        /* FIXME: this is not the right way to get this size */
+        OBD_FREE(hdr, sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep));
 
        if (!inode) 
                return ERR_PTR(-EACCES);
index 4a31e40..cc48ec0 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <asm/uaccess.h>
-#include <linux/vmalloc.h>
 #include <asm/segment.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
index 9c13cc6..0f647e0 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <asm/uaccess.h>
-#include <linux/vmalloc.h>
 #include <asm/segment.h>
 
 #include <linux/obd_support.h>
@@ -57,7 +56,7 @@ static char *ll_read_opt(const char *opt, char *data)
        }
 
         value++;
-        OBD_ALLOC(retval, char *, strlen(value) + 1);
+        OBD_ALLOC(retval, strlen(value) + 1);
         if ( !retval ) {
                 printk(KERN_ALERT __FUNCTION__ ": out of memory!\n");
                 return NULL;
@@ -168,7 +167,9 @@ static struct super_block * ll_read_super(struct super_block *sb,
         
 ERR:
        if (hdr)
-               kfree(hdr);
+                /* FIXME: sigh, another stupid hardcoded size */
+                OBD_FREE(hdr, sizeof(struct ptlrep_hdr) +
+                         sizeof(struct mds_rep));
         if (device)
                 OBD_FREE(device, strlen(device) + 1);
         if (version)
index 15b490c..541eaf2 100644 (file)
@@ -1,5 +1,22 @@
-/*
- * Copryright (C) 2001 Cluster File Systems, Inc.
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
+ *
+ *   This file is part of Portals, http://www.sf.net/projects/lustre/
+ *
+ *   Portals 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.
+ *
+ *   Portals 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 Portals; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  */
 
@@ -22,7 +39,6 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <asm/uaccess.h>
-#include <linux/vmalloc.h>
 #include <asm/segment.h>
 #include <linux/miscdevice.h>
 
@@ -32,7 +48,8 @@
 #include <linux/lustre_mds.h>
 
 extern int mdc_reint(struct lustre_peer *peer, struct ptlrpc_request *request);
-extern struct ptlrpc_request *mds_prep_req(int opcode, int namelen, char *name, int tgtlen, char *tgt);
+extern struct ptlrpc_request *mds_prep_req(int opcode, int namelen, char *name,
+                                           int tgtlen, char *tgt);
 
 int mdc_setattr(struct lustre_peer *peer, 
                struct inode *inode, struct iattr *iattr,
@@ -102,7 +119,7 @@ int mdc_create(struct lustre_peer *peer,
                *hdr = request->rq_rephdr;
        }
 
-       kfree(request); 
+        OBD_FREE(request, sizeof(*request));
        return rc;
 }
 
@@ -136,7 +153,7 @@ int mdc_unlink(struct lustre_peer *peer,
                *hdr = request->rq_rephdr;
        }
 
-       kfree(request); 
+        OBD_FREE(request, sizeof(*request));
        return rc;
 }
 
@@ -170,7 +187,7 @@ int mdc_link(struct lustre_peer *peer, struct dentry *src,
                *hdr = request->rq_rephdr;
        }
 
-       kfree(request); 
+        OBD_FREE(request, sizeof(*request));
        return rc;
 }
 
@@ -206,6 +223,6 @@ int mdc_rename(struct lustre_peer *peer, struct inode *src,
                *hdr = request->rq_rephdr;
        }
 
-       kfree(request); 
+        OBD_FREE(request, sizeof(*request));
        return rc;
 }
index 8a438ff..a22582e 100644 (file)
@@ -1,5 +1,22 @@
-/*
- * Copryright (C) 2001 Cluster File Systems, Inc.
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
+ *
+ *   This file is part of Portals, http://www.sf.net/projects/lustre/
+ *
+ *   Portals 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.
+ *
+ *   Portals 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 Portals; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  */
 
@@ -22,7 +39,6 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <asm/uaccess.h>
-#include <linux/vmalloc.h>
 #include <asm/segment.h>
 #include <linux/miscdevice.h>
 
@@ -38,13 +54,14 @@ extern int mds_queue_req(struct ptlrpc_request *);
 /* FIXME: this belongs in some sort of service struct */
 static int mdc_xid = 0;
 
-struct ptlrpc_request *mds_prep_req(int opcode, int namelen, char *name, int tgtlen, char *tgt)
+struct ptlrpc_request *mds_prep_req(int opcode, int namelen, char *name,
+                                    int tgtlen, char *tgt)
 {
        struct ptlrpc_request *request;
        int rc;
        ENTRY; 
 
-       request = (struct ptlrpc_request *)kmalloc(sizeof(*request), GFP_KERNEL); 
+       OBD_ALLOC(request, sizeof(*request));
        if (!request) { 
                printk("mds_prep_req: request allocation out of memory\n");
                return NULL;
@@ -113,7 +130,7 @@ static int mds_queue_wait(struct ptlrpc_request *req, struct lustre_peer *peer)
 
 void mdc_free_req(struct ptlrpc_request *request)
 {
-       kfree(request);
+       OBD_FREE(request, sizeof(*request));
 }
 
 int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid, 
@@ -215,7 +232,7 @@ int mdc_reint(struct lustre_peer *peer, struct ptlrpc_request *request)
 
 
 static int request_ioctl(struct inode *inode, struct file *file, 
-                      unsigned int cmd, unsigned long arg)
+                         unsigned int cmd, unsigned long arg)
 {
        int err;
        struct lustre_peer peer, *peer_ptr = NULL;
@@ -245,8 +262,11 @@ static int request_ioctl(struct inode *inode, struct file *file,
                struct ptlrep_hdr *hdr = NULL;
                printk("-- getting attr for ino 2\n"); 
                err = mdc_getattr(peer_ptr, 2, S_IFDIR, ~0, NULL, &hdr);
-               if (hdr)
-                       kfree(hdr);
+               if (hdr) {
+                        /* FIXME: there must be a better way to get the size */
+                       OBD_FREE(hdr, sizeof(struct ptlrep_hdr) +
+                                 sizeof(struct mds_rep));
+                }
                printk("-- done err %d\n", err);
                break;
        }
@@ -254,7 +274,7 @@ static int request_ioctl(struct inode *inode, struct file *file,
        case IOC_REQUEST_READPAGE: { 
                struct ptlrep_hdr *hdr = NULL;
                char *buf;
-               buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 
+               OBD_ALLOC(buf, PAGE_SIZE);
                if (!buf) { 
                        err = -ENOMEM;
                        break;
@@ -265,10 +285,11 @@ static int request_ioctl(struct inode *inode, struct file *file,
                if (!err) { 
                        printk("-- status: %d\n", hdr->status); 
                        err = hdr->status;
-                       if (hdr) 
-                               kfree(hdr);
+                        if (hdr)
+                                OBD_FREE(hdr, sizeof(struct ptlrep_hdr) +
+                                         sizeof(struct mds_rep));
                }
-               kfree(buf); 
+               OBD_FREE(buf, PAGE_SIZE);
                break;
        }
 
@@ -288,7 +309,8 @@ static int request_ioctl(struct inode *inode, struct file *file,
                        printk("-- status: %d\n", hdr->status); 
                        err = hdr->status;
                } else {
-                       kfree(hdr); 
+                        OBD_FREE(hdr, sizeof(struct ptlrep_hdr) +
+                                 sizeof(struct mds_rep));
                }
                break;
        }
@@ -312,7 +334,8 @@ static int request_ioctl(struct inode *inode, struct file *file,
                        printk("-- status: %d\n", hdr->status); 
                        err = hdr->status;
                }
-               kfree(hdr); 
+                OBD_FREE(hdr, sizeof(struct ptlrep_hdr) +
+                         sizeof(struct mds_rep));
                break;
        }
 
index 3db4517..2308ffb 100644 (file)
@@ -47,7 +47,7 @@ static int mds_queue_req(struct ptlrpc_request *req)
                return -1;
        }
 
-       srv_req = kmalloc(sizeof(*srv_req), GFP_KERNEL);
+       OBD_ALLOC(srv_req, sizeof(*srv_req));
        if (!srv_req) { 
                EXIT;
                return -ENOMEM;
@@ -60,7 +60,7 @@ static int mds_queue_req(struct ptlrpc_request *req)
 
        /* move the request buffer */
        srv_req->rq_reqbuf = req->rq_reqbuf;
-       srv_req->rq_reqlen    = req->rq_reqlen;
+       srv_req->rq_reqlen = req->rq_reqlen;
        srv_req->rq_obd = MDS;
 
        /* remember where it came from */
@@ -89,24 +89,25 @@ int mds_sendpage(struct ptlrpc_request *req, struct file *file,
        } else {
                char *buf;
 
-               buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-               if (!buf) {
+               OBD_ALLOC(buf, PAGE_SIZE);
+               if (!buf)
                        return -ENOMEM;
-               }
 
                set_fs(KERNEL_DS); 
                rc = generic_file_read(file, buf, PAGE_SIZE, &offset); 
                set_fs(oldfs);
 
-               if (rc != PAGE_SIZE) 
+               if (rc != PAGE_SIZE) {
+                        OBD_FREE(buf, PAGE_SIZE);
                        return -EIO;
+                }
 
                req->rq_bulkbuf = buf;
                req->rq_bulklen = PAGE_SIZE;
                rc = ptl_send_buf(req, &req->rq_peer, MDS_BULK_PORTAL, 0);
                init_waitqueue_head(&req->rq_wait_for_bulk);
                sleep_on(&req->rq_wait_for_bulk);
-               kfree(buf);
+                OBD_FREE(buf, PAGE_SIZE);
                req->rq_bulklen = 0; /* FIXME: eek. */
        }
 
@@ -134,7 +135,7 @@ int mds_reply(struct ptlrpc_request *req)
                req->rq_replen = 0;
 
                /* free the request buffer */
-               kfree(req->rq_reqbuf);
+               OBD_FREE(req->rq_reqbuf, req->rq_reqlen);
                req->rq_reqbuf = NULL;
 
                /* wake up the client */ 
@@ -151,7 +152,7 @@ int mds_error(struct ptlrpc_request *req)
 
        ENTRY;
 
-       hdr = kmalloc(sizeof(*hdr), GFP_KERNEL);
+       OBD_ALLOC(hdr, sizeof(*hdr));
        if (!hdr) { 
                EXIT;
                return -ENOMEM;
@@ -170,7 +171,8 @@ int mds_error(struct ptlrpc_request *req)
        return mds_reply(req);
 }
 
-struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, struct vfsmount **mnt)
+struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
+                              struct vfsmount **mnt)
 {
        /* stolen from NFS */ 
        struct super_block *sb = mds->mds_sb; 
@@ -572,8 +574,7 @@ static int mds_setup(struct obd_device *obddev, obd_count len,
 
        err = kportal_uuid_to_peer("self", &peer);
        if (err == 0) {
-               mds->mds_service = kmalloc(sizeof(*mds->mds_service),
-                                                 GFP_KERNEL);
+               OBD_ALLOC(mds->mds_service, sizeof(*mds->mds_service));
                if (mds->mds_service == NULL)
                        return -ENOMEM;
                mds->mds_service->srv_buf_size = 64 * 1024;
@@ -611,6 +612,9 @@ static int mds_cleanup(struct obd_device * obddev)
 
        MDS = NULL;
        mds_stop_srv_thread(mds);
+        rpc_unregister_service(mds->mds_service);
+        OBD_FREE(mds->mds_service, sizeof(*mds->mds_service));
+
         sb = mds->mds_sb;
         if (!mds->mds_sb){
                 EXIT;
index 893162c..0aa03fe 100644 (file)
@@ -42,7 +42,6 @@
 #include <linux/delay.h>
 #include <linux/skbuff.h>
 #include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/poll.h>
 #include <linux/init.h>
@@ -725,7 +724,6 @@ int obd_register_type(struct obd_ops *ops, char *nm)
 {
         struct obd_type *type;
 
-
         if (obd_init_magic != 0x11223344) {
                 printk(__FUNCTION__ ": bad magic for type\n");
                 EXIT;
@@ -738,7 +736,7 @@ int obd_register_type(struct obd_ops *ops, char *nm)
                 return -EEXIST;
         }
         
-        OBD_ALLOC(type, struct obd_type * , sizeof(*type));
+        OBD_ALLOC(type, sizeof(*type));
         if ( !type ) {
                 EXIT;
                 return -ENOMEM;
@@ -785,7 +783,6 @@ static struct file_operations obd_psdev_fops = {
         release: obd_class_release,     /* release */
 };
 
-
 /* modules setup */
 #define OBD_MINOR 241
 static struct miscdevice obd_psdev = {
@@ -840,7 +837,7 @@ EXPORT_SYMBOL(obdo_cachep);
 /* EXPORT_SYMBOL(gen_multi_attach); */
 EXPORT_SYMBOL(gen_multi_setup);
 EXPORT_SYMBOL(gen_multi_cleanup);
-
+EXPORT_SYMBOL(obd_memory);
 
 #ifdef MODULE
 int init_module(void)
index fc8770e..c24089c 100644 (file)
@@ -87,7 +87,7 @@ int gen_connect (struct obd_conn *conn)
 {
         struct obd_client * cli;
 
-        OBD_ALLOC(cli, struct obd_client *, sizeof(struct obd_client));
+        OBD_ALLOC(cli, sizeof(struct obd_client));
         if ( !cli ) {
                 printk(__FUNCTION__ ": no memory! (minor %d)\n", 
                        conn->oc_dev->obd_minor);
index 2422881..7a9481a 100644 (file)
@@ -56,7 +56,7 @@ static char *obdfs_read_opt(const char *opt, char *data)
                 return NULL;
 
         value++;
-        OBD_ALLOC(retval, char *, strlen(value) + 1);
+        OBD_ALLOC(retval, strlen(value) + 1);
         if ( !retval ) {
                 printk(KERN_ALERT __FUNCTION__ ": out of memory!\n");
                 return NULL;
index f1cfd3f..e40bb36 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <asm/uaccess.h>
-#include <linux/vmalloc.h>
 #include <asm/segment.h>
 #include <linux/miscdevice.h>
 
@@ -53,7 +52,7 @@ struct ptlrpc_request *ost_prep_req(int opcode, int buflen1, char *buf1,
        int rc;
        ENTRY; 
 
-       request = (struct ptlrpc_request *)kmalloc(sizeof(*request), GFP_KERNEL); 
+       OBD_ALLOC(request, sizeof(*request));
        if (!request) { 
                printk("osc_prep_req: request allocation out of memory\n");
                return NULL;
@@ -132,7 +131,7 @@ extern int osc_queue_wait(struct obd_conn *conn, struct ptlrpc_request *req)
 
 static void osc_free_req(struct ptlrpc_request *request)
 {
-       kfree(request);
+       OBD_FREE(request, sizeof(*request));
 }
 
 static int osc_connect(struct obd_conn *conn)
@@ -431,7 +430,7 @@ int osc_brw(int rw, struct obd_conn *conn, obd_count num_oa,
 
  out:
        if (request->rq_rephdr)
-               kfree(request->rq_rephdr);
+               OBD_FREE(request->rq_rephdr, request->rq_replen);
        n = 0;
        for (i=0; i < num_oa; i++) { 
                for (j = 0 ; j < oa_bufs[i] ; j++) { 
index dfeecea..dc034b9 100644 (file)
@@ -49,7 +49,7 @@ static int ost_queue_req(struct obd_device *obddev, struct ptlrpc_request *req)
                return -1;
        }
 
-       srv_req = kmalloc(sizeof(*srv_req), GFP_KERNEL); 
+       OBD_ALLOC(srv_req, sizeof(*srv_req));
        if (!srv_req) { 
                EXIT;
                return -ENOMEM;
@@ -94,7 +94,7 @@ int ost_reply(struct obd_device *obddev, struct ptlrpc_request *req)
                req->rq_replen = 0;
 
                /* free the request buffer */
-               kfree(req->rq_reqbuf);
+               OBD_FREE(req->rq_reqbuf, req->rq_reqlen);
                req->rq_reqbuf = NULL;
 
                /* wake up the client */ 
@@ -111,7 +111,7 @@ int ost_error(struct obd_device *obddev, struct ptlrpc_request *req)
 
        ENTRY;
 
-       hdr = kmalloc(sizeof(*hdr), GFP_KERNEL);
+       OBD_ALLOC(hdr, sizeof(*hdr));
        if (!hdr) { 
                EXIT;
                return -ENOMEM;
@@ -420,7 +420,6 @@ int ost_handle(struct obd_device *obddev, struct ptlrpc_request *req)
 
        case OST_CONNECT:
                CDEBUG(D_INODE, "connect\n");
-               printk("----> connect \n"); 
                rc = ost_connect(ost, req);
                break;
        case OST_DISCONNECT:
@@ -474,31 +473,19 @@ int ost_main(void *arg)
        struct obd_device *obddev = (struct obd_device *) arg;
        struct ost_obd *ost = &obddev->u.ost;
        ENTRY;
-       printk("---> %d\n", __LINE__);
-
 
        lock_kernel();
-       printk("---> %d\n", __LINE__);
        daemonize();
-       printk("---> %d\n", __LINE__);
        spin_lock_irq(&current->sigmask_lock);
-       printk("---> %d\n", __LINE__);
        sigfillset(&current->blocked);
-       printk("---> %d\n", __LINE__);
        recalc_sigpending(current);
-       printk("---> %d\n", __LINE__);
        spin_unlock_irq(&current->sigmask_lock);
-       printk("---> %d\n", __LINE__);
 
-       printk("---> %d\n", __LINE__);
        sprintf(current->comm, "lustre_ost");
-       printk("---> %d\n", __LINE__);
 
        /* Record that the  thread is running */
        ost->ost_thread = current;
-       printk("---> %d\n", __LINE__);
        wake_up(&ost->ost_done_waitq); 
-       printk("---> %d\n", __LINE__);
 
        /* XXX maintain a list of all managed devices: insert here */
 
@@ -581,15 +568,11 @@ static void ost_start_srv_thread(struct obd_device *obd)
        ENTRY;
 
        init_waitqueue_head(&ost->ost_waitq);
-       printk("---> %d\n", __LINE__);
        init_waitqueue_head(&ost->ost_done_waitq);
-       printk("---> %d\n", __LINE__);
        kernel_thread(ost_main, (void *)obd, 
                      CLONE_VM | CLONE_FS | CLONE_FILES);
-       printk("---> %d\n", __LINE__);
        while (!ost->ost_thread) 
                sleep_on(&ost->ost_done_waitq);
-       printk("---> %d\n", __LINE__);
        EXIT;
 }
 
@@ -636,8 +619,7 @@ static int ost_setup(struct obd_device *obddev, obd_count len,
 
        err = kportal_uuid_to_peer("self", &peer);
        if (err == 0) {
-               ost->ost_service = kmalloc(sizeof(*ost->ost_service),
-                                          GFP_KERNEL);
+               OBD_ALLOC(ost->ost_service, sizeof(*ost->ost_service));
                if (ost->ost_service == NULL)
                        return -ENOMEM;
                ost->ost_service->srv_buf_size = 64 * 1024;
@@ -674,9 +656,9 @@ static int ost_cleanup(struct obd_device * obddev)
                 return -EBUSY;
         }
 
-       rpc_unregister_service(ost->ost_service);
-
        ost_stop_srv_thread(ost);
+       rpc_unregister_service(ost->ost_service);
+        OBD_FREE(ost->ost_service, sizeof(*ost->ost_service));
 
        if (!list_empty(&ost->ost_reqs)) {
                // XXX reply with errors and clean up
index d86bc1f..df6e1bb 100644 (file)
@@ -43,7 +43,7 @@ static int request_callback(ptl_event_t *ev, void *data)
         ENTRY;
 
         if (ev->type == PTL_EVENT_SENT) {
-                kfree(ev->mem_desc.start);
+                OBD_FREE(ev->mem_desc.start, ev->mem_desc.length);
         } else if (ev->type == PTL_EVENT_PUT) {
                 rpc->rq_repbuf = ev->mem_desc.start + ev->offset;
                 wake_up_interruptible(&rpc->rq_wait_for_rep);
@@ -169,7 +169,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, struct lustre_peer *peer)
                 return -EINVAL;
         }
 
-        request->rq_repbuf = kmalloc(request->rq_replen, GFP_KERNEL); 
+        OBD_ALLOC(request->rq_repbuf, request->rq_replen);
         if (!request->rq_repbuf) { 
                 EXIT;
                 return -ENOMEM;
@@ -239,7 +239,7 @@ int rpc_register_service(struct ptlrpc_service *service, char *uuid)
                 return -EINVAL;
         }
 
-        service->srv_buf = kmalloc(service->srv_buf_size, GFP_KERNEL);
+        OBD_ALLOC(service->srv_buf, service->srv_buf_size);
         if (service->srv_buf == NULL) {
                 printk(__FUNCTION__ ": no memory\n");
                 return -ENOMEM;
@@ -298,7 +298,7 @@ int rpc_unregister_service(struct ptlrpc_service *service)
         if (rc)
                 printk(__FUNCTION__ ": PtlMEUnlink failed: %d\n", rc);
 
-        kfree(service->srv_buf);
+        OBD_FREE(service->srv_buf, service->srv_buf_size);
         return 0;
 }
 
@@ -338,6 +338,8 @@ static int __init ptlrpc_init(void)
 static void __exit ptlrpc_exit(void)
 {
         PtlEQFree(req_eq);
+        PtlEQFree(bulk_source_eq);
+        PtlEQFree(bulk_sink_eq);
 
         inter_module_put(LUSTRE_NAL "_ni");
 
index 40bbf16..a087eb0 100755 (executable)
@@ -5,19 +5,19 @@ SRCDIR="`dirname $0`"
 
 mknod /dev/portals c 10 240
 
-insmod $R/usr/src/portals/linux/oslib/portals.o
-insmod $R/usr/src/portals/linux/socknal/ksocknal.o
+insmod $R/usr/src/portals/linux/oslib/portals.o || exit -1
+insmod $R/usr/src/portals/linux/socknal/ksocknal.o || exit -1
 
 $R/usr/src/portals/linux/utils/acceptor 1234 &
 
-insmod $R/usr/src/obd/rpc/ptlrpc.o
-insmod $R/usr/src/obd/class/obdclass.o 
-insmod $R/usr/src/obd/ext2obd/obdext2.o
-insmod $R/usr/src/obd/ost/ost.o
-insmod $R/usr/src/obd/osc/osc.o
-insmod $R/usr/src/obd/mds/mds.o
-insmod $R/usr/src/obd/mdc/mdc.o
-insmod $R/usr/src/obd/llight/llight.o
+insmod $R/usr/src/obd/class/obdclass.o || exit -1
+insmod $R/usr/src/obd/rpc/ptlrpc.o || exit -1
+insmod $R/usr/src/obd/ext2obd/obdext2.o || exit -1
+insmod $R/usr/src/obd/ost/ost.o || exit -1
+insmod $R/usr/src/obd/osc/osc.o || exit -1
+insmod $R/usr/src/obd/mds/mds.o || exit -1
+insmod $R/usr/src/obd/mdc/mdc.o || exit -1
+insmod $R/usr/src/obd/llight/llight.o || exit -1
 
 $R/usr/src/portals/linux/utils/ptlctl <<EOF
 mynid
@@ -31,11 +31,11 @@ EOF
 
 dd if=/dev/zero of=/tmp/ost bs=1024 count=10000
 mke2fs -b 4096 -F /tmp/ost
-losetup ${LOOP}0 /tmp/ost
+losetup ${LOOP}0 /tmp/ost || exit -1
 
 dd if=/dev/zero of=/tmp/mds bs=1024 count=10000
 mke2fs -b 4096 -F /tmp/mds
-losetup ${LOOP}1 /tmp/mds
+losetup ${LOOP}1 /tmp/mds || exit -1
 
 mknod /dev/obd c 10 241
 echo 8291 > /proc/sys/obd/debug
index 6681d3f..548098b 100755 (executable)
@@ -28,8 +28,8 @@ rmmod mds
 rmmod osc
 rmmod ost
 rmmod obdext2
-rmmod obdclass
 rmmod ptlrpc
+rmmod obdclass
 
 $R/usr/src/portals/linux/utils/ptlctl <<EOF
 setup tcp