|
|
@ -68,8 +68,10 @@ class PosixWritableFile : public WritableFile { |
|
|
|
const std::string filename_; |
|
|
|
const std::string filename_; |
|
|
|
int fd_; |
|
|
|
int fd_; |
|
|
|
uint64_t filesize_; |
|
|
|
uint64_t filesize_; |
|
|
|
|
|
|
|
#ifdef ROCKSDB_FALLOCATE_PRESENT |
|
|
|
bool allow_fallocate_; |
|
|
|
bool allow_fallocate_; |
|
|
|
bool fallocate_with_keep_size_; |
|
|
|
bool fallocate_with_keep_size_; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
PosixWritableFile(const std::string& fname, int fd, |
|
|
|
PosixWritableFile(const std::string& fname, int fd, |
|
|
@ -87,9 +89,11 @@ class PosixWritableFile : public WritableFile { |
|
|
|
virtual bool IsSyncThreadSafe() const override; |
|
|
|
virtual bool IsSyncThreadSafe() const override; |
|
|
|
virtual uint64_t GetFileSize() override; |
|
|
|
virtual uint64_t GetFileSize() override; |
|
|
|
virtual Status InvalidateCache(size_t offset, size_t length) override; |
|
|
|
virtual Status InvalidateCache(size_t offset, size_t length) override; |
|
|
|
|
|
|
|
#ifdef ROCKSDB_FALLOCATE_PRESENT |
|
|
|
virtual Status Allocate(off_t offset, off_t len) override; |
|
|
|
virtual Status Allocate(off_t offset, off_t len) override; |
|
|
|
virtual Status RangeSync(off_t offset, off_t nbytes) override; |
|
|
|
virtual Status RangeSync(off_t offset, off_t nbytes) override; |
|
|
|
virtual size_t GetUniqueId(char* id, size_t max_size) const override; |
|
|
|
virtual size_t GetUniqueId(char* id, size_t max_size) const override; |
|
|
|
|
|
|
|
#endif |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class PosixMmapReadableFile : public RandomAccessFile { |
|
|
|
class PosixMmapReadableFile : public RandomAccessFile { |
|
|
@ -119,8 +123,10 @@ class PosixMmapFile : public WritableFile { |
|
|
|
char* dst_; // Where to write next (in range [base_,limit_])
|
|
|
|
char* dst_; // Where to write next (in range [base_,limit_])
|
|
|
|
char* last_sync_; // Where have we synced up to
|
|
|
|
char* last_sync_; // Where have we synced up to
|
|
|
|
uint64_t file_offset_; // Offset of base_ in file
|
|
|
|
uint64_t file_offset_; // Offset of base_ in file
|
|
|
|
|
|
|
|
#ifdef ROCKSDB_FALLOCATE_PRESENT |
|
|
|
bool allow_fallocate_; // If false, fallocate calls are bypassed
|
|
|
|
bool allow_fallocate_; // If false, fallocate calls are bypassed
|
|
|
|
bool fallocate_with_keep_size_; |
|
|
|
bool fallocate_with_keep_size_; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// Roundup x to a multiple of y
|
|
|
|
// Roundup x to a multiple of y
|
|
|
|
static size_t Roundup(size_t x, size_t y) { return ((x + y - 1) / y) * y; } |
|
|
|
static size_t Roundup(size_t x, size_t y) { return ((x + y - 1) / y) * y; } |
|
|
@ -150,7 +156,9 @@ class PosixMmapFile : public WritableFile { |
|
|
|
virtual Status Fsync() override; |
|
|
|
virtual Status Fsync() override; |
|
|
|
virtual uint64_t GetFileSize() override; |
|
|
|
virtual uint64_t GetFileSize() override; |
|
|
|
virtual Status InvalidateCache(size_t offset, size_t length) override; |
|
|
|
virtual Status InvalidateCache(size_t offset, size_t length) override; |
|
|
|
|
|
|
|
#ifdef ROCKSDB_FALLOCATE_PRESENT |
|
|
|
virtual Status Allocate(off_t offset, off_t len) override; |
|
|
|
virtual Status Allocate(off_t offset, off_t len) override; |
|
|
|
|
|
|
|
#endif |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class PosixDirectory : public Directory { |
|
|
|
class PosixDirectory : public Directory { |
|
|
|