Commit Graph

507 Commits

Author SHA1 Message Date
Xavier Deguillard
93ecf2126b fs: ensure that a minidump is created on crash
Summary:
After printing the exception backtrace, EdenFS terminates manually.
Unfortunately, this means that Windows can't detect that the process crashed as
it thinks it terminated correctly. In turn, this prevents minidumps from being
created which makes debugging the crash impossible.

Fixing this is no easy task as returning from the exception handler would
always trigger an infinite recursion of unwind somewhere in the CRT code. This
would produce a minidump, but it wouldn't be handy to use. The only solution I
found is to reset the exception handler and invoke one as by default, this
creates a minidump. After that, we can exit EdenFS in the same way as before,
being careful to not call `std::abort` or `std::terminate`.

Reviewed By: chadaustin

Differential Revision: D41362303

fbshipit-source-id: 42422db66a5f8033796ed8cb5b3ccf1a235f1da5
2022-11-16 23:22:50 -08:00
Chad Austin
cf0bb5d1f4 rely on SemiFuture move being nothrow
Summary:
SemiFuture is a pointer-sized, noncopyable type. We can assume it's
always nothrow-move, so assert that fact and remove some noexcept
checks.

Reviewed By: xavierd

Differential Revision: D41052209

fbshipit-source-id: d9507bcc7ef4dd4f9c1d621aa75a157ed0ba1c5f
2022-11-16 18:09:51 -08:00
Chad Austin
69c8693356 ensure Paths are noexcept-move
Summary:
Moving a PathPiece, AbsolutePath, RelativePath, or PathComponent
should never throw. Add static_asserts to indicate that.

Reviewed By: kmancini

Differential Revision: D41272812

fbshipit-source-id: 0b4b10f8430f31aafe6229f88995108251e52de7
2022-11-16 18:09:51 -08:00
Chad Austin
02f6f891be AbsolutePathPiece and RelativePathPiece should be nothrow default constructible
Reviewed By: genevievehelsel

Differential Revision: D41087154

fbshipit-source-id: 567717bdda728532b44685993ad784b2309f219c
2022-11-16 18:09:51 -08:00
Chad Austin
a1bc268963 port Path and PathPiece from folly::StringPiece to std::string_view
Summary:
std::string_view has noexcept accessors and folly::Range doesn't, so
this allows us to make Path and PathPiece noexcept.

Reviewed By: kmancini

Differential Revision: D41145426

fbshipit-source-id: 046f6f6a532d8d0da8508ccf7896c914e19a25ec
2022-11-16 18:09:51 -08:00
Chad Austin
870ffb721a format path types with fmt instead of folly/Conv
Summary:
For compile times, runtime performance, and compile-time checking,
we're standardizing on fmt over folly/Conv.

Reviewed By: kmancini

Differential Revision: D41105228

fbshipit-source-id: d6fddf93670bbd64d8dfd61921fcc319ea368d2c
2022-11-15 15:40:33 -08:00
Chad Austin
6f60c48ea8 decouple ObjectFetchContext lifetime from RequestContext
Summary:
Requiring that callers ensure that ObjectFetchContext outlives the
asynchronous result is a burden and a memory-safety risk. Without
Rust's borrow checker, we can't feel confident this is safe under all
error and timeout conditions. It also requires we use
folly::collectAll and collectAllSafe, which means that an error during
fanout has to wait until the fanout completes before we can report the
error to our caller.

Moreover, tying the ObjectFetchContext's lifetime to the
FUSE/NFS/Thrift/etc. request's lifetime gives us incorrect statistics
about how long the request takes. I consider this an API design
mistake (on my part).

Correct the situation by decoupling ObjectFetchContext from
RequestContext, and begin reference-counting ObjectFetchContext.

This does increase the number of atomic RMW operations, but we can
alleviate those where they matter by manually checking
*Future::isReady() before calling .then*.

Reviewed By: xavierd

Differential Revision: D40744706

fbshipit-source-id: 5baf654f6d65790ed0cafb45c0bc7f2aaa8ecec2
2022-11-15 13:35:45 -08:00
Chad Austin
ec7d88dc8a format keys in FaultInjector with fmt
Reviewed By: xavierd

Differential Revision: D41145295

fbshipit-source-id: 06b534583c5e665f23ee3ebb46184bcea6fb8bbc
2022-11-14 10:56:34 -08:00
Chad Austin
529c388885 fix a potential buffer overread in FileUtils
Summary:
AbsolutePathPiece does not guarantee null termination. Therefore, we
must allocate a null-terminated string every time.

Reviewed By: xavierd

Differential Revision: D41099085

fbshipit-source-id: 3b8cb1b2630b9e2c190f8efbaa694e7868723e1b
2022-11-11 18:46:15 -08:00
Chad Austin
6d3664ee86 introduce an asString() on Path and PathPiece
Summary:
At API boundaries, it's common to want to convert a Path or PathPiece
to std::string. Previously, code would call
`.stringPiece().str()`. Add an `asString()` to make this explicit.

Reviewed By: xavierd

Differential Revision: D41140757

fbshipit-source-id: 72003dc9a353cdfa4632a7d1ab433122211186e0
2022-11-11 18:46:15 -08:00
Chad Austin
6e1789bfff remove unnecessary copies from FileUtils
Summary:
RVO only works when the local and the return type are exact
matches. Here, we're invoking the constructor, so we need to
std::move.

Reviewed By: xavierd

Differential Revision: D41097721

fbshipit-source-id: 52e4425a960ce0aa8ae59a827ddde4e9b58a7f92
2022-11-09 18:38:58 -08:00
Chad Austin
c1db56d68d add a polyfill for std::string_view::{starts,ends}_with
Summary:
We won't be on C++20 for a while and we'd like to cut dependencies on
folly::Range where possible. starts_with and ends_with are too useful,
so add a polyfill.

Reviewed By: xavierd

Differential Revision: D41097519

fbshipit-source-id: 298f65b15b8beb6f56ab1b6b9896fc6b1225f0fb
2022-11-09 18:38:58 -08:00
Xavier Deguillard
f199e93924 utils: AbsolutePath are always UNC on Windows
Summary:
On Windows, absolute paths are of multiple shape, with all of them having pros
and cons. In particular, device paths (C:/) that EdenFS is using is limited to
260 characters. To bypass this limitation, UNC paths (\\?\) can be used, but no
normalization is done automatically, specifically '/' aren't converted to '\'.

Since UNC paths allow us to support long paths, and would also bring more
safety to EdenFS by enforcing that all AbsolutePath are of the UNC form, let's
use them.

One of the other downside of UNC is that applications may not support them or
may misbehave when passed to them. For this reason, EdenFS doesn't expose UNC
paths in its Thrift API, changing the path to a device path, applications
relying on Thrift are expected to re-UNC them.

Reviewed By: chadaustin

Differential Revision: D40818724

fbshipit-source-id: 260b8732df04bbffee6b2fe52f0ceda222d3941b
2022-11-08 08:49:16 -08:00
Chad Austin
e6983b51ea introduce a SourceLocation type
Summary:
We can't use std::source_location just yet, but I'd like to switch
ThriftLogHelper to it. Therefore, introduce a polyfill for the near
term.

Reviewed By: genevievehelsel

Differential Revision: D40701594

fbshipit-source-id: 4a39644439df15300df4a5bc303b7f2e87d0bf15
2022-11-03 14:18:34 -07:00
Chad Austin
b77d9a0337 add a microbenchmark for RefPtr vs. unique_ptr and shared_ptr
Summary:
Add a silly microbenchmark that compares the innate overheads of
unique_ptr, shared_ptr, and RefPtr.

It's primarily a malloc() benchmark, and the results have the same
caveats that all microbenchmarks do, but we can illustrate that
RefPtr's single-threaded use case is on par with unique_ptr.

Reviewed By: genevievehelsel

Differential Revision: D40355895

fbshipit-source-id: f1d620df14a028749df8ae8893eaf86e25eb5797
2022-11-03 09:57:10 -07:00
Chad Austin
1cc4c95632 allow refcount-free conversion of RefPtr<T> to const RefPtr<U>&
Summary:
In cases where a function takes a `const Ptr<Base>&` but we have a
`Ptr<Derived>`, allow access to the `Ptr<Derived>` through a `const
Ptr<Base>&` without bumping the reference count.

Reviewed By: kmancini

Differential Revision: D40351346

fbshipit-source-id: 534607f74264ed1c18557dc28a6688e7a9c992a4
2022-11-02 23:06:45 -07:00
Chad Austin
79cdf007b1 fix opt-builds under -Werror
Reviewed By: xavierd

Differential Revision: D40822558

fbshipit-source-id: e2f4acbe2b92869fa275f0dfb39f59c9b015c92f
2022-10-28 17:58:18 -07:00
Chad Austin
78d38866e4 log exception parameters during a crash
Summary:
Windows exception (like access violation) come with parameters. These
parameters tell you whether a read or a write was attempted, and the
faulting pointer value. It's very helpful when debugging crashes, so
log all exception parameters too.

Reviewed By: xavierd

Differential Revision: D40780025

fbshipit-source-id: bc221555b4f615c3146c7c3a100d898046ad9733
2022-10-27 20:32:12 -07:00
Chad Austin
95824d22fc add intrusive RefCounted and RefPtr types
Summary:
I plan to improve the safety of how ObjectFetchContext is passed
through EdenFS by making it reference-counted. First, let's introduce
some lightweight reference-counting that avoids any atomic RMWs at all
in the case that an object is never shared.

Reviewed By: kmancini

Differential Revision: D39978716

fbshipit-source-id: d42dbbf4d2bae5a55b67b40149b62dc461badf78
2022-10-25 10:30:23 -07:00
Chad Austin
0c6786f5e2 remove an unnecessary conditional include
Reviewed By: xavierd

Differential Revision: D40490560

