From a5b848422f5deed183b1f3d08c3f0896fe91dc01 Mon Sep 17 00:00:00 2001 From: pschwan Date: Thu, 14 Mar 2002 06:33:35 +0000 Subject: [PATCH] - fixed some NTOH/HTON mixups - added some BUG()s in niobuf pack/unpack to catch bogus offsets - added a couple of BUGs() in dropped-packet cases --- lustre/lib/obd_pack.c | 40 ++++++++++++++++++++++++---------------- lustre/llite/dir.c | 1 + lustre/mds/handler.c | 6 +++--- lustre/osc/osc_request.c | 2 +- lustre/ptlrpc/client.c | 1 + lustre/ptlrpc/events.c | 3 +-- lustre/ptlrpc/niobuf.c | 14 ++++++-------- lustre/ptlrpc/service.c | 15 ++++++++++----- lustre/tests/llmount.sh | 1 - 9 files changed, 47 insertions(+), 36 deletions(-) diff --git a/lustre/lib/obd_pack.c b/lustre/lib/obd_pack.c index df237b2..9daf8cc 100644 --- a/lustre/lib/obd_pack.c +++ b/lustre/lib/obd_pack.c @@ -77,12 +77,12 @@ int ost_pack_req(char *buf1, int buflen1, char *buf2, int buflen2, (*hdr)->type = OST_TYPE_REQ; - req->buflen1 = NTOH__u32(buflen1); + req->buflen1 = HTON__u32(buflen1); if (buf1) { LOGL(buf1, buflen1, ptr); } - req->buflen2 = NTOH__u32(buflen2); + req->buflen2 = HTON__u32(buflen2); if (buf2) { LOGL(buf2, buflen2, ptr); } @@ -155,12 +155,14 @@ int ost_pack_rep(char *buf1, int buflen1, char *buf2, int buflen2, ptr = *buf + sizeof(**hdr) + sizeof(*rep); - rep->buflen1 = NTOH__u32(buflen1); + rep->buflen1 = HTON__u32(buflen1); if (buf1) { LOGL(buf1, buflen1, ptr); - } + } else { + ptr += size_round(buflen1); + } - rep->buflen2 = NTOH__u32(buflen2); + rep->buflen2 = HTON__u32(buflen2); if (buf2) { LOGL(buf2, buflen2, ptr); } @@ -214,11 +216,11 @@ void ost_pack_ioo(void **tmp, struct obdo *oa, int bufcnt) { struct obd_ioobj *ioo = *tmp; char *c = *tmp; - - ioo->ioo_id = NTOH__u64(oa->o_id); - ioo->ioo_gr = NTOH__u64(oa->o_gr); - ioo->ioo_type = NTOH__u64(oa->o_mode); - ioo->ioo_bufcnt = NTOH__u32(bufcnt); + + ioo->ioo_id = HTON__u64(oa->o_id); + ioo->ioo_gr = HTON__u64(oa->o_gr); + ioo->ioo_type = HTON__u64(oa->o_mode); + ioo->ioo_bufcnt = HTON__u32(bufcnt); *tmp = c + sizeof(*ioo); } @@ -227,7 +229,7 @@ void ost_unpack_ioo(void **tmp, struct obd_ioobj **ioop) char *c = *tmp; struct obd_ioobj *ioo = *tmp; *ioop = *tmp; - + ioo->ioo_id = NTOH__u64(ioo->ioo_id); ioo->ioo_gr = NTOH__u64(ioo->ioo_gr); ioo->ioo_type = NTOH__u64(ioo->ioo_type); @@ -241,11 +243,14 @@ void ost_pack_niobuf(void **tmp, void *addr, __u64 offset, __u32 len, struct niobuf *ioo = *tmp; char *c = *tmp; - ioo->addr = NTOH__u64((__u64)(unsigned long)addr); - ioo->offset = NTOH__u64(offset); - ioo->len = NTOH__u32(len); - ioo->flags = NTOH__u32(flags); - ioo->xid = NTOH__u32(xid); + if ((offset >> 32) != 0) + BUG(); + + ioo->addr = HTON__u64((__u64)(unsigned long)addr); + ioo->offset = HTON__u64(offset); + ioo->len = HTON__u32(len); + ioo->flags = HTON__u32(flags); + ioo->xid = HTON__u32(xid); *tmp = c + sizeof(*ioo); } @@ -261,5 +266,8 @@ void ost_unpack_niobuf(void **tmp, struct niobuf **nbp) nb->len = NTOH__u32(nb->len); nb->flags = NTOH__u32(nb->flags); + if ((nb->offset >> 32) != 0) + BUG(); + *tmp = c + sizeof(*nb); } diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 887cf11..fe6aff8 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -237,6 +237,7 @@ Eend: fail: SetPageChecked(page); SetPageError(page); + BUG(); } static struct page * ext2_get_page(struct inode *dir, unsigned long n) diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 78ab4fc..0f038c7 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -437,8 +437,7 @@ out: /* mount the file system (secretly) */ -static int mds_setup(struct obd_device *obddev, obd_count len, - void *buf) +static int mds_setup(struct obd_device *obddev, obd_count len, void *buf) { struct obd_ioctl_data* data = buf; struct mds_obd *mds = &obddev->u.mds; @@ -448,7 +447,8 @@ static int mds_setup(struct obd_device *obddev, obd_count len, mnt = do_kern_mount(data->ioc_inlbuf2, 0, data->ioc_inlbuf1, NULL); err = PTR_ERR(mnt); - if (IS_ERR(mnt)) { + if (IS_ERR(mnt)) { + CERROR("do_kern_mount failed: %d\n", err); EXIT; return err; } diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 16d0558..96999f7 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1,7 +1,7 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Copryright (C) 2001 Cluster File Systems, Inc. + * Copryright (C) 2001, 2002 Cluster File Systems, Inc. * * This code is issued under the GNU General Public License. * See the file COPYING in this distribution diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 4557395..6118366 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -267,6 +267,7 @@ int ptlrpc_queue_wait(struct ptlrpc_client *cl, struct ptlrpc_request *req) if (req->rq_flags != PTL_RPC_REPLY) { CERROR("Unknown reason for wakeup\n"); + BUG(); EXIT; return -EINTR; } diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c index 20977f4..f977307 100644 --- a/lustre/ptlrpc/events.c +++ b/lustre/ptlrpc/events.c @@ -115,7 +115,7 @@ int server_request_callback(ptl_event_t *ev, void *data) } service->srv_me_active = NEXT_INDEX(service->srv_me_active, - service->srv_ring_length); + service->srv_ring_length); if (service->srv_me_h[service->srv_me_active] == 0) CERROR("All %d ring ME's are unlinked!\n", @@ -131,7 +131,6 @@ int server_request_callback(ptl_event_t *ev, void *data) return 0; } - static int bulk_source_callback(ptl_event_t *ev, void *data) { struct ptlrpc_bulk_desc *bulk = ev->mem_desc.user_ptr; diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c index 15ab612..cb95b2e 100644 --- a/lustre/ptlrpc/niobuf.c +++ b/lustre/ptlrpc/niobuf.c @@ -93,8 +93,8 @@ 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); + BUG(); return rc; } @@ -107,10 +107,10 @@ int ptl_send_buf(struct ptlrpc_request *request, struct lustre_peer *peer, rc = PtlPut(md_h, ack, remote_id, portal, 0, 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 */ + BUG(); } return rc; @@ -131,8 +131,8 @@ int ptlrpc_send_bulk(struct ptlrpc_bulk_desc *bulk, int portal) rc = PtlMDBind(bulk->b_peer.peer_ni, bulk->b_md, &md_h); if (rc != 0) { - BUG(); CERROR("PtlMDBind failed: %d\n", rc); + BUG(); return rc; } @@ -145,10 +145,10 @@ int ptlrpc_send_bulk(struct ptlrpc_bulk_desc *bulk, int portal) rc = PtlPut(md_h, PTL_ACK_REQ, remote_id, portal, 0, bulk->b_xid, 0, 0); if (rc != PTL_OK) { - BUG(); CERROR("PtlPut(%d, %d, %d) failed: %d\n", remote_id.nid, portal, bulk->b_xid, rc); - /* FIXME: tear down md */ + PtlMDUnlink(md_h); + BUG(); } return rc; @@ -190,11 +190,9 @@ int ptlrpc_register_bulk(struct ptlrpc_bulk_desc *bulk) return 0; cleanup2: - EXIT; PtlMEUnlink(bulk->b_me_h); cleanup1: PtlMDUnlink(bulk->b_md_h); - EXIT; return rc; } @@ -373,8 +371,8 @@ int ptl_received_rpc(struct ptlrpc_service *service) { CDEBUG(D_INFO, "Attach MD in ring, rc %d\n", rc); if (rc != PTL_OK) { /* XXX cleanup */ - BUG(); CERROR("PtlMDAttach failed: %d\n", rc); + BUG(); return rc; } diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 306f7813..045c353 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -36,7 +36,6 @@ extern int server_request_callback(ptl_event_t *ev, void *data); static int ptlrpc_check_event(struct ptlrpc_service *svc) { - if (sigismember(&(current->pending.signal), SIGKILL) || sigismember(&(current->pending.signal), SIGINT)) { svc->srv_flags |= SVC_KILLED; @@ -49,6 +48,9 @@ static int ptlrpc_check_event(struct ptlrpc_service *svc) return 1; } + if (svc->srv_flags & SVC_EVENT) + BUG(); + if ( svc->srv_eq_h ) { int rc; rc = PtlEQGet(svc->srv_eq_h, &svc->srv_ev); @@ -73,7 +75,7 @@ static int ptlrpc_check_event(struct ptlrpc_service *svc) EXIT; return 1; } - + EXIT; return 0; } @@ -143,7 +145,6 @@ static int ptlrpc_main(void *arg) /* And now, loop forever on requests */ while (1) { - wait_event(svc->srv_waitq, ptlrpc_check_event(svc)); if (svc->srv_flags & SVC_SIGNAL) { @@ -165,7 +166,8 @@ static int ptlrpc_main(void *arg) * mds_handle instead. */ memset(&request, 0, sizeof(request)); request.rq_obd = obddev; - request.rq_reqbuf = svc->srv_ev.mem_desc.start + svc->srv_ev.offset; + request.rq_reqbuf = (svc->srv_ev.mem_desc.start + + svc->srv_ev.offset); request.rq_reqlen = svc->srv_ev.mem_desc.length; request.rq_xid = svc->srv_ev.match_bits; CDEBUG(D_NET, "got req %d\n", request.rq_xid); @@ -176,6 +178,7 @@ static int ptlrpc_main(void *arg) request.rq_peer.peer_ni = svc->srv_self.peer_ni; rc = svc->srv_handler(obddev, svc, &request); ptl_received_rpc(svc); + svc->srv_flags &= ~SVC_EVENT; continue; } @@ -266,6 +269,9 @@ int rpc_register_service(struct ptlrpc_service *service, char *uuid) return rc; } + CDEBUG(D_NET, "Starting service listening on portal %d\n", + service->srv_req_portal); + /* Attach the leading ME on which we build the ring */ rc = PtlMEAttach(peer.peer_ni, service->srv_req_portal, service->srv_id, 0, ~0, PTL_RETAIN, @@ -344,4 +350,3 @@ int rpc_unregister_service(struct ptlrpc_service *service) return 0; } - diff --git a/lustre/tests/llmount.sh b/lustre/tests/llmount.sh index ed089fb..dd2d690 100755 --- a/lustre/tests/llmount.sh +++ b/lustre/tests/llmount.sh @@ -21,7 +21,6 @@ MDSFS=ext2 new_fs ${MDSFS} /tmp/mds 10000 MDS=$LOOPDEV -mknod /dev/obd c 10 241 echo 0xffffffff > /proc/sys/portals/debug $R/usr/src/obd/utils/obdctl <