]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-darwin-pageout-limit-to-filesize-20040405
authorChaskiel M Grundman <cg2v@andrew.cmu.edu>
Mon, 18 Oct 2004 06:11:10 +0000 (06:11 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 18 Oct 2004 06:11:10 +0000 (06:11 +0000)
FIXES 3870

previously we weren't limiting to file size, now we are

(cherry picked from commit 3e45fd85912ad14fa88eb7d16fa1dfe6c3c8664c)

src/afs/DARWIN/osi_vnodeops.c

index 8d23b7df51b7421f194b58647e4a43944c37412f..0a1fb4007f53dad1afa71b737ee156ef50a5ac77 100644 (file)
@@ -445,6 +445,7 @@ afs_vop_pagein(ap)
     struct iovec    aiov;
     struct uio * uio = &auio;
     int nocommit = flags & UPL_NOCOMMIT;
+    int iosize;
 
     int code;
     struct vcache *tvc=VTOAFS(vp);
@@ -584,7 +585,7 @@ afs_vop_pageout(ap)
             panic("afs_vop_pageout: no upl");
     }
 #if 1
-    { int lbn, iosize, s;
+    { int lbn, s;
       struct buf *bp;
       int biosize = DEV_BSIZE;
 
@@ -634,6 +635,19 @@ afs_vop_pageout(ap)
     if (f_offset & PAGE_MASK)
             panic("afs_vop_pageout: offset not page aligned");
 
+    /* size will always be a multiple of PAGE_SIZE */
+    /* pageout isn't supposed to extend files */
+    if (f_offset + size > tvc->m.Length) 
+       iosize = tvc->m.Length - f_offset;
+    else
+       iosize = size;
+    
+    if (size > (iosize + (PAGE_SIZE - 1)) & ~PAGE_MASK && !nocommit)  {
+       int iosize_rnd=(iosize + (PAGE_SIZE - 1)) & ~PAGE_MASK;
+       kernel_upl_abort_range(pl, pl_offset + iosize_rnd,
+                              size - iosize_rnd,
+                              UPL_ABORT_FREE_ON_EMPTY);
+    }
     auio.uio_iov = &aiov;
     auio.uio_iovcnt = 1;
     auio.uio_offset = f_offset;
@@ -642,7 +656,7 @@ afs_vop_pageout(ap)
     auio.uio_procp = NULL;
     kernel_upl_map(kernel_map, pl, &ioaddr);
     ioaddr += pl_offset;
-    auio.uio_resid = aiov.iov_len = size;
+    auio.uio_resid = aiov.iov_len = iosize;
     aiov.iov_base = (caddr_t)ioaddr;
 #if 1 /* USV [ */
         {