Fix build for FreeBSD 10.0
[openafs.git] / src / afs / afs_bypasscache.c
1 /*
2  * COPYRIGHT  ©  2000
3  * THE REGENTS OF THE UNIVERSITY OF MICHIGAN
4  * ALL RIGHTS RESERVED
5  *
6  * Permission is granted to use, copy, create derivative works
7  * and redistribute this software and such derivative works
8  * for any purpose, so long as the name of The University of
9  * Michigan is not used in any advertising or publicity
10  * pertaining to the use of distribution of this software
11  * without specific, written prior authorization.  If the
12  * above copyright notice or any other identification of the
13  * University of Michigan is included in any copy of any
14  * portion of this software, then the disclaimer below must
15  * also be included.
16  *
17  * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION
18  * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY
19  * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY O
20  * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
21  * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
22  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
23  * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE
24  * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR
25  * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING
26  * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN
27  * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGES.
29  */
30
31  /*
32  * Portions Copyright (c) 2008
33  * The Linux Box Corporation
34  * ALL RIGHTS RESERVED
35  *
36  * Permission is granted to use, copy, create derivative works
37  * and redistribute this software and such derivative works
38  * for any purpose, so long as the name of the Linux Box
39  * Corporation is not used in any advertising or publicity
40  * pertaining to the use or distribution of this software
41  * without specific, written prior authorization.  If the
42  * above copyright notice or any other identification of the
43  * Linux Box Corporation is included in any copy of any
44  * portion of this software, then the disclaimer below must
45  * also be included.
46  *
47  * This software is provided as is, without representation
48  * from the Linux Box Corporation as to its fitness for any
49  * purpose, and without warranty by the Linux Box Corporation
50  * of any kind, either express or implied, including
51  * without limitation the implied warranties of
52  * merchantability and fitness for a particular purpose.  The
53  * Linux Box Corporation shall not be liable for any damages,
54  * including special, indirect, incidental, or consequential
55  * damages, with respect to any claim arising out of or in
56  * connection with the use of the software, even if it has been
57  * or is hereafter advised of the possibility of such damages.
58  */
59
60
61 #include <afsconfig.h>
62 #include "afs/param.h"
63 #if defined(AFS_CACHE_BYPASS) || defined(UKERNEL)
64 #include "afs/afs_bypasscache.h"
65
66 /*
67  * afs_bypasscache.c
68  *
69  */
70 #include "afs/sysincludes.h" /* Standard vendor system headers */
71 #include "afs/afsincludes.h" /* Afs-based standard headers */
72 #include "afs/afs_stats.h"   /* statistics */
73 #include "afs/nfsclient.h"
74 #include "rx/rx_globals.h"
75
76 #ifndef afs_min
77 #define afs_min(A,B) ((A)<(B)) ? (A) : (B)
78 #endif
79
80 /* conditional GLOCK macros */
81 #define COND_GLOCK(var) \
82         do { \
83                 var = ISAFS_GLOCK(); \
84                 if(!var) \
85                         RX_AFS_GLOCK(); \
86         } while(0)
87
88 #define COND_RE_GUNLOCK(var) \
89         do { \
90                 if(var) \
91                         RX_AFS_GUNLOCK(); \
92         } while(0)
93
94
95 /* conditional GUNLOCK macros */
96
97 #define COND_GUNLOCK(var) \
98         do {    \
99                 var = ISAFS_GLOCK(); \
100                 if(var) \
101                         RX_AFS_GUNLOCK(); \
102         } while(0)
103
104 #define COND_RE_GLOCK(var) \
105         do { \
106                 if(var) \
107                         RX_AFS_GLOCK(); \
108         } while(0)
109
110
111 int cache_bypass_strategy   =   NEVER_BYPASS_CACHE;
112 afs_size_t cache_bypass_threshold  =    AFS_CACHE_BYPASS_DISABLED; /* file size > threshold triggers bypass */
113 int cache_bypass_prefetch = 1;  /* Should we do prefetching ? */
114
115 extern afs_rwlock_t afs_xcbhash;
116
117 /*
118  * This is almost exactly like the PFlush() routine in afs_pioctl.c,
119  * but that routine is static.  We are about to change a file from
120  * normal caching to bypass it's caching.  Therefore, we want to
121  * free up any cache space in use by the file, and throw out any
122  * existing VM pages for the file.  We keep track of the number of
123  * times we go back and forth from caching to bypass.
124  */
125 void
126 afs_TransitionToBypass(struct vcache *avc,
127                        afs_ucred_t *acred, int aflags)
128 {
129
130     afs_int32 code;
131     struct vrequest treq;
132     int setDesire = 0;
133     int setManual = 0;
134
135     if (!avc)
136         return;
137
138     if (aflags & TRANSChangeDesiredBit)
139         setDesire = 1;
140     if (aflags & TRANSSetManualBit)
141         setManual = 1;
142
143 #ifdef AFS_BOZONLOCK_ENV
144     afs_BozonLock(&avc->pvnLock, avc);  /* Since afs_TryToSmush will do a pvn_vptrunc */
145 #else
146     AFS_GLOCK();
147 #endif
148
149     ObtainWriteLock(&avc->lock, 925);
150     /*
151      * Someone may have beat us to doing the transition - we had no lock
152      * when we checked the flag earlier.  No cause to panic, just return.
153      */
154     if (avc->cachingStates & FCSBypass)
155         goto done;
156
157     /* If we never cached this, just change state */
158     if (setDesire && (!(avc->cachingStates & FCSBypass))) {
159         avc->cachingStates |= FCSBypass;
160         goto done;
161     }
162
163     /* cg2v, try to store any chunks not written 20071204 */
164     if (avc->execsOrWriters > 0) {
165         code = afs_InitReq(&treq, acred);
166         if (!code)
167             code = afs_StoreAllSegments(avc, &treq, AFS_SYNC | AFS_LASTSTORE);
168     }
169
170 #if 0
171     /* also cg2v, don't dequeue the callback */
172     ObtainWriteLock(&afs_xcbhash, 956);
173     afs_DequeueCallback(avc);
174     ReleaseWriteLock(&afs_xcbhash);
175 #endif
176     avc->f.states &= ~(CStatd | CDirty);      /* next reference will re-stat */
177     /* now find the disk cache entries */
178     afs_TryToSmush(avc, acred, 1);
179     osi_dnlc_purgedp(avc);
180     if (avc->linkData && !(avc->f.states & CCore)) {
181         afs_osi_Free(avc->linkData, strlen(avc->linkData) + 1);
182         avc->linkData = NULL;
183     }
184
185     avc->cachingStates |= FCSBypass;    /* Set the bypass flag */
186     if(setDesire)
187         avc->cachingStates |= FCSDesireBypass;
188     if(setManual)
189         avc->cachingStates |= FCSManuallySet;
190     avc->cachingTransitions++;
191
192 done:
193     ReleaseWriteLock(&avc->lock);
194 #ifdef AFS_BOZONLOCK_ENV
195     afs_BozonUnlock(&avc->pvnLock, avc);
196 #else
197     AFS_GUNLOCK();
198 #endif
199 }
200
201 /*
202  * This is almost exactly like the PFlush() routine in afs_pioctl.c,
203  * but that routine is static.  We are about to change a file from
204  * bypassing caching to normal caching.  Therefore, we want to
205  * throw out any existing VM pages for the file.  We keep track of
206  * the number of times we go back and forth from caching to bypass.
207  */
208 void
209 afs_TransitionToCaching(struct vcache *avc,
210                         afs_ucred_t *acred,
211                         int aflags)
212 {
213     int resetDesire = 0;
214     int setManual = 0;
215
216     if (!avc)
217         return;
218
219     if (aflags & TRANSChangeDesiredBit)
220         resetDesire = 1;
221     if (aflags & TRANSSetManualBit)
222         setManual = 1;
223
224 #ifdef AFS_BOZONLOCK_ENV
225     afs_BozonLock(&avc->pvnLock, avc);  /* Since afs_TryToSmush will do a pvn_vptrunc */
226 #else
227     AFS_GLOCK();
228 #endif
229     ObtainWriteLock(&avc->lock, 926);
230     /*
231      * Someone may have beat us to doing the transition - we had no lock
232      * when we checked the flag earlier.  No cause to panic, just return.
233      */
234     if (!(avc->cachingStates & FCSBypass))
235         goto done;
236
237     /* Ok, we actually do need to flush */
238     ObtainWriteLock(&afs_xcbhash, 957);
239     afs_DequeueCallback(avc);
240     avc->f.states &= ~(CStatd | CDirty);        /* next reference will re-stat cache entry */
241     ReleaseWriteLock(&afs_xcbhash);
242     /* now find the disk cache entries */
243     afs_TryToSmush(avc, acred, 1);
244     osi_dnlc_purgedp(avc);
245     if (avc->linkData && !(avc->f.states & CCore)) {
246         afs_osi_Free(avc->linkData, strlen(avc->linkData) + 1);
247         avc->linkData = NULL;
248     }
249
250     avc->cachingStates &= ~(FCSBypass);    /* Reset the bypass flag */
251     if (resetDesire)
252         avc->cachingStates &= ~(FCSDesireBypass);
253     if (setManual)
254         avc->cachingStates |= FCSManuallySet;
255     avc->cachingTransitions++;
256
257 done:
258     ReleaseWriteLock(&avc->lock);
259 #ifdef AFS_BOZONLOCK_ENV
260     afs_BozonUnlock(&avc->pvnLock, avc);
261 #else
262     AFS_GUNLOCK();
263 #endif
264 }
265
266 /* In the case where there's an error in afs_NoCacheFetchProc or
267  * afs_PrefetchNoCache, all of the pages they've been passed need
268  * to be unlocked.
269  */
270 #ifdef UKERNEL
271 typedef void * bypass_page_t;
272
273 #define unlock_and_release_pages(auio)
274 #define release_full_page(pp, pageoff)
275
276 #else
277 typedef struct page * bypass_page_t;
278
279 #define unlock_and_release_pages(auio) \
280     do { \
281         struct iovec *ciov;     \
282         bypass_page_t pp; \
283         afs_int32 iovmax; \
284         afs_int32 iovno = 0; \
285         ciov = auio->uio_iov; \
286         iovmax = auio->uio_iovcnt - 1;  \
287         pp = (bypass_page_t) ciov->iov_base;    \
288         while(1) { \
289             if (pp) { \
290                 if (PageLocked(pp)) \
291                     unlock_page(pp);    \
292                 put_page(pp); /* decrement refcount */ \
293             } \
294             iovno++; \
295             if(iovno > iovmax) \
296                 break; \
297             ciov = (auio->uio_iov + iovno);     \
298             pp = (bypass_page_t) ciov->iov_base;        \
299         } \
300     } while(0)
301
302 #define release_full_page(pp, pageoff)                  \
303     do { \
304         /* this is appropriate when no caller intends to unlock \
305          * and release the page */ \
306         SetPageUptodate(pp); \
307         if(PageLocked(pp)) \
308             unlock_page(pp); \
309         else \
310             afs_warn("afs_NoCacheFetchProc: page not locked!\n"); \
311         put_page(pp); /* decrement refcount */ \
312     } while(0)
313 #endif
314
315 static void
316 afs_bypass_copy_page(bypass_page_t pp, int pageoff, struct iovec *rxiov,
317         int iovno, int iovoff, struct uio *auio, int curiov, int partial)
318 {
319     char *address;
320     int dolen;
321
322     if (partial)
323         dolen = auio->uio_iov[curiov].iov_len - pageoff;
324     else
325         dolen = rxiov[iovno].iov_len - iovoff;
326
327 #if !defined(UKERNEL)
328 # if defined(KMAP_ATOMIC_TAKES_NO_KM_TYPE)
329     address = kmap_atomic(pp);
330 # else
331     address = kmap_atomic(pp, KM_USER0);
332 # endif
333 #else
334     address = pp;
335 #endif
336     memcpy(address + pageoff, (char *)(rxiov[iovno].iov_base) + iovoff, dolen);
337 #if !defined(UKERNEL)
338 # if defined(KMAP_ATOMIC_TAKES_NO_KM_TYPE)
339     kunmap_atomic(address);
340 # else
341     kunmap_atomic(address, KM_USER0);
342 # endif
343 #endif
344 }
345
346 /* no-cache prefetch routine */
347 static afs_int32
348 afs_NoCacheFetchProc(struct rx_call *acall,
349                      struct vcache *avc,
350                      struct uio *auio,
351                      afs_int32 release_pages,
352                      afs_int32 size)
353 {
354     afs_int32 length;
355     afs_int32 code;
356     int moredata, iovno, iovoff, iovmax, result, locked;
357     struct iovec *ciov;
358     struct iovec *rxiov;
359     int nio = 0;
360     bypass_page_t pp;
361
362     int curpage, bytes;
363     int pageoff;
364
365     rxiov = osi_AllocSmallSpace(sizeof(struct iovec) * RX_MAXIOVECS);
366     ciov = auio->uio_iov;
367     pp = (bypass_page_t) ciov->iov_base;
368     iovmax = auio->uio_iovcnt - 1;
369     iovno = iovoff = result = 0;
370
371     do {
372         COND_GUNLOCK(locked);
373         code = rx_Read(acall, (char *)&length, sizeof(afs_int32));
374         COND_RE_GLOCK(locked);
375         if (code != sizeof(afs_int32)) {
376             result = EIO;
377             afs_warn("Preread error. code: %d instead of %d\n",
378                 code, (int)sizeof(afs_int32));
379             unlock_and_release_pages(auio);
380             goto done;
381         } else
382             length = ntohl(length);
383
384         if (length > size) {
385             result = EIO;
386             afs_warn("Preread error. Got length %d, which is greater than size %d\n",
387                      length, size);
388             unlock_and_release_pages(auio);
389             goto done;
390         }
391
392         /* If we get a 0 length reply, time to cleanup and return */
393         if (length == 0) {
394             unlock_and_release_pages(auio);
395             result = 0;
396             goto done;
397         }
398
399         /*
400          * The fetch protocol is extended for the AFS/DFS translator
401          * to allow multiple blocks of data, each with its own length,
402          * to be returned. As long as the top bit is set, there are more
403          * blocks expected.
404          *
405          * We do not do this for AFS file servers because they sometimes
406          * return large negative numbers as the transfer size.
407          */
408         if (avc->f.states & CForeign) {
409             moredata = length & 0x80000000;
410             length &= ~0x80000000;
411         } else {
412             moredata = 0;
413         }
414
415         for (curpage = 0; curpage <= iovmax; curpage++) {
416             pageoff = 0;
417             /* properly, this should track uio_resid, not a fixed page size! */
418             while (pageoff < auio->uio_iov[curpage].iov_len) {
419                 /* If no more iovs, issue new read. */
420                 if (iovno >= nio) {
421                     COND_GUNLOCK(locked);
422                     bytes = rx_Readv(acall, rxiov, &nio, RX_MAXIOVECS, length);
423                     COND_RE_GLOCK(locked);
424                     if (bytes < 0) {
425                         afs_warn("afs_NoCacheFetchProc: rx_Read error. Return code was %d\n", bytes);
426                         result = bytes;
427                         unlock_and_release_pages(auio);
428                         goto done;
429                     } else if (bytes == 0) {
430                         /* we failed to read the full length */
431                         result = EIO;
432                         afs_warn("afs_NoCacheFetchProc: rx_Read returned zero. Aborting.\n");
433                         unlock_and_release_pages(auio);
434                         goto done;
435                     }
436                     size -= bytes;
437                     auio->uio_resid -= bytes;
438                     iovno = 0;
439                 }
440                 pp = (bypass_page_t)auio->uio_iov[curpage].iov_base;
441                 if (pageoff + (rxiov[iovno].iov_len - iovoff) <= auio->uio_iov[curpage].iov_len) {
442                     /* Copy entire (or rest of) current iovec into current page */
443                     if (pp)
444                         afs_bypass_copy_page(pp, pageoff, rxiov, iovno, iovoff, auio, curpage, 0);
445                     length -= (rxiov[iovno].iov_len - iovoff);
446                     pageoff += rxiov[iovno].iov_len - iovoff;
447                     iovno++;
448                     iovoff = 0;
449                 } else {
450                     /* Copy only what's needed to fill current page */
451                     if (pp)
452                         afs_bypass_copy_page(pp, pageoff, rxiov, iovno, iovoff, auio, curpage, 1);
453                     length -= (auio->uio_iov[curpage].iov_len - pageoff);
454                     iovoff += auio->uio_iov[curpage].iov_len - pageoff;
455                     pageoff = auio->uio_iov[curpage].iov_len;
456                 }
457
458                 /* we filled a page, or this is the last page.  conditionally release it */
459                 if (pp && ((pageoff == auio->uio_iov[curpage].iov_len &&
460                             release_pages) || (length == 0 && iovno >= nio)))
461                     release_full_page(pp, pageoff);
462
463                 if (length == 0 && iovno >= nio)
464                     goto done;
465             }
466         }
467     } while (moredata);
468
469 done:
470     osi_FreeSmallSpace(rxiov);
471     return result;
472 }
473
474
475 /* dispatch a no-cache read request */
476 afs_int32
477 afs_ReadNoCache(struct vcache *avc,
478                 struct nocache_read_request *bparms,
479                 afs_ucred_t *acred)
480 {
481     afs_int32 code;
482     afs_int32 bcnt;
483     struct brequest *breq;
484     struct vrequest *areq;
485
486     /* the reciever will free this */
487     areq = osi_Alloc(sizeof(struct vrequest));
488
489     if (avc->vc_error) {
490         code = EIO;
491         afs_warn("afs_ReadNoCache VCache Error!\n");
492         goto cleanup;
493     }
494     if ((code = afs_InitReq(areq, acred))) {
495         afs_warn("afs_ReadNoCache afs_InitReq error!\n");
496         goto cleanup;
497     }
498
499     AFS_GLOCK();
500     code = afs_VerifyVCache(avc, areq);
501     AFS_GUNLOCK();
502
503     if (code) {
504         code = afs_CheckCode(code, areq, 11);   /* failed to get it */
505         afs_warn("afs_ReadNoCache Failed to verify VCache!\n");
506         goto cleanup;
507     }
508
509     bparms->areq = areq;
510
511     /* and queue this one */
512     bcnt = 1;
513     AFS_GLOCK();
514     while(bcnt < 20) {
515         breq = afs_BQueue(BOP_FETCH_NOCACHE, avc, B_DONTWAIT, 0, acred, 1, 1,
516                           bparms, (void *)0, (void *)0);
517         if(breq != 0) {
518             code = 0;
519             break;
520         }
521         afs_osi_Wait(10 * bcnt, 0, 0);
522     }
523     AFS_GUNLOCK();
524
525     if(!breq) {
526         code = EBUSY;
527         goto cleanup;
528     }
529
530     return code;
531
532 cleanup:
533     /* If there's a problem before we queue the request, we need to
534      * do everything that would normally happen when the request was
535      * processed, like unlocking the pages and freeing memory.
536      */
537     unlock_and_release_pages(bparms->auio);
538     osi_Free(areq, sizeof(struct vrequest));
539     osi_Free(bparms->auio->uio_iov,
540              bparms->auio->uio_iovcnt * sizeof(struct iovec));
541     osi_Free(bparms->auio, sizeof(struct uio));
542     osi_Free(bparms, sizeof(struct nocache_read_request));
543     return code;
544 }
545
546
547 /* Cannot have static linkage--called from BPrefetch (afs_daemons) */
548 afs_int32
549 afs_PrefetchNoCache(struct vcache *avc,
550                     afs_ucred_t *acred,
551                     struct nocache_read_request *bparms)
552 {
553     struct uio *auio;
554 #ifndef UKERNEL
555     struct iovec *iovecp;
556 #endif
557     struct vrequest *areq;
558     afs_int32 code = 0;
559     struct rx_connection *rxconn;
560 #ifdef AFS_64BIT_CLIENT
561     afs_int32 length_hi, bytes, locked;
562 #endif
563
564     struct afs_conn *tc;
565     struct rx_call *tcall;
566     struct tlocal1 {
567         struct AFSVolSync tsync;
568         struct AFSFetchStatus OutStatus;
569         struct AFSCallBack CallBack;
570     };
571     struct tlocal1 *tcallspec;
572
573     auio = bparms->auio;
574     areq = bparms->areq;
575 #ifndef UKERNEL
576     iovecp = auio->uio_iov;
577 #endif
578
579     tcallspec = osi_Alloc(sizeof(struct tlocal1));
580     do {
581         tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK /* ignored */, &rxconn);
582         if (tc) {
583             avc->callback = tc->parent->srvr->server;
584             tcall = rx_NewCall(rxconn);
585 #ifdef AFS_64BIT_CLIENT
586             if (!afs_serverHasNo64Bit(tc)) {
587                 code = StartRXAFS_FetchData64(tcall,
588                                               (struct AFSFid *) &avc->f.fid.Fid,
589                                               auio->uio_offset,
590                                               bparms->length);
591                 if (code == 0) {
592                     COND_GUNLOCK(locked);
593                     bytes = rx_Read(tcall, (char *)&length_hi,
594                                     sizeof(afs_int32));
595                     COND_RE_GLOCK(locked);
596
597                     if (bytes != sizeof(afs_int32)) {
598                         length_hi = 0;
599                         code = rx_Error(tcall);
600                         COND_GUNLOCK(locked);
601                         code = rx_EndCall(tcall, code);
602                         COND_RE_GLOCK(locked);
603                         tcall = NULL;
604                     }
605                 }
606             } /* afs_serverHasNo64Bit */
607             if (code == RXGEN_OPCODE || afs_serverHasNo64Bit(tc)) {
608                 if (auio->uio_offset > 0x7FFFFFFF) {
609                     code = EFBIG;
610                 } else {
611                     afs_int32 pos;
612                     pos = auio->uio_offset;
613                     COND_GUNLOCK(locked);
614                     if (!tcall)
615                         tcall = rx_NewCall(rxconn);
616                     code = StartRXAFS_FetchData(tcall,
617                                         (struct AFSFid *) &avc->f.fid.Fid,
618                                         pos, bparms->length);
619                     COND_RE_GLOCK(locked);
620                 }
621                 afs_serverSetNo64Bit(tc);
622             }
623 #else
624             code = StartRXAFS_FetchData(tcall,
625                                         (struct AFSFid *) &avc->f.fid.Fid,
626                                         auio->uio_offset, bparms->length);
627 #endif
628             if (code == 0) {
629                 code = afs_NoCacheFetchProc(tcall, avc, auio,
630                                             1 /* release_pages */,
631                                             bparms->length);
632             } else {
633                 afs_warn("BYPASS: StartRXAFS_FetchData failed: %d\n", code);
634                 unlock_and_release_pages(auio);
635                 goto done;
636             }
637             if (code == 0) {
638                 code = EndRXAFS_FetchData(tcall, &tcallspec->OutStatus,
639                                           &tcallspec->CallBack,
640                                           &tcallspec->tsync);
641             } else {
642                 afs_warn("BYPASS: NoCacheFetchProc failed: %d\n", code);
643             }
644             code = rx_EndCall(tcall, code);
645         } else {
646             afs_warn("BYPASS: No connection.\n");
647             code = -1;
648             unlock_and_release_pages(auio);
649             goto done;
650         }
651     } while (afs_Analyze(tc, rxconn, code, &avc->f.fid, areq,
652                                                  AFS_STATS_FS_RPCIDX_FETCHDATA,
653                                                  SHARED_LOCK,0));
654 done:
655     /*
656      * Copy appropriate fields into vcache
657      */
658
659     if (!code)
660         afs_ProcessFS(avc, &tcallspec->OutStatus, areq);
661
662     osi_Free(areq, sizeof(struct vrequest));
663     osi_Free(tcallspec, sizeof(struct tlocal1));
664     osi_Free(bparms, sizeof(struct nocache_read_request));
665 #ifndef UKERNEL
666     /* in UKERNEL, the "pages" are passed in */
667     osi_Free(iovecp, auio->uio_iovcnt * sizeof(struct iovec));
668     osi_Free(auio, sizeof(struct uio));
669 #endif
670     return code;
671 }
672 #endif