fbshipit-source-id: d6ebd2b82d8d13803d7ebe7d97c546380adc8774
2022-10-19 12:18:34 -07:00
Xavier Deguillard
159e446d4d inodes: fix checkout with concurrent recursive grep
Summary:
The checkout code was designed with the assumption that concurrent reads/writes
to the working copy would block on locks that checkout holds, thus preventing
races. On Windows, this assumption is slightly broken as reads to the working
copy are served by the tree hierarchy not by the inode hierarchy. Reads are
then reflected back to the inode hierarchy in a background manner to increment
the FS refcount. If, somehow a directory is read at the same time as the
corresponding directory entry for it is being invalidated in checkout, checkout
will attempt to invalidate the directory, but since the directory isn't empty
the invalidation would fail, failing checkout.

To solve this, we could simply pretend that the directory is loaded and
recursively run checkout on it.

Reviewed By: kmancini

Differential Revision: D39596117

fbshipit-source-id: 95a42553b8779d904f57f9d168197398f5d45436
2022-10-18 12:32:52 -07:00
Xavier Deguillard
74bb88e6a6 immediate_future: use logical not-equal instead of xor operator
Summary:
As chadaustin pointed, logical not-equal are easier to read than xors. Let's
use the former.

Reviewed By: genevievehelsel

Differential Revision: D40366550

fbshipit-source-id: b9c0f23e47ba40ddc16bd578b303008987a41b95
2022-10-14 09:57:11 -07:00
Xavier Deguillard
0149d15d1e immediatefuture: make ready when the SemiFuture is ready
Summary:
In the case where the promise associated with a SemiFuture is set after the
ImmediateFuture construction, EdenFS will still attempt to push the SemiFuture
to an executor. Since this is quite expensive, let's handle this case by
considering the ImmediateFuture as ready.

In very high fanout computation (like glob), this is expected to reduce the
amount of futures pushed to the Thrift executor. This is expected to help
reduce the amount of Queue Timeout in `glob(**/*)` cases.

Reviewed By: genevievehelsel

Differential Revision: D40312497

fbshipit-source-id: e48efac2e4f2640b6a7ad50957ee7c723772ec81
2022-10-13 21:44:10 -07:00
Xavier Deguillard
c305812528 immediatefuture: redo makeNotReadyImmediateFuture
Summary:
In the following change, ImmediateFuture contains an additional optimization to
treat ready SemiFuture as an immediate value. Thus makeNotReadyImmediateFuture
can no longer be written with the help of an initially unset Promise. To
achieve the same result, we can make the ImmediateFuture class be aware of
never-ready SemiFuture.

Reviewed By: genevievehelsel

Differential Revision: D40322423

fbshipit-source-id: 4faa0c513d1e6afa26951dd00bb8015cc45ac510
2022-10-13 21:44:10 -07:00
Yedidya Feldblum
307a25e13c migrate constructions of folly::exception_wrapper
Summary: It is no longer necessary to pass a reference to the caught exception along with `std::current_exception()`.

Reviewed By: xavierd

Differential Revision: D40252106

fbshipit-source-id: 08bfbea675c60097050f3f026af308fcf0a240df
2022-10-12 12:01:08 -07:00
Chad Austin
1aaf41f638 migrate EdenBug to fmt
Reviewed By: genevievehelsel

Differential Revision: D39992442

fbshipit-source-id: e54fe65fcb7fc4b3954a81586cd54e11de853bdd
2022-10-04 21:42:44 -07:00
Chad Austin
2ae7ffa43f migrate EdenError to fmt
Summary:
EdenError is another header file that pulls in folly/Conv.h. It also
uses folly::to's concatenation capabilities. Migrate it to fmt just
like Throw.h.

Reviewed By: genevievehelsel

Differential Revision: D39992358

fbshipit-source-id: 09d1d3446f664ec55b91e5b37ee9299ef253e991
2022-10-04 21:42:44 -07:00
Chad Austin
11ad1a4122 remove unnecessary forwarding from throw_ and throwf
Summary:
fmt never takes ownership of its arguments. Therefore, we can always
pass by const reference.

Reviewed By: genevievehelsel

Differential Revision: D39992308

fbshipit-source-id: 03713338530cbc1d775c6a0089bce140cf0ea030
2022-10-04 21:42:44 -07:00
Chad Austin
08086fafc0 migrate utils/Throw.h to fmt
Summary:
The main non-mechanical conversion from folly/Conv to fmt is replacing
folly::to<std:string>'s variadic concatenation operation with
fmt::join. Now that that's solved, we can slowly migrate the rest.

Reviewed By: genevievehelsel

Differential Revision: D39992102

fbshipit-source-id: 81df8e805c78ea5ca80ad5977f20b19e5a7467a3
2022-10-04 21:42:44 -07:00
Chad Austin
0081eb6c26 fix the custom PathFuncs and ObjectId formatters
Summary:
I don't know the difference between our prior magic incantations and
the new magic incantations, but the old ones crazy errors when writing
variadic wrappers that eventually call into fmt::format or fmt::join.

Reviewed By: vitaut

Differential Revision: D39991902

fbshipit-source-id: 8ca3215267912b3bb0ddf586681d3eb5294f52ff
2022-10-04 21:42:44 -07:00
Chad Austin
bea4ee5043 migrate AbsolutePathPiece, RelativePathPiece, and PathComponentPiece to std::string_view
Summary:
I'm having some confusing conflicts between fmt and our PathPieces. To
at least make the error messages clearer, migrate them to
std::string_view.

Reviewed By: genevievehelsel

Differential Revision: D39991418

fbshipit-source-id: 34d0f1ee23618da4595ee1d072e9cdf4f51736b6
2022-10-04 21:42:44 -07:00
Xavier Deguillard
9336b4d45f getdeps: fix broken Windows build
Summary:
The build was broken due to incompatible types being used. Clang doesn't
complain about these, but msvc does.

Reviewed By: fanzeyi

Differential Revision: D39561417

fbshipit-source-id: 605e8cb5537defc31c21b54e67317ceeb8935674
2022-09-15 18:04:16 -07:00
Xavier Deguillard
a0a5c2a26a fsck: properly fixup socket files
Summary:
While EdenFS now properly handle socket files written to the working copy, the
FSCK code was not, thinking socket files are placeholders. For socket files
already present in the working copy this means that `eden doctor` would
complain about them.

Reviewed By: fanzeyi

Differential Revision: D39442575

fbshipit-source-id: 6dfb8fefe67d80dab32960d39c0b91f8148e2345
2022-09-14 13:04:34 -07:00
Xavier Deguillard
4a68beebb7 utils: allow ImmediateFuture<T> to be constructed from a compatible type
Summary:
In some cases, it's desirable to be able to construct an ImmediateFuture<T>
from another type, like in case of inheritence where T is the base class. In
this case, a static_cast is required for the compiler to not error out, instead
we can slightly change ImmediateFuture constructor to allow this conversion.

A couple of manual ImmediateFuture constructors were no longer necessary and
thus removed as a result.

Reviewed By: genevievehelsel

Differential Revision: D39158019

fbshipit-source-id: eb3452ba33d941251d9b4efaee28f82fd2c2dbd3
2022-08-31 17:04:13 -07:00
Katie Mancini
32679fb9a1 log architecture on macOS to edenfs_events
Summary:
It's not possible to differentiate NFS m1 and intel users in edenfs_events
right now. We are currently rolling out to intel users and it would be good
to understand the real number of intel users on NFS vs fuse.

Let's log the cpu architecture so that we can differentiate them.

Reviewed By: mshroyer

Differential Revision: D39139996

fbshipit-source-id: 582804707a7816c41aa6c69594f7198d3ce5dfe1
2022-08-31 11:57:28 -07:00
Xavier Deguillard
133853d3c6 utils: add a makeNotReadyImmediateFuture
Summary:
There are cases where the code doesn't wish to execute the ImmediateFuture
continuation inline. For instance, if the code wants to spawn many CPU
intensive futures to be executed in background threads and then collected,
executing these inline would make the code slower.

One easy way to solve this would be to simply use SemiFuture and push them to
background threads, but the rest of the code would need to be ported to use
SemiFuture all over the place. The use of SemiFuture would also slow down the
callers that wish to execute the continuation inline, which isn't desired.

Thankfully, we can achieve both by using ImmediateFuture, the caller can just
decide if it wants the code to execute inline (a regular ImmediateFuture), or
not (by building a not ready ImmediateFuture).

Reviewed By: chadaustin

Differential Revision: D37330741

fbshipit-source-id: 911827f12725d7a0d64986737d02026386fe459e
2022-08-30 18:20:55 -07:00
Xavier Deguillard
adea4946e4 utils: in debug mode ImmediateFuture are always SemiFuture
Summary:
Due to their eager nature, an ImmediateFuture will execute future continuation
immediately when constructed with either an immediate value, or a ready
SemiFuture. One of the drawback of doing that is that tests often manipulate
data that is already ready, and thus we may rarely execute the not-ready code
path. This can lead to use after free when the capture list of a continuation
is not properly set.

To avoid this, we can make ImmediateFuture always be a wrapper on a SemiFuture,
even when constructed from an immediate value. This way, the use after free
described above will always occur in debug/sanitized builds, and
AddressSanitizer will tell us when these occur.

Reviewed By: kmancini

Differential Revision: D37729622

fbshipit-source-id: bcd858f821cc39d63fb446b0891a067bee370a22
2022-08-19 16:34:11 -07:00
Xavier Deguillard
81c4573942 utils: close process handle after waiting for it
Summary:
Looking at procexp, EdenFS appears to be holding handles of dead processes.
After forcing a process to be spawned by SpawnProcess and killing it, I can see
that the handle doesn't go away. This is due to missing CloseHandle of the
process itself.

Reviewed By: chadaustin

Differential Revision: D38472410

fbshipit-source-id: b9d22ec52e7e9f1d33ff923d47cba49a3135067c
2022-08-16 16:24:13 -07:00
Zeyi (Rice) Fan
b56f28bf22 common: rename utils -> edencommon_utils
Summary:
Fixes https://github.com/facebookexperimental/edencommon/issues/3

`utils` is a bit too generic and Gentoo seems to be building edencommon into a shared library.

Reviewed By: chadaustin

Differential Revision: D38719753

fbshipit-source-id: fb46b6a7c9d3bcc3034765cb47e997a80c646b3d
2022-08-16 11:23:53 -07:00
Durham Goode
3baf67065c Close Windows file handle during Windows Fsck
Summary: This file handle was being opened but never closed. Let's expose the FileUtils.cpp FileHandle helper so we can use it to close the handle when it goes out of scope.

