afs: Fix EIO error when reading a 4G or larger file 02/14002/3
authorCheyenne Wills <cwills@sinenomine.net>
Thu, 2 Jan 2020 18:18:16 +0000 (11:18 -0700)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 3 Jan 2020 17:41:04 +0000 (12:41 -0500)
When reading a file with a file length of >= 4G, the cache manager is
failing the read with an EIO error.

In afs_GetDCache, the call to IsDCacheSizeOK is passed a parameter that
contains only the lower 32bits of the file length (which requires a 64
bit value). This results in the EIO error if the length is over 2^32 -1.

The AFSFetchStatus.Length member needs to be combined with the
AFSFetchStatus.Length_hi to obtain the full 64bit file length.

Fix the calls to IsDCacheSizeOK to use the full 64bit file length.

Commit "afs: Check dcache size when checking DVs
7c60a0fba11dd24494a5f383df8bea5fdbabbdd7" - gerrit 13436 - added the
IsDCacheSizeOK function and the associated calls.

As a note, the AFSFetchStatus.DataVersion is the lower 32 bits of the
full 64bit version number, AFSFetchStatus.dataVersionHigh contains
the high order 32bits.  The function IsDCacheSizeOK is passed just the
32bit component, the only use of the parameter is in an error message.

Change-Id: Idbe6233bd6ef792ed2b92d9337aba334e23f1452
Reviewed-on: https://gerrit.openafs.org/14002
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/afs/afs_dcache.c

index ef32feb..4716cb7 100644 (file)
@@ -2638,6 +2638,8 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
                     * validPos is updated by CacheFetchProc, and can only be
                     * modifed under a dcache write lock, which we've blocked out
                     */
+                   afs_size_t length;
+
                    size = tdc->validPos - Position;    /* actual segment size */
                    if (size < 0)
                        size = 0;
@@ -2645,8 +2647,9 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
 
                    /* Check that the amount of data that we fetched for the
                     * dcache makes sense. */
+                   FillInt64(length, tsmall->OutStatus.Length_hi, tsmall->OutStatus.Length);
                    if (!IsDCacheSizeOK(tdc, avc, size,
-                                       tsmall->OutStatus.Length,
+                                       length,
                                        tsmall->OutStatus.DataVersion, 1)) {
                        code = EIO;
                    }