From: Michael Meffie Date: Tue, 13 Oct 2015 02:16:54 +0000 (-0400) Subject: afs: fix for return an error from afs_readdir when out of buffers X-Git-Tag: upstream/1.8.0_pre1^2~213 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=eca86749d8f158d27d131ecaafe6be282703535e;p=packages%2Fo%2Fopenafs.git afs: fix for return an error from afs_readdir when out of buffers Commit 9b0d5f274fe79ccc5dd0e4bba86b3f52b27d3586 added a return code to BlobScan to allow afs_readdir to return an error when afs_newslot failed to allocate a buffer. Unfortunately, that change introduced a false EIO error. Originally, BlobScan would return a blob number of 0 to indicate the end of the file has been reached while traversing the directory blobs. Restore that behavior by changing the cache manager's DRead function to return ENOENT instead of the generic EIO error to indicate the page to be read is out of bounds, and change BlobScan to return a blob of zero to indicate to callers the last blob has been reached. All callers already check for a blob number of zero, which is out of range. Change-Id: I5baae8e5377dd49dcca6765b7a4ddc89cca70738 Reviewed-on: http://gerrit.openafs.org/12058 Tested-by: BuildBot Reviewed-by: Mark Vitale Tested-by: Mark Vitale Reviewed-by: Benjamin Kaduk --- diff --git a/src/afs/VNOPS/afs_vnop_readdir.c b/src/afs/VNOPS/afs_vnop_readdir.c index 83e76dd04..9efe8eb5a 100644 --- a/src/afs/VNOPS/afs_vnop_readdir.c +++ b/src/afs/VNOPS/afs_vnop_readdir.c @@ -53,7 +53,9 @@ * * Note that BlobScan switches pages if necessary. BlobScan may * return either 0 for success or an error code. Upon successful - * return, the new blob value is assigned to *ablobOut. + * return, the new blob value is assigned to *ablobOut. The new + * blob value (*ablobOut) is set to 0 when the end of the file has + * been reached. * * BlobScan is used by the Linux port in a separate file, so it should not * become static. @@ -73,6 +75,10 @@ BlobScan(struct dcache * afile, afs_int32 ablob, int *ablobOut) while (1) { pageBlob = ablob & ~(EPP - 1); /* base blob in same page */ code = afs_dir_GetBlob(afile, pageBlob, &headerbuf); + if (code == ENOENT) { + *ablobOut = 0; /* past the end of file */ + return 0; /* not an error */ + } if (code) return code; tpe = (struct PageHeader *)headerbuf.data; diff --git a/src/afs/afs_buffer.c b/src/afs/afs_buffer.c index 2810d9d3e..439947358 100644 --- a/src/afs/afs_buffer.c +++ b/src/afs/afs_buffer.c @@ -236,7 +236,7 @@ DRead(struct dcache *adc, int page, struct DirBuffer *entry) afs_reset_inode(&tb->inode); tb->lockers--; ReleaseWriteLock(&tb->lock); - return EIO; + return ENOENT; /* past the end */ } tfile = afs_CFileOpen(&adc->f.inode); code =