]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Direct I/O Reads Handle the last sector correctly.
authorSiying Dong <siying.d@fb.com>
Sat, 19 Nov 2016 03:17:25 +0000 (19:17 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Sat, 19 Nov 2016 03:24:13 +0000 (19:24 -0800)
Summary:
Currently, in the Direct I/O read mode, the last sector of the file, if not full, is not handled correctly. If the return value of pread is not multiplier of kSectorSize, we still go ahead and continue reading, even if the buffer is not aligned. With the commit, if the return value is not multiplier of kSectorSize, and all but the last sector has been read, we simply return.
Closes https://github.com/facebook/rocksdb/pull/1550

Differential Revision: D4209609

Pulled By: lightmark

fbshipit-source-id: cb0b439

util/io_posix.cc

index 426d2c56044ca0c044b44d2ae0b8ef69621f4cbd..111f899ee0ed3946ea0e65f3882887c4f3ff9e78 100644 (file)
@@ -105,6 +105,11 @@ Status ReadAligned(int fd, Slice* data, const uint64_t offset,
       break;
     }
     bytes_read += status;
+    if (status % static_cast<ssize_t>(kSectorSize) != 0) {
+      // Bytes reads don't fill sectors. Should only happen at the end
+      // of the file.
+      break;
+    }
   }
 
   *data = Slice(scratch, bytes_read);