From 3293f5b9676e5336d92950f7210823c54c36c784 Mon Sep 17 00:00:00 2001 From: pschwan Date: Thu, 7 Mar 2002 20:16:05 +0000 Subject: [PATCH] - module insert code moved to tests/common.sh - refactored request freeing code to handle the use of the reply buffer after the mdc_getattr, etc. returns. --- lustre/include/linux/lustre_mds.h | 15 +++-- lustre/include/linux/lustre_net.h | 1 + lustre/llite/dir.c | 21 ++----- lustre/llite/namei.c | 94 ++++++++++------------------ lustre/llite/rw.c | 4 +- lustre/llite/super.c | 29 ++++----- lustre/mdc/mdc_reint.c | 120 +++++++++++++----------------------- lustre/mdc/mdc_request.c | 125 ++++++++++++-------------------------- lustre/osc/osc_request.c | 4 -- lustre/ptlrpc/client.c | 39 +++++++++++- lustre/tests/common.sh | 23 +++++++ lustre/tests/llecho.sh | 17 +----- lustre/tests/llmount.sh | 20 +----- lustre/utils/obdctl.c | 19 +++++- 14 files changed, 220 insertions(+), 311 deletions(-) diff --git a/lustre/include/linux/lustre_mds.h b/lustre/include/linux/lustre_mds.h index 022875a..7616bcb 100644 --- a/lustre/include/linux/lustre_mds.h +++ b/lustre/include/linux/lustre_mds.h @@ -100,27 +100,26 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, struct vf /* llight/request.c */ int mdc_getattr(struct ptlrpc_client *peer, ino_t ino, int type, int valid, - struct mds_rep **mds_reply, struct ptlrep_hdr **hdr); + struct ptlrpc_request **); int mdc_setattr(struct ptlrpc_client *peer, struct inode *inode, - struct iattr *iattr, struct mds_rep **mds_reply, - struct ptlrep_hdr **hdr); + struct iattr *iattr, struct ptlrpc_request **); int mdc_readpage(struct ptlrpc_client *peer, ino_t ino, int type, __u64 offset, - char *addr, struct mds_rep **rep, struct ptlrep_hdr **hdr); + char *addr, struct ptlrpc_request **); 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); + struct ptlrpc_request **); int mdc_unlink(struct ptlrpc_client *peer, struct inode *dir, const char *name, int namelen, - struct mds_rep **rep, struct ptlrep_hdr **hdr); + struct ptlrpc_request **); 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); + struct ptlrpc_request **); 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); + struct ptlrpc_request **); int mdc_create_client(char *uuid, struct ptlrpc_client *cl); /* ioctls for trying requests */ diff --git a/lustre/include/linux/lustre_net.h b/lustre/include/linux/lustre_net.h index 3b384ee..609f2e1 100644 --- a/lustre/include/linux/lustre_net.h +++ b/lustre/include/linux/lustre_net.h @@ -220,6 +220,7 @@ struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl, int tgtlen, char *tgt); void ptlrpc_free_req(struct ptlrpc_request *request); struct ptlrpc_bulk_desc *ptlrpc_prep_bulk(struct lustre_peer *); +int ptlrpc_check_status(struct ptlrpc_request *req, int err); /* rpc/service.c */ struct ptlrpc_service * diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index b8a55e7..2a02a04 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -60,7 +60,7 @@ static int ll_dir_readpage(struct file *file, struct page *page) char *buf; __u64 offset; int rc = 0; - struct ptlrep_hdr *hdr; + struct ptlrpc_request *request; ENTRY; @@ -80,24 +80,15 @@ static int ll_dir_readpage(struct file *file, struct page *page) offset = page->index << PAGE_SHIFT; buf = kmap(page); rc = mdc_readpage(&sbi->ll_mds_client, inode->i_ino, S_IFDIR, offset, - buf, NULL, &hdr); + buf, &request); kunmap(page); - if ( rc ) { - EXIT; - goto readpage_out; - } - - if ((rc = hdr->status)) { - EXIT; - goto readpage_out; - } + ptlrpc_free_req(request); + if ( !rc ) + SetPageUptodate(page); - /* PDEBUG(page, "READ"); */ - - SetPageUptodate(page); + EXIT; readpage_out: UnlockPage(page); - EXIT; return rc; } /* ll_dir_readpage */ diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index ac6fb3d..aa33c80 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -82,8 +82,7 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) /* methods */ static struct dentry *ll_lookup(struct inode * dir, struct dentry *dentry) { - struct mds_rep *rep; - struct ptlrep_hdr *hdr = NULL; + struct ptlrpc_request *request; struct inode * inode = NULL; struct ll_sb_info *sbi = ll_i2sbi(dir); int err; @@ -99,20 +98,18 @@ static struct dentry *ll_lookup(struct inode * dir, struct dentry *dentry) goto negative; err = mdc_getattr(&sbi->ll_mds_client, ino, type, - OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, &rep, &hdr); + OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, &request); if ( err ) { CERROR("obdo_fromid failed\n"); EXIT; - return ERR_PTR(-EACCES); + return ERR_PTR(-abs(err)); } - inode = iget4(dir->i_sb, ino, NULL, rep); - - /* FIXME: this is not the right way to get this size */ - OBD_FREE(hdr, sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep)); + inode = iget4(dir->i_sb, ino, NULL, request->rq_rep.mds); + ptlrpc_free_req(request); if (!inode) - return ERR_PTR(-EACCES); + return ERR_PTR(-ENOMEM); negative: d_add(dentry, inode); @@ -141,8 +138,8 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, int mode, __u64 id) { struct inode *inode; - struct mds_rep *rep; - struct ptlrep_hdr *hdr; + struct ptlrpc_request *request; + struct mds_rep *rep; int err; time_t time = CURRENT_TIME; struct ll_sb_info *sbi = ll_i2sbi(dir); @@ -150,16 +147,14 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, ENTRY; err = mdc_create(&sbi->ll_mds_client, dir, name, namelen, tgt, tgtlen, - mode, id, - current->uid, current->gid, time, &rep, &hdr); + mode, id, current->uid, current->gid, time, &request); if (err) { + ptlrpc_free_req(request); + inode = ERR_PTR(err); EXIT; - return ERR_PTR(err); - } - if ( hdr->status) { - EXIT; - return ERR_PTR(hdr->status); + goto out; } + rep = request->rq_rep.mds; rep->valid = OBD_MD_FLNOTOBD; rep->objid = id; @@ -172,8 +167,9 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, inode = iget4(dir->i_sb, rep->ino, NULL, rep); if (IS_ERR(inode)) { CERROR("new_inode -fatal: %ld\n", PTR_ERR(inode)); + inode = ERR_PTR(-EIO); EXIT; - return ERR_PTR(-EIO); + goto out; } if (!list_empty(&inode->i_dentry)) { @@ -181,68 +177,52 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, rep->ino, atomic_read(&inode->i_count), inode->i_nlink); iput(inode); + inode = ERR_PTR(-EIO); EXIT; - return ERR_PTR(-EIO); + goto out; } EXIT; + out: + ptlrpc_free_req(request); return inode; } /* ll_new_inode */ int ll_mdc_unlink(struct inode *dir, const char *name, int len) { - struct mds_rep *rep; - struct ptlrep_hdr *hdr; + struct ptlrpc_request *request; int err; struct ll_sb_info *sbi = ll_i2sbi(dir); ENTRY; - err = mdc_unlink(&sbi->ll_mds_client, dir, name, len, &rep, &hdr); - - if (err) { - EXIT; - return err; - } - if ( hdr->status) { - EXIT; - return hdr->status; - } + err = mdc_unlink(&sbi->ll_mds_client, dir, name, len, &request); + ptlrpc_free_req(request); EXIT; - return 0; + return err; } int ll_mdc_link(struct dentry *src, struct inode *dir, const char *name, int len) { - struct mds_rep *rep; - struct ptlrep_hdr *hdr; + struct ptlrpc_request *request; int err; struct ll_sb_info *sbi = ll_i2sbi(dir); ENTRY; - err = mdc_link(&sbi->ll_mds_client, src, dir, name, len, &rep, &hdr); - - if (err) { - EXIT; - return err; - } - if ( hdr->status) { - EXIT; - return hdr->status; - } + err = mdc_link(&sbi->ll_mds_client, src, dir, name, len, &request); + ptlrpc_free_req(request); EXIT; - return 0; + return err; } int ll_mdc_rename(struct inode *src, struct inode *tgt, struct dentry *old, struct dentry *new) { - struct mds_rep *rep; - struct ptlrep_hdr *hdr; + struct ptlrpc_request *request; int err; struct ll_sb_info *sbi = ll_i2sbi(src); @@ -250,20 +230,11 @@ int ll_mdc_rename(struct inode *src, struct inode *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); - - if (err) { - EXIT; - return err; - } - if ( hdr->status) { - EXIT; - return hdr->status; - } + new->d_name.name, new->d_name.len, &request); + ptlrpc_free_req(request); EXIT; - return 0; + return err; } /* @@ -294,8 +265,7 @@ static int ll_create (struct inode * dir, struct dentry * dentry, int mode) CDEBUG(D_DENTRY, "name %s mode %o o_id %lld\n", dentry->d_name.name, mode, oa.o_id); inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len, - NULL, 0, - mode, oa.o_id); + NULL, 0, mode, oa.o_id); err = PTR_ERR(inode); if (!IS_ERR(inode)) { // XXX clean up the object diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 62f83e3..4a2eed2 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -294,8 +294,8 @@ 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, ll_i2obdconn(inode), num_obdo, &oa, &bufs_per_obdo, - &page, &count, &offset, &flags); + err = obd_brw(OBD_BRW_WRITE, ll_i2obdconn(inode), num_obdo, &oa, + &bufs_per_obdo, &page, &count, &offset, &flags); if ( !err ) { SetPageUptodate(page); set_page_clean(page); diff --git a/lustre/llite/super.c b/lustre/llite/super.c index 8a3f636..2d630cb 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -101,8 +101,7 @@ static struct super_block * ll_read_super(struct super_block *sb, int connected = 0; int devno; int err; - struct mds_rep *rep; - struct ptlrep_hdr *hdr = NULL; + struct ptlrpc_request *request = NULL; ENTRY; MOD_INC_USE_COUNT; @@ -163,15 +162,14 @@ static struct super_block * ll_read_super(struct super_block *sb, /* make root inode */ err = mdc_getattr(&sbi->ll_mds_client, sbi->ll_rootino, S_IFDIR, - OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, - &rep, &hdr); + OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, &request); if (err) { - CERROR("mds_getattr failed for root %d\n", err); + CERROR("mdc_getattr failed for root %d\n", err); sb = NULL; goto ERR; } - - root = iget4(sb, sbi->ll_rootino, NULL, rep); + + root = iget4(sb, sbi->ll_rootino, NULL, request->rq_rep.mds); if (root) { sb->s_root = d_alloc_root(root); } else { @@ -179,12 +177,9 @@ static struct super_block * ll_read_super(struct super_block *sb, sb = NULL; goto ERR; } - + ERR: - if (hdr) - /* FIXME: sigh, another stupid hardcoded size */ - OBD_FREE(hdr, sizeof(struct ptlrep_hdr) + - sizeof(struct mds_rep)); + ptlrpc_free_req(request); if (device) OBD_FREE(device, strlen(device) + 1); if (version) @@ -268,7 +263,7 @@ out: int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc) { - struct ptlrep_hdr *hdr = NULL; + struct ptlrpc_request *request; struct ll_sb_info *sbi = ll_i2sbi(inode); int err; @@ -277,9 +272,11 @@ 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_mds_client, inode, attr, NULL, &hdr); - if ( err ) - CERROR("ll_setattr fails (%d)\n", err); + err = mdc_setattr(&sbi->ll_mds_client, inode, attr, &request); + if (err) + CERROR("mdc_setattr fails (%d)\n", err); + + ptlrpc_free_req(request); EXIT; return err; diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index 89ae7a1..9249d89 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -54,176 +54,138 @@ extern int mdc_reint(struct ptlrpc_client *peer, struct ptlrpc_request *request) int mdc_setattr(struct ptlrpc_client *peer, struct inode *inode, struct iattr *iattr, - struct mds_rep **rep, struct ptlrep_hdr **hdr) + struct ptlrpc_request **request) { int rc; - struct ptlrpc_request *request; struct mds_rec_setattr *rec; + ENTRY; - request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec), NULL); - if (!request) { + *request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec), NULL); + if (!(*request)) { CERROR("mdc request: cannot pack\n"); return -ENOMEM; } - rec = mds_req_tgt(request->rq_req.mds); + rec = mds_req_tgt((*request)->rq_req.mds); mds_setattr_pack(rec, inode, iattr); - request->rq_req.mds->opcode = HTON__u32(REINT_SETATTR); - request->rq_replen = + (*request)->rq_req.mds->opcode = HTON__u32(REINT_SETATTR); + (*request)->rq_replen = sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); - rc = mdc_reint(peer, request); - if (rc) - return rc; + rc = mdc_reint(peer, *request); - if (rep) { - *rep = request->rq_rep.mds; - } - if (hdr) { - *hdr = request->rq_rephdr; - } - - return 0; + EXIT; + return rc; } 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) + struct ptlrpc_request **request) { int rc; - struct ptlrpc_request *request; struct mds_rec_create *rec; + ENTRY; - request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, + (*request) = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec) + size_round0(namelen) + size_round0(tgtlen), NULL); - if (!request) { + if (!(*request)) { CERROR("mdc_create: cannot pack\n"); return -ENOMEM; } - request->rq_replen = + (*request)->rq_replen = sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); - rec = mds_req_tgt(request->rq_req.mds); + rec = mds_req_tgt((*request)->rq_req.mds); mds_create_pack(rec, dir, name, namelen, mode, id, uid, gid, time, tgt, tgtlen); - rc = mdc_reint(peer, request); - - if (rep) { - *rep = request->rq_rep.mds; - } - if (hdr) { - *hdr = request->rq_rephdr; - } + rc = mdc_reint(peer, (*request)); - OBD_FREE(request, sizeof(*request)); + EXIT; return rc; } int mdc_unlink(struct ptlrpc_client *peer, struct inode *dir, const char *name, int namelen, - struct mds_rep **rep, struct ptlrep_hdr **hdr) + struct ptlrpc_request **request) { int rc; - struct ptlrpc_request *request; struct mds_rec_unlink *rec; - request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, + (*request) = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec) + size_round0(namelen), NULL); - if (!request) { + if (!(*request)) { CERROR("mdc_unlink: cannot pack\n"); return -ENOMEM; } - request->rq_replen = + (*request)->rq_replen = sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); - rec = mds_req_tgt(request->rq_req.mds); + rec = mds_req_tgt((*request)->rq_req.mds); mds_unlink_pack(rec, dir, name, namelen); - rc = mdc_reint(peer, request); - - if (rep) { - *rep = request->rq_rep.mds; - } - if (hdr) { - *hdr = request->rq_rephdr; - } + rc = mdc_reint(peer, (*request)); - OBD_FREE(request, sizeof(*request)); + EXIT; return rc; } 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) + struct ptlrpc_request **request) { int rc; - struct ptlrpc_request *request; struct mds_rec_link *rec; + ENTRY; - request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, + (*request) = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec) + size_round0(namelen), NULL); - if (!request) { + if (!(*request)) { CERROR("mdc_link: cannot pack\n"); return -ENOMEM; } - request->rq_replen = + (*request)->rq_replen = sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); - rec = mds_req_tgt(request->rq_req.mds); + rec = mds_req_tgt((*request)->rq_req.mds); mds_link_pack(rec, src->d_inode, dir, name, namelen); - rc = mdc_reint(peer, request); - - if (rep) { - *rep = request->rq_rep.mds; - } - if (hdr) { - *hdr = request->rq_rephdr; - } - - OBD_FREE(request, sizeof(*request)); + rc = mdc_reint(peer, (*request)); + EXIT; return rc; } 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) + struct ptlrpc_request **request) { int rc; - struct ptlrpc_request *request; struct mds_rec_rename *rec; + ENTRY; - request = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, + (*request) = ptlrpc_prep_req(peer, MDS_REINT, 0, NULL, sizeof(*rec) + size_round0(oldlen) + size_round0(newlen), NULL); - if (!request) { + if (!(*request)) { CERROR("mdc_link: cannot pack\n"); return -ENOMEM; } - request->rq_replen = + (*request)->rq_replen = sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); - rec = mds_req_tgt(request->rq_req.mds); + rec = mds_req_tgt((*request)->rq_req.mds); mds_rename_pack(rec, src, tgt, old, oldlen, new, newlen); - rc = mdc_reint(peer, request); - - if (rep) { - *rep = request->rq_rep.mds; - } - if (hdr) { - *hdr = request->rq_rephdr; - } + rc = mdc_reint(peer, (*request)); - OBD_FREE(request, sizeof(*request)); + EXIT; return rc; } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 66d34cf..cb8a4db 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -56,15 +56,19 @@ extern int mds_queue_req(struct ptlrpc_request *); int mdc_getattr(struct ptlrpc_client *cl, ino_t ino, int type, int valid, - struct mds_rep **rep, struct ptlrep_hdr **hdr) + struct ptlrpc_request **req) { - struct ptlrpc_request *request; - int rc; + int rc; + struct ptlrpc_request *request; + + ENTRY; request = ptlrpc_prep_req(cl, MDS_GETATTR, 0, NULL, 0, NULL); if (!request) { CERROR("llight request: cannot pack\n"); - return -ENOMEM; + rc = -ENOMEM; + EXIT; + goto out; } ll_ino2fid(&request->rq_req.mds->fid1, ino, 0, type); @@ -74,27 +78,19 @@ int mdc_getattr(struct ptlrpc_client *cl, ino_t ino, int type, int valid, sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep); rc = ptlrpc_queue_wait(cl, request); - if (rc) { - CERROR("llight request: error in handling %d\n", rc); - goto out; - } + rc = ptlrpc_check_status(request, rc); - CDEBUG(0, "mode: %o\n", request->rq_rep.mds->mode); + if (!rc) + CDEBUG(D_NET, "mode: %o\n", request->rq_rep.mds->mode); - if (rep) { - *rep = request->rq_rep.mds; - } - if (hdr) { - *hdr = request->rq_rephdr; - } - - out: - ptlrpc_free_req(request); - return rc; + EXIT; + out: + *req = request; + return rc; } int mdc_open(struct ptlrpc_client *cl, ino_t ino, int type, int flags, - __u64 *fh, struct mds_rep **rep, struct ptlrep_hdr **hdr) + __u64 *fh, struct ptlrpc_request **req) { struct ptlrpc_request *request; int rc; @@ -102,7 +98,8 @@ int mdc_open(struct ptlrpc_client *cl, ino_t ino, int type, int flags, request = ptlrpc_prep_req(cl, MDS_OPEN, 0, NULL, 0, NULL); if (!request) { CERROR("llight request: cannot pack\n"); - return -ENOMEM; + rc = -ENOMEM; + goto out; } ll_ino2fid(&request->rq_req.mds->fid1, ino, 0, type); @@ -116,22 +113,16 @@ int mdc_open(struct ptlrpc_client *cl, ino_t ino, int type, int flags, goto out; } - if (rep) { - *rep = request->rq_rep.mds; - } - if (hdr) { - *hdr = request->rq_rephdr; - } *fh = request->rq_rep.mds->objid; out: - ptlrpc_free_req(request); + *req = request; return rc; } int mdc_close(struct ptlrpc_client *cl, ino_t ino, int type, __u64 fh, - struct mds_rep **rep, struct ptlrep_hdr **hdr) + struct ptlrpc_request **req) { struct ptlrpc_request *request; int rc; @@ -139,7 +130,8 @@ int mdc_close(struct ptlrpc_client *cl, ino_t ino, int type, __u64 fh, request = ptlrpc_prep_req(cl, MDS_CLOSE, 0, NULL, 0, NULL); if (!request) { CERROR("llight request: cannot pack\n"); - return -ENOMEM; + rc = -ENOMEM; + goto out; } ll_ino2fid(&request->rq_req.mds->fid1, ino, 0, type); @@ -153,23 +145,16 @@ int mdc_close(struct ptlrpc_client *cl, ino_t ino, int type, __u64 fh, goto out; } - if (rep) { - *rep = request->rq_rep.mds; - } - if (hdr) { - *hdr = request->rq_rephdr; - } - out: - ptlrpc_free_req(request); + *req = request; return rc; } int mdc_readpage(struct ptlrpc_client *cl, ino_t ino, int type, __u64 offset, - char *addr, struct mds_rep **rep, struct ptlrep_hdr **hdr) + char *addr, struct ptlrpc_request **req) { - struct ptlrpc_request *request; - struct ptlrpc_bulk_desc *bulk; + struct ptlrpc_request *request = NULL; + struct ptlrpc_bulk_desc *bulk = NULL; struct niobuf niobuf; int rc; @@ -180,15 +165,16 @@ int mdc_readpage(struct ptlrpc_client *cl, ino_t ino, int type, __u64 offset, bulk = ptlrpc_prep_bulk(&cl->cli_server); if (bulk == NULL) { CERROR("%s: cannot init bulk desc\n", __FUNCTION__); - return -ENOMEM; + rc = -ENOMEM; + goto out; } request = ptlrpc_prep_req(cl, MDS_READPAGE, 0, NULL, sizeof(struct niobuf), (char *)&niobuf); if (!request) { - OBD_FREE(bulk, sizeof(*bulk)); CERROR("%s: cannot pack\n", __FUNCTION__); - return -ENOMEM; + rc = -ENOMEM; + goto out; } bulk->b_buflen = PAGE_SIZE; @@ -217,16 +203,10 @@ int mdc_readpage(struct ptlrpc_client *cl, ino_t ino, int type, __u64 offset, CDEBUG(D_INODE, "mode: %o\n", request->rq_rep.mds->mode); - if (rep) { - *rep = request->rq_rep.mds; - } - if (hdr) { - *hdr = request->rq_rephdr; - } - out: - ptlrpc_free_req(request); - OBD_FREE(bulk, sizeof(*bulk)); + *req = request; + if (bulk != NULL) + OBD_FREE(bulk, sizeof(*bulk)); return rc; } @@ -247,6 +227,7 @@ static int request_ioctl(struct inode *inode, struct file *file, { int err; struct ptlrpc_client cl; + struct ptlrpc_request *request; ENTRY; @@ -273,20 +254,14 @@ static int request_ioctl(struct inode *inode, struct file *file, switch (cmd) { case IOC_REQUEST_GETATTR: { - struct ptlrep_hdr *hdr = NULL; CERROR("-- getting attr for ino 2\n"); - err = mdc_getattr(&cl, 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) + - sizeof(struct mds_rep)); - } + err = mdc_getattr(&cl, 2, S_IFDIR, ~0, &request); + CERROR("-- done err %d\n", err); break; } case IOC_REQUEST_READPAGE: { - struct ptlrep_hdr *hdr = NULL; char *buf; OBD_ALLOC(buf, PAGE_SIZE); if (!buf) { @@ -294,22 +269,14 @@ static int request_ioctl(struct inode *inode, struct file *file, break; } CERROR("-- readpage 0 for ino 2\n"); - err = mdc_readpage(&cl, 2, S_IFDIR, 0, buf, NULL, &hdr); + err = mdc_readpage(&cl, 2, S_IFDIR, 0, buf, &request); CERROR("-- done err %d\n", err); - if (!err) { - CERROR("-- status: %d\n", hdr->status); - err = hdr->status; - if (hdr) - OBD_FREE(hdr, sizeof(struct ptlrep_hdr) + - sizeof(struct mds_rep)); - } OBD_FREE(buf, PAGE_SIZE); break; } case IOC_REQUEST_SETATTR: { struct inode inode; - struct ptlrep_hdr *hdr; struct iattr iattr; inode.i_ino = 2; @@ -317,21 +284,13 @@ static int request_ioctl(struct inode *inode, struct file *file, iattr.ia_atime = 0; iattr.ia_valid = ATTR_MODE | ATTR_ATIME; - err = mdc_setattr(&cl, &inode, &iattr, NULL, &hdr); + err = mdc_setattr(&cl, &inode, &iattr, &request); CERROR("-- done err %d\n", err); - if (!err) { - CERROR("-- status: %d\n", hdr->status); - err = hdr->status; - } else { - OBD_FREE(hdr, sizeof(struct ptlrep_hdr) + - sizeof(struct mds_rep)); - } break; } case IOC_REQUEST_CREATE: { struct inode inode; - struct ptlrep_hdr *hdr; struct iattr iattr; inode.i_ino = 2; @@ -342,14 +301,8 @@ static int request_ioctl(struct inode *inode, struct file *file, err = mdc_create(&cl, &inode, "foofile", strlen("foofile"), NULL, 0, 0100707, 47114711, - 11, 47, 0, NULL, &hdr); + 11, 47, 0, &request); CERROR("-- done err %d\n", err); - if (!err) { - CERROR("-- status: %d\n", hdr->status); - err = hdr->status; - } - OBD_FREE(hdr, sizeof(struct ptlrep_hdr) + - sizeof(struct mds_rep)); break; } diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index d9030ff..839379c 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -383,8 +383,6 @@ int osc_brw_read(struct obd_conn *conn, obd_count num_oa, struct obdo **oa, /* FIXME: if we've called ptlrpc_wait_bulk but rc != 0, we need to * abort those bulk listeners. */ - if (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++) { @@ -472,8 +470,6 @@ int osc_brw_write(struct obd_conn *conn, obd_count num_oa, struct obdo **oa, } OBD_FREE(src, size2); out: - if (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/ptlrpc/client.c b/lustre/ptlrpc/client.c index 2bc30c0..4557395 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -157,6 +157,9 @@ struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl, void ptlrpc_free_req(struct ptlrpc_request *request) { + if (request == NULL) + return; + if (request->rq_repbuf != NULL) OBD_FREE(request->rq_repbuf, request->rq_replen); OBD_FREE(request, sizeof(*request)); @@ -180,6 +183,40 @@ static int ptlrpc_check_reply(struct ptlrpc_request *req) return 0; } +int ptlrpc_check_status(struct ptlrpc_request *req, int err) +{ + ENTRY; + + if (err != 0) { + CERROR("err is %d\n", err); + EXIT; + return err; + } + + if (req == NULL) { + CERROR("req == NULL\n"); + EXIT; + return -ENOMEM; + } + + if (req->rq_rephdr == NULL) { + CERROR("req->rq_rephdr == NULL\n"); + EXIT; + return -ENOMEM; + } + + if (req->rq_rephdr->status != 0) { + CERROR("req->rq_rephdr->status is %d\n", + req->rq_rephdr->status); + EXIT; + /* XXX: translate this error from net to host */ + return req->rq_rephdr->status; + } + + EXIT; + return 0; +} + /* Abort this request and cleanup any resources associated with it. */ int ptlrpc_abort(struct ptlrpc_request *request) { @@ -243,7 +280,7 @@ int ptlrpc_queue_wait(struct ptlrpc_client *cl, struct ptlrpc_request *req) CDEBUG(D_NET, "got rep %d\n", req->rq_rephdr->xid); if ( req->rq_rephdr->status == 0 ) - CDEBUG(0, "--> buf %p len %d status %d\n", req->rq_repbuf, + CDEBUG(D_NET, "--> buf %p len %d status %d\n", req->rq_repbuf, req->rq_replen, req->rq_rephdr->status); EXIT; diff --git a/lustre/tests/common.sh b/lustre/tests/common.sh index ba676ad..65effbf 100644 --- a/lustre/tests/common.sh +++ b/lustre/tests/common.sh @@ -12,3 +12,26 @@ else exit -1 fi fi + +setup() { + mknod /dev/portals c 10 240 + + 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/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/obdecho/obdecho.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/debugctl modules > $R/tmp/ogdb + echo "The GDB module script is in /tmp/ogdb. Press enter to continue" + read +} diff --git a/lustre/tests/llecho.sh b/lustre/tests/llecho.sh index 6e37f6d..e3f92f8 100644 --- a/lustre/tests/llecho.sh +++ b/lustre/tests/llecho.sh @@ -3,22 +3,7 @@ SRCDIR="`dirname $0`" . $SRCDIR/common.sh -mknod /dev/portals c 10 240 - -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/class/obdclass.o || exit -1 -insmod $R/usr/src/obd/rpc/ptlrpc.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/obdecho/obdecho.o || exit -1 - -$R/usr/src/portals/linux/utils/debugctl modules > $R/tmp/ogdb -echo "The GDB module script is in /tmp/ogdb. Press enter to continue" -read +setup $R/usr/src/portals/linux/utils/ptlctl < $R/tmp/ogdb -echo "The GDB module script is in /tmp/ogdb. Press enter to continue" -read +setup $R/usr/src/portals/linux/utils/ptlctl < ", list); Parser_commands(); + do_disconnect(); return 0; } -- 1.8.3.1