#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)
/*
#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
-
#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>
*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;
*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;
#include <linux/fs.h>
#include <linux/stat.h>
#include <asm/uaccess.h>
-#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <asm/segment.h>
#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>
*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;
*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;
#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>
}
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);
#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>
#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>
}
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;
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)
-/*
- * 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.
*
*/
#include <linux/fs.h>
#include <linux/stat.h>
#include <asm/uaccess.h>
-#include <linux/vmalloc.h>
#include <asm/segment.h>
#include <linux/miscdevice.h>
#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,
*hdr = request->rq_rephdr;
}
- kfree(request);
+ OBD_FREE(request, sizeof(*request));
return rc;
}
*hdr = request->rq_rephdr;
}
- kfree(request);
+ OBD_FREE(request, sizeof(*request));
return rc;
}
*hdr = request->rq_rephdr;
}
- kfree(request);
+ OBD_FREE(request, sizeof(*request));
return rc;
}
*hdr = request->rq_rephdr;
}
- kfree(request);
+ OBD_FREE(request, sizeof(*request));
return rc;
}
-/*
- * 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.
*
*/
#include <linux/fs.h>
#include <linux/stat.h>
#include <asm/uaccess.h>
-#include <linux/vmalloc.h>
#include <asm/segment.h>
#include <linux/miscdevice.h>
/* 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;
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,
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;
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;
}
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;
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;
}
printk("-- status: %d\n", hdr->status);
err = hdr->status;
} else {
- kfree(hdr);
+ OBD_FREE(hdr, sizeof(struct ptlrep_hdr) +
+ sizeof(struct mds_rep));
}
break;
}
printk("-- status: %d\n", hdr->status);
err = hdr->status;
}
- kfree(hdr);
+ OBD_FREE(hdr, sizeof(struct ptlrep_hdr) +
+ sizeof(struct mds_rep));
break;
}
return -1;
}
- srv_req = kmalloc(sizeof(*srv_req), GFP_KERNEL);
+ OBD_ALLOC(srv_req, sizeof(*srv_req));
if (!srv_req) {
EXIT;
return -ENOMEM;
/* 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 */
} 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. */
}
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 */
ENTRY;
- hdr = kmalloc(sizeof(*hdr), GFP_KERNEL);
+ OBD_ALLOC(hdr, sizeof(*hdr));
if (!hdr) {
EXIT;
return -ENOMEM;
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;
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;
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;
#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>
{
struct obd_type *type;
-
if (obd_init_magic != 0x11223344) {
printk(__FUNCTION__ ": bad magic for type\n");
EXIT;
return -EEXIST;
}
- OBD_ALLOC(type, struct obd_type * , sizeof(*type));
+ OBD_ALLOC(type, sizeof(*type));
if ( !type ) {
EXIT;
return -ENOMEM;
release: obd_class_release, /* release */
};
-
/* modules setup */
#define OBD_MINOR 241
static struct miscdevice obd_psdev = {
/* 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)
{
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);
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;
#include <linux/fs.h>
#include <linux/stat.h>
#include <asm/uaccess.h>
-#include <linux/vmalloc.h>
#include <asm/segment.h>
#include <linux/miscdevice.h>
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;
static void osc_free_req(struct ptlrpc_request *request)
{
- kfree(request);
+ OBD_FREE(request, sizeof(*request));
}
static int osc_connect(struct obd_conn *conn)
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++) {
return -1;
}
- srv_req = kmalloc(sizeof(*srv_req), GFP_KERNEL);
+ OBD_ALLOC(srv_req, sizeof(*srv_req));
if (!srv_req) {
EXIT;
return -ENOMEM;
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 */
ENTRY;
- hdr = kmalloc(sizeof(*hdr), GFP_KERNEL);
+ OBD_ALLOC(hdr, sizeof(*hdr));
if (!hdr) {
EXIT;
return -ENOMEM;
case OST_CONNECT:
CDEBUG(D_INODE, "connect\n");
- printk("----> connect \n");
rc = ost_connect(ost, req);
break;
case OST_DISCONNECT:
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 */
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;
}
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;
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
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);
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;
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;
if (rc)
printk(__FUNCTION__ ": PtlMEUnlink failed: %d\n", rc);
- kfree(service->srv_buf);
+ OBD_FREE(service->srv_buf, service->srv_buf_size);
return 0;
}
static void __exit ptlrpc_exit(void)
{
PtlEQFree(req_eq);
+ PtlEQFree(bulk_source_eq);
+ PtlEQFree(bulk_sink_eq);
inter_module_put(LUSTRE_NAL "_ni");
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
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
rmmod osc
rmmod ost
rmmod obdext2
-rmmod obdclass
rmmod ptlrpc
+rmmod obdclass
$R/usr/src/portals/linux/utils/ptlctl <<EOF
setup tcp