-EXPORT_SYMBOL(ost_brw_write);
-
-static int ost_san_brw(struct ptlrpc_request *req, int cmd)
-{
- struct niobuf_remote *remote_nb, *res_nb, *pp_rnb;
- struct obd_ioobj *ioo;
- struct ost_body *body, *repbody;
- int rc, i, objcount, niocount, size[2] = {sizeof(*body)}, npages;
- int swab;
- ENTRY;
-
- /* XXX not set to use latest protocol */
-
- swab = lustre_msg_swabbed(req->rq_reqmsg);
- body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
- if (body == NULL) {
- CERROR("Missing/short ost_body\n");
- GOTO(out, rc = -EFAULT);
- }
-
- ioo = lustre_swab_reqbuf(req, 1, sizeof(*ioo), lustre_swab_obd_ioobj);
- if (ioo == NULL) {
- CERROR("Missing/short ioobj\n");
- GOTO(out, rc = -EFAULT);
- }
- objcount = req->rq_reqmsg->buflens[1] / sizeof(*ioo);
- niocount = ioo[0].ioo_bufcnt;
- for (i = 1; i < objcount; i++) {
- if (swab)
- lustre_swab_obd_ioobj (&ioo[i]);
- niocount += ioo[i].ioo_bufcnt;
- }
-
- remote_nb = lustre_swab_reqbuf(req, 2, niocount * sizeof(*remote_nb),
- lustre_swab_niobuf_remote);
- if (remote_nb == NULL) {
- CERROR("Missing/short niobuf\n");
- GOTO(out, rc = -EFAULT);
- }
- if (swab) { /* swab the remaining niobufs */
- for (i = 1; i < niocount; i++)
- lustre_swab_niobuf_remote (&remote_nb[i]);
- }
-
- /* CAVEAT EMPTOR this sets ioo->ioo_bufcnt to # pages */
- npages = get_per_page_niobufs(ioo, objcount,remote_nb,niocount,&pp_rnb);
- if (npages < 0)
- GOTO (out, rc = npages);
-
- size[1] = npages * sizeof(*pp_rnb);
- rc = lustre_pack_reply(req, 2, size, NULL);
- if (rc)
- GOTO(out_pp_rnb, rc);
-
- req->rq_status = obd_san_preprw(cmd, req->rq_export, &body->oa,
- objcount, ioo, npages, pp_rnb);
-
- if (req->rq_status)
- GOTO(out_pp_rnb, rc = 0);
-
- repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
- memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
-
- res_nb = lustre_msg_buf(req->rq_repmsg, 1, size[1]);
- memcpy(res_nb, remote_nb, size[1]);
- rc = 0;
-out_pp_rnb:
- free_per_page_niobufs(npages, pp_rnb, remote_nb);
-out:
- if (rc) {
- req->rq_status = rc;
- ptlrpc_error(req);
- } else
- ptlrpc_reply(req);
-
- return rc;
-}