From a7761b65d3fbc41df6a0f9bdfebcc880ea7946ce Mon Sep 17 00:00:00 2001 From: pschwan Date: Sun, 3 Mar 2002 04:34:22 +0000 Subject: [PATCH] - Added an 'xid' field to struct niobuf - Fixed bug in OST/OSC bulk handling by using this new field - fixed double free in OST --- lustre/include/linux/lustre_idl.h | 1 + lustre/include/linux/obd_ost.h | 2 +- lustre/lib/obd_pack.c | 3 ++- lustre/osc/osc_request.c | 4 ++-- lustre/ost/ost_handler.c | 9 ++------- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 5f09bf4..73587cc 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -202,6 +202,7 @@ struct niobuf { __u64 offset; __u32 len; __u32 flags; + __u32 xid; void *page; }; diff --git a/lustre/include/linux/obd_ost.h b/lustre/include/linux/obd_ost.h index 0609a7f..69dcc60 100644 --- a/lustre/include/linux/obd_ost.h +++ b/lustre/include/linux/obd_ost.h @@ -48,7 +48,7 @@ int ost_pack_rep(char *buf1, int buflen1, char *buf2, int buflen2, int ost_unpack_rep(char *buf, int len, struct ptlrep_hdr **hdr, union ptl_rep *rep); void ost_pack_niobuf(void **tmp, void *addr, __u64 offset, __u32 len, - __u32 flags); + __u32 flags, __u32 xid); void ost_unpack_niobuf(void **tmp, struct niobuf **nbp); void ost_pack_ioo(void **tmp, struct obdo *oa, int bufcnt); void ost_unpack_ioo(void **tmp, struct obd_ioobj **ioop); diff --git a/lustre/lib/obd_pack.c b/lustre/lib/obd_pack.c index 1ca6133..df237b2 100644 --- a/lustre/lib/obd_pack.c +++ b/lustre/lib/obd_pack.c @@ -236,7 +236,7 @@ void ost_unpack_ioo(void **tmp, struct obd_ioobj **ioop) } void ost_pack_niobuf(void **tmp, void *addr, __u64 offset, __u32 len, - __u32 flags) + __u32 flags, __u32 xid) { struct niobuf *ioo = *tmp; char *c = *tmp; @@ -245,6 +245,7 @@ void ost_pack_niobuf(void **tmp, void *addr, __u64 offset, __u32 len, ioo->offset = NTOH__u64(offset); ioo->len = NTOH__u32(len); ioo->flags = NTOH__u32(flags); + ioo->xid = NTOH__u32(xid); *tmp = c + sizeof(*ioo); } diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index f6f0a2b..824d36a 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -384,7 +384,7 @@ int osc_brw_read(struct obd_conn *conn, obd_count num_oa, struct obdo **oa, bulk[n]->b_buflen = PAGE_SIZE; bulk[n]->b_portal = OST_BULK_PORTAL; ost_pack_niobuf(&ptr2, bulk[n]->b_buf, offset[n], - count[n], flags[n]); + count[n], flags[n], bulk[n]->b_xid); n++; } } @@ -456,7 +456,7 @@ int osc_brw_write(struct obd_conn *conn, obd_count num_oa, struct obdo **oa, ost_pack_ioo(&ptr1, oa[i], oa_bufs[i]); for (j = 0; j < oa_bufs[i]; j++) { ost_pack_niobuf(&ptr2, kmap(buf[n]), offset[n], - count[n], flags[n]); + count[n], flags[n], 0); n++; } } diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 01e4edb..4e128bf 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -371,9 +371,6 @@ int ost_brw(struct ost_obd *obddev, struct ptlrpc_request *req) barrier(); } else { for (i = 0; i < niocount; i++) { - struct ptlrpc_service *srv = - req->rq_obd->u.ost.ost_service; - bulk = ptlrpc_prep_bulk(&req->rq_peer); if (bulk == NULL) { CERROR("cannot alloc bulk desc\n"); @@ -381,12 +378,9 @@ int ost_brw(struct ost_obd *obddev, struct ptlrpc_request *req) goto out; } - spin_lock(&srv->srv_lock); - bulk->b_xid = srv->srv_xid++; - spin_unlock(&srv->srv_lock); - src = &((struct niobuf *)tmp2)[i]; + bulk->b_xid = src->xid; bulk->b_buf = (void *)(unsigned long)src->addr; bulk->b_buflen = PAGE_SIZE; rc = ptlrpc_send_bulk(bulk, OST_BULK_PORTAL); @@ -403,6 +397,7 @@ int ost_brw(struct ost_obd *obddev, struct ptlrpc_request *req) } OBD_FREE(bulk, sizeof(*bulk)); + bulk = NULL; } #if 0 -- 1.8.3.1