From 6060a61624cc48b18b59a7bb99fdde355b0186ee Mon Sep 17 00:00:00 2001 From: braam Date: Wed, 27 Feb 2002 09:56:13 +0000 Subject: [PATCH] - bug fix to unload modules with safe wait functions - rewrite of ptlrpc client system - pivot around ptlrpc_client - mdc client & lustre_light uses generic routines - osc can do the same (tomorrow) - different event queues in rpc.c freeing packets & getting replies - every unexpected event or PtlError is now a BUG in rpc.c - change gdb script output to allow reloading everything --- lustre/include/linux/lustre_light.h | 25 +++--- lustre/include/linux/lustre_mds.h | 23 +++--- lustre/include/linux/lustre_net.h | 28 +++++++ lustre/lib/mds_pack.c | 72 ++++++++-------- lustre/llite/dir.c | 11 ++- lustre/llite/namei.c | 12 +-- lustre/llite/rw.c | 6 +- lustre/llite/super.c | 24 ++++-- lustre/mdc/mdc_reint.c | 24 +++--- lustre/mdc/mdc_request.c | 158 +++++++++--------------------------- lustre/mds/handler.c | 26 +++--- lustre/mds/mds_reint.c | 2 +- lustre/ost/ost_handler.c | 25 ++++-- lustre/ptlrpc/rpc.c | 158 ++++++++++++++++++++++++++++++++---- lustre/tests/llmount.sh | 2 +- lustre/utils/obdctl.c | 11 ++- 16 files changed, 362 insertions(+), 245 deletions(-) diff --git a/lustre/include/linux/lustre_light.h b/lustre/include/linux/lustre_light.h index b72bd7d..edb38fb 100644 --- a/lustre/include/linux/lustre_light.h +++ b/lustre/include/linux/lustre_light.h @@ -29,18 +29,21 @@ struct ll_sb_info { struct list_head ll_list; /* list of supers */ struct obd_conn ll_conn; struct super_block *ll_super; - // struct obd_device *ll_obd; - //struct obd_ops *ll_ops; - ino_t ll_rootino; /* number of root inode */ - int ll_minor; /* minor of /dev/obdX */ + ino_t ll_rootino; /* number of root inode */ + int ll_minor; /* minor of /dev/obdX */ struct list_head ll_inodes; /* list of dirty inodes */ - unsigned long ll_cache_count; + unsigned long ll_cache_count; struct semaphore ll_list_mutex; - struct lustre_peer ll_peer; - struct lustre_peer *ll_peer_ptr; + struct ptlrpc_client ll_mds_client; + struct ptlrpc_client ll_ost_client; }; +static inline struct ll_sb_info *ll_i2sbi(struct inode *inode) +{ + return (struct ll_sb_info *) (inode->i_sb->u.generic_sbp); +} + static inline struct ll_inode_info *ll_i2info(struct inode *inode) { return (struct ll_inode_info *)&(inode->u.generic_ip); @@ -52,6 +55,10 @@ static inline int ll_has_inline(struct inode *inode) } +static inline struct obd_conn *ll_i2obdconn(struct inode *inode) +{ + return &(ll_i2sbi(inode))->ll_conn; +} @@ -158,10 +165,6 @@ extern struct inode_operations ll_symlink_inode_operations; void ll_sysctl_init(void); void ll_sysctl_clean(void); -static inline struct ll_sb_info *ll_i2sbi(struct inode *inode) -{ - return (struct ll_sb_info *) &(inode->i_sb->u.generic_sbp); -} static inline struct list_head *ll_slist(struct inode *inode) diff --git a/lustre/include/linux/lustre_mds.h b/lustre/include/linux/lustre_mds.h index 02222be..8186e0b 100644 --- a/lustre/include/linux/lustre_mds.h +++ b/lustre/include/linux/lustre_mds.h @@ -89,10 +89,10 @@ struct mds_update_record { /* mds/mds_pack.c */ void *mds_req_tgt(struct mds_req *req); -int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen, struct ptlreq_hdr **hdr, struct mds_req **req, int *len, char **buf); -int mds_unpack_req(char *buf, int len, struct ptlreq_hdr **hdr, struct mds_req **req); -int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen, struct ptlrep_hdr **hdr, struct mds_rep **rep, int *len, char **buf); -int mds_unpack_rep(char *buf, int len, struct ptlrep_hdr **hdr, struct mds_rep **rep); +int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen, struct ptlreq_hdr **hdr, union ptl_req *req, int *len, char **buf); +int mds_unpack_req(char *buf, int len, struct ptlreq_hdr **hdr, union ptl_req *); +int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen, struct ptlrep_hdr **hdr, union ptl_rep *rep, int *len, char **buf); +int mds_unpack_rep(char *buf, int len, struct ptlrep_hdr **hdr, union ptl_rep *rep); /* mds/mds_reint.c */ int mds_reint_rec(struct mds_update_record *r, struct ptlrpc_request *req); @@ -110,28 +110,29 @@ void mds_rename_pack(struct mds_rec_rename *rec, struct inode *srcdir, struct in struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, struct vfsmount **mnt); /* llight/request.c */ -int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid, +int mdc_getattr(struct ptlrpc_client *peer, ino_t ino, int type, int valid, struct mds_rep **mds_reply, struct ptlrep_hdr **hdr); -int mdc_setattr(struct lustre_peer *peer, struct inode *inode, +int mdc_setattr(struct ptlrpc_client *peer, struct inode *inode, struct iattr *iattr, struct mds_rep **mds_reply, struct ptlrep_hdr **hdr); -int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset, +int mdc_readpage(struct ptlrpc_client *peer, ino_t ino, int type, __u64 offset, char *addr, struct mds_rep **rep, struct ptlrep_hdr **hdr); -int mdc_create(struct lustre_peer *peer, +int mdc_create(struct ptlrpc_client *peer, struct inode *dir, const char *name, int namelen, const char *tgt, int tgtlen, int mode, __u64 id, __u32 uid, __u32 gid, __u64 time, struct mds_rep **rep, struct ptlrep_hdr **hdr); -int mdc_unlink(struct lustre_peer *peer, +int mdc_unlink(struct ptlrpc_client *peer, struct inode *dir, const char *name, int namelen, struct mds_rep **rep, struct ptlrep_hdr **hdr); -int mdc_link(struct lustre_peer *peer, struct dentry *src, +int mdc_link(struct ptlrpc_client *peer, struct dentry *src, struct inode *dir, const char *name, int namelen, struct mds_rep **rep, struct ptlrep_hdr **hdr); -int mdc_rename(struct lustre_peer *peer, struct inode *src, +int mdc_rename(struct ptlrpc_client *peer, struct inode *src, struct inode *tgt, const char *old, int oldlen, const char *new, int newlen, struct mds_rep **rep, struct ptlrep_hdr **hdr); +int mdc_create_client(char *uuid, struct ptlrpc_client *cl); /* ioctls for trying requests */ #define IOC_REQUEST_TYPE 'f' diff --git a/lustre/include/linux/lustre_net.h b/lustre/include/linux/lustre_net.h index f312a80..2aa6862 100644 --- a/lustre/include/linux/lustre_net.h +++ b/lustre/include/linux/lustre_net.h @@ -67,8 +67,14 @@ struct ptlrpc_service { ptl_md_t srv_md[RPC_RING_LENGTH]; ptl_handle_md_t srv_md_h[RPC_RING_LENGTH]; wait_queue_head_t *srv_wait_queue; + int (*srv_req_unpack)(char *buf, int len, struct ptlreq_hdr **, + union ptl_req *); + int (*srv_rep_pack)(char *buf1, int len1, char *buf2, int len2, + struct ptlrep_hdr **, union ptl_rep*, + int *replen, char **repbuf); }; + struct ptlrpc_request { struct list_head rq_list; struct mds_obd *rq_obd; @@ -106,6 +112,21 @@ struct ptlrpc_request { struct lustre_peer rq_peer; }; +struct ptlrpc_client { + struct lustre_peer cli_server; + __u32 cli_request_portal; + __u32 cli_reply_portal; + __u32 cli_xid; + int (*cli_rep_unpack)(char *buf, int len, struct ptlrep_hdr **, + union ptl_rep *); + int (*cli_req_pack)(char *buf1, int len1, char *buf2, int len2, + struct ptlreq_hdr **, union ptl_req*, + int *reqlen, char **reqbuf); + int (*cli_enqueue)(struct ptlrpc_request *req); +}; + + + /* rpc/rpc.c */ int ptl_send_buf(struct ptlrpc_request *request, struct lustre_peer *peer, int portal, int is_request); @@ -113,6 +134,13 @@ int ptl_send_rpc(struct ptlrpc_request *request, struct lustre_peer *peer); int ptl_received_rpc(struct ptlrpc_service *service); int rpc_register_service(struct ptlrpc_service *service, char *uuid); int rpc_unregister_service(struct ptlrpc_service *service); +int ptlrpc_queue_wait(struct ptlrpc_request *req, + struct ptlrpc_client *cl); +struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl, + int opcode, int namelen, char *name, + int tgtlen, char *tgt); +void ptlrpc_free_req(struct ptlrpc_request *request); + /* FIXME */ #if 1 diff --git a/lustre/lib/mds_pack.c b/lustre/lib/mds_pack.c index eebafc3..6a4204f 100644 --- a/lustre/lib/mds_pack.c +++ b/lustre/lib/mds_pack.c @@ -52,13 +52,14 @@ #include int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen, - struct ptlreq_hdr **hdr, struct mds_req **req, + struct ptlreq_hdr **hdr, union ptl_req *r, int *len, char **buf) { + struct mds_req *req; char *ptr; *len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) + - sizeof(**req); + sizeof(*req); OBD_ALLOC(*buf, *len); if (!*buf) { @@ -68,17 +69,19 @@ int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen, memset(*buf, 0, *len); *hdr = (struct ptlreq_hdr *)(*buf); - *req = (struct mds_req *)(*buf + sizeof(**hdr)); - ptr = *buf + sizeof(**hdr) + sizeof(**req); + req = (struct mds_req *)(*buf + sizeof(**hdr)); + r->mds = req; + + ptr = *buf + sizeof(**hdr) + sizeof(*req); (*hdr)->type = MDS_TYPE_REQ; - (*req)->namelen = NTOH__u32(namelen); + req->namelen = NTOH__u32(namelen); if (name) { LOGL(name, namelen, ptr); } - (*req)->tgtlen = NTOH__u32(tgtlen); + req->tgtlen = NTOH__u32(tgtlen); if (tgt) { LOGL(tgt, tgtlen, ptr); } @@ -87,36 +90,38 @@ int mds_pack_req(char *name, int namelen, char *tgt, int tgtlen, int mds_unpack_req(char *buf, int len, - struct ptlreq_hdr **hdr, struct mds_req **req) + struct ptlreq_hdr **hdr, union ptl_req *r) { + struct mds_req *req; char *name, *tgt; - if (len < sizeof(**hdr) + sizeof(**req)) { + if (len < sizeof(**hdr) + sizeof(*req)) { EXIT; return -EINVAL; } *hdr = (struct ptlreq_hdr *) (buf); - *req = (struct mds_req *) (buf + sizeof(**hdr)); + req = (struct mds_req *) (buf + sizeof(**hdr)); + r->mds = req; - (*req)->namelen = NTOH__u32((*req)->namelen); - (*req)->tgtlen = NTOH__u32((*req)->tgtlen); + req->namelen = NTOH__u32(req->namelen); + req->tgtlen = NTOH__u32(req->tgtlen); - if (len < sizeof(**hdr) + sizeof(**req) + - size_round((*req)->namelen) + size_round((*req)->tgtlen) ) { + if (len < sizeof(**hdr) + sizeof(*req) + + size_round(req->namelen) + size_round(req->tgtlen) ) { EXIT; return -EINVAL; } - if ((*req)->namelen) { - name = buf + sizeof(**hdr) + sizeof(**req); + if (req->namelen) { + name = buf + sizeof(**hdr) + sizeof(*req); } else { name = NULL; } - if ((*req)->tgtlen) { - tgt = buf + sizeof(**hdr) + sizeof(**req) + - size_round((*req)->namelen); + if (req->tgtlen) { + tgt = buf + sizeof(**hdr) + sizeof(*req) + + size_round(req->namelen); } else { tgt = NULL; } @@ -141,13 +146,14 @@ void *mds_req_name(struct mds_req *req) } int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen, - struct ptlrep_hdr **hdr, struct mds_rep **rep, + struct ptlrep_hdr **hdr, union ptl_rep *r, int *len, char **buf) { + struct mds_rep *rep; char *ptr; *len = sizeof(**hdr) + size_round(namelen) + size_round(tgtlen) + - sizeof(**rep); + sizeof(*rep); OBD_ALLOC(*buf, *len); if (!*buf) { @@ -157,18 +163,19 @@ int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen, memset(*buf, 0, *len); *hdr = (struct ptlrep_hdr *)(*buf); - *rep = (struct mds_rep *)(*buf + sizeof(**hdr)); + rep = (struct mds_rep *)(*buf + sizeof(**hdr)); + r->mds = rep; - ptr = *buf + sizeof(**hdr) + sizeof(**rep); + ptr = *buf + sizeof(**hdr) + sizeof(*rep); (*hdr)->type = MDS_TYPE_REP; - (*rep)->namelen = NTOH__u32(namelen); + rep->namelen = NTOH__u32(namelen); if (name) { LOGL(name, namelen, ptr); } - (*rep)->tgtlen = NTOH__u32(tgtlen); + rep->tgtlen = NTOH__u32(tgtlen); if (tgt) { LOGL(tgt, tgtlen, ptr); } @@ -176,26 +183,27 @@ int mds_pack_rep(char *name, int namelen, char *tgt, int tgtlen, } int mds_unpack_rep(char *buf, int len, - struct ptlrep_hdr **hdr, struct mds_rep **rep) + struct ptlrep_hdr **hdr, union ptl_rep *r) { - + struct mds_rep *rep; if (len < sizeof(**hdr)) { EXIT; return -EINVAL; } *hdr = (struct ptlrep_hdr *) (buf); - if (len < sizeof(**hdr) + sizeof(**rep)) { + if (len < sizeof(**hdr) + sizeof(*rep)) { EXIT; return -EINVAL; } - *rep = (struct mds_rep *) (buf + sizeof(**hdr)); - (*rep)->namelen = NTOH__u32((*rep)->namelen); - (*rep)->tgtlen = NTOH__u32((*rep)->namelen); + rep = (struct mds_rep *) (buf + sizeof(**hdr)); + r->mds = rep; + rep->namelen = NTOH__u32(rep->namelen); + rep->tgtlen = NTOH__u32(rep->namelen); - if (len < sizeof(**hdr) + sizeof(**rep) - + size_round((*rep)->namelen) + size_round((*rep)->tgtlen) ) { + if (len < sizeof(**hdr) + sizeof(*rep) + + size_round(rep->namelen) + size_round(rep->tgtlen) ) { EXIT; return -EINVAL; } diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 91097ae..1cf2604 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -77,8 +77,8 @@ static int ll_dir_readpage(struct file *file, struct page *page) offset = page->index << PAGE_SHIFT; buf = kmap(page); - rc = mdc_readpage(sbi->ll_peer_ptr, inode->i_ino, S_IFDIR, offset, buf, - NULL, &hdr); + rc = mdc_readpage(&sbi->ll_mds_client, inode->i_ino, S_IFDIR, offset, + buf, NULL, &hdr); kunmap(page); if ( rc ) { EXIT; @@ -170,8 +170,11 @@ static void ext2_check_page(struct page *page) if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) { limit = dir->i_size & ~PAGE_CACHE_MASK; - if (limit & (chunk_size - 1)) + if (limit & (chunk_size - 1)) { + CERROR("limit %d dir size %lld index %ld\n", + limit, dir->i_size, page->index); goto Ebadsize; + } for (offs = limit; offsrec_len = cpu_to_le16(chunk_size); @@ -204,7 +207,7 @@ out: Ebadsize: CERROR("ext2_check_page" - "size of directory #%lu is not a multiple of chunk size", + "size of directory #%lu is not a multiple of chunk size\n", dir->i_ino ); goto fail; diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index f95a8ac..0d25f91 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -98,7 +98,7 @@ static struct dentry *ll_lookup(struct inode * dir, struct dentry *dentry) if (!ino) goto negative; - err = mdc_getattr(sbi->ll_peer_ptr, ino, type, + err = mdc_getattr(&sbi->ll_mds_client, ino, type, OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, &rep, &hdr); if ( err ) { CERROR("obdo_fromid failed\n"); @@ -149,7 +149,7 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, ENTRY; - err = mdc_create(sbi->ll_peer_ptr, dir, name, namelen, tgt, tgtlen, + err = mdc_create(&sbi->ll_mds_client, dir, name, namelen, tgt, tgtlen, mode, id, current->uid, current->gid, time, &rep, &hdr); if (err) { @@ -198,7 +198,7 @@ int ll_mdc_unlink(struct inode *dir, const char *name, int len) ENTRY; - err = mdc_unlink(sbi->ll_peer_ptr, dir, name, len, &rep, &hdr); + err = mdc_unlink(&sbi->ll_mds_client, dir, name, len, &rep, &hdr); if (err) { EXIT; @@ -223,7 +223,7 @@ int ll_mdc_link(struct dentry *src, struct inode *dir, ENTRY; - err = mdc_link(sbi->ll_peer_ptr, src, dir, name, len, &rep, &hdr); + err = mdc_link(&sbi->ll_mds_client, src, dir, name, len, &rep, &hdr); if (err) { EXIT; @@ -248,7 +248,7 @@ int ll_mdc_rename(struct inode *src, struct inode *tgt, ENTRY; - err = mdc_rename(sbi->ll_peer_ptr, src, tgt, + err = mdc_rename(&sbi->ll_mds_client, src, tgt, old->d_name.name, old->d_name.len, new->d_name.name, new->d_name.len, &rep, &hdr); @@ -283,7 +283,7 @@ static int ll_create (struct inode * dir, struct dentry * dentry, int mode) memset(&oa, 0, sizeof(oa)); oa.o_valid = OBD_MD_FLMODE; oa.o_mode = S_IFREG | 0600; - err = obd_create(IID(dir), &oa); + err = obd_create(ll_i2obdconn(dir), &oa); if (err) { EXIT; return err; diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index f69bcf3..5380675 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -174,7 +174,7 @@ static int ll_brw(int rw, struct inode *inode, struct page *page, int create) if (!oa) { return -ENOMEM; } - err = obd_brw(rw, IID(inode), num_obdo, &oa, &bufs_per_obdo, + err = obd_brw(rw, ll_i2obdconn(inode), num_obdo, &oa, &bufs_per_obdo, &page, &count, &offset, &flags); obdo_free(oa); @@ -291,7 +291,7 @@ int ll_commit_write(struct file *file, struct page *page, CDEBUG(D_INODE, "commit_page writing (at %d) to %d, count %Ld\n", from, to, count); - err = obd_brw(OBD_BRW_WRITE, IID(inode), num_obdo, &oa, &bufs_per_obdo, + err = obd_brw(OBD_BRW_WRITE, ll_i2obdconn(inode), num_obdo, &oa, &bufs_per_obdo, &page, &count, &offset, &flags); if ( !err ) { SetPageUptodate(page); @@ -331,7 +331,7 @@ void ll_truncate(struct inode *inode) CDEBUG(D_INFO, "calling punch for %ld (%Lu bytes at 0)\n", (long)oa->o_id, oa->o_size); - err = obd_punch(IID(inode), oa, oa->o_size, 0); + err = obd_punch(ll_i2obdconn(inode), oa, oa->o_size, 0); obdo_free(oa); if (err) { diff --git a/lustre/llite/super.c b/lustre/llite/super.c index 8ada5f2..754fba0 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -96,7 +96,7 @@ static struct super_block * ll_read_super(struct super_block *sb, void *data, int silent) { struct inode *root = 0; - struct ll_sb_info *sbi = (struct ll_sb_info *)(&sb->u.generic_sbp); + struct ll_sb_info *sbi; char *device = NULL; char *version = NULL; int connected = 0; @@ -108,7 +108,13 @@ static struct super_block * ll_read_super(struct super_block *sb, ENTRY; MOD_INC_USE_COUNT; + OBD_ALLOC(sbi, sizeof(*sbi)); + if (!sbi) { + EXIT; + return NULL; + } memset(sbi, 0, sizeof(*sbi)); + sb->u.generic_sbp = (struct ll_sb_info *) sbi; ll_options(data, &device, &version); @@ -134,10 +140,12 @@ static struct super_block * ll_read_super(struct super_block *sb, } connected = 1; - err = kportal_uuid_to_peer("mds", &sbi->ll_peer); - if (err == 0) - sbi->ll_peer_ptr = &sbi->ll_peer; - + err = mdc_create_client("mds", &sbi->ll_mds_client); + if (err) { + CERROR("cannot find MDS\n"); + sb = NULL; + goto ERR; + } sbi->ll_super = sb; sbi->ll_rootino = 2; @@ -148,7 +156,7 @@ static struct super_block * ll_read_super(struct super_block *sb, sb->s_op = &ll_super_operations; /* make root inode */ - err = mdc_getattr(sbi->ll_peer_ptr, sbi->ll_rootino, S_IFDIR, + err = mdc_getattr(&sbi->ll_mds_client, sbi->ll_rootino, S_IFDIR, OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, &rep, &hdr); if (err) { @@ -193,7 +201,7 @@ static void ll_put_super(struct super_block *sb) ENTRY; obd_disconnect(ID(sb)); - + OBD_FREE(sb->u.generic_sbp, sizeof(struct ll_sb_info)); MOD_DEC_USE_COUNT; EXIT; } /* ll_put_super */ @@ -263,7 +271,7 @@ int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc) /* change incore inode */ ll_attr2inode(inode, attr, do_trunc); - err = mdc_setattr(sbi->ll_peer_ptr, inode, attr, NULL, &hdr); + err = mdc_setattr(&sbi->ll_mds_client, inode, attr, NULL, &hdr); if ( err ) CERROR("ll_setattr fails (%d)\n", err); diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index 383f629..7eed74b 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -49,11 +49,9 @@ #include #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 int mdc_reint(struct ptlrpc_client *peer, struct ptlrpc_request *request); -int mdc_setattr(struct lustre_peer *peer, +int mdc_setattr(struct ptlrpc_client *peer, struct inode *inode, struct iattr *iattr, struct mds_rep **rep, struct ptlrep_hdr **hdr) { @@ -61,7 +59,7 @@ int mdc_setattr(struct lustre_peer *peer, struct ptlrpc_request *request; struct mds_rec_setattr *rec; - request = mds_prep_req(MDS_REINT, 0, NULL, sizeof(*rec), NULL); + request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec), NULL); if (!request) { CERROR("mdc request: cannot pack\n"); return -ENOMEM; @@ -87,7 +85,7 @@ int mdc_setattr(struct lustre_peer *peer, return 0; } -int mdc_create(struct lustre_peer *peer, +int mdc_create(struct ptlrpc_client *peer, struct inode *dir, const char *name, int namelen, const char *tgt, int tgtlen, int mode, __u64 id, __u32 uid, __u32 gid, __u64 time, @@ -97,7 +95,7 @@ int mdc_create(struct lustre_peer *peer, struct ptlrpc_request *request; struct mds_rec_create *rec; - request = mds_prep_req(MDS_REINT, 0, NULL, + request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec) + size_round0(namelen) + size_round0(tgtlen), NULL); if (!request) { @@ -125,7 +123,7 @@ int mdc_create(struct lustre_peer *peer, return rc; } -int mdc_unlink(struct lustre_peer *peer, +int mdc_unlink(struct ptlrpc_client *peer, struct inode *dir, const char *name, int namelen, struct mds_rep **rep, struct ptlrep_hdr **hdr) { @@ -133,7 +131,7 @@ int mdc_unlink(struct lustre_peer *peer, struct ptlrpc_request *request; struct mds_rec_unlink *rec; - request = mds_prep_req(MDS_REINT, 0, NULL, + request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec) + size_round0(namelen), NULL); if (!request) { CERROR("mdc_unlink: cannot pack\n"); @@ -159,7 +157,7 @@ int mdc_unlink(struct lustre_peer *peer, return rc; } -int mdc_link(struct lustre_peer *peer, struct dentry *src, +int mdc_link(struct ptlrpc_client *peer, struct dentry *src, struct inode *dir, const char *name, int namelen, struct mds_rep **rep, struct ptlrep_hdr **hdr) { @@ -167,7 +165,7 @@ int mdc_link(struct lustre_peer *peer, struct dentry *src, struct ptlrpc_request *request; struct mds_rec_link *rec; - request = mds_prep_req(MDS_REINT, 0, NULL, + request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec) + size_round0(namelen), NULL); if (!request) { CERROR("mdc_link: cannot pack\n"); @@ -193,7 +191,7 @@ int mdc_link(struct lustre_peer *peer, struct dentry *src, return rc; } -int mdc_rename(struct lustre_peer *peer, struct inode *src, +int mdc_rename(struct ptlrpc_client *peer, struct inode *src, struct inode *tgt, const char *old, int oldlen, const char *new, int newlen, struct mds_rep **rep, struct ptlrep_hdr **hdr) @@ -202,7 +200,7 @@ int mdc_rename(struct lustre_peer *peer, struct inode *src, struct ptlrpc_request *request; struct mds_rec_rename *rec; - request = mds_prep_req(MDS_REINT, 0, NULL, + request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec) + size_round0(oldlen) + size_round0(newlen), NULL); if (!request) { diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 83ea31a..149e8d1 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -53,115 +53,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 *request; - int rc; - ENTRY; - - OBD_ALLOC(request, sizeof(*request)); - if (!request) { - CERROR("request allocation out of memory\n"); - return NULL; - } - - memset(request, 0, sizeof(*request)); - request->rq_xid = mdc_xid++; - - rc = mds_pack_req(name, namelen, tgt, tgtlen, - &request->rq_reqhdr, &(request->rq_req.mds), - &request->rq_reqlen, &request->rq_reqbuf); - if (rc) { - CERROR("llight request: cannot pack request %d\n", rc); - return NULL; - } - CDEBUG(0, "--> len %d, req %p, tgtlen %d\n", - request->rq_reqlen, request->rq_req.mds, - request->rq_req.mds->tgtlen); - request->rq_reqhdr->opc = opcode; - - EXIT; - return request; -} - -static int mds_queue_wait(struct ptlrpc_request *req, struct lustre_peer *peer) -{ - int rc; - DECLARE_WAITQUEUE(wait, current); - - init_waitqueue_head(&req->rq_wait_for_rep); - - /* XXX fix the race here (wait_for_event?)*/ - if (peer == NULL) { - /* Local delivery */ - ENTRY; - rc = mds_queue_req(req); - } else { - /* Remote delivery via portals. */ - req->rq_req_portal = MDS_REQUEST_PORTAL; - req->rq_reply_portal = MDS_REPLY_PORTAL; - rc = ptl_send_rpc(req, peer); - } - if (rc) { - CERROR("error %d, opcode %d\n", rc, - req->rq_reqhdr->opc); - return -rc; - } - - CDEBUG(0, "-- sleeping\n"); - add_wait_queue(&req->rq_wait_for_rep, &wait); - while (req->rq_repbuf == NULL) { - set_current_state(TASK_INTERRUPTIBLE); - - /* if this process really wants to die, let it go */ - if (sigismember(&(current->pending.signal), SIGKILL) || - sigismember(&(current->pending.signal), SIGINT)) - break; - - schedule(); - } - remove_wait_queue(&req->rq_wait_for_rep, &wait); - set_current_state(TASK_RUNNING); - CDEBUG(0, "-- done\n"); - - if (req->rq_repbuf == NULL) { - /* We broke out because of a signal */ - EXIT; - return -EINTR; - } - - rc = mds_unpack_rep(req->rq_repbuf, req->rq_replen, &req->rq_rephdr, - &req->rq_rep.mds); - if (rc) { - CERROR("mds_unpack_rep failed: %d\n", rc); - return rc; - } - - if ( req->rq_rephdr->status == 0 ) - CDEBUG(0, "--> buf %p len %d status %d\n", - req->rq_repbuf, req->rq_replen, - req->rq_rephdr->status); - - EXIT; - return 0; -} - -void mdc_free_req(struct ptlrpc_request *request) -{ - OBD_FREE(request, sizeof(*request)); -} - -int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid, +int mdc_getattr(struct ptlrpc_client *peer, ino_t ino, int type, int valid, struct mds_rep **rep, struct ptlrep_hdr **hdr) { struct ptlrpc_request *request; int rc; - request = mds_prep_req(MDS_GETATTR, 0, NULL, 0, NULL); + request = ptlrpc_prep_req(peer, MDS_GETATTR, 0, NULL, 0, NULL); if (!request) { CERROR("llight request: cannot pack\n"); return -ENOMEM; @@ -173,7 +72,7 @@ int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid, request->rq_replen = sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); - rc = mds_queue_wait(request, peer); + rc = ptlrpc_queue_wait(request, peer); if (rc) { CERROR("llight request: error in handling %d\n", rc); goto out; @@ -189,11 +88,11 @@ int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid, } out: - mdc_free_req(request); + ptlrpc_free_req(request); return rc; } -int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset, +int mdc_readpage(struct ptlrpc_client *peer, ino_t ino, int type, __u64 offset, char *addr, struct mds_rep **rep, struct ptlrep_hdr **hdr) { struct ptlrpc_request *request; @@ -204,7 +103,7 @@ int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset, CDEBUG(D_INODE, "inode: %ld\n", ino); - request = mds_prep_req(MDS_READPAGE, 0, NULL, + request = ptlrpc_prep_req(peer, MDS_READPAGE, 0, NULL, sizeof(struct niobuf), (char *)&niobuf); if (!request) { CERROR("mdc request: cannot pack\n"); @@ -222,7 +121,7 @@ int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset, request->rq_replen = sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); - rc = mds_queue_wait(request, peer); + rc = ptlrpc_queue_wait(request, peer); if (rc) { CERROR("mdc request: error in handling %d\n", rc); goto out; @@ -238,15 +137,15 @@ int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset, } out: - mdc_free_req(request); + ptlrpc_free_req(request); return rc; } -int mdc_reint(struct lustre_peer *peer, struct ptlrpc_request *request) +int mdc_reint(struct ptlrpc_client *peer, struct ptlrpc_request *request) { int rc; - rc = mds_queue_wait(request, peer); + rc = ptlrpc_queue_wait(request, peer); if (rc) { CERROR("mdc request: error in handling %d\n", rc); } @@ -254,12 +153,30 @@ int mdc_reint(struct lustre_peer *peer, struct ptlrpc_request *request) return rc; } +int mdc_create_client(char *uuid, struct ptlrpc_client *cl) +{ + int err; + + memset(cl, 0, sizeof(*cl)); + cl->cli_xid = 0; + cl->cli_rep_unpack = mds_unpack_rep; + cl->cli_req_pack = mds_pack_req; + err = kportal_uuid_to_peer("mds", &cl->cli_server); + if (err == 0) { + cl->cli_request_portal = MDS_REQUEST_PORTAL; + cl->cli_reply_portal = MDS_REPLY_PORTAL; + + } else { + cl->cli_enqueue = mds_queue_req; + } + return 0; +} static int request_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { int err; - struct lustre_peer peer, *peer_ptr = NULL; + struct ptlrpc_client peer; ENTRY; @@ -277,15 +194,17 @@ static int request_ioctl(struct inode *inode, struct file *file, return -EINVAL; } - err = kportal_uuid_to_peer("mds", &peer); - if (err == 0) - peer_ptr = &peer; + err = mdc_create_client("mds", &peer); + if (err) { + CERROR("cannot create client"); + return -EINVAL; + } switch (cmd) { case IOC_REQUEST_GETATTR: { struct ptlrep_hdr *hdr = NULL; CERROR("-- getting attr for ino 2\n"); - err = mdc_getattr(peer_ptr, 2, S_IFDIR, ~0, NULL, &hdr); + err = mdc_getattr(&peer, 2, S_IFDIR, ~0, NULL, &hdr); if (hdr) { /* FIXME: there must be a better way to get the size */ OBD_FREE(hdr, sizeof(struct ptlrep_hdr) + @@ -304,7 +223,7 @@ static int request_ioctl(struct inode *inode, struct file *file, break; } CERROR("-- readpage 0 for ino 2\n"); - err = mdc_readpage(peer_ptr, 2, S_IFDIR, 0, buf, NULL, &hdr); + err = mdc_readpage(&peer, 2, S_IFDIR, 0, buf, NULL, &hdr); CERROR("-- done err %d\n", err); if (!err) { CERROR("-- status: %d\n", hdr->status); @@ -327,7 +246,7 @@ static int request_ioctl(struct inode *inode, struct file *file, iattr.ia_atime = 0; iattr.ia_valid = ATTR_MODE | ATTR_ATIME; - err = mdc_setattr(peer_ptr, &inode, &iattr, NULL, &hdr); + err = mdc_setattr(&peer, &inode, &iattr, NULL, &hdr); CERROR("-- done err %d\n", err); if (!err) { CERROR("-- status: %d\n", hdr->status); @@ -349,7 +268,7 @@ static int request_ioctl(struct inode *inode, struct file *file, iattr.ia_atime = 0; iattr.ia_valid = ATTR_MODE | ATTR_ATIME; - err = mdc_create(peer_ptr, &inode, + err = mdc_create(&peer, &inode, "foofile", strlen("foofile"), NULL, 0, 0100707, 47114711, 11, 47, 0, NULL, &hdr); @@ -401,6 +320,7 @@ MODULE_AUTHOR("Peter J. Braam "); MODULE_DESCRIPTION("Lustre MDS Request Tester v1.0"); MODULE_LICENSE("GPL"); +EXPORT_SYMBOL(mdc_create_client); EXPORT_SYMBOL(mdc_create); EXPORT_SYMBOL(mdc_unlink); EXPORT_SYMBOL(mdc_rename); diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index a6be005..c41c901 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -251,7 +251,7 @@ int mds_getattr(struct ptlrpc_request *req) struct mds_rep *rep; int rc; - rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.mds, + rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep, &req->rq_replen, &req->rq_repbuf); if (rc) { EXIT; @@ -295,7 +295,7 @@ int mds_readpage(struct ptlrpc_request *req) struct mds_rep *rep; int rc; - rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.mds, + rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep, &req->rq_replen, &req->rq_repbuf); if (rc) { EXIT; @@ -373,7 +373,7 @@ int mds_handle(struct ptlrpc_request *req) } rc = mds_unpack_req(req->rq_reqbuf, req->rq_reqlen, - &req->rq_reqhdr, &req->rq_req.mds); + &req->rq_reqhdr, &req->rq_req); if (rc) { CERROR("lustre_mds: Invalid request\n"); EXIT; @@ -453,13 +453,11 @@ int mds_main(void *arg) /* And now, wait forever for commit wakeup events. */ while (1) { + int signal; int rc; - if (mds->mds_flags & MDS_UNMOUNT) - break; wake_up(&mds->mds_done_waitq); - interruptible_sleep_on(&mds->mds_waitq); CDEBUG(D_INODE, "mds_wakes pick up req here and continue\n"); if (mds->mds_service != NULL) { @@ -469,21 +467,26 @@ int mds_main(void *arg) CDEBUG(D_IOCTL, "-- sleeping\n"); + signal = 0; add_wait_queue(&mds->mds_waitq, &wait); while (1) { + set_current_state(TASK_INTERRUPTIBLE); rc = PtlEQGet(mds->mds_service->srv_eq_h, &ev); if (rc == PTL_OK || rc == PTL_EQ_DROPPED) break; + if (mds->mds_flags & MDS_UNMOUNT) + break; - set_current_state(TASK_INTERRUPTIBLE); /* if this process really wants to die, * let it go */ if (sigismember(&(current->pending.signal), SIGKILL) || sigismember(&(current->pending.signal), - SIGINT)) + SIGINT)) { + signal = 1; break; + } schedule(); } @@ -491,10 +494,13 @@ int mds_main(void *arg) set_current_state(TASK_RUNNING); CDEBUG(D_IOCTL, "-- done\n"); - if (rc == PTL_EQ_EMPTY) { + if (signal == 1) { /* We broke out because of a signal */ EXIT; - return -EINTR; + break; + } + if (mds->mds_flags & MDS_UNMOUNT) { + break; } service = (struct ptlrpc_service *)ev.mem_desc.user_ptr; diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 69865ec..4cc4187 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -341,7 +341,7 @@ int mds_reint_rec(struct mds_update_record *rec, struct ptlrpc_request *req) return rc; } - rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.mds, + rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep, &req->rq_replen, &req->rq_repbuf); if (rc) { EXIT; diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index f665110..3ba12c7 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -525,6 +525,7 @@ out: /* FIXME: Serious refactoring needed */ int ost_main(void *arg) { + int signal; struct obd_device *obddev = (struct obd_device *) arg; struct ost_obd *ost = &obddev->u.ost; DECLARE_WAITQUEUE(wait, current); @@ -550,30 +551,32 @@ int ost_main(void *arg) while (1) { int rc; - if (ost->ost_flags & OST_EXIT) - break; - if (ost->ost_service != NULL) { ptl_event_t ev; struct ptlrpc_request request; struct ptlrpc_service *service; CDEBUG(D_IOCTL, "-- sleeping\n"); + signal = 0; add_wait_queue(&ost->ost_waitq, &wait); while (1) { + set_current_state(TASK_INTERRUPTIBLE); rc = PtlEQGet(ost->ost_service->srv_eq_h, &ev); if (rc == PTL_OK || rc == PTL_EQ_DROPPED) break; + if (ost->ost_flags & OST_EXIT) + break; - set_current_state(TASK_INTERRUPTIBLE); /* if this process really wants to die, * let it go */ if (sigismember(&(current->pending.signal), SIGKILL) || sigismember(&(current->pending.signal), - SIGINT)) + SIGINT)) { + signal = 1; break; + } schedule(); } @@ -581,10 +584,14 @@ int ost_main(void *arg) set_current_state(TASK_RUNNING); CDEBUG(D_IOCTL, "-- done\n"); - if (rc == PTL_EQ_EMPTY) { + if (signal == 1) { /* We broke out because of a signal */ EXIT; - return -EINTR; + break; + } + if (ost->ost_flags & OST_EXIT) { + EXIT; + break; } service = (struct ptlrpc_service *)ev.mem_desc.user_ptr; @@ -637,13 +644,13 @@ int ost_main(void *arg) if (list_empty(&ost->ost_reqs)) { CDEBUG(D_INODE, "woke because of signal\n"); - spin_unlock(&ost->ost_req_lock); + spin_unlock(&ost->ost_lock); } else { request = list_entry(ost->ost_reqs.next, struct ptlrpc_request, rq_list); list_del(&request->rq_list); - spin_unlock(&ost->ost_req_lock); + spin_unlock(&ost->ost_lock); rc = ost_handle(obddev, request); } } diff --git a/lustre/ptlrpc/rpc.c b/lustre/ptlrpc/rpc.c index 82eb71a..3fdc05c 100644 --- a/lustre/ptlrpc/rpc.c +++ b/lustre/ptlrpc/rpc.c @@ -31,24 +31,139 @@ #include #include -static ptl_handle_eq_t req_eq, bulk_source_eq, bulk_sink_eq; +static ptl_handle_eq_t sent_pkt_eq, rcvd_rep_eq, + bulk_source_eq, bulk_sink_eq; + +struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl, + int opcode, int namelen, char *name, + int tgtlen, char *tgt) +{ + struct ptlrpc_request *request; + int rc; + ENTRY; + + OBD_ALLOC(request, sizeof(*request)); + if (!request) { + CERROR("request allocation out of memory\n"); + return NULL; + } + + memset(request, 0, sizeof(*request)); + request->rq_xid = cl->cli_xid++; + + rc = cl->cli_req_pack(name, namelen, tgt, tgtlen, + &request->rq_reqhdr, &request->rq_req, + &request->rq_reqlen, &request->rq_reqbuf); + if (rc) { + CERROR("cannot pack request %d\n", rc); + return NULL; + } + request->rq_reqhdr->opc = opcode; + + EXIT; + return request; +} + +void ptlrpc_free_req(struct ptlrpc_request *request) +{ + OBD_FREE(request, sizeof(*request)); +} + +int ptlrpc_queue_wait(struct ptlrpc_request *req, + struct ptlrpc_client *cl) +{ + int rc; + DECLARE_WAITQUEUE(wait, current); + + init_waitqueue_head(&req->rq_wait_for_rep); + + if (cl->cli_enqueue) { + /* Local delivery */ + ENTRY; + rc = cl->cli_enqueue(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->cli_server); + } + if (rc) { + CERROR("error %d, opcode %d\n", rc, + req->rq_reqhdr->opc); + return -rc; + } + + CDEBUG(0, "-- sleeping\n"); + add_wait_queue(&req->rq_wait_for_rep, &wait); + while (req->rq_repbuf == NULL) { + set_current_state(TASK_INTERRUPTIBLE); + + /* if this process really wants to die, let it go */ + if (sigismember(&(current->pending.signal), SIGKILL) || + sigismember(&(current->pending.signal), SIGINT)) + break; + + schedule(); + } + remove_wait_queue(&req->rq_wait_for_rep, &wait); + set_current_state(TASK_RUNNING); + CDEBUG(0, "-- done\n"); + + if (req->rq_repbuf == NULL) { + /* We broke out because of a signal */ + EXIT; + return -EINTR; + } + + rc = cl->cli_rep_unpack(req->rq_repbuf, req->rq_replen, &req->rq_rephdr, &req->rq_rep); + if (rc) { + CERROR("unpack_rep failed: %d\n", rc); + return rc; + } + + if ( req->rq_rephdr->status == 0 ) + CDEBUG(0, "--> buf %p len %d status %d\n", + req->rq_repbuf, req->rq_replen, + req->rq_rephdr->status); + + EXIT; + return 0; +} /* - * 1. Free the request buffer after it has gone out on the wire - * 2. Wake up the thread waiting for the reply once it comes in. + * Free the packet when it has gone out */ -static int client_packet_callback(ptl_event_t *ev, void *data) +static int sent_packet_callback(ptl_event_t *ev, void *data) { - struct ptlrpc_request *rpc = ev->mem_desc.user_ptr; - ENTRY; - // XXX make sure we understand all events, including ACK's if (ev->type == PTL_EVENT_SENT) { OBD_FREE(ev->mem_desc.start, ev->mem_desc.length); - } else if (ev->type == PTL_EVENT_PUT) { + } else { + // XXX make sure we understand all events, including ACK's + CERROR("Unknown event %d\n", ev->type); + BUG(); + } + + EXIT; + return 1; +} + +/* + * Wake up the thread waiting for the reply once it comes in. + */ +static int rcvd_reply_callback(ptl_event_t *ev, void *data) +{ + struct ptlrpc_request *rpc = ev->mem_desc.user_ptr; + ENTRY; + + if (ev->type == PTL_EVENT_PUT) { rpc->rq_repbuf = ev->mem_desc.start + ev->offset; wake_up_interruptible(&rpc->rq_wait_for_rep); + } else { + // XXX make sure we understand all events, including ACK's + CERROR("Unknown event %d\n", ev->type); + BUG(); } EXIT; @@ -120,6 +235,7 @@ static int bulk_source_callback(ptl_event_t *ev, void *data) wake_up_interruptible(&rpc->rq_wait_for_bulk); } else { CERROR("Unexpected event type!\n"); + BUG(); } EXIT; @@ -138,6 +254,7 @@ static int bulk_sink_callback(ptl_event_t *ev, void *data) wake_up_interruptible(&rpc->rq_wait_for_bulk); } else { CERROR("Unexpected event type!\n"); + BUG(); } EXIT; @@ -159,11 +276,11 @@ int ptl_send_buf(struct ptlrpc_request *request, struct lustre_peer *peer, } else if (is_request) { request->rq_req_md.start = request->rq_reqbuf; request->rq_req_md.length = request->rq_reqlen; - request->rq_req_md.eventq = req_eq; + request->rq_req_md.eventq = sent_pkt_eq; } else { request->rq_req_md.start = request->rq_repbuf; request->rq_req_md.length = request->rq_replen; - request->rq_req_md.eventq = req_eq; + request->rq_req_md.eventq = sent_pkt_eq; } request->rq_req_md.threshold = 1; request->rq_req_md.options = PTL_MD_OP_PUT; @@ -171,6 +288,7 @@ int ptl_send_buf(struct ptlrpc_request *request, struct lustre_peer *peer, rc = PtlMDBind(peer->peer_ni, request->rq_req_md, &md_h); if (rc != 0) { + BUG(); CERROR("PtlMDBind failed: %d\n", rc); return rc; } @@ -187,6 +305,7 @@ int ptl_send_buf(struct ptlrpc_request *request, struct lustre_peer *peer, request->rq_xid, 0, 0); } if (rc != PTL_OK) { + BUG(); CERROR("PtlPut(%d, %d, %d) failed: %d\n", remote_id.nid, portal, request->rq_xid, rc); /* FIXME: tear down md */ @@ -222,10 +341,12 @@ int ptl_send_rpc(struct ptlrpc_request *request, struct lustre_peer *peer) local_id.gid = PTL_ID_ANY; local_id.rid = PTL_ID_ANY; + CERROR("sending req %d\n", request->rq_xid); rc = PtlMEAttach(peer->peer_ni, request->rq_reply_portal, local_id, request->rq_xid, 0, PTL_UNLINK, &me_h); if (rc != PTL_OK) { CERROR("PtlMEAttach failed: %d\n", rc); + BUG(); EXIT; goto cleanup; } @@ -235,12 +356,13 @@ int ptl_send_rpc(struct ptlrpc_request *request, struct lustre_peer *peer) 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 = req_eq; + request->rq_reply_md.eventq = rcvd_rep_eq; rc = PtlMDAttach(me_h, request->rq_reply_md, PTL_UNLINK, &request->rq_reply_md_h); if (rc != PTL_OK) { CERROR("PtlMDAttach failed: %d\n", rc); + BUG(); EXIT; goto cleanup2; } @@ -251,6 +373,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, struct lustre_peer *peer) &bulk_me_h); if (rc != PTL_OK) { CERROR("PtlMEAttach failed: %d\n", rc); + BUG(); EXIT; goto cleanup3; } @@ -266,6 +389,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, struct lustre_peer *peer) &request->rq_bulk_md_h); if (rc != PTL_OK) { CERROR("PtlMDAttach failed: %d\n", rc); + BUG(); EXIT; goto cleanup4; } @@ -326,7 +450,8 @@ int ptl_received_rpc(struct ptlrpc_service *service) { CDEBUG(D_INFO, "Attach MD in ring, rc %d\n", rc); if (rc != PTL_OK) { - /* cleanup */ + /* XXX cleanup */ + BUG(); CERROR("PtlMDAttach failed: %d\n", rc); return rc; } @@ -453,7 +578,11 @@ static int req_init_portals(void) } ni = *nip; - rc = PtlEQAlloc(ni, 128, client_packet_callback, NULL, &req_eq); + rc = PtlEQAlloc(ni, 128, sent_packet_callback, NULL, &sent_pkt_eq); + if (rc != PTL_OK) + CERROR("PtlEQAlloc failed: %d\n", rc); + + rc = PtlEQAlloc(ni, 128, rcvd_reply_callback, NULL, &rcvd_rep_eq); if (rc != PTL_OK) CERROR("PtlEQAlloc failed: %d\n", rc); @@ -475,7 +604,8 @@ static int __init ptlrpc_init(void) static void __exit ptlrpc_exit(void) { - PtlEQFree(req_eq); + PtlEQFree(sent_pkt_eq); + PtlEQFree(rcvd_rep_eq); PtlEQFree(bulk_source_eq); PtlEQFree(bulk_sink_eq); diff --git a/lustre/tests/llmount.sh b/lustre/tests/llmount.sh index 6518ed5..9b6d7e5 100755 --- a/lustre/tests/llmount.sh +++ b/lustre/tests/llmount.sh @@ -62,4 +62,4 @@ quit EOF mkdir /mnt/obd -mount -t lustre_light -o device=3 none /mnt/obd +# mount -t lustre_light -o device=3 none /mnt/obd diff --git a/lustre/utils/obdctl.c b/lustre/utils/obdctl.c index b91964d..979a665 100644 --- a/lustre/utils/obdctl.c +++ b/lustre/utils/obdctl.c @@ -424,15 +424,20 @@ static int jt_modules(int argc, char **argv) "obd/class", "obd/rpc", "obd/ext2obd", "obd/ost", "obd/osc", "obd/mds", "obd/mdc", "obd/llight", NULL}; char *path = ".."; + char *kernel = "linux"; int i; - if (argc == 2) + if (argc >= 2) path = argv[1]; - if (argc > 2) { - printf("%s [path]\n", argv[0]); + if (argc == 3) + kernel = argv[2]; + if (argc > 3) { + printf("%s [path] [kernel]\n", argv[0]); return 0; } + printf("symbol-file\nsymbol-file %s\nb panic\nb stop\n", kernel); + for (i = 0; modules[i] != NULL; i++) { struct module_info info; int rc; -- 1.8.3.1