summaryrefslogtreecommitdiff
path: root/util/env_posix.cc
diff options
context:
space:
mode:
authorDavid Grogan <dgrogan@chromium.org>2013-08-21 11:12:47 -0700
committerDavid Grogan <dgrogan@chromium.org>2013-08-21 11:12:47 -0700
commit748539c183453bdeaff1eb0da8ccf5adacb796e7 (patch)
tree6a1712798e5cc172b79e1113d9c1a0fc93496fa7 /util/env_posix.cc
parent5bd76dc10d840df23255ba0e635083a2a94e0461 (diff)
downloadleveldb-748539c183453bdeaff1eb0da8ccf5adacb796e7.tar.gz
LevelDB 1.13v1.13
Fix issues 77, 87, 182, 190. Additionally, fix the bug described in https://groups.google.com/d/msg/leveldb/yL6h1mAOc20/vLU64RylIdMJ where a large contiguous keyspace of deleted data was not getting compacted. Also fix a bug where options.max_open_files was not getting clamped properly.
Diffstat (limited to 'util/env_posix.cc')
-rw-r--r--util/env_posix.cc33
1 files changed, 32 insertions, 1 deletions
diff --git a/util/env_posix.cc b/util/env_posix.cc
index a3f197d..3e2925d 100644
--- a/util/env_posix.cc
+++ b/util/env_posix.cc
@@ -319,8 +319,39 @@ class PosixMmapFile : public WritableFile {
return Status::OK();
}
- virtual Status Sync() {
+ Status SyncDirIfManifest() {
+ const char* f = filename_.c_str();
+ const char* sep = strrchr(f, '/');
+ Slice basename;
+ std::string dir;
+ if (sep == NULL) {
+ dir = ".";
+ basename = f;
+ } else {
+ dir = std::string(f, sep - f);
+ basename = sep + 1;
+ }
Status s;
+ if (basename.starts_with("MANIFEST")) {
+ int fd = open(dir.c_str(), O_RDONLY);
+ if (fd < 0) {
+ s = IOError(dir, errno);
+ } else {
+ if (fsync(fd) < 0) {
+ s = IOError(dir, errno);
+ }
+ close(fd);
+ }
+ }
+ return s;
+ }
+
+ virtual Status Sync() {
+ // Ensure new files referred to by the manifest are in the filesystem.
+ Status s = SyncDirIfManifest();
+ if (!s.ok()) {
+ return s;
+ }
if (pending_sync_) {
// Some unmapped data was not synced