FBSD, DFBSD (future) vnode_pager_setsize updates
[openafs.git] / src / afs / VNOPS / afs_vnop_strategy.c
index 896add7..eed0e13 100644 (file)
 #include <afsconfig.h>
 #include "afs/param.h"
 
-RCSID
-    ("$Header$");
 
-#if !defined(AFS_HPUX_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_HPUX_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN80_ENV)
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #include "afsincludes.h"       /* Afs-based standard headers */
@@ -29,27 +27,24 @@ RCSID
 
 
 
-int
-#if    defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-afs_ustrategy(abp, credp)
-     struct AFS_UCRED *credp;
+#if defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+int afs_ustrategy(struct buf *abp, afs_ucred_t *credp)
 #else
-afs_ustrategy(abp)
+int afs_ustrategy(struct buf *abp)
 #endif
-     register struct buf *abp;
 {
-    register afs_int32 code;
+    afs_int32 code;
     struct uio tuio;
-    register struct vcache *tvc = VTOAFS(abp->b_vp);
-    register afs_int32 len = abp->b_bcount;
-#if    !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
+    struct iovec tiovec[1];
+    struct vcache *tvc = VTOAFS(abp->b_vp);
+    afs_int32 len = abp->b_bcount;
 #ifdef AFS_AIX41_ENV
     struct ucred *credp;
-#else
-    struct AFS_UCRED *credp = u.u_cred;
+#elif defined(UKERNEL)
+    afs_ucred_t *credp = get_user_struct()->u_cred;
+#elif !defined(AFS_SUN5_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
+    afs_ucred_t *credp = u.u_cred;
 #endif
-#endif
-    struct iovec tiovec[1];
 
     AFS_STATCNT(afs_ustrategy);
 #ifdef AFS_AIX41_ENV
@@ -66,7 +61,7 @@ afs_ustrategy(abp)
     ReleaseReadLock(&tvc->lock);
     osi_Assert(credp);
 #endif
-#ifdef AFS_FBSD50_ENV
+#ifdef AFS_FBSD_ENV
     if (abp->b_iocmd == BIO_READ) {
 #else
     if ((abp->b_flags & B_READ) == B_READ) {
@@ -78,19 +73,24 @@ afs_ustrategy(abp)
         */
        tuio.afsio_iov = tiovec;
        tuio.afsio_iovcnt = 1;
-#if    defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_XBSD_ENV)
-#ifdef AFS_64BIT_CLIENT
+#if defined(AFS_SUN5_ENV) || defined(AFS_XBSD_ENV)
+# ifdef AFS_64BIT_CLIENT
+#  ifdef AFS_SUN5_ENV
+       tuio.afsio_offset = (afs_offs_t) ldbtob(abp->b_lblkno);
+#  else
        tuio.afsio_offset = (afs_offs_t) dbtob(abp->b_blkno);
-#else /* AFS_64BIT_CLIENT */
+#  endif
+# else /* AFS_64BIT_CLIENT */
        tuio.afsio_offset = (u_int) dbtob(abp->b_blkno);
-#if    defined(AFS_SUN5_ENV)
-       tuio._uio_offset._p._u = 0;
-#endif
-#endif /* AFS_64BIT_CLIENT */
+# endif /* AFS_64BIT_CLIENT */
 #else
        tuio.afsio_offset = DEV_BSIZE * abp->b_blkno;
 #endif
+#if defined(AFS_NBSD40_ENV)
+       UIO_SETUP_SYSSPACE(&tuio);
+#else
        tuio.afsio_seg = AFS_UIOSYS;
+#endif
 #ifdef AFS_UIOFMODE
        tuio.afsio_fmode = 0;
 #endif
@@ -123,7 +123,7 @@ afs_ustrategy(abp)
             * to it, go ahead and write protect the page. This way we will detect
             * storing beyond EOF in the future
             */
-           if (dbtob(abp->b_blkno) + abp->b_bcount > tvc->m.Length) {
+           if (dbtob(abp->b_blkno) + abp->b_bcount > tvc->f.m.Length) {
                if ((abp->b_flags & B_PFSTORE) == 0) {
                    AFS_GUNLOCK();
                    vm_protectp(tvc->segid, dbtob(abp->b_blkno) / PAGESIZE,
@@ -136,14 +136,15 @@ afs_ustrategy(abp)
     } else {
        tuio.afsio_iov = tiovec;
        tuio.afsio_iovcnt = 1;
-#if    defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
+#if defined(AFS_SUN5_ENV)
 #ifdef AFS_64BIT_CLIENT
+#ifdef AFS_SUN5_ENV
+       tuio.afsio_offset = (afs_offs_t) ldbtob(abp->b_lblkno);
+#else
        tuio.afsio_offset = (afs_offs_t) dbtob(abp->b_blkno);
+#endif
 #else /* AFS_64BIT_CLIENT */
        tuio.afsio_offset = (u_int) dbtob(abp->b_blkno);
-#ifdef AFS_SUN5_ENV
-       tuio._uio_offset._p._u = 0;
-#endif
 #endif /* AFS_64BIT_CLIENT */
 #ifdef AFS_SUN5_ENV
 #ifdef AFS_SUN59_ENV
@@ -155,7 +156,11 @@ afs_ustrategy(abp)
 #else
        tuio.afsio_offset = DEV_BSIZE * abp->b_blkno;
 #endif
+#if defined(AFS_NBSD40_ENV)
+       UIO_SETUP_SYSSPACE(&tuio);
+#else
        tuio.afsio_seg = AFS_UIOSYS;
+#endif
 #ifdef AFS_UIOFMODE
        tuio.afsio_fmode = 0;
 #endif
@@ -164,13 +169,8 @@ afs_ustrategy(abp)
         * XXX It this really right? Ideally we should always write block size multiple
         * and not any arbitrary size, right? XXX
         */
-       len = MIN(len, tvc->m.Length - dbtob(abp->b_blkno));
+       len = MIN(len, tvc->f.m.Length - dbtob(abp->b_blkno));
 #endif
-#ifdef AFS_ALPHA_ENV
-       len =
-           MIN(abp->b_bcount,
-               (VTOAFS(abp->b_vp))->m.Length - dbtob(abp->b_blkno));
-#endif /* AFS_ALPHA_ENV */
        tuio.afsio_resid = len;
 #if defined(AFS_XBSD_ENV)
        tiovec[0].iov_base = abp->b_saveaddr;
@@ -186,29 +186,28 @@ afs_ustrategy(abp)
        code = afs_rdwr(VTOAFS(abp->b_vp), &tuio, UIO_WRITE, 0, credp);
 #endif
     }
-#if    !defined(AFS_AIX32_ENV) && !defined(AFS_SUN5_ENV)
-#if defined(AFS_DUX40_ENV) || (defined (AFS_XBSD_ENV) && !defined (AFS_FBSD50_ENV))
+
+#if defined (AFS_XBSD_ENV)
     if (code) {
        abp->b_error = code;
+#if !defined(AFS_FBSD_ENV)
        abp->b_flags |= B_ERROR;
-    }
-    biodone(abp);
-#if defined(AFS_DUX40_ENV)
-    if (code && !(abp->b_flags & B_READ)) {
-       /* prevent ubc from retrying writes */
-       AFS_GUNLOCK();
-       ubc_invalidate(AFSTOV(tvc)->v_object,
-                      (vm_offset_t) dbtob(abp->b_blkno), PAGE_SIZE, B_INVAL);
-       AFS_GLOCK();
-    }
 #endif
-#else /* AFS_DUX40_ENV */
-    iodone(abp);
-#endif /* AFS_DUX40_ENV */
+    }
 #endif
-#ifdef AFS_AIX32_ENV
+
+#if defined(AFS_AIX32_ENV)
     crfree(credp);
+#elif defined(AFS_FBSD60_ENV)
+    (*abp->b_iodone)(abp);
+#elif defined(AFS_FBSD_ENV)
+    biodone(&abp->b_io);
+#elif defined(AFS_XBSD_ENV)
+    biodone(abp);
+#elif !defined(AFS_SUN5_ENV)
+    iodone(abp);
 #endif
+
     afs_Trace3(afs_iclSetp, CM_TRACE_STRATEGYDONE, ICL_TYPE_POINTER, tvc,
               ICL_TYPE_INT32, code, ICL_TYPE_LONG, tuio.afsio_resid);
     return code;