Reviewed By: xavierd

Differential Revision: D38556231

fbshipit-source-id: f1038eb1b802ebb193116edb4e537945ff4ac737
2022-08-12 12:28:58 -07:00
Katie Mancini
c56693d4e2 remove folly::Format TimeUtil
Summary:
From the folly format docs
> Use fmt::format instead of folly::format for better performance, build times and compatibility with std::format

eden build times have gotten a bit high, cutting out folly format will help reduce build time, so let's start
by banishing it from eden

see the last change in this group for the difference

Reviewed By: xavierd

Differential Revision: D38250999

fbshipit-source-id: bfa6debfb9cc9abb8634df69701658308645e6f1
2022-08-02 11:44:19 -07:00
Katie Mancini
cff9ff7e4f remove folly::Format PathFuncs
Summary:
From the folly format docs
> Use fmt::format instead of folly::format for better performance, build times and compatibility with std::format

eden build times have gotten a bit high, cutting out folly format will help reduce build time, so let's start
by banishing it from eden

see the last change in this group for the difference

Reviewed By: xavierd

Differential Revision: D38251000

fbshipit-source-id: a5aee79f7f0acbf969a351c3aa5ac32bb6c01b2a
2022-08-02 11:44:19 -07:00
Philip Pronin
f6a52160c5 use appendCodePointToUtf8
Summary:
Replace `codePointToUtf8` with `appendCodePointToUtf8` (D38305991)
where it makes sense.

Reviewed By: luciang

Differential Revision: D38306295

fbshipit-source-id: 6203f3509cc5bedd8cf8d484305ac8be583c16d6
2022-08-01 07:09:24 -07:00
Genevieve Helsel
91ce14539e use auto* for OverlayEntry::get_hash()
Reviewed By: xavierd

Differential Revision: D38253811

fbshipit-source-id: 69156056b649786e7ce96954fbf0418972f6526b
2022-07-29 10:40:08 -07:00
Chad Austin
63971e5fba shave 5-7 seconds off C++ unit test compile times
Summary:
I was iterating on a single unit test and noticed our compilation times have
crossed the threshold from bad to horrific. I was seeing 30+ seconds per unit
test .cpp file.

After playing around with -ftime-trace, I found some obvious low-hanging fruit:
- forward declaration opportunities
- pImpl
- moving some implementation to cpp files

Some bigger opportunities remain:

The folly/portability/GTest.h and folly/portability/Windows.h header situation
isn't great. They pull in winsock2.h which alone takes two seconds to compile.
We also probably don't need the folly/portability/Unistd.h compatibility
wrappers in EdenFS or Watchman.

Also, folly/Format.h is quite expensive, and there are other dependencies that
pull in Boost MPL.

Reviewed By: xavierd

Differential Revision: D38195736

fbshipit-source-id: 9c64bab5ff5851d5a896674712aec71d6780c79a
2022-07-28 13:32:42 -07:00
Xavier Deguillard
24cecc95fb paths: in debug/sanitized builds pessimize moves to copies
Summary:
In D37422971 (3d9636fe8c), it was shown that moving a path will invalidate the pieces on the
moved path. Unfortunately, this can only be observed when the path is short
enough to fit in the SSO of std::string. To force this to be true even without
SSO, we can pessimize moves into copies and leverage the use of ASAN to tell us
if the code is misbehaving.

Reviewed By: kmancini

Differential Revision: D37705144

fbshipit-source-id: a4446632b0e5d3b422226e85c324059c5b8cf379
2022-07-27 13:38:40 -07:00
Genevieve Helsel
073a8f2296 process TreeOverlay functions on BufferedTreeOverlay worker thread
Summary: moves `void` `TreeOverlay` functions to the `BufferedTreeOverlay`'s worker thread and waits on non-`void` functions. This maintains ordering with a `flush` which puts a no-op wait onto the `BufferedTreeOverlay`'s worker thread.

Reviewed By: chadaustin

Differential Revision: D35634643

fbshipit-source-id: fe080b4940e17fc6328f7246179185dcc7d16f70
2022-07-25 16:55:43 -07:00
Andrew Milas
18bc0ee56a Add path information to inode tracing commands
Summary:
Currently the eden trace inode live and retroactive commands only display inode numbers in order to identify the inode whose event is being referenced. In order to help users more easily debug Eden, it would be helpful to also provide Inode names and/or inode paths to these commands. While computing inode paths can potentially be an expensive operation, we get over this by computing these paths outside of the critical path when inode events get published into tracebus and instead compute the paths in the thrift service handler for all inodes as they are needed. These paths are computed using the EdenMount's InodeMap.

However, as a consequence this might mean path information is not always available, namely during a start event when creating a new file, directory, or symlink while the live `eden trace inode` command is being run, or after an inode has been removed after its materialization event has occurred in the `eden trace indeed --retroactive` command. In these cases, an empty string is shown for the path, though a follow up diff is planned that will add file name information (not full paths) to each inode event as they occur that will be shown when full path information is unavailable.

Reviewed By: MichaelCuevas

Differential Revision: D37961108

fbshipit-source-id: 88d5d303eb5afc616ff46bc083cd96b55c572cfa
2022-07-19 16:30:46 -07:00
Chad Austin
265128f4f4 remove some conditional includes
Summary:
To simplify the build and fall in line with Folly's conventions,
remove several conditional includes. Instead, headers conditionally
define symbols.

Reviewed By: xavierd

Differential Revision: D37897850

fbshipit-source-id: 8b52d5310f5cd8cb17fdc013117c271ae09dd5d6
2022-07-19 12:37:57 -07:00
Xavier Deguillard
4e5e144c4f utils: make move ImmediateFuture conditionally noexcept
Summary:
In most cases, the type held by an ImmediateFuture is moveable in a noexcept
fashion. However, several debugability improvements are being added to both
PathFuncs and ImmediateFuture which makes this no longer true in
debug/sanitized builds. Thus let's go the more complex route of properly
specifying the noexcept qualifier.

Reviewed By: kmancini

Differential Revision: D37840356

fbshipit-source-id: 452dd2b65ae813ce24617753d5f51ccfe00eb184
2022-07-14 15:11:54 -07:00
Xavier Deguillard
1df7efd261 utils: fix compilation in ImmediateFuture
Summary:
When the ImmediateFuture is holding a SemiFuture, the compiler complains about
the use of `std::forward`, let's fix that and add few tests to verify that it
now compiles well.

Reviewed By: fanzeyi

Differential Revision: D37861191

fbshipit-source-id: 590f22f1fdbfda7e7106730a7d77ddfd5b08d815
2022-07-14 13:51:39 -07:00
Durham Goode
eb22573c51 Add process kill fault to FaultInjector
Summary:
I want to test how Eden recovers from an ungraceful process exit. Let's
enable FaultInjector to kill the process.

Reviewed By: xavierd

Differential Revision: D36986502

fbshipit-source-id: 3a92a16e7ed11a8afbe2dc81f84f43666d5bd73f
2022-07-13 20:08:12 -07:00
Xavier Deguillard
7581f36534 utils: refinement to ImmediateFuture::thenError
Summary:
While using thenError in the following diff, I realized that the thenError code
had a bug that failed compiling. The added test is an example of a similar code
that would fail to compile despite being perfectly valid.

As a bonus, this also makes thenValue slightly more efficient when dealing with
exceptions in the SemiFuture case.

Reviewed By: chadaustin

Differential Revision: D37824174

fbshipit-source-id: 2f759a65ebffce456f8f4f13ea4792ce078ae926
2022-07-13 15:31:42 -07:00
Chad Austin
b26418ef01 migrate to throw_ and throwf
Summary:
I've always been annoyed at needing to include folly/Conv.h or fmt to
throw a formatted exception. And while exceptions are rarely in the
hot path, it's still worth having the option to optimize the
formatting and exception allocation step at some point in the future.

I'm sure I missed some, but this diff migrates most of our
`throw T{fmt::format(...)}` patterns to `throwf` and
`throw T{folly::to<std::string>(...)}` to `throw_`.

Reviewed By: genevievehelsel

Differential Revision: D37229822

fbshipit-source-id: c053b5cdaed99e58c485afd2a99be98828f07657
2022-07-08 13:30:53 -07:00
Xavier Deguillard
3d9636fe8c prjfs: fix use after free in handleNotPresentFileNotification
Summary:
In order to avoid copying paths and allocation, this code cleverly uses path
piece on a path that is moved and will live for longer than the path pieces.
Unfortunately, the assumption on which this optimization was built is not
always true. To understand more, we need to dig onto the implementation details
of RelativePath and of std::string.

A RelativePath is merely a wrapper around an std::string, and a
RelativePathPiece is also just a wrapper on top of a folly::StringPiece (which
has similar semantic as std::string_view), that is, a RelativePathPiece merely
holds a view of to the underlying std::string buffer. When a RelativePath is
being moved, the held std::string is also moved, which in most cases prevents
copying and re-allocating a string, this makes the move operation fairly cheap
and since the RelativePathPiece were a view on that first string memory
allocation, these are still viewing valid and allocated memory.

However, std::string have an optimization where small strings aren't heap
allocated, but are stored in the std::string object itself, this is called SSO
for small string optimization. In this case, a folly::StringPiece is no longer
a view on the heap allocated memory, but on that SSO memory. What this means is
that moving a SSO std::string will make the folly::StringPiece invalid as it
would no longer point to valid memory!

As mentioned above, RelativePath and RelativePathPiece are just wrappers on top
of std::string and folly::StringView, and thus the same caveat exist. This
means that the optimization performed in handleNotPresentFileNotification is
correct only for RelativePath long enough to not trigger the SSO.

Since this pitfall is extremely easy to fall into, follow up changes will
attempt to reduce the likelyhood of falling into them.

Reviewed By: genevievehelsel

Differential Revision: D37422971

fbshipit-source-id: 610bcf955d53498710b79f12754cd2b1344bc001
2022-07-05 19:49:18 -07:00
Xavier Deguillard
04f372352a immediatefuture: add a thenError method
Summary:
Intended as a more lighteight version of thenTry when only an exception needs
to be handled.

Reviewed By: chadaustin

