mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
acaba247cf
Summary: Some linkers (lld being one) use fallocate() or posix_fallocate() on the output file before writing its contents. EdenFS would return ENOSYS or ENOTSUP so glibc would fall back and write a single byte to every 512 byte block, which is terribly slow and generates a bunch of fake traffic in the Watchman journal. This diff implements basic support for FUSE_FALLOCATE, avoiding this slow emulation. Reviewed By: xavierd Differential Revision: D25934694 fbshipit-source-id: c6c90ea2b517d4dbedce29d9a4340870c8c177c3
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <folly/Expected.h>
|
|
#include <folly/File.h>
|
|
#include <folly/portability/SysUio.h>
|
|
|
|
namespace folly {
|
|
class File;
|
|
}
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
class Overlay;
|
|
|
|
class OverlayFile {
|
|
public:
|
|
OverlayFile() = default;
|
|
explicit OverlayFile(folly::File file, std::weak_ptr<Overlay> overlay);
|
|
|
|
OverlayFile(OverlayFile&&) = default;
|
|
OverlayFile& operator=(OverlayFile&&) = default;
|
|
|
|
folly::Expected<struct stat, int> fstat() const;
|
|
folly::Expected<ssize_t, int> preadNoInt(void* buf, size_t n, off_t offset)
|
|
const;
|
|
folly::Expected<off_t, int> lseek(off_t offset, int whence) const;
|
|
folly::Expected<ssize_t, int>
|
|
pwritev(const iovec* iov, int iovcnt, off_t offset) const;
|
|
folly::Expected<int, int> ftruncate(off_t length) const;
|
|
folly::Expected<int, int> fsync() const;
|
|
folly::Expected<int, int> fallocate(off_t offset, off_t length) const;
|
|
folly::Expected<int, int> fdatasync() const;
|
|
folly::Expected<std::string, int> readFile() const;
|
|
|
|
private:
|
|
OverlayFile(const OverlayFile&) = delete;
|
|
OverlayFile& operator=(const OverlayFile&) = delete;
|
|
|
|
folly::File file_;
|
|
std::weak_ptr<Overlay> overlay_;
|
|
};
|
|
} // namespace eden
|
|
} // namespace facebook
|