-static int sanosc_brw_write(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *lsm, obd_count page_count,
- struct brw_page *pga)
-{
- struct ptlrpc_request *request = NULL;
- struct ost_body *body;
- struct niobuf_remote *nioptr;
- struct obd_ioobj *iooptr;
- int rc, size[3] = {sizeof(*body)}, mapped = 0;
- int swab;
- ENTRY;
-
- size[1] = sizeof(struct obd_ioobj);
- size[2] = page_count * sizeof(*nioptr);
-
- request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
- OST_SAN_WRITE, 3, size, NULL);
- if (!request)
- RETURN(-ENOMEM);
-
- body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
- iooptr = lustre_msg_buf(request->rq_reqmsg, 1, sizeof (*iooptr));
- nioptr = lustre_msg_buf(request->rq_reqmsg, 2,
- sizeof (*nioptr) * page_count);
-
- memcpy(&body->oa, oa, sizeof(body->oa));
-
- obdo_to_ioobj(oa, iooptr);
- iooptr->ioo_bufcnt = page_count;
-
- /* pack request */
- for (mapped = 0; mapped < page_count; mapped++, nioptr++) {
- LASSERT(PageLocked(pga[mapped].pg));
- LASSERT(mapped == 0 ||
- pga[mapped].disk_offset > pga[mapped - 1].disk_offset);
-
- nioptr->offset = pga[mapped].disk_offset;
- nioptr->len = pga[mapped].count;
- nioptr->flags = pga[mapped].flag;
- }
-
- size[1] = page_count * sizeof(*nioptr);
- request->rq_replen = lustre_msg_size(2, size);
-
- rc = ptlrpc_queue_wait(request);
- if (rc)
- GOTO(out_req, rc);
-
- swab = lustre_msg_swabbed (request->rq_repmsg);
- LASSERT_REPSWAB (request, 1);
- nioptr = lustre_msg_buf(request->rq_repmsg, 1, size[1]);
- if (!nioptr) {
- CERROR("absent/short niobuf array\n");
- GOTO(out_req, rc = -EPROTO);
- }
-
- /* actual write */
- for (mapped = 0; mapped < page_count; mapped++, nioptr++) {
- struct page *page = pga[mapped].pg;
- struct buffer_head *bh;
- kdev_t dev;
-
- if (swab)
- lustre_swab_niobuf_remote (nioptr);
-
- /* got san device associated */
- LASSERT(exp->exp_obd != NULL);
- dev = exp->exp_obd->u.cli.cl_sandev;
-
- if (!page->buffers) {
- create_empty_buffers(page, dev, PAGE_SIZE);
- } else {
- /* checking */
- LASSERT(!test_bit(BH_New, &page->buffers->b_state));
- LASSERT(test_bit(BH_Mapped, &page->buffers->b_state));
- LASSERT(page->buffers->b_blocknr ==
- (unsigned long)nioptr->offset);
- }
- bh = page->buffers;
-
- LASSERT(bh);
-
- /* if buffer locked, wait it's io completion */
- if (test_bit(BH_Lock, &bh->b_state))
- wait_on_buffer(bh);
-
- clear_bit(BH_New, &bh->b_state);
- set_bit(BH_Mapped, &bh->b_state);
-
- /* override the block nr */
- bh->b_blocknr = (unsigned long)nioptr->offset;
-
- /* we are about to write it, so set it
- * uptodate/dirty
- * page lock should garentee no race condition here */
- set_bit(BH_Uptodate, &bh->b_state);
- set_bit(BH_Dirty, &bh->b_state);
-
- ll_rw_block(WRITE, 1, &bh);
-
- /* must do syncronous write here */
- wait_on_buffer(bh);
- if (!buffer_uptodate(bh) || test_bit(BH_Dirty, &bh->b_state)) {
- /* I/O error */
- rc = -EIO;
- goto out_req;
- }
- }
-
-out_req:
- ptlrpc_req_finished(request);
- RETURN(rc);
-}
-
-static int sanosc_brw(int cmd, struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *lsm, obd_count page_count,
- struct brw_page *pga, struct obd_trans_info *oti)
-{
- ENTRY;
-
- while (page_count) {
- obd_count pages_per_brw;
- int rc;
-
- if (page_count > PTLRPC_MAX_BRW_PAGES)
- pages_per_brw = PTLRPC_MAX_BRW_PAGES;
- else
- pages_per_brw = page_count;
-
- if (cmd & OBD_BRW_WRITE)
- rc = sanosc_brw_write(exp, oa, lsm, pages_per_brw,pga);
- else
- rc = sanosc_brw_read(exp, oa, lsm, pages_per_brw, pga);
-
- if (rc != 0)
- RETURN(rc);
-
- page_count -= pages_per_brw;
- pga += pages_per_brw;
- }
- RETURN(0);
-}
-#endif
-#endif
-
-static void osc_set_data_with_check(struct lustre_handle *lockh, void *data)