Differential Revision: D37476671

fbshipit-source-id: 6d8e1a24cb8eaccf60bd9715abaebf81c7b367d9
2022-07-05 14:21:25 -07:00
Andrew Milas
d5573cf20b Create an EdenFS CLI to display retroactive Inode materializations
Summary:
This change finishes the implementation for the `eden trace inode --retroactive` subcommand. This subcommand allows users to retroactively see information about past inode events, which will help with retroactively debugging EdenFS when things don't go as expected. Currently only start and finish times for inode materialization events are shown, though we intend to generalize this with other types of inode state transitions (i.e. loading inodes) as well.

This change specifically builds off of D37288805 (13ab48d2ab), and utilizes the thrift endpoint built there for retrieving retroactive inode events in order to properly display them.

Example of command output
{F746522409}

Reviewed By: genevievehelsel

Differential Revision: D37356739

fbshipit-source-id: 7d46a69057329e9fc7f205253b822053fa9505e2
2022-06-24 16:07:22 -07:00
Chad Austin
b12c397618 compilation fixes for gcc
Summary:
GCC provides some useful warnings and errors when compiling EdenFS,
and I noticed our open source build was failing. Fix some of the
issues.

Reviewed By: xavierd

Differential Revision: D37157074

fbshipit-source-id: de5705ec2eac18cd269143739289031ca5d478fc
2022-06-23 15:45:36 -07:00
Xavier Deguillard
72183fc7ef unistd: replace with Folly's portability header
Reviewed By: chadaustin

Differential Revision: D37217336

fbshipit-source-id: 31eb2a86a509b6b4d21e444e3efca769c86c725d
2022-06-17 09:52:56 -07:00
Xavier Deguillard
57e50f8578 sys/socket: replace with Folly's portability header
Reviewed By: genevievehelsel

Differential Revision: D37217338

fbshipit-source-id: 40e68f25e577015ebb87929aca82c2934450dd85
2022-06-17 09:52:56 -07:00
Xavier Deguillard
f179b76b47 openssl: use Folly's portability header instead
Reviewed By: chadaustin

Differential Revision: D37217337

fbshipit-source-id: ad1b6c9018b38d5fc6dd60ffeb4dff73e4bd1f98
2022-06-17 09:52:56 -07:00
Xavier Deguillard
6dd4d77e88 utils: properly detect ENOENT on Windows
Summary:
On Windows, system error may be using the Win32ErrorCategory, and not the
generic system_category or generic_category. Thus we also need to test for that
category as well as the Windows error codes.

Reading a bit on the internet how Win32 error codes are supposed to be handled,
in theory, using the system_category should be the preferred method. However,
this would also mean that printing exceptions would also contain a \r at the
end, which feels suboptimal. Maybe xlog should just be fixed to never try to
print \r characters to avoid this issue?

Reviewed By: genevievehelsel

Differential Revision: D37189378

fbshipit-source-id: 03ca35c38a05bc35c8a184a6069b1ab41b6852c0
2022-06-16 15:57:28 -07:00
Xavier Deguillard
a7f0370727 pathmap: fix case sensitivity insertion ordering
Summary:
When the PathMap is case insensitive, its ordering must be the same as if only
lower cased elements were inserted into it. Unfortunately, due to the use of a
case sensitive std::lower_bound, this property is violated. To fix this, and
simplify the code a bit, the comparator passed to std::lower_bound must be case
insensitive so searching and inserting are looking in the same location.

To achieve this, a new generic and centralized way of comparing path is
introduced. Since A couple of places are interested in comparing paths, and
doing so with cross platform and case insensitively in mind can be tricky.
Let's add this code to the PathFuncs code directly so it's available everywhere
for every paths types.

Reviewed By: chadaustin

Differential Revision: D36119091

fbshipit-source-id: 3f7f6349c00d14bb9cb424d33328024f2962d7c8
2022-05-19 18:57:33 -07:00
Xavier Deguillard
db078643a3 model: use PathMap in Tree
Summary:
One of the unchecked and not documentation assumption of Tree is that they must
be sorted the same way as a TreeInode. Unfortunately, there is no guarantee
that the TreeEntry in a Tree are sorted, and the only place where this
guarantee is upheld... is in the testharness test library.

To solve this, the best way is to use the same underlying datastructure in both
TreeInode and Tree: a PathMap. This is guarantee to be sorted, and it properly
takes into account case sensistivity.

Reviewed By: chadaustin

Differential Revision: D36257252

fbshipit-source-id: 0fadd3c84d8e95631a8293c6797544ea94046a10
2022-05-19 18:57:33 -07:00
Adam Simpkins
8985d9dc80 add FaultInjector::check() methods that dynamically construct the key
Summary:
Add some `FaultInjector` methods to allow passing in multiple arguments to
construct the fault key value.

These APIs make it easy for the caller to dynamically construct the key, but
skip doing key construction entirely when fault injection is disabled.

Reviewed By: xavierd

Differential Revision: D36435174

fbshipit-source-id: 4d37a18610ba95e90b86b49c9342de5e782362ed
2022-05-18 20:12:47 -07:00
Adam Simpkins
195d65c8bb improve the documentation comments for FaultInjector
Summary:
Add a couple more comments documenting the usage of the FaultInjector class.

Also improve the comments for check() and checkAsync().  The previous comments
for check() incorrectly stated that it did not support faults that block or
delay execution.

Reviewed By: genevievehelsel

Differential Revision: D36435175

fbshipit-source-id: eb95f00562cc3c24feb130807e5e5621b16b6595
2022-05-18 20:12:47 -07:00
Adam Simpkins
eef2f6deb5 use F14NodeMap in FaultInjector
Summary:
Update FaultInjector to use F14NodeMap directly rather than the
older StringKeyedUnorderedMap class from folly/experimental.  These days
StringKeyedUnorderedMap is just a wrapper around F14NodeMap, and it is better
to just use F14NodeMap directly.

Reviewed By: genevievehelsel

Differential Revision: D36435176

fbshipit-source-id: 3d9425bf885282f497729b28a5253c27454b86bd
2022-05-17 13:38:33 -07:00
Adam Simpkins
1a3ebe18d0 use std::variant instead of boost:variant in FaultInjector
Summary: Update the FaultInjector code to use the C++17 std::variant class.

Reviewed By: genevievehelsel

Differential Revision: D36435177

fbshipit-source-id: 2cc9087f6bd202339b7d6409ca895c9aa18e191c
2022-05-17 13:38:33 -07:00
Chad Austin
9fa292b9ed standardize namespaces on C++17 syntax
Reviewed By: genevievehelsel

Differential Revision: D36429182

fbshipit-source-id: 7d355917abf463493c37139856810de13e1090ff
2022-05-17 10:12:56 -07:00
Zeyi (Rice) Fan
b8d1edbc75 windows: allow setting creation flags in SpawnedProcess
Summary: Allow setting creation flags on Windows. This is used in the next diff in the stack.

Reviewed By: chadaustin

Differential Revision: D35948068

fbshipit-source-id: 8fce0c86c81ea53c191dffa02d772d8adbfa23e0
2022-05-05 15:43:41 -07:00
Zeyi (Rice) Fan
7f7945d720 windows: teach eden to look for pdb in the binary path
Summary:
On Windows, dbghelp.dll does not look at the executable path for debug symbol files by default. This has caused us to not be able to see stack traces when iterating / debugging EdenFS on Windows.

This diff fixes it by manually adding the binary directory to the search list, and explicitly load it when reporting a crash.

This will also trigger loading from the debug symbol server **if it is configured in the environment variable**.

Reviewed By: xavierd

Differential Revision: D35623865

fbshipit-source-id: 72822bf38af93632fbd3a20757863d6bea4b078a
2022-05-03 13:39:24 -07:00
Zeyi (Rice) Fan
938c92c4b7 utils: support multibyte in SpawnedProcess
Summary: This diff makes SpawnedProcess to be Unicode-compatible.

Reviewed By: xavierd

Differential Revision: D35267985

fbshipit-source-id: 627035bf5170b2f300ede8553dff08b4ab7385a3
2022-04-20 20:02:11 -07:00
Katie Mancini
8f3f873874 fix invalidation on NFS
Summary:
TL;DR: File invalidation after checkout is broken on NFS macOS. This proposes a
fix.

Previously, to invalidate things on NFS we opened and closed all the parent
directories of any files/directories that changed during a checkout operation.

This worked on Linux because all open calls result in some request into the
EdenFS daemon (usually a getattr I think). The returned response from this
would show that the directory had update timestamps. So the open would see the
parent directories in their updated state. This would trigger the NFS client to
clear it's caches for that directory and their recursive children to preserve
CTO. CTO or close-to-open consistency guarantees that if on process observed a
file in state A and closed the file, then another process opened that same file
, it will see the file in state A or a later state.

macOS does not seem to do CTO.

It seems that most of the "read" filesystem calls can basically be served from
cache on NFS. Only writes seem to be guaranteed to make it into eden.

So instead of using a "read" filesystem call to trigger invalidation, we need to
use a write one.

I tried opening things in write mode, but the problem is that we need to
invalidate directories (to ensure the entry information is updated) and
directories can not be opened in write mode.

I tried writing 0 bytes to the files themselves that have changed, but this
empty write is short circuited somewhere in the kernel.

The only filesystem call that can be a noop, and seems to trigger a call into
eden is chmod. We are not really working off any guarantees any more, but
it seems to work on both Linux and macOS in my testing so far and is better
than our current broken state of invalidation.

So now to invalidate we chmod parent directories that have changed with their
current mode. Note that this could get extra tricky if we were mixing updating
directory permissions with invalidating them. We would need to ensure we chmod
with the most up to date mode bits. However, because we do not update
permissions anywhere that we also invalidate (checkout does not know how to
update directory permissions) things are a little simpler.

