/* Cannot have static linkage--called from BPrefetch (afs_daemons) */ afs_int32 afs_PrefetchNoCache(struct vcache *avc, afs_ucred_t *acred, struct nocache_read_request *bparms) { struct uio *auio; #ifndef UKERNEL struct iovec *iovecp; #endif struct vrequest *areq; afs_int32 code = 0; struct rx_connection *rxconn; #ifdef AFS_64BIT_CLIENT afs_int32 length_hi, bytes, locked; #endif struct afs_conn *tc; struct rx_call *tcall; struct tlocal1 { struct AFSVolSync tsync; struct AFSFetchStatus OutStatus; struct AFSCallBack CallBack; }; struct tlocal1 *tcallspec; auio = bparms->auio; areq = bparms->areq; #ifndef UKERNEL iovecp = auio->uio_iov; #endif tcallspec = osi_Alloc(sizeof(struct tlocal1)); do { tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK /* ignored */, &rxconn); if (tc) { avc->callback = tc->parent->srvr->server; tcall = rx_NewCall(rxconn); #ifdef AFS_64BIT_CLIENT if (!afs_serverHasNo64Bit(tc)) { code = StartRXAFS_FetchData64(tcall, (struct AFSFid *) &avc->f.fid.Fid, auio->uio_offset, bparms->length); if (code == 0) { COND_GUNLOCK(locked); bytes = rx_Read(tcall, (char *)&length_hi, sizeof(afs_int32)); COND_RE_GLOCK(locked); if (bytes != sizeof(afs_int32)) { length_hi = 0; code = rx_Error(tcall); COND_GUNLOCK(locked); code = rx_EndCall(tcall, code); COND_RE_GLOCK(locked); tcall = NULL; } } } /* afs_serverHasNo64Bit */ if (code == RXGEN_OPCODE || afs_serverHasNo64Bit(tc)) { if (auio->uio_offset > 0x7FFFFFFF) { code = EFBIG; } else { afs_int32 pos; pos = auio->uio_offset; COND_GUNLOCK(locked); if (!tcall) tcall = rx_NewCall(rxconn); code = StartRXAFS_FetchData(tcall, (struct AFSFid *) &avc->f.fid.Fid, pos, bparms->length); COND_RE_GLOCK(locked); } afs_serverSetNo64Bit(tc); } #else code = StartRXAFS_FetchData(tcall, (struct AFSFid *) &avc->f.fid.Fid, auio->uio_offset, bparms->length); #endif if (code == 0) { code = afs_NoCacheFetchProc(tcall, avc, auio, 1 /* release_pages */, bparms->length); } else { afs_warn("BYPASS: StartRXAFS_FetchData failed: %d\n", code); unlock_and_release_pages(auio); goto done; } if (code == 0) { code = EndRXAFS_FetchData(tcall, &tcallspec->OutStatus, &tcallspec->CallBack, &tcallspec->tsync); } else { afs_warn("BYPASS: NoCacheFetchProc failed: %d\n", code); } code = rx_EndCall(tcall, code); } else { afs_warn("BYPASS: No connection.\n"); code = -1; unlock_and_release_pages(auio); goto done; } } while (afs_Analyze(tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_FETCHDATA, SHARED_LOCK,0)); done: /* * Copy appropriate fields into vcache */ if (!code) afs_ProcessFS(avc, &tcallspec->OutStatus, areq); osi_Free(areq, sizeof(struct vrequest)); osi_Free(tcallspec, sizeof(struct tlocal1)); osi_Free(bparms, sizeof(struct nocache_read_request)); #ifndef UKERNEL /* in UKERNEL, the "pages" are passed in */ osi_Free(iovecp, auio->uio_iovcnt * sizeof(struct iovec)); osi_Free(auio, sizeof(struct uio)); #endif return code; }
static void * client_thread( void *vparams) { struct client_data *params = (struct client_data *)vparams; struct rx_call *call; afs_int32 data; int i, j; afs_uint32 *readwrite; int readp = FALSE; afs_uint32 size; afs_uint32 num; for (i = 0; i < params->times; i++) { DBFPRINT(("starting command ")); call = rx_NewCall(params->conn); if (call == NULL) errx(1, "rx_NewCall failed"); data = htonl(RX_PERF_VERSION); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send version (err %d)", rx_Error(call)); data = htonl(params->command); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send command (err %d)", rx_Error(call)); data = htonl(rxread_size); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call)); data = htonl(rxwrite_size); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call)); switch (params->command) { case RX_PERF_RECV: DBFPRINT(("command ")); data = htonl(params->bytes); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send size (err %d)", rx_Error(call)); DBFPRINT(("sending(%d) ", params->bytes)); if (do_readbytes(call, params->bytes)) errx(1, "sendbytes (err %d)", rx_Error(call)); if (rx_Read32(call, &data) != 4) errx(1, "failed to read result from server (err %d)", rx_Error(call)); if (data != htonl(RXPERF_MAGIC_COOKIE)) warn("server send wrong magic cookie in responce"); DBFPRINT(("done\n")); break; case RX_PERF_SEND: DBFPRINT(("command ")); data = htonl(params->bytes); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send size (err %d)", rx_Error(call)); DBFPRINT(("sending(%d) ", params->bytes)); if (do_sendbytes(call, params->bytes)) errx(1, "sendbytes (err %d)", rx_Error(call)); if (rx_Read32(call, &data) != 4) errx(1, "failed to read result from server (err %d)", rx_Error(call)); if (data != htonl(RXPERF_MAGIC_COOKIE)) warn("server send wrong magic cookie in responce"); DBFPRINT(("done\n")); break; case RX_PERF_RPC: DBFPRINT(("commands ")); data = htonl(params->sendbytes); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send command (err %d)", rx_Error(call)); data = htonl(params->readbytes); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send command (err %d)", rx_Error(call)); DBFPRINT(("send(%d) ", params->sendbytes)); if (do_sendbytes(call, params->sendbytes)) errx(1, "sendbytes (err %d)", rx_Error(call)); DBFPRINT(("recv(%d) ", params->readbytes)); if (do_readbytes(call, params->readbytes)) errx(1, "sendbytes (err %d)", rx_Error(call)); if (rx_Read32(call, &data) != 4) errx(1, "failed to read result from server (err %d)", rx_Error(call)); if (data != htonl(RXPERF_MAGIC_COOKIE)) warn("server send wrong magic cookie in responce"); DBFPRINT(("done\n")); break; case RX_PERF_FILE: readfile(params->filename, &readwrite, &num); data = htonl(num); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send size (err %d)", rx_Error(call)); if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32)) != num * sizeof(afs_uint32)) errx(1, "rx_Write failed to send list (err %d)", rx_Error(call)); for (j = 0; j < num; j++) { if (readwrite[j] == 0) readp = !readp; size = ntohl(readwrite[j]) * sizeof(afs_uint32); if (readp) { if (do_readbytes(call, size)) errx(1, "sendbytes (err %d)", rx_Error(call)); DBFPRINT(("read\n")); } else { if (do_sendbytes(call, size)) errx(1, "sendbytes (err %d)", rx_Error(call)); DBFPRINT(("send\n")); } } break; default: abort(); } rx_EndCall(call, 0); } #ifdef AFS_PTHREAD_ENV pthread_exit(NULL); #endif return NULL; }