[OpenAFS-devel] patch for LFS in AIX

Hartmut Reuter reuter@rzg.mpg.de
Tue, 16 Mar 2004 10:23:42 +0100


There was still a bug in the large file support of the AIX client: you
could read
after the end of a large file.

Here is the diff on base of the version of src/afs/AIX/osi_vnodeops.c in
the CVS:


@@ -1066,6 +1066,7 @@
      afs_size_t finalOffset;
      off_t toffset;
      int mixed = 0;
+    afs_size_t add2resid = 0;
  #endif /* AFS_64BIT_CLIENT */
      register struct vcache *vcp = VTOAFS(vp);
      struct dcache *tdc;
@@ -1104,6 +1105,16 @@

  #ifdef AFS_64BIT_CLIENT
      if (xfrOffset + xfrSize > afs_vmMappingEnd) {
+        if (rw == UIO_READ) {
+            /* don't read past EOF */
+            if (xfrSize+xfrOffset > fileSize) {
+            add2resid = xfrSize + xfrOffset - fileSize;
+            xfrSize = fileSize - xfrOffset;
+            if (xfrSize <= 0) goto fail;
+                txfrSize = xfrSize;
+                afsio_trim(uiop, txfrSize);
+            }
+        }
         if (xfrOffset < afs_vmMappingEnd) {
             /* special case of a buffer crossing the VM mapping line */
             struct uio tuio;
@@ -1135,6 +1146,7 @@
         } else {
             ReleaseReadLock(&vcp->lock);
             code = afs_direct_rdwr(vp, uiop, rw, ioflag, credp);
+            uiop->uio_resid += add2resid;
             return code;
         }
      }
@@ -1198,6 +1210,7 @@
         if (mixed) {
             uiop->afsio_offset = finalOffset;
         }
+        uiop->uio_resid += add2resid;
  #endif /* AFS_64BIT_CLIENT */
         return code;
      }


Hartmut
-----------------------------------------------------------------
Hartmut Reuter                           e-mail reuter@rzg.mpg.de
					   phone +49-89-3299-1328
RZG (Rechenzentrum Garching)               fax   +49-89-3299-1301
Computing Center of the Max-Planck-Gesellschaft (MPG) and the
Institut fuer Plasmaphysik (IPP)
-----------------------------------------------------------------