It's important that the chmod can not complete until it seems an updated view of
the parent directory. So we have to be careful about locking here. (Although
that hasn't really changed since we switched from open to chmod.)

One thing that does change is that since chmod is technically a write, it could
cause extra materialization that would be bad for checkout and status
performance. To prevent these problems I have updated setattr to not materialize
a directory when the attribute change is a noop which it should be in our
invalidation technique unless another client modified the directory in the
meantime in which case the directory should be modified anyways. This would
mean that we could end up wiping out clients changes to permissions in the
working copy during checkout. but this matches non eden checkout behavior. So I
think this is ok.

Reviewed By: xavierd

Differential Revision: D35435764

fbshipit-source-id: 196c4995b130b595f9582204237e726e5212993f
2022-04-19 20:32:54 -07:00
Jeremy Braun
93f731cf79 Limit watchman+eden's fetching of inodes on common hg updates
Summary: Eden's `getEntryInformation` API currently loads Inodes for all paths queried, force-materializing the path component's Inodes. This often isn't required, and eden could be fetching non-loaded data from the object store instead.

Reviewed By: chadaustin

Differential Revision: D35372760

fbshipit-source-id: e31a450a20b09249f03339dcd1aeca2eb363046e
2022-04-19 09:33:32 -07:00
Katie Mancini
3d1eb3a8f9 move process name cache
Summary:
Stack context:
To get a build setup for edencommon I picked an eden library to move over
to edencommon.

I picked process name cache. I would like to have this library in watchman
so that I can log spawning process command lines as well as client command
lines.

This diff:
finally actually moves over process name cache

Reviewed By: chadaustin

Differential Revision: D34218020

fbshipit-source-id: 1e51ec6524d1e67a1dfd4d03a8189f882f5d3ff1
2022-04-04 11:37:38 -07:00
Katie Mancini
2a7ecc039c move benchharness
Summary:
Stack context:
To get a build setup for edencommon I picked an eden library to move over
to edencommon.

I picked process name cache. I would like to have this library in watchman
so that I can log spawning process command lines as well as client command
lines.

This diff:

process name cache has some benchmark tests so I am moving benchharness over.

Reviewed By: chadaustin

Differential Revision: D34218024

fbshipit-source-id: 260730adb7e5d4a3131e72fa2f03cc4c5066c075
2022-04-04 11:37:38 -07:00
Katie Mancini
1891bbddec move StringConv
Summary:
Stack context:
To get a build setup for edencommon I picked an eden library to move over
to edencommon.

I picked process name cache. I would like to have this library in watchman
so that I can log spawning process command lines as well as client command
lines.

This diff:

process name cache depends on StringConv.h so I am moving that over.

Reviewed By: chadaustin

Differential Revision: D34218023

fbshipit-source-id: d928768a6b5f737a1c546c6f3c73acc5535fc44c
2022-04-04 11:37:38 -07:00
Katie Mancini
f9b8b89509 move win error
Summary:
Stack context:
To get a build setup for edencommon I picked an eden library to move over
to edencommon.

I picked process name cache. I would like to have this library in watchman
so that I can log spawning process command lines as well as client command
lines.

This Diff:

process name cache depends on WinError.h so I am moving that over.

Reviewed By: chadaustin

Differential Revision: D34218026

fbshipit-source-id: 064f5bfc50c4ba120c887b01ff1f0a3e0543d498
2022-04-04 11:37:38 -07:00
Katie Mancini
d69e8c766a move handle
Summary:
To get a build setup for edencommon I picked an eden library to move over
to edencommon.

I picked process name cache. I would like to have this library in watchman
so that I can log spawning process command lines as well as client command
lines.

Diff:

process name cache depends on Handle.h so I am moving that over.

Reviewed By: chadaustin

Differential Revision: D34218022

fbshipit-source-id: 05c42eb0fa8be78fd001249c0c09ed7fa515ea44
2022-04-04 11:37:38 -07:00
Katie Mancini
1f44f4a882 move Synchronized
Summary:
Stack context:

To get a build setup for edencommon I picked an eden library to move over
to edencommon.

I picked process name cache. I would like to have this library in watchman
so that I can log spawning process command lines as well as client command
lines.

Diff:

process name cache depends on Synchronized so I am moving that over in this diff.

Reviewed By: chadaustin

Differential Revision: D34218021

fbshipit-source-id: 528e7b4b12476b33a294a342e6e4ee13c92c7361
2022-04-04 11:37:38 -07:00
Xavier Deguillard
83e08ada44 utils: add a getAllDirectoryEntryNames function
Summary:
This opens the directory and reads all the names from it, excluding "." and
"..". On Windows, this function is written in such a way that it allows
concurrent deletion/renaming of the directory while this is running.

Reviewed By: chadaustin

Differential Revision: D35067144

fbshipit-source-id: 20fb8f9ac8a49970cb360eb3307e86d846760e98
2022-03-23 13:59:52 -07:00
Xavier Deguillard
fe7cc8b0a9 pathfuncs: remove boost::filesystem exported dependency
Summary:
The PathFuncs.h header is included pretty much everywhere in EdenFS, and thus
its compile speed affects the entirety of EdenFS. Unfortunately, the
boost::filesystem dependency is pretty large and is thus slowing down the
compilation.

Since the few methods that rely on Boost are only used in one place, let's
instead inline the use of Boost in these places.

Reviewed By: chadaustin, fanzeyi

Differential Revision: D35058316

fbshipit-source-id: b80a39f1575acc0fa4b9e64eb5375b95b4b421da
2022-03-22 15:48:40 -07:00
Xavier Deguillard
791417c61a prjfs: remove the dependency on RCU
Summary:
Our use of RCU is fundamentally incompatible with N4895 since it allows a read
section to be entered in one thread and closed in another one. We use this
feature in Prjfs to prevent a mount to be unmounted while requests are ongoing
on it.

Let's instead make use of a folly::AtomicReadMostlyMainPtr which is equivalent
to a folly::Synchronized<std::shared_ptr<>> without requiring as many atomics
in the read path.

Reviewed By: Decave

Differential Revision: D34982722

fbshipit-source-id: 299f25fc8c8aa72fb89cc9fc880860780ea0517d
2022-03-22 10:08:32 -07:00
David Vernet
2588b7a46d folly: Change rcu_default_domain to return a reference to an rcu_domain
Summary:
Section 5.3.5 in the new C++ Concurrency Technical Specification 2
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/n4895.pdf) specifies
the following function:

rcu_domain& rcu_default_domain() noexcept;

The folly RCU header file currently exposes a very similar rcu_default_domain()
function that returns a pointer to an rcu_domain rather than a reference. This
change updates the folly RCU implementation to instead return a reference, and
updates the few callers in fbcode that were invoking it to instead expect a
reference.

Note that in doing so, we also update rcu_barrier(), rcu_retire(), and
rcu_obj_base::retire() to adhere to the new standard.

Reviewed By: yfeldblum

Differential Revision: D34622786

fbshipit-source-id: 4460ce563f9e9ef4d65cdd517707297c23091c80
2022-03-10 11:16:04 -08:00
Xavier Deguillard
a29d465ee8 fs: fix license header
Summary:
With Facebook having been renamed Meta Platforms, we need to change the license
headers.

Reviewed By: fanzeyi

Differential Revision: D33407812

fbshipit-source-id: b11bfbbf13a48873f0cea75f212cc7b07a68fb2e
2022-01-04 15:00:07 -08:00
Thomas Orozco
8aa7b1cc88 eden: declare dependency on test data in ProcUtilTest
Summary:
Like it says in the title. In Buck2 this doesn't quite work as `__FILE__` is
relative to fbsource but now tests are relative to fbcode.

This might be something we have to fix in some way, but until then let's just
fix the test.

Reviewed By: xavierd

Differential Revision: D33092380

fbshipit-source-id: f54fabe795f909111cc7f2269359a4117232e630
2021-12-14 09:14:29 -08:00
Chad Austin
1781a4b704 display actual size when static_assert sizeof fails
Summary:
static_assert sizeof doesn't show the actual size in clang or gcc, so
implement a CheckSize template.

Reviewed By: xavierd

Differential Revision: D32998926

fbshipit-source-id: 432fbf19eae5b4572e5a4908f9007b7242a3ae69
2021-12-09 14:52:53 -08:00
Xavier Deguillard
ddf046b995 utils: add tryToHResult
Summary: This will be used in a subsequent diff.

Reviewed By: chadaustin

Differential Revision: D32837579

fbshipit-source-id: 9a32be6a9c912faaf43064c98f61c9fbec17c7ba
2021-12-06 20:44:03 -08:00
Katie Mancini
43fc599083 teach Takeover Server/Client how to pass NFS info
Summary:
Now that we have NFS mounts we need to support takeover for those mounts.
This commit teaches the takeover server and client to serialize and deserialize
NFS information.

