]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix sync read zeroing at EOF
authorSage Weil <sage@inktank.com>
Mon, 17 Jun 2013 02:48:52 +0000 (19:48 -0700)
committerSage Weil <sage@inktank.com>
Mon, 17 Jun 2013 19:24:02 +0000 (12:24 -0700)
If we have a read that hits EOF, we need to do a short read.  Previously
we would zero the buffer if we were completely withing the file, but
we also need to zero things if we overlap with EOF.  This fixes a hang
of mpi-fsx on ceph-fuse.  Triggered/tested by
LibCephFS.MulticlientHoleEOF.

Fixes: #5368
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/client/Client.cc

index 204dc98d74d05dddbb139138b448132ea4211f8b..dec364567b62f48250d366273d0d4d5a3a26f951 100644 (file)
@@ -5826,13 +5826,17 @@ int Client::_read_sync(Fh *f, uint64_t off, uint64_t len, bufferlist *bl)
     }
     // short read?
     if (r >= 0 && r < wanted) {
-      if (pos + left <= in->size) {
-       // hole, zero and return.
-       bufferptr z(left);
+      if (pos < in->size) {
+       // zero up to known EOF
+       int some = MIN(in->size - pos, left);
+       bufferptr z(some);
        z.zero();
        bl->push_back(z);
-       read += left;
-       return read;
+       read += some;
+       pos += some;
+       left -= some;
+       if (left == 0)
+         return read;
       }
 
       // reverify size