From 0fb1379443f04da458f97998e3427d57a5f44961 Mon Sep 17 00:00:00 2001 From: pschwan Date: Thu, 21 Feb 2002 23:15:18 +0000 Subject: [PATCH] Pass 1 of debugging and leak cleanup: - 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 --- lustre/include/linux/obd_support.h | 52 +++++++++++++++++-------------------- lustre/lib/mds_pack.c | 5 ++-- lustre/lib/mds_updates.c | 1 - lustre/lib/obd_pack.c | 5 ++-- lustre/lib/page.c | 1 - lustre/llite/namei.c | 4 ++- lustre/llite/rw.c | 1 - lustre/llite/super.c | 7 ++--- lustre/mdc/mdc_reint.c | 33 ++++++++++++++++++------ lustre/mdc/mdc_request.c | 53 +++++++++++++++++++++++++++----------- lustre/mds/handler.c | 28 +++++++++++--------- lustre/obdclass/class_obd.c | 7 ++--- lustre/obdclass/genops.c | 2 +- lustre/obdfs/super.c | 2 +- lustre/osc/osc_request.c | 7 +++-- lustre/ost/ost_handler.c | 30 +++++---------------- lustre/ptlrpc/rpc.c | 10 ++++--- lustre/tests/llmount.sh | 24 ++++++++--------- lustre/tests/llmountcleanup.sh | 2 +- 19 files changed, 145 insertions(+), 129 deletions(-) diff --git a/lustre/include/linux/obd_support.h b/lustre/include/linux/obd_support.h index c091236..7d76129 100644 --- a/lustre/include/linux/obd_support.h +++ b/lustre/include/linux/obd_support.h @@ -9,16 +9,15 @@ #include #include -#include - - -#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 - diff --git a/lustre/lib/mds_pack.c b/lustre/lib/mds_pack.c index 033e68a..0b4e38b 100644 --- a/lustre/lib/mds_pack.c +++ b/lustre/lib/mds_pack.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -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; diff --git a/lustre/lib/mds_updates.c b/lustre/lib/mds_updates.c index 45317b5..f5e5b7f 100644 --- a/lustre/lib/mds_updates.c +++ b/lustre/lib/mds_updates.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include diff --git a/lustre/lib/obd_pack.c b/lustre/lib/obd_pack.c index 47917ab..e787e26 100644 --- a/lustre/lib/obd_pack.c +++ b/lustre/lib/obd_pack.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -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; diff --git a/lustre/lib/page.c b/lustre/lib/page.c index ee96147..28f9d8b 100644 --- a/lustre/lib/page.c +++ b/lustre/lib/page.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 99e5107..b746770 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -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); diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 4a31e40..cc48ec0 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/lustre/llite/super.c b/lustre/llite/super.c index 9c13cc6..0f647e0 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -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) diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index 15b490c..541eaf2 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -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 #include #include -#include #include #include @@ -32,7 +48,8 @@ #include 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; } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 8a438ff..a22582e 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -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 #include #include -#include #include #include @@ -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; } diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 3db4517..2308ffb 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -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; diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 893162c..0aa03fe 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -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) diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index fc8770e..c24089c 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -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); diff --git a/lustre/obdfs/super.c b/lustre/obdfs/super.c index 2422881..7a9481aa 100644 --- a/lustre/obdfs/super.c +++ b/lustre/obdfs/super.c @@ -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; diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index f1cfd3f..e40bb36 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -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++) { diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index dfeecea..dc034b9 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -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(¤t->sigmask_lock); - printk("---> %d\n", __LINE__); sigfillset(¤t->blocked); - printk("---> %d\n", __LINE__); recalc_sigpending(current); - printk("---> %d\n", __LINE__); spin_unlock_irq(¤t->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 diff --git a/lustre/ptlrpc/rpc.c b/lustre/ptlrpc/rpc.c index d86bc1f..df6e1bb 100644 --- a/lustre/ptlrpc/rpc.c +++ b/lustre/ptlrpc/rpc.c @@ -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"); diff --git a/lustre/tests/llmount.sh b/lustre/tests/llmount.sh index 40bbf16..a087eb0 100755 --- a/lustre/tests/llmount.sh +++ b/lustre/tests/llmount.sh @@ -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 < /proc/sys/obd/debug diff --git a/lustre/tests/llmountcleanup.sh b/lustre/tests/llmountcleanup.sh index 6681d3f..548098b 100755 --- a/lustre/tests/llmountcleanup.sh +++ b/lustre/tests/llmountcleanup.sh @@ -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 <