NFS information includes:
- the mountd socket. Mountd is used to register mount points, and should keep
the same socket across graceful restarts.
- a connected socket for each of the NFS mount points.
- All the rest of the mount point information that we send for fuse mounts (with
the exception of the fuse negotiated parameters.

Future commits will teach the NFS components to graceful stop and yield this info
as well as restart with this info.

Reviewed By: xavierd

Differential Revision: D31802787

fbshipit-source-id: 667625589b77eed79f7e17390013a818d4be7068
2021-11-17 17:13:11 -08:00
Michael Cuevas
826c926a47 Implement getBlobMetadata
Summary: adds FileInode::getBlobMetadata() method. Instead of fetching sha1 and filesize separately, we can use this method to get them both at the same time

Reviewed By: xavierd

Differential Revision: D32399852

fbshipit-source-id: 6b4e271136492a7fa836a49c3794347a5ebab9ef
2021-11-17 11:31:26 -08:00
Jim Meyering
71ebf27844 eden/fs/utils/test/Utf8Test.cpp: fix platform010-exposed build errors
Summary:
We should all be migrating to platform010, for the improved performance of its
generated code and for its improved diagnostics/portability.

reinterpret_cast another u8"..." literal to const char*

This avoids the following errors:
```
stderr: In file included from eden/fs/utils/test/Utf8Test.cpp:9:
In file included from folly/portability/GTest.h:32:
third-party-buck/platform010/build/googletest/include/gtest/gtest.h:1545:11: error: invalid operands to binary expression ('char8_t const[4]' and 'const std::basic_string<char>')
  if (lhs == rhs) {
      ~~~ ^  ~~~
third-party-buck/platform010/build/googletest/include/gtest/gtest.h:1572:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<char8_t [4], std::basic_string<char>>' requested here
    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
           ^
eden/fs/utils/test/Utf8Test.cpp:43:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<char8_t [4], std::basic_string<char>, nullptr>' requested here
  EXPECT_EQ(u8"\uFFFD", ensureValidUtf8("\xff"));
```

Differential Revision: D32484896

fbshipit-source-id: b271292eb121e0e183bec56ab51fc6acb791b052
2021-11-16 21:10:13 -08:00
Andrii Grynenko
1d19898163 Remove MicroLock::init()
Summary: Have constructor do init() instead. I can't think of any valid reason to have this API other than confusing everyone who decides to use it.

Reviewed By: praihan

Differential Revision: D32302228

fbshipit-source-id: 136e0d2919291acd60be953337309cd006bd674b
2021-11-15 14:20:38 -08:00
Xavier Deguillard
438d4a1a4c immediatefuture: add makeImmediateFuture that takes an exception_wrapper
Summary:
When unwrapping Try it is convenient to be able to build an ImmediateFuture
directly from the .exception() call.

Reviewed By: chadaustin

Differential Revision: D32333774

fbshipit-source-id: 0066ca7eddc4a57010f60974c234b57691b73d77
2021-11-15 13:52:59 -08:00
Xavier Deguillard
dda17f055f immediatefuture: fully qualify collectAll calls
Summary:
For some reason, in some cases the compiler wants to use the folly::collectAll
function instead of the ImmediateFuture one. Adding the namespace solves this
issue.

Reviewed By: chadaustin

Differential Revision: D32329807

fbshipit-source-id: 22ee9b20cf33e5718c9bb0270dd93f3f857b0967
2021-11-15 13:52:59 -08:00
Xavier Deguillard
03731ee50d utils: add a collectAllSafe for vectors
Summary:
We already had a collectAllSafe for argument packs, let's have a similar
function when the argument is a vector.

Reviewed By: chadaustin

Differential Revision: D32323573

fbshipit-source-id: 2cfa3da565a7d9bb88746e3cc6b10d1d8890c05e
2021-11-10 13:39:49 -08:00
Jim Meyering
fc23fbd7ee eden/fs/utils/test/ImmediateFutureTest.cpp: fix platform010-exposed build errors
Summary:
We should all be migrating to platform010, for the improved performance of its
generated code and for its improved diagnostics/portability.

add an explicit constructor, now required for C++20, see https://en.cppreference.com/w/cpp/language/default_constructor

This avoids the following errors:

  eden/fs/utils/test/ImmediateFutureTest.cpp:335:17: error: no matching constructor for initialization of 'Uncopyable'

# Context:
The cost of delaying a platform upgrade is now estimated at about $3M/week.
For the preceding one, it was measured at [**$1M/week**](https://fburl.com/jfmpsqmy).

Differential Revision: D32250064

fbshipit-source-id: 8c6990489cafb09629c03e56bdbae92395d6f85f
2021-11-08 10:38:37 -08:00
Chad Austin
225a341914 C++20 fixes
Summary:
C++20 changed the rules around char8_t. Cast to char* as
necessary. Also, fix references to some removed std::allocator
associated types.

Reviewed By: fanzeyi, meyering

Differential Revision: D32155762

fbshipit-source-id: dc72e5bc58e8c08612ea1a1eb2568861701287c6
2021-11-03 17:55:42 -07:00
Katie Mancini
3f9520cbcd make "FuseType" generic
Summary:
Takeover data needs to include fuse data for fuse
mounts and NFS data for NFS mounts.

Fuse related data is already wrapped up in
FuseChannelData. we are making an NfsChannelData to
mirror this for NFS. These structs will be used in
TakeoverData in a later commit.

Reviewed By: xavierd

Differential Revision: D31740475

fbshipit-source-id: f64367a5881175b9e20d261e43ec7570c498f380
2021-11-01 11:47:42 -07:00
Xavier Deguillard
224e11801f immediatefuture: help compiler with exhaustive switch cases
Summary:
Some compiler (msvc, old gcc) can't seem to figure out that these switch cases
are exhaustive and thus warn about them. Let's help it to silence the warnings.

Reviewed By: chadaustin

Differential Revision: D32022198

fbshipit-source-id: 67f89d52211db45a09e8a2fc0ed64da667b8cbbc
2021-10-29 13:06:20 -07:00
Chad Austin
91502de90c break privhelper dependency on OpenSSL
Summary:
To avoid any risk of SSLKEYLOGFILE being used to unexpectedly write
files as root, ensure the privhelper does not even link against
OpenSSL.

Reviewed By: fanzeyi

Differential Revision: D31944839

fbshipit-source-id: 3280657a10f4a468ddb63a874d38198bd333e01c
2021-10-27 16:04:36 -07:00
Xavier Deguillard
a954c9a113 immediatefuture: tag the semi() method with FOLLY_NODISCARD
Summary:
Ignoring the return value of this method is equivalent to dropping the future
entirely, which isn't what is usually desired. Let's make sure the compiler
helps us in finding these cases as code is converted.

Reviewed By: chadaustin

Differential Revision: D31945362

fbshipit-source-id: dd646365e00d3ebb04ed9b6803c561fc11ff4a14
2021-10-27 13:38:30 -07:00
Xavier Deguillard
b7108967f4 immediatefuture: add a collectAllSafe
Summary:
This mimics the one eden/fs/utils/Future.h behavior where all the Try are
unwrapped to simply return a tuple.

Reviewed By: kmancini

Differential Revision: D31668773

fbshipit-source-id: f4b9b6b2564cc1e2c43aa5b03bfb06048f0a39c1
2021-10-25 14:32:06 -07:00
Xavier Deguillard
72e7764a1c immediatefuture: add collectAll that takes a parameter pack
Summary:
In some places, EdenFS uses folly::collectAll passing futures to it. In order
to replace it, we need an equivalent for ImmediateFuture.

The implementation relies on the fact that ImmediateFuture's constructor will
extract the value from a SemiFuture if it is ready, and thus the code doesn't
have to special case when all the passed in ImmediateFuture are immediate
values.

Reviewed By: chadaustin

Differential Revision: D31667897

fbshipit-source-id: ea680e1c74528d1eb34210cacb58efda8a26fee0
2021-10-25 14:32:06 -07:00
Xavier Deguillard
11714d7367 immediatefuture: add a makeImmediateFuture function from an exception
Summary:
This will cut some of the boiler plate of returning an ImmediateFuture in the
error case.

Reviewed By: chadaustin

Differential Revision: D31769752

fbshipit-source-id: 42be026aee6a6071bbb2c1f8af918b107d593eab
2021-10-19 14:18:12 -07:00
Xavier Deguillard
a49e86d091 utils: speedup ImmediateFuture::thenValue exception case by 78x
Summary:
Exception cases should be rare, but EdenFS has a couple of spots where
exceptions are somewhat expected. One of which being a lookup failure due to a
non-existing file. Due to the overhead of these lookup failures, EdenFS is
actually spending as much time resolving these, than resolving successful
lookups.

The reason for the high overhead is due to the ImmediateFuture::thenValue just
relying on an exception being thrown when accessing the stored Try value. We
can do better than this by testing the Try before hand, and bailing out in that
case.

Reviewed By: fanzeyi

Differential Revision: D31655223

fbshipit-source-id: 29da7ef38a19f09c91c931e7e8e080e5ed6af269
2021-10-15 17:50:18 -07:00
Xavier Deguillard
c0d8596fdd immediatefuture: add a collectAll function
Summary:
When dealing with a large amount of futures, one of the common pattern is to
store all the pending one into a vector and collect them all at once. Let's add
a similar function for ImmediateFuture to allow converting code that make use
of this pattern.

Reviewed By: chadaustin

Differential Revision: D31452296

fbshipit-source-id: 04aee8f358727e02b4202d09d78fafc0917b8dec
2021-10-14 18:58:43 -07:00
Chad Austin
48c1e390f6 clarify ImmediateFuture's callback rules and introduce isReady
Summary:
In a meeting today, the question arose "when should one use Future,
SemiFuture, or ImmediateFuture?" To help clarify the situation,
reframe some of ImmediateFuture's doc comments in terms of their
semantics.

Simultaneously, replace hasImmediate with isReady, which returns true
when a value can be retrieved without blocking.

Also, allow converting a completed SemiFuture into an ImmediateFuture
which is also isReady.

Reviewed By: xavierd

Differential Revision: D31563622

fbshipit-source-id: b942031c15d46948b1f60ade9f8043fa19442b65
2021-10-13 21:05:49 -07:00
Andrey Chursin
ae684f3993 explicit Hash20 instead of Hash [proxy hash removal 2/n]
Summary:
This is fairly mechanical diff that finalizes split of Hash into ObjectId and Hash20.

More specifically this diff does two things:
* Replaces `Hash` with `Hash20`
* Removes alias `using Hash = Hash20`

Reviewed By: chadaustin

Differential Revision: D31324202

fbshipit-source-id: 780b6d2a422ddf6d0f3cfc91e3e70ad10ebaa8b4
2021-10-01 12:43:26 -07:00
Xavier Deguillard
8c26a8ffe5 immediatefuture: speed up by 40%
Summary:
While std::variant is convenient, they are both slow to compile, and the
compiler cannot optimize it as well as a manually written tagged union. Since
ImmediateFuture is performance critical for EdenFS, let's use a tagged union
and speed them up by an additional 40%.

Reviewed By: chadaustin

Differential Revision: D31272296

fbshipit-source-id: e34be4489a596d3577b3bd900a1f20d6c7d8b693
2021-10-01 10:43:05 -07:00
Xavier Deguillard
5b5157ab51 immediatefuture: split get with and without timeout
Summary:
The max duration would cause UBSAN failures due to folly's SemiFuture code
multiplying the value which understandably cannot be represented. Splitting the
function is easy and avoids the problem entirely.

Reviewed By: genevievehelsel

Differential Revision: D31272297

fbshipit-source-id: c15ca70ad771c11b4f68bb9974422c0986d4928b
2021-10-01 10:43:05 -07:00
Chad Austin
49e49f9fc2 replace most folly:format uses
Summary:
folly:format is deprecated in lieu of fmt and std::format. Migrate
most of EdenFS to fmt instead.

Differential Revision: D31025948

fbshipit-source-id: 82ed674d5e255ac129995b56bc8b9731a5fbf82e
2021-09-20 16:23:22 -07:00
Xavier Deguillard
de4be2df48 utils: mark SpawnedProcess as being waited when waitpid fails
Summary: This is a similar diff to D30915090, but for EdenFS.

Differential Revision: D30915126

fbshipit-source-id: 9a718e47237924ebe20176c522a1b1193224236c
2021-09-13 20:00:45 -07:00
Xavier Deguillard
09f97fa27a store: diff should respect the mount case sensitivity
Summary:
During a diff operation, files that have a case change should not reported as
changed for case insensitive mount. This is a follow up to D29150552 (37ccaa9231) where the
TreeInode code was taught to ignore case changes for case insensitive mounts.

Reviewed By: kmancini

Differential Revision: D29952464

fbshipit-source-id: e5fa8eccc1c1984a680838fd8589a0278989d9d0
2021-07-29 11:29:42 -07:00
Zhengchao Liu
8f58e523cd synchronize getClient in scs metadata importer
Reviewed By: kmancini

Differential Revision: D29794557

fbshipit-source-id: e8e09c9aea994fad649af5119f3d8e42e12f5417
2021-07-29 09:56:24 -07:00
Xavier Deguillard
628ba1b62d utils: fix race in SpawnedProcess::threadedCommunicate
Summary:
TSAN complains that pipes_ is read and written in different threads without
proper synchronization. To avoid this, we can simply close the FileDescriptor
without removing it from the pipes map as this achieve the same result: it
notifies the reader that the endpoint is closed.

Differential Revision: D29924043

fbshipit-source-id: be92630799bb5c78089dbe85f9c2f02f937300bc
2021-07-27 07:32:42 -07:00
Zhengchao Liu
321cb87688 cli support for ActivityRecorder
Summary:
This adds debug commands for ActivityRecorder:
```
eden debug start_recording --output-dir <DIR>
  * stdout: the id of the profile
eden debug stop_recording --unique <ID>
  * stdout: the output file path
```
Users can record multiple profiles concurrently. Each profile is identified by the timestamp when it started.

Reviewed By: genevievehelsel

Differential Revision: D29666359

fbshipit-source-id: 487ca67de77378a8141bc4ac46b9abd1375ffd23
2021-07-23 12:32:25 -07:00
Zhengchao Liu
067abe2d55 collect memory and disk fetch counts
Summary: This adds counters for memory and disk counts in addition to import count so that we can understand cache hit rates during local investigation or output this in ActivityRecorder.

Reviewed By: genevievehelsel

Differential Revision: D29805637

fbshipit-source-id: 34261f91c33d6bd4bcb4b85b17d2e68360410896
2021-07-21 21:37:20 -07:00
Prabhash Rathore
889ceef7b9 Remove direct uses of gmock.h
Summary: Remove direct uses of gmock.h

Reviewed By: chadaustin

Differential Revision: D29532548

fbshipit-source-id: c4262eb2bba7461c4f4b6dc9114dae4bcb4c5f82
2021-07-07 13:32:31 -07:00
Genevieve Helsel
9b4909d022 create util EdenTaskQueue from NfsTaskQueue
Summary: NfsTaskQueue can be made more generic to be shared across the codebase, so this makes it its own target in `eden/fs/utils` w/ the name EdenTaskQueue.

Reviewed By: xavierd

Differential Revision: D29244762

fbshipit-source-id: 78348f2ff8fa66bc801aefe7d6b3905e0da278e8
2021-06-29 09:45:46 -07:00
Zhengchao Liu
1f9541251f utils: add ImmediateFuture::ensure
Summary:
We are adding tracing to nfs. To record the elapsed time of a call, we need to invoke a callback when future is ready (has value or exception). For fuse, this is done with `Future::ensure`. Nfs is using `ImmediateFuture`, so I am adding `ImmediateFuture::ensure` accordingly.

https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/fbcode/eden/fs/fuse/FuseChannel.cpp?commit=64091acc4e2905bfb58b4795e705fa6b554c487c&lines=1733-1735

Reviewed By: chadaustin

Differential Revision: D29278838

fbshipit-source-id: 176d6361a0ef1dd4a89db470acbb36b4868e04ef
2021-06-23 14:23:40 -07:00
Xavier Deguillard
cc5951d322 service: key mount map with an AbsolutePath
Summary:
Using a PathMap to hold the list of mounts gives us case sensitivity for free
without needing to have #ifdef _WIN32, we can also avoid copying the paths just
to normalize them.

Reviewed By: fanzeyi

Differential Revision: D28969795

fbshipit-source-id: 859cdc3881e36db120913099ce3f451940fa48a4
2021-06-09 21:34:27 -07:00
Yipu Miao
f2bb80c128 Not use gtest for UserInfo.h on Windows
Summary: There are some unused warning on Windows, should be an easy fix.

Reviewed By: fanzeyi

Differential Revision: D28663227

fbshipit-source-id: cee18ec28283c0aef18151465a3c13e9be604d7d
2021-05-25 23:55:08 -07:00
Yipu Miao
405c6996cd Fix warning on FileDescriptor.cpp
Summary: FileDescriptor.cp throws some warning on comparison of signed long and unsigned long.  So fix these warning and follow how ```folly/portability/SysUio.cpp:doVecOperation``` did

Reviewed By: fanzeyi

Differential Revision: D28608581

fbshipit-source-id: 3b6e35e9764548ce470634f16a1f6eec5118d7ed
2021-05-25 19:45:22 -07:00
Xavier Deguillard
5a84f7ac85 utils: add an makeImmediateFutureWith function
Summary: This will be used to replace calls to folly::makeFutureWith.

Reviewed By: chadaustin

Differential Revision: D28515786

fbshipit-source-id: 2c2c542392e8e57b8f865173d6878cb9d00ba376
2021-05-25 09:45:47 -07:00
Xavier Deguillard
de7a364e78 utils: really skip path sanity checking when asked
Summary:
When the caller asks to not perform sanity checking, this should be honored as
the caller can for instance tell that a path is guaranteed to be valid and
shouldn't be checked.

When running the newly added glob benchmark, EdenFS was spending 7.5% of the
time validating a path that was constructed via the operator+.

Reviewed By: fanzeyi

Differential Revision: D28612665

fbshipit-source-id: 282155d0415ab6458bd9307c89a24e9e090bf09d
2021-05-21 19:26:46 -07:00
Xavier Deguillard
de6ca0c970 utils: handle void lambda in ImmediateFuture
Summary:
Lambda returning no values would cause the compiler to try to instantiate an
ImmediateFuture<void>, which doesn't compile. We could try special casing the
void type, but it's easier if we simply consider these lambda to return unit.

Reviewed By: genevievehelsel

Differential Revision: D28372253

fbshipit-source-id: 1368ae5dc5e2d4d6a5c3e31bc87ed7d230027c3a
2021-05-17 14:07:29 -07:00
Xavier Deguillard
3863a8972a utils: add a timeout to ImmediateFuture::{get,getTry}
Summary:
This is to mimic the folly::Future API which allows the `get` and `getTry` to
throw if the Future isn't ready. One difference is that the ImmediateFuture API
has a default argument of a max duration instead of having a separate method.
Since chrono durations are expressed as intmax_t (64-bits on systems supported
by EdenFS) a max duration is virtually infinite.

Reviewed By: chadaustin

Differential Revision: D28424053

fbshipit-source-id: 319493174f31367184dbe0aa811a97145b0310cf
2021-05-17 14:07:28 -07:00
Xavier Deguillard
288a56327b utils: EDEN_BUG_FUTURE returns a Try<T>
Summary:
This allows the macro to be used for both folly::Future, but also with
ImmediateFuture, reducing the cost of migrating to the latter.

Reviewed By: chadaustin

Differential Revision: D28302478

fbshipit-source-id: d8470428ecaa6aaccf2aa884437ca97d4b45806f
2021-05-13 16:51:34 -07:00
Xavier Deguillard
189934f9ac utils: allow mutable lambda to be passed to ImmediateFuture::thenValue
Summary:
Since lambda are default capturing by const, Func was also captured that way,
which made it impossible to call if Func was actually a mutable lambda.

Reviewed By: chadaustin

Differential Revision: D28297423

fbshipit-source-id: b9c6bdcf024c2e219ec0f8f5be2379e51df24db0
2021-05-13 16:51:34 -07:00
Xavier Deguillard
5ee950f5e0 utils: also call func when an ImmediateFuture holds an exception
Summary:
This code initially was for thenValue, but when I converted it for thenTry I
forgot to also remove the hasException case. We were never calling the callback
on a Try that had an exception.

Reviewed By: chadaustin

Differential Revision: D28302477

fbshipit-source-id: 755fb2c8928627fbe1883f3863cafc360e34a038
2021-05-13 16:51:34 -07:00
Xavier Deguillard
7d48df9938 utils: coerce a SemiFuture<ImmediateFuture<T>> to a SemiFuture<T>
Summary:
When the passed in callback returns an ImmediateFuture, the code had a small
typing bug where we would try to return an ImmediateFuture<ImmediateFuture<T>>
while the function signature expected an ImmediateFuture<T>. This is due to the
SemiFuture code not coalescing a SemiFuture<ImmediatureFuture<T>> into a
SemiFuture<T>.

Reviewed By: chadaustin

Differential Revision: D28293942

fbshipit-source-id: 1bc8f58d387766f29e573499fb37402ff9b49c83
2021-05-13 16:51:34 -07:00
Katie Mancini
85942cfaad use portable version of gtest
Summary:
gtest includes some windows headers that will have conflicts with the
folly portability versions. This caused some issues in my in-memory tree
cache diffs (D27050310 (8a1a529fcc)).

We should probably generally be using the folly portable gtests so we can
avoid such issues in the future.

see here for more details: bd600cd4e8/folly/portability/GTest.h (L19)

I ran this with codemod yes to all

- convert all the includes with quotes:
`codemod -d eden/fs --extensions cpp,h '\#include\ "gtest/gtest\.h"' '#include <folly/portability/GTest.h>'`

- convert all the includes with brackets
`codemod -d eden/fs --extensions cpp,h '\#include\ <gtest/gtest\.h>' '#include <folly/portability/GTest.h>'`

- convert the test template
`codemod -d eden/facebook --extensions template '\#include\ <gtest/gtest\.h>' '#include <folly/portability/GTest.h>'`

then used `arc lint` to clean up all the targets files

Reviewed By: genevievehelsel, xavierd

Differential Revision: D28035146

fbshipit-source-id: c3b88df5d4e7cdf4d1e51d9689987ce039f47fde
2021-05-12 15:58:27 -07:00
Xavier Deguillard
f2e7099799 nfs: allow mountd and nfsd to bind to a unix socket on macOS
Summary:
Due to NFS being designed as a network filesystem, it default to binding on a
TCP socket. For EdenFS, since we're not expecting to mount an actual remote
filesystem, we bind these sockets to localhost. Unfortunately, TCP sockets have
some inherent overhead due to being designed to be reliable over a non-reliable
medium.

On macOS, Apple provides a way to mount an NFS server that is listening on a
unix domain socket. Thanks for unix socket being reliable, the TCP overhead
goes away leading to some higher throughput and lower latency for the NFS
server. For EdenFS, timing `rg foobar` over a directory containing 27k files gives:

NFS over TCP:
rg foobar > /dev/null  0.80s user 5.44s system 567% cpu 1.100 total

NFS over UDS:
rg foobar > /dev/null  0.77s user 5.27s system 679% cpu 0.888 total

osxfuse:
rg foobar > /dev/null  0.87s user 5.59s system 662% cpu 0.975 total

The main drawback of going through a unix socket is that D27717945 (bcf6aa465c) appears to
no longer be effective due to
8f02f2a044/bsd/nfs/nfs_vfsops.c (L3739)

Reviewed By: kmancini

Differential Revision: D28261422

fbshipit-source-id: 25dc1dc78cdb50d6c6550a86ef01ea2c894c110f
2021-05-12 13:06:57 -07:00
Xavier Deguillard
935791590a utils: add a semi() method to ImmediateFuture
Summary:
While ImmediateFuture are expected to be used on values that are mostly
immediate, there are cases where it won't be. In these cases we need a way to
wait for the computation/IO to complete. In order to achieve this, we need to
transform an ImmediateFuture onto a SemiFuture.

Reviewed By: fanzeyi

Differential Revision: D28293941

fbshipit-source-id: 227c0acf1e22e4f23a948ca03f2c92ccc160c862
2021-05-11 08:05:11 -07:00
Xavier Deguillard
be1aeaf5be utils: add default constructor to ImmediateFuture
Summary:
When a T can be default constructed, make an ImmediateFuture default
constructible.

Reviewed By: fanzeyi

Differential Revision: D28292874

fbshipit-source-id: 4c239cc9c3f448652b2bcdc103ea1a81ace46402
2021-05-11 08:05:11 -07:00
Xavier Deguillard
f331a0c3f9 utils: add noexcept qualifier to ImmediateFuture
Summary: This should help the compiler generate even better code.

Reviewed By: chadaustin

Differential Revision: D28153979

fbshipit-source-id: b1d84c92af4fa760c92624c53d7f57330d7706fa
2021-05-11 08:05:11 -07:00
Xavier Deguillard
b7ab05edc5 utils: add an ImmediateFuture type
Summary:
In very hot code path, EdenFS is spending a very large amount of time creating
and destroying folly::Future objects. This is due to the required memory
allocation, as well as the handful of atomics that are happening at creation
time, and these are showing up in EdenFS profiles.

In the steady state, EdenFS actually doesn't need futures, as it often times is
able to service requests from its in-memory caches, in which case we should
ideally just return the value itself and not wrap it in a folly::Future. The
added ImmediateFuture is a step in this direction, as it can hold either an
immediate value, or a folly::SemiFuture, and allow the same API to be used
transparently between these 2.

Reviewed By: genevievehelsel

Differential Revision: D28006802

fbshipit-source-id: 89eaa32e7fa82c44844c4b23c4cb30dbeea46ca8
2021-05-06 10:54:03 -07:00
Zeyi (Rice) Fan
e94d69dcd5 utils: define symlink type for Windows
Summary:
This diff defines symlink type in `DirType`.

Even though it is not directly used in the FSCK diff. This will allow us to support symlink in EdenFS Windows in the future.

Reviewed By: genevievehelsel

Differential Revision: D28016305

fbshipit-source-id: 67c1aa22e39198f9c91845129695f27b8303a5f1
2021-04-29 13:17:54 -07:00
Zeyi (Rice) Fan
a87cfb9aa3 utils: expand AbsolutePathBase to provide some filesystem related methods via Boost
Summary:
These methods will be used in my later Windows fsck diff as it will need to scan disk state to find changes.

It is a bit unfortunate that we'll need to stick with boost for now. However this should be a fairly easy migration to `std::filesystem` once that is available.

Reviewed By: kmancini

Differential Revision: D27872828

fbshipit-source-id: f6b27a171026aeaaea3db9f17b8f43cfa25004e4
2021-04-23 15:22:09 -07:00
Zeyi (Rice) Fan
287a9ff724 utils: add stack trace for Windows
Summary:
Copy from Watchman.

This allows us to show stack trace when EdenFS terminates on Windows.

Reviewed By: chadaustin

Differential Revision: D27896966

fbshipit-source-id: f3238a37a1176f879d5e6bc051ec97031c9a7096
2021-04-23 13:20:46 -07:00
Genevieve Helsel
f6e1705b7e use getGlobalIOExecutor instead of getIOExecutor
Summary:
We started getting the message
```stderr: eden/fs/utils/SpawnedProcess.cpp:798:21: error: 'getIOExecutor' is deprecated: getIOExecutor is deprecated. To use the global mutable executor use getUnsafeMutableGlobalIOExecutor. For a better solution use getGlobalIOExecutor. [-Werror,-Wdeprecated-declarations]
```
I don't see why we would need a mutable executor here so I chose `getGlobalIOExecutor` over `getUnsafeMutableGlobalIOExecutor`.

Reviewed By: kmancini

Differential Revision: D27912276

fbshipit-source-id: 95b1053f72c2b4eb2746e3c40c0cf76b69d90d6e
2021-04-21 22:13:53 -07:00
Zeyi (Rice) Fan
a3d912f2cd utils: introduce CaseSensitivity
Summary: `CaseSensitivity::Sensitive` is better than a mere `true` out of nowhere.

Reviewed By: kmancini

Differential Revision: D27867180

fbshipit-source-id: 39d21d3cc3b70c78c6984c3ddbd65b53520770be
2021-04-20 13:08:27 -07:00
Zeyi (Rice) Fan
5407ab67bd make msvc happy
Summary: Apparently MSVC isn't able to accept `std::array<char, N>::end()` as `const char*`. This fixes that.

Reviewed By: xavierd

Differential Revision: D27744719

fbshipit-source-id: 61c30f987612db4274c210aea67163505a8878bf
2021-04-13 14:34:41 -07:00
Yedidya Feldblum
d5de1b81dd migrate from uint64ToBufferUnsafe
Summary: Migrate the codebase away from the ad-hoc `folly::uint64ToBufferUnsafe` and to `folly::to_ascii_decimal` which is intended for these cases.

Reviewed By: WillerZ

Differential Revision: D27281875

fbshipit-source-id: 0c98749e4aed9c873853eed2221cf54a89279ff4
2021-04-09 21:34:38 -07:00
Anna Kukliansky
b8be7b6b29 fix compilation error of missing type
Summary:
example failure:https://www.internalfb.com/intern/buck/build/89566c50-0f40-4940-bee8-c58e4597db69/

{F508857478}

Reviewed By: mzlee

Differential Revision: D27037961

fbshipit-source-id: dd77219870f368586567b4acf2247cde2855042e
2021-03-15 22:31:25 -07:00
Chad Austin
7a3ac07f7f move EdenError to utils/
Summary:
I want to use EdenError from some code outside of service/, so move
EdenError into utils.

Reviewed By: genevievehelsel

Differential Revision: D25447438

fbshipit-source-id: 2d1ddfa379238369679e84708518a9ba106f76b9
2021-02-23 19:58:03 -08:00
Xavier Deguillard
8853701e91 path: forbid building non-utf8 paths
Summary:
The world has moved on utf-8 as the default encoding for files and data, but
EdenFS still accepts non utf-8 filenames to be written to it. In fact, most of
the time when a non utf-8 file is written to the working copy, and even though
EdenFS handles it properly, Mercurial ends up freaking out and crash. In all of
these cases, non-utf8 files were not intentional, and thus refusing to create
them wouldn't be a loss of functionality.

Note that this diff makes the asumption that Mercurial's manifest only accept
utf8 path, and thus we only have to protect against files being created in the
working copy that aren't utf8.

The unfortunate part of this diff is that it makes importing trees a bit more
expensive as testing that a path is utf8 valid is not free.

Reviewed By: chadaustin

Differential Revision: D25442975

fbshipit-source-id: 89341a004272736a61639751da43c2e9c673d5b3
2021-02-23 11:35:12 -08:00
Shai Szulanski
dba656e44d Rename Try::throwIfFailed -> throwUnlessValue
Summary: Update name to match usage of Try as tri-state, since this method also throws if the Try is empty

Reviewed By: yfeldblum

Differential Revision: D25737810

fbshipit-source-id: a4166153362f07353d212216fbaf7105867eef2a
2021-01-11 13:05:17 -08:00
Andres Suarez
21c95391ca Apply clang-format update fixes
Reviewed By: igorsugak

Differential Revision: D25861960

fbshipit-source-id: e3c39c080429058a58cdc66d45350e5d1420f98c
2021-01-10 10:06:29 -08:00
Xavier Deguillard
978cd4549c hg: ignore invalid filename when importing manifest
Summary:
Mercurial support files with `\` in their name, which can't be represented on
Windows due to `\` being the path separator. Currently, EdenFS will throw
errors at the user when such file are encountered, let's simply warn, and
continue.

Reviewed By: chadaustin

Differential Revision: D25430523

fbshipit-source-id: 4167b4cd81380226aead8e4f4850a7738087fd95
2021-01-05 14:08:14 -08:00