Commit Graph

2589 Commits

Author SHA1 Message Date
Stanislau Hlebik
eec5a3d725 return pid even if opcode is 0
Summary:
I'm not sure if that's the right thing to do, so I'd like feedback on that.
Check for opcode was added in D22050919 (fdb1af8bc9), but there was also a comment from
chadaustin

```
Why do you think fuseHeader isn't staying valid? It's a struct that's copied
into the RequestData. It does look like stealReq() sets the opcode to 0, but I
don't see anything that would affect the pid field.
```

So I wonder if this code can be responsible for some of the blind spots in
logging?

Reviewed By: chadaustin

Differential Revision: D23422635

fbshipit-source-id: 4d9a7171d685eb3f6f69da7b8a191df2f65ad897
2020-08-31 23:18:30 -07:00
Stanislau Hlebik
71e1d6493e pass context to getOrLoadChild
Summary:
Scuba logging that tracks undesired file fetches has some blind spots i.e. a
lot of fetches have null pid and null cmd line. This diff tries to fix another
part of the problem.

TreeInode::getOrLoadChild() has TODO `pass a fetch context down through
getOrLoadChild to track this load`. This diff fixes this TODO, and also starts
to pass context from EdenDispatcher:lookup method.

Note that it adds quite a lot of new `ObjectFetchContext::getNullContext()`
calls, and potentially those might be responsible for blind spots in logging.
I'll try to address this problem in the next diffs.

Reviewed By: kmancini

Differential Revision: D23418218

fbshipit-source-id: 319d7436494d8dce3580289aae9963aa13bfc191
2020-08-31 10:05:02 -07:00
Stanislau Hlebik
ea4e64864c fix one case of logging of null ClientPid
Summary:
Scuba logging that tracks undesired file fetches has some blind spots i.e. a
lot of fetches have null pid and null cmd line. This diff fixes at least part
of the problem.

TreePrefetchContext which is used from TreePrefetchLease didn't logged client
pid at all (in fact, it logged almost nothing). This diff fixes at least one blind spot, however it doesn't look like this is the only one.

Reviewed By: kmancini

Differential Revision: D23417451

fbshipit-source-id: 107884e94c6b40de999328ec2ef78fe22174c1ca
2020-08-31 10:05:02 -07:00
Genevieve Helsel
5157cf6f34 fix eden thrift legacy dependencies
Summary: `legacy.py` depends on other files in this directory, so lets add them all to the link tree

Reviewed By: fanzeyi

Differential Revision: D23356917

fbshipit-source-id: e4bfd82ebbd9d143a5454a43bb47e8dd55b4485f
2020-08-31 07:55:27 -07:00
Genevieve Helsel
89791f6b89 mock kerberos checks in doctor tests
Summary: These tests fail locally since adding these checks in eden doctor, so we need to mock them.

Reviewed By: chadaustin

Differential Revision: D23326597

fbshipit-source-id: 87a0e6ab0472e3ae56f89503e928c5a00a16ab04
2020-08-31 07:51:17 -07:00
Xavier Deguillard
4f9e1750c2 cli: enable doctor on Windows
Summary:
Most of the fixes are pretty trivial as the code was using functions not
present on Windows, either work around them, or switch to ones that are
multi-platform.

Of note, it looks like `hg doctor` doesn't properly detect when Mercurial and
EdenFS are out of sync, disabling the  tests until we figure out why.

Reviewed By: genevievehelsel, fanzeyi

Differential Revision: D23409708

fbshipit-source-id: 3314c197d43364dda13891a6874caab4c29e76ca
2020-08-28 19:49:37 -07:00
Genevieve Helsel
92eba77a06 remove duplicated code in proc_utils
Summary: I refactored this method to be a member fuction of `EdenFSProcess` and I thought this instance of the method was deleted, but I came across it while working in this area again.

Reviewed By: fanzeyi

Differential Revision: D23113075

fbshipit-source-id: 2c257cca2da3a4bfefb974753eb00c7580c5a104
2020-08-27 09:53:10 -07:00
Chad Austin
0683ab6586 fix hg importer test regression
Summary:
Enabling hg dynamicconfigs in D23309090 (d643f48c8c) changed the output of `hg
manifest --debug` and broke HgImportTest. Set TESTTMP to avoid
production configs.

Reviewed By: DurhamG

Differential Revision: D23335847

fbshipit-source-id: 7ffd0394aa7a8466b266000b18f8742ed4a6b53f
2020-08-27 09:44:37 -07:00
Chad Austin
8e848c7a77 stop using RequestContext
Summary:
Setting up, tearing down, and querying RequestContext has some
overhead that I would like to avoid in the inner FUSE loop, so replace
RequestData with a single class that's heap-allocated at the start of
a request and is guaranteed to survive until the request ends, and is
otherwise explicitly passed where it's needed.

Reviewed By: kmancini

Differential Revision: D22712310

fbshipit-source-id: fc30d0b0f7e22b39306b857194ea07a913110b0f
2020-08-27 00:19:04 -07:00
Chad Austin
e505d33da7 stop using deprecated std::iterator
Summary:
std::iterator is deprecated in C++17. Removing it fixes warnings in
the Clang/Windows build.

Reviewed By: genevievehelsel

Differential Revision: D23352927

fbshipit-source-id: 293e30909eaa8a7c4856a91930a3886ad0b19364
2020-08-26 17:08:05 -07:00
generatedunixname89002005287564@sandcastle1323.prn2.facebook.com
2961ea533b Daily arc lint --take CLANGFORMAT
Reviewed By: zertosh

Differential Revision: D23341246

fbshipit-source-id: a084d09f2c21c3dc515bbb2e6eaf150fc05f16a9
2020-08-26 13:47:00 -07:00
Zeyi (Rice) Fan
50378e741a run edenfsctl redirect fixup after mout is done
Summary: Use `Subprocess` in `win/utils` to call `edenfsctl redirection fixup` after mount is done.

Reviewed By: wez

Differential Revision: D22958764

fbshipit-source-id: a485994a3816169299e8514a5c355f3d37edad99
2020-08-24 21:38:12 -07:00
Zeyi (Rice) Fan
4d21d2dd8a clean up fs/win/utils/Process.h
Summary: Some clean up to do. `Process` will crash the entire process if `Pipe` is ever `std::nullptr`. So let's not give it a default argument `std::nullptr`.

Reviewed By: xavierd

Differential Revision: D22958765

fbshipit-source-id: 0c35e805f24a0d572bbc08efc97e59a37d0cbf88
2020-08-24 21:38:12 -07:00
Zeyi (Rice) Fan
17d2c95a18 enable mkscratch on Windows
Summary: With D22956659, we can now use mkscratch on Windows with EdenFS.

Reviewed By: xavierd

Differential Revision: D22956983

fbshipit-source-id: 995073cbc89d5cb23dbb9c1a58926f8c51f0a896
2020-08-24 21:38:12 -07:00
Xavier Deguillard
111d960ccb win: move some code between the dispatcher and the channel
Summary:
By making the EdenDispatcher less Windows dependant, we can more easily move it
into a non-Windows specific location later.

Reviewed By: chadaustin

Differential Revision: D23298028

fbshipit-source-id: 21726677808a9b8ce3d3e211dd65d9e47caad569
2020-08-24 16:49:12 -07:00
Katie Mancini
3827b9787d add fetch type to data fetch logging
Summary:
Having the type of data fetched can help in debugging where these fetches are
comming from. In the currently logs figuring out if a data fetch is blob or
tree requires some manual work. When looking at a big bunch of fetches this is
not super practical.

So this includes this info in our logging.

Reviewed By: chadaustin

Differential Revision: D23243444

fbshipit-source-id: 9abe5180c5d2afc0d02b27ba6a6b76401e86556e
2020-08-21 17:38:14 -07:00
Katie Mancini
e1836f679c Add spaces to process name in data fetch logs
Summary:
Previously pieces of the command line for a process were seperated by `\0`.
This makes them a bit hard to read and also makes running queries on them
harder. Converts these `\0` back to spaces to fix this.

see https://fb.workplace.com/groups/edenfs/permalink/1446711485499079/ for
more motivation.

Reviewed By: wez

Differential Revision: D23266909

fbshipit-source-id: e4a9284e04039fcd971bed0d6e21d220e946acdb
2020-08-21 13:57:56 -07:00
Alfred Fuller
9ddeabde96 Remove all remaining calls to completeInThread
Reviewed By: iahs

Differential Revision: D23035578

fbshipit-source-id: 24e68e693751cc7e7f7b3c0db966581b72469f0a
2020-08-21 13:00:45 -07:00
Xavier Deguillard
f4f159537f utils: add a platform independent FileUtils
Summary:
Up to now, Windows had to have its own version of folly::{readFile, writeFile,
writeFileAtomic} as these only operate on `char *` path, which can only
represent ascii paths on Windows. Since the Windows version is slightly
different from folly, this forced the code to either ifdef _WIN32, or use the
folly version pretending that it would be OK. The Windows version was also
behaving slightly differently from folly. For instance, where folly would
return a boolean to indicate success, on Windows we would throw an exception.

To simplify our code, add type safety and unify both, we can implement our own
wrappers on top of either folly or Windows APIs.

We still have some code that uses folly::readFile but these should only be
dealing with filedescriptors. As a following step, we may want to have our own
File class that wraps a file descriptor/HANDLE so we can completely remove all
uses of folly::readFile.

Reviewed By: wez

Differential Revision: D23037325

fbshipit-source-id: 2b9a026f3ee6220ef55097abe649b23e38d9fe91
2020-08-14 18:56:33 -07:00
Xavier Deguillard
17776fbbc1 win: various micro-optimization for opendir/readdir
Summary:
After enabling strace profiling for the dispatcher, it became very clear that
once files are populated on disk, most of the notification in edenfs come from
listing directories. While looking at the code to find any improvements, I
picked up a couple of low hanging fruits and cleanup that should help (not
measured).

Reviewed By: chadaustin

Differential Revision: D23121434

fbshipit-source-id: 8a8b369f3be6ffb6097e6e12ab0f07af0a6d56b7
2020-08-14 17:35:50 -07:00
Xavier Deguillard
76ea3054de win: conditionally enable negative path caching
Summary:
From a quick experiment, this greatly cuts down on the amount requests to
nonexistent files. For instance, the .hg directory in folders is now only
looked up once and no longer afterwards.

Reviewed By: wez

Differential Revision: D23112343

fbshipit-source-id: 223134ca591054ae9ac2e839033bbd1b714443da
2020-08-14 17:35:50 -07:00
Xavier Deguillard
3fb1b56ea7 win: remove PrjfsChannel::removeCachedFile
Summary: This function was unused, remove it.

Reviewed By: wez

Differential Revision: D23112344

fbshipit-source-id: e37dd1e07067cf457eeb5d6c0af35db3dfab9b43
2020-08-14 17:35:50 -07:00
Xavier Deguillard
79c8f0e86e win: unify the EdenDispatcher lifetime management
Summary:
This is purely moving code around to be more similar between Unices/Windows.
At some point in the future, I'd like to see just one EdenDispatcher class in
the shared code with as few platform specific code (ie: ifdef) as possible,
this is small step in this direction.

Reviewed By: wez

Differential Revision: D23112345

fbshipit-source-id: feb276040aea106d5951af30c5d445b4cb654e01
2020-08-14 17:35:50 -07:00
Xavier Deguillard
f1da417cea win: use the strace logger
Summary:
On Linux, all the notifications are sent to the strace logger, let's do the
same on Windows. Whenever possible, I've tried to use the name of the Linux
syscalls that correspond to the notification.

Reviewed By: chadaustin

Differential Revision: D23105536

fbshipit-source-id: 31c6e545cdec93b0f751682e34c34b894b2890c4
2020-08-14 16:01:27 -07:00
Tao Chen
f55d4fc261 Remove old getSelection APIs from ServiceSelectorCache
Summary: Remove old getSelection APIs from ServiceSelectorCache

Reviewed By: ovoietsa

Differential Revision: D23070503

fbshipit-source-id: ea013e43215b8bc7aa463efe7b374d67749dda97
2020-08-14 03:21:12 -07:00
Ailin Zhang
58561f9df2 use Eden native import in prefetchBlobs
Summary: Previously we use HgImporter prefetch request in `prefetchBlobs()`, but using `getBlob()` can give us more control over the prefetch process later. So now `getBlob()` is used in `prefetchBlobs()` when `useEdenNativePrefetch` is configured as true.

Reviewed By: kmancini

Differential Revision: D22984848

fbshipit-source-id: 0bd0b1c5b50bb16da36f188915904d0223827dc3
2020-08-13 21:09:09 -07:00
Genevieve Helsel
fdccaae59b add unique return code for unhealthy instance before restart
Reviewed By: xavierd

Differential Revision: D23024654

fbshipit-source-id: c306752219bfe594dc9486d6770f8b7118deb8d5
2020-08-13 09:44:11 -07:00
Xavier Deguillard
5ef7260cc4 cli: remove the repo on edenfsctl remove
Summary:
On Windows, unmounting the repo isn't sufficient to remove all traces of the
repo as ProjectedFS uses it as a cache, and thus all the files that were
touched by the user are still present on disk after unmounting it.

Reviewed By: wez

Differential Revision: D22915349

fbshipit-source-id: 445379fef57160b5da39a298ca4518e2662d16e3
2020-08-13 08:28:45 -07:00
Xavier Deguillard
e5558221ac store: plumb CMD_CAT_TREE
Summary:
With Mercurial now supporting CMD_CAT_TREE for efficiently fetching and reading
trees, we can plumb this onto EdenFS. At startup time, we detect whether
Mercurial supports CMD_CAT_TREE and use that method, otherwise, we fallback to
the old CMD_FETCH_TREE.

Reviewed By: wez

Differential Revision: D23044953

fbshipit-source-id: 9aea5c5b82e97039a75ef18976a155dcb6e150bc
2020-08-12 08:17:25 -07:00
Xavier Deguillard
077ba2fd96 cli: properly detect running buck on Windows
Summary:
Using os.kill on EdenFS would always fail and raise an exception. Use the
proc_utils code to detect if the process is running. Also using BUCKVERSION
always raises an error on Windows, so let's ignore that for now.

Reviewed By: fanzeyi

Differential Revision: D22915350

fbshipit-source-id: 806bfab12ae0e8fc97e83d5720481f2a47516129
2020-08-11 19:01:13 -07:00
Tao Chen
dd6d5900f5 Mark getSelection APIs deprecated
Summary: Mark ServiceRouter getSelection APIs deprecated

Differential Revision: D22990911

fbshipit-source-id: b4de95335005f08948796f6017e3317bb1224fd0
2020-08-11 12:34:15 -07:00
Tao Chen
e41f32a9f1 Add deprecated getSelection APIs to ServiceSelectorCache
Summary:
Instead of modifying the existing APIs and marking all callsites as deprecated in one diff, I am going to take the "add and remove" approach, where I will add the deprecated version of methods first, then mark all callsites, and finally remove the existing ones. This provides some backward compatibility without breaking things.

This diff is to add deprecated getSelection APIs to ServiceSelectorCache.

Differential Revision: D22981269

fbshipit-source-id: 6e3025e7f7df6ee7f9e1cba9dc036ca84adbe49a
2020-08-11 00:14:23 -07:00
Katie Mancini
58d012d8b4 enable metadata fetching by manifest id
Summary:
Previously we fetched metadata by commit hash and path. We knew this would be a
little extra expensive, but turns out this is a lot extra expensive.

Wait why is it expensive?
In short: lots of extra lookups that are not satisfied by cache :(
In long:
1. Each piece of the path would require a read to fetch the fsnode for that tree.
So this means asking for the metadata of a/b/c/d/e means 5 reads.
2. Normally these reads could be cached, but often we would make these requests
with a commit hash for a draft commit. On the server side this info is not
cached for a draft commit, this means a lot of database reads and recalculating.
(Most of the real uses of metadata prefetching is when an engineer is working
on a local commit. We just use the commit hash of the commit the user was on
when fetching metadata for a tree, even if that tree hasn't changed since a public
commit. so this means lots of requests with draft commit hashes).

Fetching by manifest id we are able to bypass this sequential path look up.
(and even if we are on a draft commit, if the tree has not locally changed
since a public commit, the manifest id will be the same as the public commit
avoiding this whole draft commit issue).

This allows us to query scs with a manifest id for a tree.

Reviewed By: wez

Differential Revision: D22990687

fbshipit-source-id: aa81d67de1f1d04a14d174774ee216f5ac6be5ba
2020-08-10 23:53:10 -07:00
Xavier Deguillard
0273817488 win: simplify path management
Summary:
The StringConv.h header contains many functions to convert from Windows paths
to Eden's path (and vice versa) to workaround the fact that Eden's path don't
support wide strings that Windows uses. Let's simply add support for these wide
strings in PathFuncs so we can greatly simplify all the call sites. Instead of
calling "edenToWinName(winstr)", "PathComponent(winstr)" is both more
descriptive and more idiomatic.

To be fair, I'm not entirely a fan of the approach taken in this diff, as this
adds Windows specific code to PathFuncs.h, but I feel that the benefit is too
big to not do that.

Reviewed By: chadaustin

Differential Revision: D23004523

fbshipit-source-id: 3a1507e398a66909773251907db01e06603b91dd
2020-08-10 08:53:13 -07:00
Xavier Deguillard
53c6c0befd win: rework the Pipe API a bit
Summary:
This makes it similar to the Unix one, which reduces the ifdef a tiny bit.
Ideally I'd want to move the pipe handling into its own class so callers won't
have to care about windows/linux specificities.

Reviewed By: fanzeyi

Differential Revision: D22954056

fbshipit-source-id: c92a25b6abe084a7c7496c0d6e07795779e0abad
2020-08-07 11:05:31 -07:00
Ailin Zhang
4f43f8bb8d make a separate command for prefetch_profile
Summary:
Previously `eden prefetch` had two subcommands `record-profile` and `finish-profile`, but then when we only want to use `eden prefetch PATTERN`, an error shows up saying that the COMMAND argument is missed.

Since `eden prefetch` has many of its own arguments, and we don't want to use it with `record-profile` and `finish-profile` all the time, we remove those subcommands and create a new `eden debug prefetch_profile` command to get prefetch profiles.

Reviewed By: fanzeyi

Differential Revision: D22959981

fbshipit-source-id: 21b278555fcb56580a62f66a7384b1cff54ba398
2020-08-06 13:17:07 -07:00
Xavier Deguillard
ae62478818 cli: wait for EdenFS to be healthy on start
Summary:
On Windows, we were just spawning EdenFS without waiting for it to become
either healthy, or unhealthy. While in most cases EdenFS becomes healthy
shortly after, scripts could race with it and behave weirdly as a consequence.
For instance, `eden clone` would start EdenFS if it isn't started already, and
then immediately clone the repo, that second step may fail and just leave an
empty folder on disk.

On unices, due to EdenFS daemonizing itself, edenfsctl waits for the parent
process to exit which signify that EdenFS is either started, or dead. On
Windows, we can wait on the pid that CreateProcess returns. One drawback is
that the user won't see what `edenfsctl start` is doing while on unices we have
progress bars regarding the repositories being mounted. One approach to
alleviate this would be to use a pipe as the StartupLogger and close it once
EdenFS is initialized.

Reviewed By: fanzeyi

Differential Revision: D22964058

fbshipit-source-id: 4e83c265d22e7e5150ed8b40e2b554cfcd181f8e
2020-08-06 12:31:57 -07:00
Xavier Deguillard
746a4a7ac0 win: remove the Edenwin.h header
Summary: It served no purpose. Also as a bonus, remove an unecessary std::endl.

Reviewed By: fanzeyi

Differential Revision: D22954057

fbshipit-source-id: bcaca833cdef8b643b16fbda2a0d576b655c2857
2020-08-06 09:15:16 -07:00
Wez Furlong
f8c2c0291f eden: macos: avoid UB with shared_errno
Summary: as above

Reviewed By: chadaustin

Differential Revision: D22954008

fbshipit-source-id: 520db285ac4d3ba3569427a586f042fbb0883e29
2020-08-05 19:58:03 -07:00
Ailin Zhang
ff363ae090 don't print fsck progress bars when fsck does not happen
Summary: fix the problem of printing 0% fsck progress bars when fsck is actually not happening.

Reviewed By: genevievehelsel

Differential Revision: D22927401

fbshipit-source-id: 868fa188e3c2671b0f6e18e842ec6a23281dc337
2020-08-05 18:27:34 -07:00
Zeyi (Rice) Fan
8a61bc52d3 treat bind mount redirection as symlink
Summary:
For EdenFS Redirection on Windows, we can simply use symlinks in place of bind mounts on other platforms. This works fine from what I can tell.

NOTE: at this commit EdenFS on Windows is still not able to create these redirections at start up time since that code is located in `EdenMount` and it uses `folly::subprocess`: https://www.internalfb.com/intern/diffusion/FBS/browse/master/fbcode/eden/fs/inodes/EdenMount.cpp. For the same reason we can't enable the EdenFS redirection integration tests.

Reviewed By: xavierd

Differential Revision: D22544200

fbshipit-source-id: b1a33da128c932544660c3e895583574d7891be9
2020-08-05 14:27:05 -07:00
Zeyi (Rice) Fan
a4d520acc6 replace os.path with pathlib in redirect
Summary:
The mix use of `os.path` and `pathlib` in `redirect.py` is a little messy, which is making adding Windows support trickier since `os.path` functions do not accept `Path` until 3.8. So before I make the change I think it's better to clean it up.

Since we are target Python 3 nowadays, replacing `os.path` with `pathlib` seems to be better. Basically this diff does the following:

* Replace use of `os.path` functions with the counterpart in `pathlib`.
* Reduce unnecessary conversions from/to `Path` to `str` / `bytes`.
* Only convert `Path` to `str` or `bytes` when interactive with other APIs (Thrift or os)
  * Cross-platform APIs: `os.fspath`
  * API expecting `str`: `os.fsdecode`
  * API expecting `bytes`: `os.fsencode`

Reviewed By: chadaustin

Differential Revision: D22879004

fbshipit-source-id: a247973dc9919c8805daa4046472124310725516
2020-08-05 14:27:04 -07:00
Genevieve Helsel
7c5ebb67bf check kerberos certificate issues in eden doctor
Summary: Often users run into kerberos certificate issues, which in turn causes permissions issues with mercurial and eden. This issue is not obvious while users are running hg commands, so `eden doctor` should identity this issue and tell the user about it. `hg doctor` runs `eden doctor`, so this should also show itself if a user runs `hg doctor`.

Reviewed By: wez

Differential Revision: D22825882

fbshipit-source-id: 5f51901934862336b0ebc2996da6e1168ea8d8a3
2020-08-05 12:48:30 -07:00
Jon Maltiel Swenson
80df65c36e Join outstanding requests when stopWorkersOnStopListening is disabled
Summary: In cases where `stopWorkersOnStopListening` is disabled, `ThriftServer` continues to process inflight and even new requests after `ThriftServer::serve()` has returned. This is unintuitive and error-prone. This diff ensures that when `serve()` returns, there are no outstanding requests and new requests will not be processed.

Reviewed By: yfeldblum, genevievehelsel

Differential Revision: D22827447

fbshipit-source-id: cda35843ee6be084042e1a7c806c77fb472dd114
2020-08-05 10:04:14 -07:00
Wez Furlong
f9ba8e3c57 eden: macos: avoid blocking mount(2) call with osxfuse 3.11.0
Summary:
We're seeing a trivially reproducible deadlock upon upgrading
to osxfuse 3.11:

```
task                 vm_map               ipc_space            #acts flags    pid       process             io_policy  wq_state  command
0xffffff802a794358   0xffffff802a6dcf00   0xffffff80214b0980       1 D       1348   0xffffff8024772380                 0  0  0    edenfs
  thread                   thread_id  processor            base   pri    sched_mode      io_policy       state    ast          waitq                            wait_event           wmesg                thread_name
  0xffffff802146f000       0x1d11     0xffffff8080085000   31     31     timeshare                       WU                    0xffffff807f74bb40               0xffffff8019b15af0   fu_ini               edenfs_privhelp
    kernel_stack = 0xffffff80a0800000
    stacktop = 0xffffff80a0803590
    0xffffff80a0803590 0xffffff800dc0c475 machine_switch_context((thread_t) old = 0xffffff802146f000, (thread_continue_t) continuation = 0x0000000000000000, (thread_t) new = 0xffffff8018963000)
    0xffffff80a0803610 0xffffff800dab1134 thread_invoke((thread_t) self = 0xffffff802146f000, (thread_t) thread = 0xffffff8018963000, (ast_t) reason = 0)
    0xffffff80a0803670 0xffffff800daaf47c thread_block_reason((thread_continue_t) continuation = <>, , (void *) parameter = <>, , (ast_t) reason = <>, )
    0xffffff80a08036b0 0xffffff800daa0768 thread_block [inlined]((thread_continue_t) continuation = <>, )
    0xffffff80a08036b0 0xffffff800daa075d lck_mtx_sleep((lck_mtx_t *) lck = 0xffffff8027379870, (lck_sleep_action_t) lck_sleep_action = 1, (event_t) event = 0x0000000000000001, (wait_interrupt_t) interruptible = 0)
    0xffffff80a0803730 0xffffff800e03239a _sleep((caddr_t) chan = 0xffffff8019b15af0 "\x03", (int) pri = 1024, (const char *) wmsg = 0xffffff7f903025fa "fu_ini", (u_int64_t) abstime = 0, (int (*)(int)) continuation = 0x0000000000000000, (lck_mtx_t *) mtx = 0xffffff8027379870)
    0xffffff80a0803770 0xffffff800e032962 msleep((void *) chan = 0xffffff8019b15af0, (lck_mtx_t *) mtx = 0xffffff8027379870, (int) pri = 1024, (const char *) wmsg = 0xffffff7f903025fa "fu_ini", (timespec *) ts = <>, )
    0xffffff80a08037c0 0xffffff7f902fd5b8 fuse_internal_msleep((void *) chan = 0xffffff8019b15af0, (lck_mtx_t *) mtx = 0xffffff8027379870, (int) pri = 1024, (const char *) wmesg = 0xffffff7f903025fa "fu_ini", (timespec *) ts = 0x0000000000000000, (fuse_data *) data = 0xffffff8019b15a00)
    0xffffff80a08037f0 0xffffff7f902f01c5 fdata_wait_init_locked [inlined](void)
    0xffffff80a08037f0 0xffffff7f902f01ab fuse_ticket_fetch((fuse_data *) data = 0xffffff8019b15a00)
    0xffffff80a0803840 0xffffff7f902f07e7 fdisp_make((fuse_dispatcher *) fdip = 0xffffff80a0803860, (fuse_opcode) op = FUSE_STATFS, (fuse_data *) data = <register rdx is not available>, , (uint64_t) nid = 1, (vfs_context_t) context = 0xffffff8020ed8168)
    0xffffff80a08038c0 0xffffff7f90301608 fuse_vfsop_getattr [inlined]((vfs_attr *) attr = <>, , (vfs_context_t) context = 0xffffff8020ed8168)
    0xffffff80a08038c0 0xffffff7f90301588 fuse_vfsop_biglock_getattr((mount_t) mp = <>, , (vfs_attr *) attr = 0xffffff80a0803928, (vfs_context_t) context = 0xffffff8020ed8168)
    0xffffff80a0803b00 0xffffff800dd45f3c vfs_getattr [inlined]((mount_t) mp = <>, , (vfs_attr *) vfa = 0x0000000000000000, (vfs_context_t) ctx = <no location, value may have been optimized out>, )
    0xffffff80a0803b00 0xffffff800dd45f30 mount_common((char *) fstypename = <>, , (vnode_t) pvp = 0xffffff801b03b5d0, (vnode_t) vp = <>, , (componentname *) cnp = <>, , (user_addr_t) fsmountargs = 140728898420737, (int) flags = 8, (uint32_t)
internal_flags = 0, (char *) labelstr = 0x0000000000000000, (boolean_t) kernelmount = 0, (vfs_context_t) ctx = 0xffffff8020ed8168)
    0xffffff80a0803ef0 0xffffff800dd46d8c __mac_mount((proc *) p = <>, , (__mac_mount_args *) uap = <>, , (int32_t *) retval = <no location, value may have been optimized out>, )
    0xffffff80a0803f30 0xffffff800dd46996 mount((proc_t) p = <>, , (mount_args *) uap = <>, , (int32_t *) retval = <no location, value may have been optimized out>, )
    0xffffff80a0803fa0 0xffffff800e15bc95 unix_syscall64((x86_saved_state_t *) state = 0xffffff80209464c0)
    0x0000000000000000 0xffffff800da2a306 kernel.development`hndl_unix_scall64 + 0x16
    stackbottom = 0xffffff80a0803fa0
```

Here we can see that `edenfs_privhelp` called `mount(2)` and that that is
trying to call to the FUSE daemon.  However, the daemon cannot respond because
we cannot return the fuse device fd to the FuseChannel until `mount` returns.

This commit farms out the `mount` call to a secondary thread that is free to
block.  In order to catch invalid parameter errors (eg: bad flags to mount),
we'll wait a short grace period to see if the mount yields an errno value and
raise that.

Otherwise we assume success and return the device to the channel.

Reviewed By: rb2k

Differential Revision: D22939891

fbshipit-source-id: 1a144486672af8386b31e46345958bc5a99ec233
2020-08-04 23:34:41 -07:00
Xavier Deguillard
fcc32885ea win: compute sha1 in constant memory
Summary:
Reading the entire file to compute its sha1 can cause EdenFS to OOM on large
files. Instead, let's simpy read 8k at  a time, like what we do on Linux.

Reviewed By: chadaustin

Differential Revision: D22924710

fbshipit-source-id: cd472f396a4385049994a1976c7d046cb901337a
2020-08-04 23:00:11 -07:00
Xavier Deguillard
e8c0739b74 cli: return the full path from get_eden_mount_name
Summary:
The non-Windows part of it returns the full path for the mount, do the same on
Windows. Since this is used in the remove path to unmount the repo, and the
paths expected in unmount are fullpaths, this meant remove would always fail to
unmount the repo.

Reviewed By: chadaustin

Differential Revision: D22915352

fbshipit-source-id: 6739267188c46d5ca1d6cb212a7155e70056f0f7
2020-08-04 17:36:41 -07:00
Xavier Deguillard
7f5696155e sqliteoverlay: properly mark it initialized
Summary:
The initialized_ field was never set, which meant that Overlay::close would
never close the sqlite overlay. This had the negative effect of allowing the
unmount thrift call to return before the sqliteoverlay is properly closed which
on Windows meant that the overlay couldn't be deleted.

Reviewed By: chadaustin

Differential Revision: D22915353

fbshipit-source-id: e501b2d0268449d109cc37dfdc62faebf1953e09
2020-08-04 12:05:43 -07:00
Ailin Zhang
afe509981e avoid startRecordingBackingStoreFetch calling startRecordingFetch() for shared backing stores more than once
Summary: Since multiple mount points can share the same BackingStore object, it is better to start recording profile for each unique backing store instead of get backing stores by mounts.

Reviewed By: chadaustin

Differential Revision: D22904499

fbshipit-source-id: f95508044912503509c4ac0f84b4a061e41ca0f3
2020-08-04 06:50:45 -07:00
Ailin Zhang
bbc193c7ed eden prefetch record-profile and eden prefetch finish-profile
Summary:
added `record-profile` and `finish-profile` subcommands to `eden prefetch`
`eden prefetch record-profile` triggers `startRecordingFetch()` in `HgQueuedBackingStore`. `eden prefetch finish-profile` triggers `stopRecordingFetch()` in `HgQueuedBackingStore` and write the returned fetched file names to a text file. We can use the output file to predict what files are fetched for frequently used commands.

Reviewed By: chadaustin

Differential Revision: D22797896

fbshipit-source-id: ff240829b4fb3c47093279a1f2bd453009ff5f73
2020-08-04 06:50:45 -07:00
Ailin Zhang
106ce3af12 record fetch in HgQueuedBackingStore
Summary:
after `startRecordingFetch()` is called by `HgQueuedBackingStore`, record the path for each fetched file. When `stopRecordingFetch()` is called, stop recording and return the collected file paths.

`startRecordingFetch()` and `stopRecordingFetch()` will be used in the next diff.

Reviewed By: chadaustin

Differential Revision: D22797037

fbshipit-source-id: a1fe30424d3c2884ffe139a0062b1e36328fd4fe
2020-08-04 06:50:45 -07:00
Chad Austin
83888d06f8 remove several extraneous futures
Summary:
Our error handling looked pretty, but allocating all of these futures
is expensive. Each future is an allocation and some atomics. This diff
buys back some performance which I will soon spend on a new async
event queue.

Reviewed By: xavierd

Differential Revision: D22799737

fbshipit-source-id: 91dcfe974cf8f461109dfaa9dbf75c054ed84f59
2020-08-03 18:48:39 -07:00
Xavier Deguillard
0d45afef56 win: make recursive call more explicit about the path
Summary:
I've seen the error a couple of times when messing up with my clones, not
having the path makes it a bit difficult to fully understand what's going on,
make sure we log it.

Reviewed By: fanzeyi

Differential Revision: D22899098

fbshipit-source-id: c9a60b71ea20514158e62fe8fa9c409d6f0f37ff
2020-08-03 12:12:34 -07:00
Xavier Deguillard
ef4db32904 inodes: invalidate more on Windows
Summary:
Cache invalidation is hard, and on Windows we avoided doing a lot of them. It
turns out, this was the wrong decision as it's fairly easy to find cases where
the filesystem view is different from the manifest state.

Since the Linux code is most likely correct in where the invalidation is done,
let's also do the same on Windows, removing a whole lot of #ifdef. It is very
likely that as a result of this diff we end up invalidating more than needed,
thus slowing down EdenFS, but at this point I'd prefer to err on the side of
correctness, performance will come later.

While invalidating files should use PrjDeleteFile, for directories, we simply
need to mark them as placeholder, as directories created by a user won't have a
placeholder, thus ProjectedFS would bypass EdenFS when listing in.

Reviewed By: chadaustin

Differential Revision: D22833202

fbshipit-source-id: d807557f5e44279c49ab701b7a797253ef1f0717
2020-08-03 11:26:31 -07:00
Genevieve Helsel
395c78df5b fix typo in restarter log message
Summary: While testing something for another change, I came across this overlooked typo.

Reviewed By: wez

Differential Revision: D22894060

fbshipit-source-id: 8aa48ef5da714650c974adcf8a34a542fdd4ed9e
2020-08-03 11:19:21 -07:00
Chad Austin
a26afc332f simplify BufVec (for now)
Summary:
Avoid some overhead and complexity by storing BufVec as a
unique_ptr<IOBuf>. The complexity can be reintroduced if we ever find
FUSE splice support to be a performance win for us.

Reviewed By: kmancini

Differential Revision: D22710795

fbshipit-source-id: e58eedc0fb5cea9e9743ccd20d3e4e2b7cc5d198
2020-08-03 11:16:06 -07:00
Ailin Zhang
40422c12be log fetch-heavy processes to Scuba at each 2000 more fetches
Summary:
Previously we log a process to Scuba when it does 2000 (fetchThreshold_) fetchs, but then in Scuba all processes have fetch_count = 2000. In order to see how many fetches a process really did approximately, we log the same process to Scuba every time it does 2000 more fetches.

Note: this change could make the total count of fetch-heavy events in Scuba inaccurate, as we log the same process more than once. So when users want to see how many fetch-heavy events happened, instead of setting "type = fetch_heavy", they should set exactly "fetch_count = 2000".

Reviewed By: chadaustin

Differential Revision: D22867679

fbshipit-source-id: ae3c768a8d3b03628db6a77263e715303a814e3d
2020-08-03 11:13:20 -07:00
Genevieve Helsel
1e9ae5dc55 don't make local store compaction on graceful restart a hard failure
Summary: Since local store compaction is not a hard requirement for graceful restart, make this issue non blocking. We've seen some users fail restarts because they had compaction issues due to lack of space on their device. If we fail during the compaction stage, we should continue the restart anyway. This is also because there is a chance that the local store will clear columns that are no longer in use.

Reviewed By: chadaustin

Differential Revision: D22828433

fbshipit-source-id: 9a2aaec64e77c2d00089834fda8f8cffda472735
2020-08-03 07:20:55 -07:00
Katie Mancini
0b76c1db46 follow up from thift codemod
Summary:
TL:DR:
A codemod did something a bit unclean, so they added a lint. This will keep bugging us if we make changes here, so let's satisfy the linter.

More info:

 `x.y_ref() = ...` and `*x.y_ref() = ...` are pretty much the same except `*x.y_ref() = ...` can throw for optional fields.

A codemod added a bunch of `*x.y_ref() = ...`, but after they didn't want people to copy paste this for optional fields so they added a lint that pops up on non optional fields too :(

https://fb.workplace.com/groups/thriftusers/permalink/509303206445763/

Reviewed By: chadaustin

Differential Revision: D22823686

fbshipit-source-id: b3b1b8a3b6b1f1245176be19c961476e4554a8e5
2020-07-31 12:18:39 -07:00
Ailin Zhang
7f2329a3ff add space between command name and args when logging fetch heavy processes to Scuba
Summary:
Previously, fetch heavy event's cmdline was delimited by '\x00' when logged to Scuba. (for example: `grep--color=auto-rtest.`)
Now we replace \x00 with a space, so command name and args will be separated by space. ( `grep --color=auto -r test .` )

Reviewed By: kmancini

Differential Revision: D22772868

fbshipit-source-id: 4ab42e78c7bc786767eee3413b9586739a12e8ac
2020-07-31 11:42:51 -07:00
Xavier Deguillard
e488d238f3 win: add DBG6 logging when invalidating files
Summary:
This helps in understanding what's going on when some files disappear and/or
aren't flushed properly.

Reviewed By: fanzeyi

Differential Revision: D22833201

fbshipit-source-id: 09beb5796cb40c0a93107ee6a3a3497abb2578f0
2020-07-31 11:28:28 -07:00
Wez Furlong
28fa90d6fd eden: fixup capsFlagsToLabel bit clearing logic
Summary:
The tilde got dropped as part of the changes in D22672240 (be3683b1d4)
(an easy mistake to make!) and that renders this function less
useful.

Thankfully the caps display isn't a critical function; just for
some diagnostic printing.

Reviewed By: chadaustin

Differential Revision: D22847590

fbshipit-source-id: 716d7c7bd674260687fbc09e3dc94538359f98b3
2020-07-30 12:47:56 -07:00
Ailin Zhang
b6bb0fe3ba use logVerbose for fsck bars
Summary:
`log()` passes fsck bars to standard output, but it will also print the same message to the log with level DBG2. (example below)
```V0713 07:05:45.971511 3510654 StartupLogger.cpp:96] [====================>] 100%: fsck on /home/ailinzhang/eden-state/clients/dev-fbsource6/local
```
Since we don't want the log file to be messed up with fsck bars, we use `logVerbose()` with level DBG7.

Reviewed By: kmancini

Differential Revision: D22727965

fbshipit-source-id: 0700503af511030df2abbca4ad2fa1540995e919
2020-07-30 08:47:54 -07:00
Xavier Deguillard
f03b2277cb service: make rocksdb the default on Windows
Summary:
Unfortunately, using sqlite causes `edenfsctl prefetch` to take several orders
of magnitude more time than with rocksdb, tuning sqlite to be faster (at the
expense of reliability) still doesn't come closer to rocksdb. From profiling,
this is due to sqlite only allowing a single thread to read/write onto it
serializing all the work that EdenFS is doing.

A rework on the storage will be necessary to be able to get both good
performance, and reliability but that's a long term project, for now, make
Windows use rocksdb by default.

Reviewed By: wez

Differential Revision: D22819084

fbshipit-source-id: 62f397858ed547da30ef8a6346b767461dc53493
2020-07-29 13:57:00 -07:00
Xavier Deguillard
07df8faf5e win: when creating a file/directory, create the parents too
Summary:
As opposed to FUSE, ProjectedFS sends notifications for file/directory creation
after the fact, and for directory that means these will be visible on disk before
EdenFS may be aware of it. While EdenFS usually process it quickly, a heavily
multi-threaded application that tries to concurrently create a directory
hierarchy may end up sending notifications to EdenFS in a somewhat out of order
fashion.

Since this should be a very rare occurence, we make this a very slow path by
being optimistic and calling `getInode` first, and then only if that fails, we
aggressively create all the parent directories. During a buck build of ~1k
jobs, this happened only 3 times.

If we fully think this through, this change doesn't fully fix the race, as a
similar race can now happen when a create and remove/rename operations are
concurrent. However, a client performing these operations concurrently is
either aware that this is racy and should handle these properly, or is most
likely buggy. Both of these should significantly reduce the likelyhod of this
happening, thus, I'm leaving this unfixed for now.

To better understand how frequently this happens, I've added a stat counter.
For now, these aren't published to ODS, but this will be tackled later.

Reviewed By: wez

Differential Revision: D22783484

fbshipit-source-id: ea3aafc2f77b65d3967f697f68114921d5909137
2020-07-29 12:17:17 -07:00
Chad Austin
bbda65d500 guarantee make_iovec and sendReply only take standard layout types
Summary:
To avoid mistakes when refactoring, static_assert that the template
variant of sendReply and make_iovec are only used with POD types.

Reviewed By: genevievehelsel

Differential Revision: D22710742

fbshipit-source-id: 4557761f3946fe8969ce31a42502f64cc3298e1d
2020-07-28 14:47:41 -07:00
Chad Austin
26b7cd7ad4 directly track fuse_in_header in the live fuse requests
Summary:
Previously, we kept a list of weak pointers to RequestData instances
to track live FUSE calls, but the only thing we need is the FUSE
request header, so directly track that instead.

Reviewed By: kmancini

Differential Revision: D22710716

fbshipit-source-id: 3820acb314ac2db85b86de128fd082bc4871d9c6
2020-07-28 14:47:41 -07:00
Chad Austin
943a79bf2b remove isFuseRequest
Summary:
Now that we are explicit about whether the kernel caches must be
invalidated, we can remove a use of folly::RequestContext.

Reviewed By: kmancini

Differential Revision: D22710518

fbshipit-source-id: 4bd5267bf5dd3135adf33e4f4fa1ea2649816564
2020-07-28 14:47:41 -07:00
Chad Austin
dd4f1c0faa make rename explicit about kernel cache invalidation
Summary:
Avoid the cost of dynamically querying whether we are in a FUSE
request handler or not by passing a flag.

Reviewed By: kmancini

Differential Revision: D22710480

fbshipit-source-id: 010bb8efee8074441aa20aab0eb12277452c5252
2020-07-28 14:47:40 -07:00
Chad Austin
7cdb962d1d make mkdir explicit about kernel cache invalidation
Summary:
Avoid the cost of dynamically querying whether we are in a FUSE
request handler or not by passing a flag.

Reviewed By: kmancini

Differential Revision: D22710452

fbshipit-source-id: 818035b72b793fa895147d9df3bb668d5b9c55f3
2020-07-28 14:47:40 -07:00
Chad Austin
bfbd3bbb8e make symlink and mkmod explicit about kernel cache invalidation
Summary:
Avoid the cost of dynamically querying whether we are in a FUSE
request handler or not by passing a flag.

Reviewed By: kmancini

Differential Revision: D22710422

fbshipit-source-id: 65b0737ad5f8ca74d12f2c657691d3751df4aa54
2020-07-28 14:47:40 -07:00
Chad Austin
9034f43c75 make unlink and rmdir explicit about kernel cache invalidation
Summary:
Avoid the cost of dynamically querying whether we are in a FUSE
request handler or not by passing a flag.

Reviewed By: genevievehelsel

Differential Revision: D22710397

fbshipit-source-id: 7c62f45dfc227416c91070842a349b9d0c626cba
2020-07-28 14:47:40 -07:00
Victor Zverovich
5914a60995 Migrate to field_ref Thrift API
Summary:
We are unifying C++ APIs for accessing optional and unqualified fields:
https://fb.workplace.com/groups/1730279463893632/permalink/2541675446087359/.

This diff migrates code from accessing data members generated from unqualified
Thrift fields directly to the `field_ref` API, i.e. replacing

```
thrift_obj.field
```

with

```
*thrift_obj.field_ref()
```

The `_ref` suffixes will be removed in the future once data members are private
and names can be reclaimed.

The output of this codemod has been reviewed in D20039637.

The new API is documented in
https://our.intern.facebook.com/intern/wiki/Thrift/FieldAccess/.

drop-conflicts

Reviewed By: iahs

Differential Revision: D22764126

fbshipit-source-id: 67b1bc6d4a9135f594d78325cee8a194255bdcb8
2020-07-28 14:32:44 -07:00
Xavier Deguillard
d98e5ebe1d win: remove DirList code
Summary: This is unused, and won't ever be used.

Reviewed By: genevievehelsel

Differential Revision: D22744352

fbshipit-source-id: 9d20db608f972288eaf33e3ea0a79ffe5e13e03e
2020-07-28 11:52:54 -07:00
Xavier Deguillard
85e4b37849 win: remove unused getEnumerationEntries
Summary: These were only used in tests, no need to keep it.

Reviewed By: chadaustin

Differential Revision: D22744353

fbshipit-source-id: 57596d641ab85f15e8c945327d7849a64aa73ef8
2020-07-27 20:48:10 -07:00
Xavier Deguillard
48507f7215 inodes: remove ifdef around cache flushing functions
Summary:
Both unices and Windows needs to invalidate the cache in the same place, let's
avoid ifdef and consolidate the function name to clean things up a bit.

Reviewed By: chadaustin

Differential Revision: D22741709

fbshipit-source-id: 04060c0080eff9840abd22747ea48404fa50fd86
2020-07-27 20:48:10 -07:00
Wez Furlong
8d56e5ccbc eden: support NO_OPEN support on macOS
Summary:
We're experimenting with enabling NO_OPEN support in our internal
build of the osxfuse kext.  This commit includes the relevant capability bits
for the kernel interface (which are compatible with the linux FUSE
implementation) as well as adjusts our FUSE client code to detect and use
those bits on macOS.

Reviewed By: xavierd

Differential Revision: D22744378

fbshipit-source-id: 21376439a85b0b0f5a71916dd1af618d9627695e
2020-07-27 17:53:03 -07:00
Xavier Deguillard
79f3797514 win: handle pre rename notification
Summary:
Even though we never asked for a pre rename notification, ProjectedFS would
anyway send one to us, and since we're now failing on unrecognized
notification, that meant renames would always fail. Handle them and do nothing in them.

I'm not sure yet if we want to move the actual rename logic into the pre rename
callback, or keep it as is. The benefit of the pre rename code is that it can
fail the user request, while the current code will fail, but not prevent the
rename from happening.

Reviewed By: wez

Differential Revision: D22738388

fbshipit-source-id: 487e1f90b503bc59cff7315dd38d2a3039552eaf
2020-07-27 09:35:40 -07:00
Xavier Deguillard
d88350426e win: move all the code in future combinators in getFileInfo
Summary: This will make it easier to support PrjFS async programming model.

Reviewed By: chadaustin

Differential Revision: D22738408

fbshipit-source-id: 2e2e4f6f2f718b0226cf9fab66589c50b6db49db
2020-07-27 08:51:43 -07:00
Xavier Deguillard
1854587a57 win: micro-optimize exceptionToHResult
Summary:
The pattern when using it is to catch the exception, then call the function,
which then would re-throw it and catch the subtyped exception. We can avoid a
re-throw entirely by having the function take the exception that was thrown in
the first place and dynamic cast it.

Reviewed By: chadaustin

Differential Revision: D22736772

fbshipit-source-id: 0efa3134bccf3ba8bdcd51d67e03c7ee4483a99f
2020-07-27 08:51:43 -07:00
Xavier Deguillard
f754c7f285 win: make getFileData more Future friendly
Summary:
We're still reading the entire file at a time, but this paves the way to not do
that.

While the change looks big, a lot of it is just moving code around. The main
gist of it is removing EdenMount::readFile and writing the proper future
combinator in EdenDispatcher::getFileData.

Reviewed By: wez

Differential Revision: D22361748

fbshipit-source-id: 6391a29d25a4c9e61b91952c40c21ad52e728c8b
2020-07-27 08:51:43 -07:00
Xavier Deguillard
53a1508307 win: make readdir more Future friendly
Summary:
This would enable the enumeration callback to use ProjectedFS asynchronous
completion.

Reviewed By: chadaustin

Differential Revision: D22361747

fbshipit-source-id: b2d31533ee5128e9dd3da7f91d5225331cf8e926
2020-07-27 08:51:43 -07:00
Xavier Deguillard
67cb7dcf97 inodes: add missing cleanupPrjfsCache
Summary:
We've had a long latent bug where for some reason a file that should be in the
repo isn't visible on the filesystem. Turning on logging and running `ls` shows
that EdenFS tells ProjectedFS about the file, but it's somehow not shown. The
reason being that ProjectedFS keeps track of all the removed files by adding a
tombstone for these, and will not list them until EdenFS removes this
tombstone.

Looking at the various places where we invalidate FUSE's cache, but not
ProjectedFS, only one stands out, and it has to do with files not being present
in the working copy, but added in the update destination. Adding the right
flush there appear to solve the simple repro listed below.

I'll remove all the ifdef around flushing in a later diff to avoid this issue
from re-appearing again.

Reviewed By: fanzeyi

Differential Revision: D22739916

fbshipit-source-id: 3a4fbc825cd21b36cbd2616882fd50e3d9741f63
2020-07-27 08:42:06 -07:00
Katie Mancini
ed1745bf6a logging for thrift object fetch: globFiles
Summary:
This adds logging for data fetches that come from the thrift globfiles call to
help debug the cause of unexpected data fetches. (See D22448048 for more
motivation)

Reviewed By: genevievehelsel

Differential Revision: D22489512

fbshipit-source-id: 040cf1277205d08ea864a1f30f8d3b25ee7c4508
2020-07-26 23:09:40 -07:00
Katie Mancini
b71d531a39 add data fetch logging for prefetch
Summary:
This adds logging for files fetched in prefetch like was aleady added for
blob and tree fetches.

This is needed to log the fetches caused by the glob files thrift call. The
purpose of this to help debug the cause of unexpected data fetches (See
D22448048 for more motivation).

Reviewed By: genevievehelsel

Differential Revision: D22561619

fbshipit-source-id: 5ae78b99fb0c7d863d8223b93492b0d0210ddf9e
2020-07-26 23:09:40 -07:00
Katie Mancini
ad20cb26a4 logging for thrift object fetch: getSHA1
Summary:
This adds logging for data fetches that come from the thrift getSHA1 call to
help debug the cause of unexpected data fetches. (See D22448048 for more
motivation)

Reviewed By: genevievehelsel

Differential Revision: D22489514

fbshipit-source-id: eb2d82c206af857cc79439d2854d682641292db8
2020-07-26 23:09:40 -07:00
Katie Mancini
3beecaa211 logging for thrift object fetch: getFileInformation
Summary:
This adds logging for data fetches that come from the thrift getFileInformation call to
help debug the cause of unexpected data fetches. (See D22448048 for more
motivation)

Reviewed By: genevievehelsel

Differential Revision: D22489513

fbshipit-source-id: ab6283476d05b06b9f9e37c6b4fd81c1282046ff
2020-07-26 23:09:40 -07:00
Katie Mancini
e97f1c7240 logging for thrift object fetch: checkout
Summary:
This adds logging for data fetches that come from the thrift checkout call to
help debug the cause of unexpected data fetches. (See D22448048 for more
motivation)

Reviewed By: chadaustin

Differential Revision: D22489504

fbshipit-source-id: 3b732a1e5627c2130f561ec0138a1df270e1925d
2020-07-26 23:09:40 -07:00
Katie Mancini
9fa13b9393 Create ObjectFetchContext for Thrift
Summary:
We have seen that some of the unexpected data fetches do not originate from
FUSE. This adds parity to the logging for data fetches that come from the thrift
interface. Adding this logging improves the overall observability of eden, and
will help us debug the cause of unexpected data fetching.

This introduces plumbing to allow logging data fetches that originate from
thrift requests.

Reviewed By: chadaustin

Differential Revision: D22448048

fbshipit-source-id: a39dde72467c4922c07c569c14fb499341d40258
2020-07-26 23:09:40 -07:00
Katie Mancini
e6bdf0c3ff refactor ThriftLogHelper
Summary:
What does this do: allocate a ThriftLogHelper and ensure it lives for the
duration of its coresponding thrift request.

Why: By ensuring that the log helper's lifetime matches that of the thrift
request, we simplify adding to the logger. We wont have to think about the
lifetime of each of the members of the logger, we simply can stick them in the
log helper and let shared_ptr do its magic.

More specific why: This refactor helps make adding Thrift data fetch logging
cleaner (see following changes). We need to ensure the ObjectFetchContext
stays around for the duration of the thrift request since we pass it around
by reference. Sticking this in ThriftLogHelper avoids adding another disjoint
piece of plumbing and makes the code easier to maintain going forward.

Reviewed By: genevievehelsel

Differential Revision: D22632546

fbshipit-source-id: 1baa79419386947e52a386d89a65f032f1988622
2020-07-26 23:09:40 -07:00
Xavier Deguillard
2bd669aeda win: remove unused enumerateDirectory
Summary: This is unused, no need to keep it around.

Reviewed By: wez

Differential Revision: D22361749

fbshipit-source-id: 3c353776437b59c6c7735652f7eb1ce052215e11
2020-07-24 22:28:27 -07:00
Xavier Deguillard
c25799bdb1 win: define a new struct for placeholder information
Summary:
Instead of overloading the FileMetadata struct that is used for directory
listing, let's use one tailored for our use. This will enable more flexibility
when deciding what to provide ProjectedFS. For instance, we could send the
InodeNumber so we don't need to do expensive path resolution for every notification.

Reviewed By: wez

Differential Revision: D22361751

fbshipit-source-id: 4801be45d8afc3af51e0a9564d9acb0a8e32255a
2020-07-24 22:28:27 -07:00
Xavier Deguillard
9aefef2064 win: make the dispatcher more Future friendly
Summary:
Futures are intended to be chained together and not synchronously waited one
after the other. While this may be one of the goal, it also paves the way to
enable ProjectedFS asynchronous notification handling.

While doing this, a bunch of code was moved from EdenMount.cpp to the
dispatcher itself, the rationale behind this is to follow what the unix
EdenDispacher with the long term plan to merge the 2 as much as possible.

Reviewed By: wez

Differential Revision: D22361750

fbshipit-source-id: fa679a8b94ff6f8b5a33782fdb6b129ab066c4d8
2020-07-24 22:28:27 -07:00
Xavier Deguillard
1d6c111452 win: bail on prjfs notification from edenfs
Summary:
Whenever EdenFS reads a file from the overlay, there is a risk of this
triggering a prjfs notification, especially when there is a discrepancy between
the actual state of the overlay, and what EdenFS thinks the overlay should look
like.

A simple example of this includes removing a materialized file in the overlay
when EdenFS isn't running, and running `hg status` when it's back up.  The
status call will try to compute the sha1 of the file, and thus will call into
the `CreateFile` API, which will then trigger an EdenFS callback to be called.
This callback will then try to recursively acquire the inode lock, which is
already held by the sha1 computation code. And that's a textbook example of a
deadlock.

To avoid this in the first place, let's simply refuse recursive callbacks. The
sha1 code will either have to be modified to handle errors, or we need to scan
the overlay when mounting the repo.

Reviewed By: fanzeyi

Differential Revision: D22288431

fbshipit-source-id: 2b4b31eddf7debcde55c22dd704d198ec44e59b4
2020-07-24 22:28:27 -07:00
Xavier Deguillard
ad5402810a win: make .eden/config an in-memory blob
Summary:
At mount time, EdenFS will try to create the .eden/config file which will
indicate to the client that this is an EdenFS repo, this config also contains
the location of the socket to talk to EdenFS.

On unices, and while the .eden directory is slightly different, the content of
this directory is written onto the overlay, but on Windows, the overlay is the
repository itself. What this means is that creating this config file will end
up triggering a ProjFS callback, which can potentially lead to deadlocks if
we're not careful.

A future change will simply prevent these recursive callbacks from happening
and thus a solution needs to be found for the .eden/config file itself. Since
the file itself is tiny (about 400B), and should only be accessed once[0], the
simple approach to keep it in memory and special case it works perfectly.

[0]: Once a file was read fully by ProjFS, it's present in the overlay and
     EdenFS will no longer be requested to provide it.

Reviewed By: chadaustin

Differential Revision: D22310734

fbshipit-source-id: 6b2dba2164496ebd251104d7875b51569be2471f
2020-07-24 22:28:27 -07:00
Chad Austin
be3683b1d4 refactor fuse handler table
Summary: Instead of static initializers, use constexpr arrays.

Reviewed By: wez

Differential Revision: D22672240

fbshipit-source-id: b43fe336e998acceacb042fc5cea7e0ceade2bbe
2020-07-24 13:03:07 -07:00
Ailin Zhang
03a2308028 get priority from ObjectFetchContext in BackingStore
Summary: Previously, `BackingStore` and all its sub-classes' `getBlob` and `getTree` methods accepted both `ObjectFetchContext` and `ImportPriority`  as arguments. Now, `ImportPriority`  is removed because we can get the priority from `ObjectFetchContext `

Reviewed By: kmancini

Differential Revision: D22650629

fbshipit-source-id: e1b0c57a059f11504b28b2c17d698bb58f51e1ee
2020-07-24 08:24:02 -07:00
Ailin Zhang
ce28ec8caa deprioiritize when fetch count exceeds threshold
Summary:
check fetch count before `getPriority()` is used. If fetch count has exceeded `fetchThreshold_`, lower the priority by 1.

Note: this diff only guarantees that the `getPriority()` function is returning the lowered priority. How the returned value is used for scheduling is handled by `HgQueuedBackingStore`

Reviewed By: kmancini

Differential Revision: D22550640

fbshipit-source-id: c032f8f72ca658618ac118dfb3ad3dcae61e9735
2020-07-24 08:24:02 -07:00
Ailin Zhang
102d8586cc make ObjectFetchContext own a copy of ImportPriority
Summary: Previously `getPriority()` always returned a fixed priority. Now that we want `ObjectFetchContext` to lower its priority, it is better to make it have its own copy of `ImportPriority`.

Reviewed By: kmancini

Differential Revision: D22550587

fbshipit-source-id: 029c797def477ae4533f66cfba146a3972cfb65d
2020-07-24 08:24:02 -07:00
Ailin Zhang
faa691ec33 change default value of ImportPriority
Summary: This diff ensures that the value of ImportPriority is always positive and changes offset from 0 to half of the maximum offset to allow lowering offset in the future.

Reviewed By: kmancini

Differential Revision: D22550462

fbshipit-source-id: 69f45369359c7b2c39a0c6831e9b33982e26a16a
2020-07-24 08:24:02 -07:00
Chad Austin
9ddaa5ff8e fix flakiness in mountIsShuttingDownWhileInodeIsReferencedDuringShutdown
Summary:
within() schedules work on the singleton timekeeper thread which
sometimes scheduled a timer callback on the ServerExecutor while
TestMount was shutting down, causing an assertion failure. Since
TestMount's executor is deterministic, just make the entire test
deterministic.

Reviewed By: genevievehelsel

Differential Revision: D22709150

fbshipit-source-id: 0a1621df0a9934bb7944fc259f7f83d110b35e93
2020-07-23 22:23:17 -07:00
Ailin Zhang
fb5d18666a allow specifying a mount for 'eden debug gc_process_fetch'
Summary: If the user specifies a mount, only clear for that mount, otherwise clear for all mounts.

Reviewed By: fanzeyi

Differential Revision: D22674210

fbshipit-source-id: 832c4fd37a63fdb44cb12844378b61d113731016
2020-07-23 11:54:12 -07:00
Ailin Zhang
20ae54a69b clear fetch counts using eden debug gc_process_fetch
Summary: add a thrift call to clear `pidFetchCount_` in `ObjectStore` and call it in `eden debug gc_process_fetch`. Users might want this command to start a new recording of process fetch counts.

Reviewed By: kmancini

Differential Revision: D22583430

fbshipit-source-id: eba7d63b08da5134fd09b7512895aba06f6a7ca5
2020-07-23 11:54:12 -07:00
Xavier Deguillard
31044a4cb2 thrift: do not test for socket before connecting to it
Summary:
In Windows 10 2004, the behavior of AF_UNIX socket changed slightly, a socket
on which a server is listening to now appears to be shown as a "reparse point"
on disk. This appears to confuse Python as `os.path.exists(socketpath)` no
longer returns `True` for a listened to socket, which means that edenfsctl
would not be able to communicate with EdenFS, even though it is up and running.

Windows still has this weird behavior where the socket is created on disk
during connect, but EdenFS knows about this and already retries several times
(D21755498 (2c5768404d)) to avoid the issue, it's therefore fine to remove this code.

Reviewed By: wez

Differential Revision: D22666081

fbshipit-source-id: e2eea3fdd7628354b8b187b76899be4e9e2fa17f
2020-07-22 15:37:14 -07:00
Katie Mancini
c6900de010 quiet noisy scs proxy hash logging
Summary:
lower the debug level for scs proxy hash logging so that this does not cause so
much noise in the logs of production eden

Reviewed By: chadaustin

Differential Revision: D22668574

fbshipit-source-id: 1a7c2a4706514c0ef0bb848424681eef9316d296
2020-07-22 13:10:07 -07:00
generatedunixname89002005287564
839c31572e Daily arc lint --take CLANGFORMAT
Reviewed By: zertosh

Differential Revision: D22661583

fbshipit-source-id: feb6b7fddee4809d8d089dd6eb51aa3f7185faed
2020-07-22 04:35:29 -07:00
Victor Zverovich
e3f4a56f6b Migrate to field_ref Thrift API
Summary:
We are unifying C++ APIs for accessing optional and unqualified fields:
https://fb.workplace.com/groups/1730279463893632/permalink/2541675446087359/.

This diff migrates code from accessing data members generated from unqualified
Thrift fields directly to the `field_ref` API, i.e. replacing

```
thrift_obj.field
```

with

```
*thrift_obj.field_ref()
```

The `_ref` suffixes will be removed in the future once data members are private
and names can be reclaimed.

The output of this codemod has been reviewed in D20039637.

The new API is documented in
https://our.intern.facebook.com/intern/wiki/Thrift/FieldAccess/.

drop-conflicts

Reviewed By: yfeldblum

Differential Revision: D22631599

fbshipit-source-id: 9bfcaeb636f34a32fd871c7cd6a2db4a7ace30bf
2020-07-21 11:23:35 -07:00
Chad Austin
8a19bac535 remove some journal update duplication
Reviewed By: genevievehelsel

Differential Revision: D21489112

fbshipit-source-id: c31808f68cda79ed20ef27415837eb89e11ca825
2020-07-21 00:39:55 -07:00
generatedunixname89002005307016
6527db2809 suppress errors in eden - batch 1
Reviewed By: pradeep90

Differential Revision: D22628389

fbshipit-source-id: c109334243a92269a7fb9a9b0515565ac22ecfac
2020-07-20 13:29:51 -07:00
Stanislau Hlebik
9d18c46b1f remediation of S205607
fbshipit-source-id: 798decc90db4f13770e97cdce3c0df7d5421b2a3
2020-07-17 17:16:13 -07:00
Stanislau Hlebik
3665548bb0 remediation of S205607
fbshipit-source-id: 5113fe0c527595e4227ff827253b7414abbdf7ac
2020-07-17 17:16:13 -07:00
Ailin Zhang
316698a3c6 add --mount option to eden debug processfetch
Summary: add `--mount` option to `eden debug processfetch` as users might want to know under which checkout they have run those commands.

Reviewed By: kmancini

Differential Revision: D22485225

fbshipit-source-id: df321e6c30064c17abc62584863119b362b2c296
2020-07-17 06:43:58 -07:00
Ailin Zhang
aef527dbb0 eliminate extra blank line in tabulate
Summary: Eliminate extra blank line in tabulate

Reviewed By: kmancini

Differential Revision: D22477405

fbshipit-source-id: b867bfa5c971fcac0104563e866a314416f24fb0
2020-07-17 06:43:58 -07:00
Ailin Zhang
2deb2f28eb eden debug processfetch
Summary:
This diff added a sub-command `process_fetch` to `eden debug`, which lists eden processes sorted by their fetch counts.

New argument options will be added in following diffs.

Reviewed By: fanzeyi

Differential Revision: D22456147

fbshipit-source-id: 75f94ec0ad03d59af1a5bf31c37bdf56de70241b
2020-07-17 06:43:57 -07:00
Chad Austin
d0fb86a240 add 4k random writes benchmark
Summary:
To help investigate a Linux kernel performance dropoff where the
kernel falsely thinks the EdenFS FUSE mount can't handle dirty page
writes at a high rate, add a 4k random writes benchmark.

Reviewed By: simpkins

Differential Revision: D21328771

fbshipit-source-id: c9977bd2e291d01e92631094aba3d8d807ec62da
2020-07-14 16:13:37 -07:00
Lee Howes
2254db881b Replace Future<T>::getTry with Future<T>::result
Summary:
Replace calls to Future<T>::getTry() with Future<T>::result().

This change is behaviour-neutral. It enables us to make the behavior of getTry
match expectations and be blocking, like get, and r-value qualfiied, like
SemiFuture<T>::getTry().

Reviewed By: yfeldblum

Differential Revision: D22527935

fbshipit-source-id: 7fa634375b71c13ee58cb699e5ac8dcd37fe9c30
2020-07-14 11:04:12 -07:00
Claire (Yue) Zhang
ee52d3b641 Deprecate setMinCompressBytes on Thrift Server (4/n)
Summary:
Deprecate server-side minCompressBytes.

Background:
The minCompressBytes on ThriftServer is another knob to control whether or not to compress payloads. The reason to deprecate it is twofold:
(1) to provide a single place for compression control.
(2) 99.99% of services only copy-paste the default value (200) anyways.

Since rocket transport will be the default transport for all future thrift RPC, D21702725 introduced the ability for client to pass CompressionConfig to server (in rocket) which informs server both codec and size limit. This way the compression is enabled and controlled only from the client-side.

Reviewed By: iahs

Differential Revision: D22354858

fbshipit-source-id: dd920d4d38969f8ee7894b1aaafbe71c0e8b8d86
2020-07-14 10:24:25 -07:00
Xavier Deguillard
3e529c2f92 win: move EdenMount::fetchFileInfo into EdenDispatcher
Summary:
This function is only used in EdenDispatcher, and all of it can be achieved by
simply calling InodeBase::stat method to fetch the file size.

As a bonus, the code now uses future continuation, instead of individual calls
to `get`.

Reviewed By: chadaustin

Differential Revision: D22310733

fbshipit-source-id: c81be7dd114c3a9bebc6b1b5b0887ae3ade30602
2020-07-14 00:02:44 -07:00
Xavier Deguillard
92d32045a9 win: remove WinStore and fold it in EdenDispatcher
Summary:
The WinStore was only used for 2 simple things: checking that a file is
present, and getting its blob. Since both of these are trivial to implement
with EdenMount, there is no reason for WinStore to exist.

Reviewed By: chadaustin

Differential Revision: D22288430

fbshipit-source-id: 90567ac39b5124039becd3599766fcd0cde3e9aa
2020-07-14 00:02:44 -07:00
Xavier Deguillard
1412938382 win: implement edenfsctl stats
Summary:
While there isn't a direct equivalent to the unix RSS and VSZ, the working set
size and the page file usage can be used instead, they roughly have the same
meaning and that's probably good enough.

I've also moved the private bytes into the MemoryStats as it's a memory stat
too.

Reviewed By: chadaustin

Differential Revision: D22081006

fbshipit-source-id: d597d523eee21e7651a14e60b1fd6dc152a61185
2020-07-14 00:02:43 -07:00
TJ Yin
3855fddd0f Remove thrift setters
Summary:
Thrift setter API is deprecated since it doesn't bring any value over direct assignment. Removing it can reduce build-time and make our codebase more consistent.

If result of `s.set_foo(bar)` is unused, this diff replaces

    s.set_foo(bar);

with

    s.foo_ref() = bar;

Otherwise, it replaces

    s.set_foo(bar)

with

    s.foo_ref().emplace(bar)

Reviewed By: chadaustin

Differential Revision: D22487354

fbshipit-source-id: d2f77c1410dc9b83805cb12f818f01eb939d0e29
2020-07-13 14:30:00 -07:00
Lee Howes
63faf1efd6 Replace Future::getTry with Future::result
Summary:
Replace calls to Future<T>::getTry() with Future<T>::result().

This change is behaviour-neutral. It enables us to make the behavior of getTry
match expectations and be blocking, like get, and r-value qualfiied, like
SemiFuture<T>::getTry().

Reviewed By: chadaustin

Differential Revision: D22510034

fbshipit-source-id: bd45cc6a404293089371654829a63c81b1c706aa
2020-07-13 14:14:30 -07:00
Chad Austin
58cf030382 prepare for unique_ptr AsyncSocket::newSocket
Summary:
AsyncSocket::newSocket will soon return a unique_ptr. In preparation,
explicitly update the call sites to move instead of copy the socket
when possible.

Reviewed By: simpkins

Differential Revision: D22402156

fbshipit-source-id: 52580826fb70fea915cf124d264bbe13bd56484e
2020-07-13 12:34:28 -07:00
Katie Mancini
a701242bf7 fetch aux data on corp
Summary:
This extends the metadata importer to work on corp.

Prefetching metadata for the entries in a tree when we fetch it saves us
an extra round trip to the server to fetch a blob when only the metadata
for that blob is fetched. This is particularly important on corp where the
latencies to the server are larger.

Requesting metadata with out the blob itself happens often in the parsing
phase of buck commands, thus this metadata prefetch should improve
the build times, and other work flows that rely heavily on buck queries.

Reviewed By: chadaustin

Differential Revision: D21698728

fbshipit-source-id: 4072be23f2fa7df33cf46879e8c1d8ddd6c316ba
2020-07-10 16:03:32 -07:00
Katie Mancini
614729cb49 Fetch aux data for blobs from scs
Summary:
Buck uses the content SHA-1 to identify each of the source files for a target.
During the parsing phase it needs these SHAs, though the content of the
files is not yet needed, and may never be needed if the file has already
been built and is in the buck cache.

Currently, if we do not already have metadata cached for a file when
requested we fetch the contents of the file, and compute the hash.

We want to avoid this.

Eventually this data will be available from the Mononoke EdenAPI server,
but for now we want a temporary solution to unblock the Buck team, and
ship benefits early.

Reviewed By: chadaustin

Differential Revision: D21820913

fbshipit-source-id: 56a7e32519f0fb04881518306d94aaed33527fd9
2020-07-10 16:03:32 -07:00
Katie Mancini
4962a7face tree metdata storage
Summary:
Prefetching metadata for the entries in a tree when we fetch it saves us
an extra round trip to the server to fetch a blob when only the metadata
for that blob is fetched. (This can happen often while parsing targets in
builds)

We will to prefetch the metadata for each of the entries in a tree when
we fetch the tree and store the metadata for each entry under that
entries id (to make looking up the entry metadata by its id quick)

However, we also don't want to unnecessarily fetch data from
the server if we already done so.

To accomplish this we will also store the metadata for each entry under the tree
id in the local store. This will: 1) allow us to check if we have already fetched
the metadata from the server when we are fetching a tree (we only have the
tree id easily available here to storing the metadata under the tree id makes
it much easier/less expensive to do this check). 2) allow us to refil the
metadata for each entry stored under that entries blob id if it has been cleared
from the local store (this may happen is the local store is gets large and gets
partially cleaned to reclaim space).

This implements the method to store tree metadata for all entries under the tree
id and under the blob id for each entry.

Reviewed By: chadaustin

Differential Revision: D22239173

fbshipit-source-id: d4e0ffd642ce0b4034188cfc4eeaf2ea05f54e77
2020-07-10 16:03:32 -07:00
Katie Mancini
d2b4855372 introduce scs metadata importer
Summary:
Prefetching metadata for the entries in a tree when we fetch it saves us
an extra round trip to the server to fetch a blob when only the metadata
for that blob is fetched. (This can happen often while parsing targets in
builds)

This implements a custom metadata fetcher to fetch this data when we
fetch a tree from the server.

Reviewed By: chadaustin

Differential Revision: D22086639

fbshipit-source-id: 5fe31d375bf6f7376eb67496d553d6b4540fc0c9
2020-07-10 16:03:32 -07:00
Katie Mancini
af70a36a41 introduce metadata importer
Summary:
This will allow adding custom MetadataImporters in different eden builds.

DefaultMetadataImporter provides a no-op version of the interface to be
used by default.

Reviewed By: chadaustin

Differential Revision: D21960834

fbshipit-source-id: aec8a3627ab1223f74466b92a0ebe3290b67b7ed
2020-07-10 16:03:32 -07:00
Katie Mancini
26a7f3ad25 Wrap backing stores copy of local store in shared ptr
Summary:
Previously the BackingStore kept a raw pointer to the LocalStore. To do this we relied on EdenServer ensuring the lifetime of the LocalStore exceeds that of the BackingStore.

This makes the LocalStore pointer a shared pointer to explictly make sure that the LocalStores lifetime matches the BackingStores lifetime.

Reviewed By: chadaustin

Differential Revision: D22394597

fbshipit-source-id: c81cb26c6fc8f834bc46d8576ced06ba6a96ac2c
2020-07-10 16:03:32 -07:00
Katie Mancini
550400364d introduce tree metadata storage in local store
Summary:
This introduces a class to manipulate the metadata for all the entries in a
tree. This adds serialization and deserialization to this class so that it can
be written to the local store.

Why do we need this? We need some way to easily check when we have already
fetched metadata for a tree and do not need to refetch this from the server to
avoid expensive network requests. Later diffs add functionally to store the metadata
for tree entries in the local store under the tree hash using this class.

Reviewed By: chadaustin

Differential Revision: D21959015

fbshipit-source-id: 0c0e8750737f3076c1f9604d0319cab7f2658656
2020-07-10 16:03:32 -07:00
Katie Mancini
264d749d67 record ScsProxyHash in LocalStore during import
Summary:
In following diffs we will use scs to prefetch meta-data for files, so that this data
will be available with out fetching the file content (which will improve build times
on eden).

This builds up the proxy hash index that serves as a conversion between eden
specific identifiers and commit and path which we will use to index into scs.

Reviewed By: chadaustin

Differential Revision: D21820909

fbshipit-source-id: 17891f6772f49c7c183061d7a4df2fe0a3be9d25
2020-07-10 16:03:32 -07:00
Katie Mancini
dc94bc8916 create scs proxy hash
Summary:
In following diffs we will use scs to prefetch meta-data for files, so that this data
will be available with out fetching the file content (which will improve build times
on eden).

SCS indexes trees by an scs specific hash (blake2 content hash) or by the commit
hash and path. Since this is different from the eden hashes and mercurial
hashes, we need another index to go between the current ids we have in eden
and identifiers for scs.

This introduces a proxy hash that serves as this conversion. Because we have
commit hashes around in eden right now, this is an easier route to indexing
into scs currently.

Reviewed By: chadaustin

Differential Revision: D21237648

fbshipit-source-id: 79115ac034a5f062ae879713cd2c1a17f348c725
2020-07-10 16:03:31 -07:00
Ailin Zhang
763f855e5a show fsck progress animation bars
Summary: This diff updated `eden start` to show animated fsck progress bars

Reviewed By: genevievehelsel

Differential Revision: D22357699

fbshipit-source-id: f399cc78fc25c85100e5931505ce787899c3fff4
2020-07-09 14:43:42 -07:00
Zeyi (Rice) Fan
30ba5cf783 fix missed use of Path.resolve
Summary:
There was some missed usage of `Path.resolve`. This diff should cover it all.

```
cli $ rg -F ".resolve"
main.py
967:        uid = self.resolve_uid(args.uid)
968:        gid = self.resolve_gid(args.gid)

util.py
622:    `Path.resolve`. This is a helper method to work around that by using
628:    return path.resolve(strict=strict)
```

Reviewed By: chadaustin

Differential Revision: D22459188

fbshipit-source-id: c2a1b132f752cc399ebf34723f26123559939f2a
2020-07-09 13:03:58 -07:00
Chad Austin
1031c6a211 stop shipping hg_import_helper.py
Summary:
proxy_import_helper.py exists for compatibility with older EdenFS
builds. None of those builds are running anymore, so remove it.

Reviewed By: genevievehelsel

Differential Revision: D22451196

fbshipit-source-id: 4d258b3fafe13bb67bd11259f5d1193a7e5575e6
2020-07-09 11:28:07 -07:00
Ailin Zhang
a1163c34f2 using ProgressCallback type for simplification to print fsck messages
Summary: This diff defines `Overlaychecker::ProgressCallback` to replace repetitive function type declaration.

Reviewed By: genevievehelsel

Differential Revision: D22243160

fbshipit-source-id: ea05e451817a760b5266879b956eaea48dc8d85e
2020-07-09 11:13:18 -07:00
Katie Mancini
df2b9b9009 open all RocksDB column families for backwards compatabiliy
Summary:
From the Rocks DB documentation:

> When opening a DB in a read-write mode, you need to specify all Column
Families that currently exist in a DB. If that's not the case, DB::Open call
will return Status::InvalidArgument()

This can cause problems for us in a couple of situations:
- When we need to rollback from an eden version where we added a column to
our configuration for RocksDB
- When we delete a column from our configuration for RocksDB

To make sure we do not encounter this error we need to make sure that we still
open all the columns existing in the database, even if they are not in our
configured list of family columns.

Reviewed By: wez

Differential Revision: D22425310

fbshipit-source-id: 9822b22cfedf4633f65bbed96f95a546dd3614f4
2020-07-09 10:28:14 -07:00
Katie Mancini
81a21ac4fa Increase process cmdline buffer
Summary:
Currently when we are resolving the full command line for a client pid, we only
read the first 256 bytes of the command.

This means that some commands will be truncated, this has come up in some
of our recently added logs. This ups the buffer size so that we can
hopefully get the full command line.

The longer term solution would be to implement the something fancier mentioned
in the comment in the code copied below, but also has drawbacks as mentioned.

> // Could do something fancy if the entire buffer is filled, but it's better
// if this code does as few syscalls as possible, so just truncate the
// result

Reviewed By: wez

Differential Revision: D22436219

fbshipit-source-id: 80a9aecfe148aa3e333ca480c6a8cb8b9c5c86f2
2020-07-08 15:48:15 -07:00
Chad Austin
4c0996afa5 make systemd management functions explicitly async
Summary:
Rather than dynamically allocating an event loop in the systemd async
code, make all the corresponding functions async, so the caller is
responsible for threading an event loop down.

Reviewed By: genevievehelsel

Differential Revision: D21894106

fbshipit-source-id: 398c769c30c85a3bb210dbc209f34f9f7336996c
2020-07-07 11:31:33 -07:00
Genevieve Helsel
bda44c5201 move is_system_idle to procutils
Summary: I'd eventually like to use this in the edenfs_monitor, so moving it to `proc_utils` for sharibility.

Reviewed By: chadaustin

Differential Revision: D21998763

fbshipit-source-id: 052e78fb8e58515f98eb465b8041fd0e621fc9da
2020-07-07 11:22:33 -07:00
Genevieve Helsel
cd1196bb28 move eden idleness detection to EdenFSProcess
Summary: I'd eventually like to use this in the edenfs_monitor, so I'm adding this to `proc_utils` for future ease of use.

Reviewed By: chadaustin

Differential Revision: D21987390

fbshipit-source-id: 076672b44311c2a1e0cac934c0674a18a87649af
2020-07-07 11:22:33 -07:00
Genevieve Helsel
0f9cff3b88 Add tests for ignored file with carriage return in name
Summary: On macOS, "Icon?" (aka "Icon\r") is a sometimes added. This file is weird to ignore, and should be ignored using "Icon\r\r" or "Icon[/r]". This won't be hidden with "Icon\r" or "Icon\r"

Reviewed By: chadaustin

Differential Revision: D22050682

fbshipit-source-id: 51d7d4c2414a07b959120455ae991d2425c1ea4d
2020-07-07 11:13:12 -07:00
Ratnadeep Joshi
ce4b8122ae Some minor modifications to verbiage in documentation
Summary: [edenfs] Some minor modifications to verbiage in documentation

Reviewed By: chadaustin

Differential Revision: D22394129

fbshipit-source-id: 2d662e56d621fd5e5d5ba6de284ca3d08f8bd4e5
2020-07-06 22:20:17 -07:00
Zeyi (Rice) Fan
21c11f4921 make FuseRequest high priority & TreePrefetchLease low priority
Summary:
This is much better than having `ObjectFetchContext` itself owns a copy of `ImportPriority`. We can actually customize how different fetch context manages these priority.

We set all FUSE requests to a higher priority and prefetch requests to a lower priority

Reviewed By: xavierd

Differential Revision: D22342802

fbshipit-source-id: b9c1d0f2ddbc7a5e5d619bc2c2222e5df0e702af
2020-07-02 12:00:45 -07:00
Zeyi (Rice) Fan
07452335fb use ObjectFetchContext for priority
Summary: This commit switch from explicitly specifying `ImportPriority` into passing priorities from `ObjectFetchContext`.

Reviewed By: xavierd

Differential Revision: D21872720

fbshipit-source-id: 26055eff21cab4ce6370e96ac3acbac2fd6af3f0
2020-07-02 12:00:45 -07:00
Zeyi (Rice) Fan
d10b17a031 make prefetch in TreeInode low priority
Summary:
This commit makes prefetch requests derived in `TreeInode` assigned to lower priority.

Since prefetch is not running under the original request's context, we create a new `ObjectFetchContext` specifically for this case, and attach it to `prefetchLease` since it is guaranteed to be alive during the span of prefetch.

Reviewed By: chadaustin

Differential Revision: D21872719

fbshipit-source-id: d1495b06031980d7d1c21ecf2a0b47e83fc9672d
2020-07-02 12:00:45 -07:00
Zeyi (Rice) Fan
5030f0be35 add ImportPriority to ObjectFetchContext
Summary:
This commit adds `ImportPriority` to `ObjectFetchContext`. By doing so we can tweak priority for a request at different stage.

This commit also provides a default implementation for the virtual methods in `ObjectFetchContext` so we can create one to carry `ImportPriority` in some specific cases.

Reviewed By: chadaustin

Differential Revision: D21872718

fbshipit-source-id: 6e8cfd84959b368e6fe69fda2baf0debf7a88295
2020-07-02 12:00:45 -07:00
Zeyi (Rice) Fan
99f8448e99 adding ObjectFetchContext to readdir
Summary: This commit makes `readdir()` to correct send its `RequestContext`  to `EdenDispatcher` method so underlying code can know the current request being processed is from FUSE.

Reviewed By: xavierd

Differential Revision: D21821949

fbshipit-source-id: f41ba912fedbfc040e3c9267aad25e7f33f8e912
2020-07-02 12:00:45 -07:00
Ailin Zhang
7c603e51f8 make fetch heavy threshold configurable
Summary: This diff made fetch threshold configurable, so we can change it later as repository size grows.

Reviewed By: fanzeyi

Differential Revision: D22337850

fbshipit-source-id: 4b46420cb4e7164a3f1080279d67fa5f90549cd8
2020-07-02 08:44:02 -07:00
Ailin Zhang
36fd61dbaa send fetch heavy events to Scuba
Summary: This diff updated `ObjectStore` to send a `FetchHeavy` event to Scuba when the number of fetching requests of a process has reached 2000.

Reviewed By: fanzeyi

Differential Revision: D22292104

fbshipit-source-id: b7ac48412868216ea960c8681a5fb71c587952bc
2020-07-02 07:57:15 -07:00
Xavier Deguillard
9fee1b5008 win: disallow hardlink
Summary:
Hardlinks aren't supported on EdenFS, let's not silently allow them since this
can cause unintended behavior. It's possible that this might break some
workflows, but it's better to be strict about this.

Reviewed By: genevievehelsel

Differential Revision: D22250849

fbshipit-source-id: 9f90e6a8e9c9715bb4b925c3d7f952e965683081
2020-07-01 16:16:56 -07:00
Xavier Deguillard
873406ae96 win: do not ignore errors in notification callbacks
Summary:
Errors are usually a sign that we're doing something wrong. Ignoring them can
thus lead to weird behavior, hence let's not ignore them. This may have the
potential to breaking user applications if they were doing something we're not
handling properly, but it was likely that EdenFS was broken in a subtle way. We
should be able to better understand what's wrong and fix it properly then.

Reviewed By: genevievehelsel

Differential Revision: D22250852

fbshipit-source-id: 91daa60065b5621542aee1ca3207d1d7c54f8639
2020-07-01 16:16:56 -07:00
Xavier Deguillard
9de603d063 win: rework rename notification a bit
Summary:
When files are moved in and out the repo, the paths being passed in might be
empty. For code clarity, let's treat these as file creation and removal.

We also do not need to actually tell ProjectedFS about removed files, since
ProjectedFS is actually telling us that the file is moved/removed.

Reviewed By: fanzeyi

Differential Revision: D22250851

fbshipit-source-id: a678e58eb9c36d4dcbf1bb41d56b38fef8943284
2020-07-01 16:16:56 -07:00
Xavier Deguillard
6d97b429ad win: wait on unlink/rmdir/rename futures
Summary:
If we don't wait on these futures, they might never execute, which may lead to
EdenFS not being aware of files no longer present in the overlay.

For now, just add .get() to these futures, but really, we need to make these be
futures themselves and use continuation style code.

Reviewed By: fanzeyi

Differential Revision: D22326570

fbshipit-source-id: 7584981bec284f35f8d2689a3a5dafd1a111a3d8
2020-07-01 10:16:16 -07:00
Genevieve Helsel
da7b453306 fix AssertionError if a checkout is in the middle of a merge
Summary:
An assertion error is raised if `eden doctor` is in the middle of a merge. This is because we enter a specific "if" condition in the case that mercurial has two parent commits, and EdenFS only ever tracks `p0`, so EdenFS simply sets `p1` to the null commit in `_select_new_parents()`. Specifically, this is in the case in which both `_old_dirstate_parents` and `_old_snapshot` are not None.

Because `_old_dirstate_parents` has `p1` set to nonnull, and Eden thinks it is null , the check `self._new_parents != self._old_dirstate_parents` would be `True` even though there was actually no error.

Reviewed By: chadaustin

Differential Revision: D22048525

fbshipit-source-id: 9a19cc092e2bd80db0e01fb38533a1007640bee6
2020-06-30 13:58:21 -07:00
Xavier Deguillard
1ed57a034a win: remove dead code
Summary: None of this code is used, just remove it.

Reviewed By: genevievehelsel

Differential Revision: D22083565

fbshipit-source-id: ad24a0e8ea04797e146ebb9b99c125539197cb89
2020-06-30 13:47:13 -07:00
Adam Simpkins
14a289528d fix a crash in edenfsctl top
Summary:
Older versions of EdenFS do not return the `fetchCountsByPid` field in the
`getAccessCounts()`.

The Python thrift client code returns this as `None` instead of as an empty
dictionary.  This behavior arguably seems like a bug in the thrift code, since
the field is not marked optional.  However, updating the thrift behavior would
have much wider implications for other projects.  Additionally it's probably
not worth putting a lot of effort in to the older "py" thrift generator code.

Update the `edenfsctl` code to explicitly use an empty dictionary if the value
received from the thrift call is `None`

Reviewed By: fanzeyi

Differential Revision: D22302992

fbshipit-source-id: eced35a19d86e34174f73e27fdc61f1e2ba6a57f
2020-06-29 20:43:01 -07:00
Xavier Deguillard
426e1ee41d inodes: fix typo in EdenDispatcher
Summary: The method name is symlink, not rmdir.

Reviewed By: genevievehelsel

Differential Revision: D22291297

fbshipit-source-id: 5dc37b053e06c965fd47df79990fc40adc097f87
2020-06-29 16:17:21 -07:00
Xavier Deguillard
99ca6c74d9 win: do not ignore notification from .hg and .eden
Summary:
While suppressing notification should in theory be faster than getting
notification, it however causes a couple of issues due to the fact that EdenFS
is simply not creating inodes for any of the files in these directories.
Renaming a file in and out of these directories would for instance fail, due to
the inode not being present.

Since these directories are very low traffic overall and on Linux/macOS these
are not treated specifically (well, except for .eden, but that's a different
story), let's do the same on Windows.

Reviewed By: chadaustin

Differential Revision: D22250850

fbshipit-source-id: c13ed29faedc33c98b1a30227e44afc3f2c84c89
2020-06-26 10:41:28 -07:00
Xavier Deguillard
c1a6d6fd21 dirstate: paths in hg are unicode, not bytes
Summary:
This was causing `hg mv` to fail due to trying to hash a unicode path, but
Python3 refuses to hash anything but bytes.

Reviewed By: DurhamG

Differential Revision: D22235561

fbshipit-source-id: 3eb80b8e02d442a4036ab7be7ea5c139bd24ff5e
2020-06-25 15:48:00 -07:00
Xavier Deguillard
a935fc38b4 inodes: fix casing issue on Windows
Summary:
On Windows, paths are case insensitive (but the filesystem is case preserving),
and thus `open("FILE.TXT")` and `open("file.txt")` refer to the same file. When
that file is not materialized and its parent directory isn't yet enumerated,
PrjFS will call the PRJ_GET_PLACEHOLDER_INFO_CB with the file name passed in to
the `open` call. In this callback, if the passed in name refers to a valid
file, it needs to call PrjWritePlaceholderInfo to populate the directory entry.
Here is what the documentation for that function states:

"For example, if the PRJ_GET_PLACEHOLDER_INFO_CB callback specifies
dir1\dir1\FILE.TXT in callbackData->FilePathName, and the provider's backing
store contains a file called File.txt in the dir1\dir2 directory, and
PrjFileNameCompare returns 0 when comparing the names FILE.TXT and
File.txt, then the provider specifies dir1\dir2\File.txt as the value of
this parameter."

While the documentation doesn't state how that name is used internally, we can
infer (and test) that the returned case will be used as the canonical
representation of that file, ie: the one that a directory listing will see.

Since the PathMap code already does a case insensitive search, we just need to
make sure to use what it returns instead of re-using the name used for the search.

The only caveat to all of this is the original comment that describe that
`metadata.name` can't be used as it causes crashes. From what I can tell, this
was written in later 2018, and I believe is no longer relevant: the
`metadata.name` field was simply not populated.

Reviewed By: wez

Differential Revision: D21799627

fbshipit-source-id: aee877cc2d5f057944fcd39b1d59f0e97de6315c
2020-06-24 18:59:16 -07:00
Ailin Zhang
dde49c1c44 add a new column FUSE FETCH to eden top to display fetchCounts
Summary:
updated `eden top` to:
- obtain PID-fetchCounts data from the updated -`getAccessCounts` thrift call in the previous diff
- display that data in a new column `FUSE FETCH`

Reviewed By: kmancini

Differential Revision: D22101430

fbshipit-source-id: 6584e71ce3a4629c73469607ca0a4c6ffd63e46f
2020-06-24 15:56:14 -07:00
Ailin Zhang
c33f8ba494 add PID-fetchCount map data to the result of getAccessCounts
Summary:
This diff updates `getAccessCounts` to
- obtain the PID-fetchCount map data added in the previous diff
- put that data into its `result`

Reviewed By: kmancini

Differential Revision: D22101232

fbshipit-source-id: 1d41715339d418b03c17f6c93a7a497b432973ae
2020-06-24 15:36:51 -07:00
Xavier Deguillard
bd26254f79 eden: fix windows build
Summary:
Both optional and pid_t weren't found and the right includes needed to be
provided. On Windows, the ProcessNameCache isn't compiled (yet), and since it
looks like the process name is optional in the BackingStoreLogger, let's not
provide it for now.

Reviewed By: fanzeyi

Differential Revision: D22215581

fbshipit-source-id: 31a7e7be62cd3d14108dc437d3dfabfb9e62f8d5
2020-06-24 15:12:47 -07:00
Zeyi (Rice) Fan
4e7af724fb avoid using Path.resolve on Windows
Summary:
On Windows, `pathlib.Path.resolve` has an use of uninitialized memory bug in Python 3.6.2. Lego Windows has this version of Python 3 installed.

When `eden prefetch` runs, it will first attempt to read the config file at the root of the repository (`$REPOROOT/.eden/config`). Because of this bug, when we normalize the path in edenfsctl, it will get some random bytes as a result. This subsequently causes `toml.read` to fail as it is unable to read a path containing NUL byte.

As you can see, this is the same exception as we see on Windows:

```
In [1]: open("test\x00")
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-57764b20d660> in <module>
----> 1 open("test\x00")

ValueError: embedded null byte
```

Reviewed By: xavierd

Differential Revision: D22177997

fbshipit-source-id: ab2565c8946d809bc15bc1597b749fb5e9440ca0
2020-06-23 16:55:13 -07:00
Katie Mancini
f8d69a24cf fix rendering of process commands in eden top
Summary:
`eden top` often adds extra quotes to the end of the commands in the process
table, this removes those pesky quotes

Reviewed By: genevievehelsel

Differential Revision: D21440316

fbshipit-source-id: f1200a28a5345691fcce517526d119f44e5993d0
2020-06-23 13:39:45 -07:00
Katie Mancini
1876c4e77b adding logging for selective paths
Summary:
Eden can sometimes unexpectedly fetch files from the server, and we want
to know why this is happening. This adds logging for the source of
data fetching in edens backing store to help obviate why these fetches
are happening.

This temporarily adds the logging in the HgQueuedBacking store to get a naive
version of logging rolled out sooner. Follow up changes will move this logging
closer to the data fetching itself if possible (in HgDatapackStore and HgImporter).

Reviewed By: chadaustin

Differential Revision: D22012572

fbshipit-source-id: b1b012ce4ee133fbacecd586b7365c3c5a5386df
2020-06-23 10:02:41 -07:00
Katie Mancini
8d32611a23 add data fetch logger
Summary:
We have seen that eden will unexpectedly fetch data, we want to know why.

This adds the plumbing to interact with edens current logging to be able to
log when eden fetches data from the server and what caused eden to do this
fetch. Later changes will use the classes created here to log the cause of data
fetches.

Reviewed By: chadaustin

Differential Revision: D22051013

fbshipit-source-id: 27d377d7057e66f3e7a304cd7004f8aa44f8ba62
2020-06-23 10:02:41 -07:00
Katie Mancini
fdb1af8bc9 add cause info to objectFetchContext
Summary:
Recently the server team added an un-used directory to test that eden would not
fetch these as a test for the upcoming repo merge. They saw that these files
were fetched a non trivial number of times. We want to know why eden is causing
these fetches.

This adds the pid and interface through which the client is interacting with eden to
ObjectFetchContext for this purpose. This information will be logged in later
changes.

note: currently this is only for fetches through Fuse (thrift interface to follow).

Reviewed By: chadaustin

Differential Revision: D22050919

fbshipit-source-id: 49b93257a0e6d910f48b1e8ec6471527e056d22a
2020-06-23 10:02:40 -07:00
Katie Mancini
a0b05b4bf0 thread ObjectFetchContext to backing store
Summary:
This passes ObjectFetchContext into the backing store to prepare for adding
logging for the cause of server fetches.

In following changes I will add logging in the HgQueuedBackingStore.
Ultimately we will want to move this logging to be closer to the data fetching
(in HgDatapackStore and HgImporter), but I plan to temporarily add logging to
the HgQueuedBackingStore to simplify so that we can more quickly roll out.

Reviewed By: chadaustin

Differential Revision: D22022992

fbshipit-source-id: ccb428458cbf7a1e33aaf9be9d0d766c45acedb3
2020-06-23 10:02:40 -07:00
Katie Mancini
480277e328 refactor - move ObjectFetchContext to its own file
Summary:
In following changes I will be threading ObjectFetchContext into the backing
store importing process, since this will start to be used more outside of the
ObjectStore, I am moving this class into its own files.

Reviewed By: chadaustin

Differential Revision: D22022488

fbshipit-source-id: 1a291fea6e0fd56855936962363dfc9f6de8533d
2020-06-23 10:02:40 -07:00
Chad Austin
65e7a01d6f allow async subcmd run functions
Summary: In advance of peppering async everywhere, allow subcmd's run method to be async.

Reviewed By: genevievehelsel

Differential Revision: D21892187

fbshipit-source-id: f611faacf95649d8bb5588aeefc4546bd5f63984
2020-06-22 11:27:11 -07:00
Ailin Zhang
cec1cf648c make ObjectStore manage a PID-fetchCounts map
Summary: This diff adds a PID-fetchCounts map to `ObjectStore` and makes `ObjectStore` update that map after every `didFetch`

Reviewed By: kmancini

Differential Revision: D22100413

fbshipit-source-id: 740342c7b4a453fe482344c2db9542381c3772e4
2020-06-19 21:07:49 -07:00
Xavier Deguillard
51df752a46 cli: support re-mounting a repo on Windows
Summary:
On Windows, we can't rely on the .eden directory to not be present to decide if
the repository is mounted. Instead, we can just let edenfs decide and catch the
exception if it tells us that it's already mounted.

Reviewed By: fanzeyi

Differential Revision: D21934538

fbshipit-source-id: 60ed9f530456b627091f95f7387dc4b8f3a8dc5c
2020-06-19 18:13:20 -07:00
Xavier Deguillard
7862d8fde0 mount: enable unmount
Summary:
All the unification of the mount code lead to this point, where supporting
unmount is merely just removing the various #ifdef.

Reviewed By: fanzeyi

Differential Revision: D21797078

fbshipit-source-id: 7602eb85e3fa276b72daebda36ae269ec38cde66
2020-06-19 18:13:19 -07:00
Xavier Deguillard
4fcdd44819 prjfschannel: add a stop promise
Summary:
On unmount, the code relies on the channel (fuse/prjfs) to set a promise, while
not strictly required on Windows as the interface is synchronous, this will
enable unmount to be the same between on all platforms.

Reviewed By: fanzeyi

Differential Revision: D21797081

fbshipit-source-id: c3eac448d2b13ef49db7a7d1f36bb084130ea63a
2020-06-19 18:13:19 -07:00
Xavier Deguillard
ffb214384d mount: unify channelMount
Summary:
Most of what fuseMount does can be shared between fuse and prjfs, so let's
rename it and start using it on Windows.

Reviewed By: fanzeyi

Differential Revision: D21797079

fbshipit-source-id: b92a36ecc702ee72df8ebdf9534add42bea9b97e
2020-06-19 18:13:19 -07:00
Chad Austin
6d79d2559a fall back on the subprocess telemetry logger when necessary
Summary:
When the scuba telemetry logger is unavailable, fall back on the
subprocess.

Reviewed By: genevievehelsel

Differential Revision: D21687855

fbshipit-source-id: c58a4bc1b34974add35d194c8aafdaac7ed47fdb
2020-06-19 15:15:26 -07:00
Xavier Deguillard
baa6894151 store: reap importer when the importer thread dies
Summary:
On Windows (haven't verified on other platforms), ThreadLocalPtr don't appear
to be releasing resources when a thread die. This means that when the importer
thread dies, the actual importer (hg.real) would still run and use resources,
with no way of talking to it.

To fix this, let's manually reset it when the main thread function returns,
this forces the importer to be destroyed and therefore the various handles to
hg.real to be released, effectively terminating it.

I'm not sure if this is the proper fix, but delving into folly feels a bit
daunting. Keeping a TODO for later to go back to it and fix it properly in
folly.

Reviewed By: chadaustin

Differential Revision: D22012540

fbshipit-source-id: 99f994bb5128b38ccf8474031763b8a21055759a
2020-06-18 20:41:53 -07:00
Zeyi (Rice) Fan
6700fa7d08 adding ObjectFetchContext to lookup
Summary:
This diff makes `lookup` to use `RequestData` as `ObjectFetchContext` in `getattr` calls.

This will make sure we correctly record backing store fetches in `eden top`

Reviewed By: chadaustin

Differential Revision: D21780969

fbshipit-source-id: 468e2fadcebf4a00477bc5de434e6c658b99d1ce
2020-06-18 10:40:41 -07:00
Zeyi (Rice) Fan
b9332b3673 adding ObjectFetchContext to getattr
Summary: This diff teaches `getattr` to accept `ObjectFetchContext` and pass along.

Reviewed By: chadaustin

Differential Revision: D21780970

fbshipit-source-id: 0f4b1295753281420323a3b33ce76af0ff386587
2020-06-18 10:40:41 -07:00
Zeyi (Rice) Fan
ec622e8e1c start to accept ObjectFetchContext to InodeBase::stat()
Summary: This diff makes `InodeBase::stat()` to be able to accept `ObjectFetchContext` as a parameter.

Reviewed By: chadaustin

Differential Revision: D21780883

fbshipit-source-id: 9b1db2e2268cb98663bcf902ea61897da593ea05
2020-06-18 10:40:41 -07:00
Zeyi (Rice) Fan
7c483e1c02 use RequestData as ObjectFetchContext in read()
Summary: This diff starts to use `RequestData` as `ObjectFetchContext` in our `read()` methods. This ensures EdenFS could track backing store fetches happened in FUSE requests.

Reviewed By: chadaustin

Differential Revision: D21792503

fbshipit-source-id: 9509a1bc8f28100a0dfe196e312c4785c7842345
2020-06-18 10:40:41 -07:00
Zeyi (Rice) Fan
ae0d08f884 record backing store import in RequestData
Summary:
Previously we check if a request is a fuse request when we fetch anything from backing store, so we can collect number of fetches happened for each process in eden top.

This is creating a dependency from store to fuse, which is a little awkward. Instead, we could make `RequestData` a `ObjectFetchContext` and record the fetches when that happens.

Similarly in the future we should also have something equivalent in our Thrift layer.

Reviewed By: kmancini

Differential Revision: D21775919

fbshipit-source-id: 95056830ddbe7c999051c43e0d8eca9a67350904
2020-06-18 10:40:40 -07:00
Ailin Zhang
41df657be1 update eden du backing repos printing
Summary:
This diff updated the `eden du` command. Instead of printing
```Reclaim space from the LFS cache directory by running:

hg -R /data/users/akushner/eden-repos/opsfiles gc

Reclaim space from the LFS cache directory by running:

hg -R /data/users/akushner/eden-repos/megarepo_test gc

Reclaim space from the LFS cache directory by running:

hg -R /data/users/akushner/eden-repos/instagram-server_test gc
```
We now print "Reclaim.." only once and put available commands together
```
LFS cache detected in backing repo. To reclaim space from the LFS cache directory, run:

hg -R /data/users/akushner/eden-repos/opsfiles gc
hg -R /data/users/akushner/eden-repos/megarepo_test gc
hg -R /data/users/akushner/eden-repos/instagram-server_test gc
```
and did the same for working copy under backing repositories.

Reviewed By: fanzeyi

Differential Revision: D22038555

fbshipit-source-id: c19869db6f91e90a0627b3bb4b4f7e95142ae198
2020-06-15 11:57:29 -07:00
Ailin Zhang
2c52eed9e4 update eden du summary printing
Summary: This diff fixed small problems in previous `eden du` summary printing and added a reminder of option `--clean` to users.

Reviewed By: fanzeyi

Differential Revision: D22038552

fbshipit-source-id: 7dbac858b74833e59d8d3f1c6fb1f5d8944935d0
2020-06-15 11:40:04 -07:00
Ailin Zhang
ec906443ea print fsck to stdout
Summary: This diff passes a callback function `progressCallback` from `EdenServer` to make `OverlayChekcer` print fsck messages to stdout.

Reviewed By: fanzeyi

Differential Revision: D21966060

fbshipit-source-id: 317b2c8954c718b51b5295c9f8d7698eb203906e
2020-06-12 12:34:55 -07:00
Chad Austin
6185a90dc6 fix warnings on macOS
Summary: Fix a couple warnings in the macOS build.

Reviewed By: genevievehelsel

Differential Revision: D21992085

fbshipit-source-id: 578adb3b95d29177740debbce4dc4626ba9eed64
2020-06-12 10:28:28 -07:00
Genevieve Helsel
ca1da512bf store force restart action as its own flag
Summary: In its current state, FORCE is a restart mode that cannot be combined with other modes (specifically `graceful`). Removing this coupling from `force` will allow us to at first attempt a graceful restart, but if the daemon is not healthy, then do a force restart, all within one call.

Reviewed By: wez

Differential Revision: D21873166

fbshipit-source-id: 079a777ff6e7b219198cbef15335244b9865f5f3
2020-06-11 17:40:51 -07:00
Jun Wu
277933aad8 enable remotenames extension in cpp tests
Summary:
The remotenames extension was enabled everywhere in production. It is
unsupported if remotenames is disabled.

Ideally the cpp tests should use the in-repo configuration instead of
maintaining its own hardcoded hgrc. For now I just did the minimal change to
unblock tests.

Reviewed By: fanzeyi

Differential Revision: D21986274

fbshipit-source-id: b632da074baf4026f331381ae8f2f8479a34e1b3
2020-06-10 22:36:10 -07:00
Zeyi (Rice) Fan
ab26fb2b83 fix eden rage on Windows
Summary:
This diff fixes `eden rage` command on Windows.

`eden doctor` and `eden redirect` related rage items are disabled as they are not implemented on Windows yet.

Reviewed By: chadaustin

Differential Revision: D21962673

fbshipit-source-id: 14399a89c26eead8fe5114e0a3764644ee86a1ed
2020-06-10 19:29:52 -07:00
Chad Austin
a06da8f73c ensure that EdenError messages are always valid UTF-8
Summary:
Some Thrift clients require that values of type `string` must contain
valid UTF-8, and fail to decode otherwise. Ensure that EdenError's
message is always valid UTF-8.

Reviewed By: fanzeyi

Differential Revision: D21890761

fbshipit-source-id: 93b554e0bc6648c685f5fa54612576bd95d95ae5
2020-06-10 19:29:51 -07:00
Chad Austin
ab3b2be7bf add some utf-8 helper functions
Summary:
Add some functions for validating and producing valid UTF-8 to be used
in an upcoming diff.

Reviewed By: fanzeyi

Differential Revision: D21890510

fbshipit-source-id: b25144a34f1df91c72e8ed776b1ee7c1d68344c8
2020-06-10 19:29:51 -07:00
Xavier Deguillard
4b8809c786 win: handle moving files in and out of the repo
Summary:
The documentation for PRJ_NOTIFICATION_FILE_RENAMED points out that the
filenames can be empty strings to represent files moved to and from the
repository itself. By not special casing this we were trying to create and/or
remove an empty file at the root of the repo which would lead to an overlay
corruption.

Reviewed By: genevievehelsel

Differential Revision: D21961579

fbshipit-source-id: fbfd872ca0377cb90224eba5505ff406812d51a7
2020-06-10 19:29:50 -07:00
Ailin Zhang
1b159d58b9 fix __isset deprecated problem
Summary: This diff fixes `'__isset' is deprecated` problem when building `//eden/fs/service:edenfs`

Reviewed By: simpkins

Differential Revision: D21966922

fbshipit-source-id: c3b12134f3f84db0a97f3975dae5d64a2c98641a
2020-06-10 19:29:49 -07:00
Chad Austin
7e4835f677 rename eden.thrift Python module to eden.thrift.legacy
Summary:
The Python 2-and-3 Thrift API is sort of deprecated and does not
handle binary data in `binary` fields. In advance of migrating to the
modern Python 3 API, remane eden.thrift to eden.thrift.legacy.

Reviewed By: fanzeyi

Differential Revision: D21889697

fbshipit-source-id: a745ee8977999acbfb383a4edebe81d8deb1734e
2020-06-10 19:29:42 -07:00
Xavier Deguillard
8822c2bfaf prjfsChannel: do not store the mount path
Summary:
The mount path is required in 2 places: at mount time, and when deleting files.
It turns out that the second one doesn't require it as PrjDeleteFile specify
the filename to be: "A null-terminated Unicode string specifying the path,
relative to the virtualization root, to the file or directory to be deleted."

Thus, we only need it during mount time, so let's pass it to the start method.

Reviewed By: fanzeyi

Differential Revision: D21797080

fbshipit-source-id: 27f5d18841ac077c81ad3f6b3686e20917505c41
2020-06-10 19:29:36 -07:00
Xavier Deguillard
d40d5360b0 prjfschannel: do not do IO in the constructor
Summary:
This will simplify some later diffs where the channel construction doesn't
change any state.

Reviewed By: fanzeyi

Differential Revision: D21797077

fbshipit-source-id: 67d9ee693b067a08986e9bd33f9d91f9a1dadac1
2020-06-10 19:29:36 -07:00
Xavier Deguillard
c5b06ecc0f prjfschannel: remove re-creation of mount directory
Summary: This is already created, no need for re-recreating it.

Reviewed By: fanzeyi

Differential Revision: D21676314

fbshipit-source-id: 8e3eecfb6069f9bed5bfec7ad6631ed8830d796d
2020-06-10 19:29:35 -07:00
Xavier Deguillard
e83578d0b6 prjfschannel: move the static function out of the class
Summary:
These are pure implementation details of ProjectedFs, and don't need to be in
the class, let's move them onto an anonymous namespace in the cpp file.

Reviewed By: chadaustin

Differential Revision: D21676315

fbshipit-source-id: 4fa7088a10256581d7eed2c7cbd90c30a7fef3d2
2020-06-10 19:29:35 -07:00
Xavier Deguillard
7baa3c3bc0 prjfschannel: inline initialize the notification mapping
Summary:
I find this approach to be slighly less error prone due to not having
to manually specify the array size in advance. We lose the field names,
but they should be pretty self explanatory.

Reviewed By: chadaustin

Differential Revision: D21676319

fbshipit-source-id: db4dc993d3dd2a502ae188b08b8d4230939c0415
2020-06-10 19:29:35 -07:00
Xavier Deguillard
3f7a0c519f prjfschannel: use RelativePathPiece instead of wchar_t*
Summary:
This moves the edenToWinPath inside Windows specific files and makes
the interface clear about the kind of path that is expected.

Reviewed By: fanzeyi

Differential Revision: D21676318

fbshipit-source-id: d153bb543da5f481e94f83d52e45c6cc871d1f54
2020-06-10 19:29:34 -07:00
Xavier Deguillard
a29cd80510 mount: remove the need for setFsChannel in tests
Summary:
The only reason tests need to set an FsChannel is for calling
cleanupPrjfsCache. For consistency sake, let's do the same as what we do on
unices: verify if we have a valid channel first.

Reviewed By: wez

Differential Revision: D21676316

fbshipit-source-id: 022ca91d32a7ab047a79acccd7d17dfd7906d527
2020-06-10 19:29:34 -07:00
Xavier Deguillard
d559d2d217 mount: remove most of the ifdef in EdenServer::mount
Summary:
The only missing piece on Windows is the bind mount/redirection due to
folly::Subprocess not being present on Windows.

Reviewed By: wez

Differential Revision: D21676313

fbshipit-source-id: a5ba09be04c94b66edf9d40884753afa3865def2
2020-06-10 19:29:34 -07:00
Xavier Deguillard
1844b98457 mount: rename the various mount/unmount promises
Summary:
We want to use these on Windows too, so let's rename them to not be FUSE
specific.

Reviewed By: wez

Differential Revision: D21676317

fbshipit-source-id: 9f1bde9e0467d8828d4168a69581c8fea54669cd
2020-06-10 19:29:33 -07:00
Xavier Deguillard
e28113b695 mount: move setFsChannel
Summary:
This moves it out of EdenServer and into EdenMount directly. This is closer
to what is happening in the Linux code and thus better.

Reviewed By: fanzeyi

Differential Revision: D21663501

fbshipit-source-id: 84420fcb37586cc2695568f0167b39f91c9bfb63
2020-06-10 19:29:33 -07:00
Xavier Deguillard
74404f1b41 mount: unify EdenMount::start
Summary:
Instead of having 2 different functions for Windows and other unices, let's
only have one. This allows more of the mount code to be shared between both.

Reviewed By: wez

Differential Revision: D21517477

fbshipit-source-id: 185ce864aecdf9a7880a9c705df444ec1e39319a
2020-06-10 19:29:32 -07:00
Ailin Zhang
e9e6f94b92 update eden du to display a summary and display warnings with color
Summary: This diff updated `eden du` to display a summary and display warnings and cleaning information with colors.

Reviewed By: kmancini

Differential Revision: D21885051

fbshipit-source-id: be127b81c92bea1051a80715682cdbccf22f22e3
2020-06-10 19:29:26 -07:00
Ailin Zhang
a2a754b6f0 update eden du to display an aggregated result of all mounts.
Summary: This diff updated  `eden du` to display an aggregated result of all mounts instead of showing all details for each mount, as users generally just want to reduce disk usage but don't really care about details.

Reviewed By: genevievehelsel

Differential Revision: D21877178

fbshipit-source-id: dde43e51e96a5c2569c9fe21ab06cc7ea4295866
2020-06-10 19:29:25 -07:00
Zeyi (Rice) Fan
3754c14ec3 batch imports blobs from Rust stores from EdenAPI
Summary:
NOTE: This stack works together, they are separated for easier reviewing. Check D21723465 if you want to read this stack in one place.

This diff finally connects EdenAPI with EdenFS. Previously we only had basic EdenAPI implemented but the performance was not acceptable. This is largely due to overheads in talking with the remote server. Now EdenFS is able to import multiple files at once, we efficiently use EdenAPI to import these data now.

Reviewed By: chadaustin

Differential Revision: D21576569

fbshipit-source-id: a45e832ec63d057730138551393ff7547fa2c22f
2020-06-10 19:29:25 -07:00
Chad Austin
11d569b04d refactor EdenClient construction
Summary:
I am planning to start migrating Eden's CLI to the new Python 3 Thrift
implementation. In preparation, slightly clean up the interface and
implementation of our Python 2 Thrift wrapper.

Reviewed By: genevievehelsel

Differential Revision: D21854539

fbshipit-source-id: d398dd3f324c12288871cf0c9db41e64ed4cf7ed
2020-06-10 19:29:23 -07:00
Xavier Deguillard
16bbe5baa2 win: only inherit the pipe handles
Summary:
The CreateProcess API allows inheritable handles to be available in the spawned
process by passing a flag to it. What the documentation for this API leave to
the imagination is what happens when processes are spawned concurrently in
multiple threads and handles are opened and made inheritable while doing this.
The answer is obvious but the consequences aren't: they are inherited.

When anonymous Pipes are used, one end needs to be inheritable for the spawned
process to being able use it, but if one is created concurrently with spawning
a process, that other process may have an open handle to that unrelated pipe.
And since to detect that a pipe is closed, all handles to the other end needs
to be closed, this can lead to never being able to detect that it is closed...

This scenario is exactly what is happening in eden when spawning the Mercurial
process, and when one of these processes would die, eden would just hang trying
to write to the pipe, not knowing that the process was already gone. To unblock
eden, all the hg.real processes had to be killed, as this would close all the
pipe handles, and then eden would detect that the pipe was closed and re-spawn
Mercurial (only for the exact same thing to happen).

In order to fix this, we need to tell CreateProcess to only inherit the pipes
handles, and nothing else.

Reviewed By: wez

Differential Revision: D21895537

fbshipit-source-id: 3c84a1d0316b50b5750f554fa20f72f59a718882
2020-06-10 19:29:18 -07:00
Chad Austin
e2d26877d6 enable py3 thrift language
Summary:
The old `py` Thrift language support doesn't correctly handle string
vs. bytes, which causes an exception to be thrown when deserializing
paths or blobs that aren't UTF-8.

We will eventually want to migrate to the py3 language implementation,
which supports streaming.

Reviewed By: genevievehelsel

Differential Revision: D21693082

fbshipit-source-id: 0ea10fd3960f5acba353bccb83b5cf539e7eeffb
2020-06-10 19:29:17 -07:00
Xavier Deguillard
93ad242d60 packaging: use scheduled tasks
Summary:
In order to start EdenFS automatically at boot, a template service was used
previously, but due to several issues, we decided to move away from it.
Thankfully microsoft supports several other ways of starting tasks at startup,
one of which is the "Task Scheduler" itself.

One of the weird part of the task scheduler is that there isn't a good way
to tell it to not show a console for a non-graphical application, and thus
plainly executing edenfsctl start in it would create a cmd window, which
would then disappear a couple of seconds later. To avoid this, a "graphical"
version of Python is used (pythonw.exe) to start edenfsctl.

Reviewed By: fanzeyi

Differential Revision: D21732281

fbshipit-source-id: 87ef3a2d5569302392bd30a4b9e7fc48807ee316
2020-06-10 19:29:15 -07:00
Katie Mancini
137b6d984f add OS release version to eden rage
Summary:
When I was debugging the multithreaded bug issue it came up that the issue would
only affect certain versions of macos. There may be other bugs that come up
affecting only certain os versions. Having the os version in eden rage could be
helpful to identify such issues.

Reviewed By: chadaustin

Differential Revision: D21776154

fbshipit-source-id: a493e7da1823075ca4a845bd73b21716ce884911
2020-06-10 19:29:14 -07:00
Genevieve Helsel
2dba19bf43 refactor eden stop during graceful takeover request to remove usage of some thrift functions
Summary: The thrift team is looking to retire `stopWorkers()` and `stopListening()`, so this refactors our code to stop using both of those methods.

Differential Revision: D21851442

fbshipit-source-id: 6d63d435cbd4a51c855bf71a3b2165e35431a4d7
2020-06-03 20:07:29 -07:00
Ailin Zhang
c44c95441f update eden du to look at all mounts by default
Summary: This diff made `eden du` able to run under any directory and gives statistics for every EdenFS mount on disk by default.

Reviewed By: fanzeyi

Differential Revision: D21846894

fbshipit-source-id: 2d421db8a4a0202419aa7a41e620d92f6ebdea2e
2020-06-02 21:12:27 -07:00
Xavier Deguillard
2c5768404d service: remove thrift socket before starting the thrift server
Summary:
Somehow, on Windows, the socket file that was removed during `prepare` may be
back, but not bound, preventing Thrift from binding to it, let's remove it
again since it's not supposed to be there.

Note that this happens 100% of the time when starting EdenFS via the Task
Scheduler at log on, I couldn't reproduce when triggering the task manually,
or when starting edenfs by hand.

Reviewed By: simpkins

Differential Revision: D21755498

fbshipit-source-id: 32a343d9de531b90417dac0aa382a07c85cdee5a
2020-06-02 15:56:59 -07:00
Xavier Deguillard
223846d313 win: do not pass CREATE_NO_WINDOW to CreateProcess
Summary:
The CREATE_NO_WINDOW is documented as:

The process is a console application that is being run without a console
window. Therefore, the console handle for the application is not set.

The last part is what matters here, by default stdin, stdout and stderr are
inherited from the parent process, with this flag, they won't as these 3 will
simply not be set. Removing it allows Mercurial's output to be sent directly to
the edenfs log which will greatly improve our debuggability.

Reviewed By: akrieger

Differential Revision: D21820195

fbshipit-source-id: 63496a1ad28ecf5440c0846d80e1fbda5756b971
2020-06-02 14:06:07 -07:00
Genevieve Helsel
1cc1ba124c run eden start command with stdin set to /dev/null
Summary: When calling `eden start` from the CLI layer, make sure to redirect stdin in order to daemonize.

Reviewed By: chadaustin

Differential Revision: D21675707

fbshipit-source-id: 26085cc2ff7774e86f03872030c8885bc3c3b949
2020-05-28 11:32:01 -07:00
Katie Mancini
6801240ecf flag to silence fork error on mac os
Summary:
Currently when you run commands on eden on mac that both fetch data for commit
and update to that commit there is a multithreading bug. This could be a new bug
or an old bug that was not causing problems before, but is showing up a lot more
recently.

See http://sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html
for a nice explanation of this.

The root cause of this is still unknown, but this flag should bring back the
old behavior where we were not seeing this bug.

Reviewed By: fanzeyi

Differential Revision: D21744987

fbshipit-source-id: 85092e32212e83b16bc00dc0188f03b643c48eea
2020-05-28 10:31:12 -07:00
Xavier Deguillard
0cb5ceedfe unify the EdenMain code on Windows
Summary:
Update EdenFS on Windows to use EdenMain.cpp, the same as on POSIX.

This reduces the amount of code divergence, and also brings several
improvements to Windows: exposing version information over fb303, support for
dynamically changing logging configuration over fb303, etc.

Reviewed By: simpkins

Differential Revision: D21332569

fbshipit-source-id: dd2da7c385e96f65fc3927511c9f84b96bec9e2b
2020-05-28 09:01:03 -07:00
Xavier Deguillard
0c4f3b108d revert: Run Eden as a Windows service
Summary:
Wanting to have EdenFS run as a service on Windows cause a couple of issues
on Windows:
 - Needing to log out after installing
 - Forcing Sandcastle to use --foreground, which means the edenfs.log is
   empty, making it impossible to debug anything on Sandcastle,
 - Services can only be started by an elevated user, while the rest of EdenFS
   doesn't have this requirement,
 - Uses undocumented template services

The next diffs in the stack will attempt to solve all of these by starting
EdenFS as a scheduled task instead, which should solve all the above.

Reviewed By: fanzeyi

Differential Revision: D21732280

fbshipit-source-id: b959344da1e77819220d26695ff6634f13ac4e0d
2020-05-28 09:01:03 -07:00
Genevieve Helsel
83079bd6ca use system configs in HgPrefetchTest
Reviewed By: chadaustin

Differential Revision: D21665935

fbshipit-source-id: 31019020769548e01c011d021a39d7e50e288664
2020-05-27 20:19:19 -07:00
Xavier Deguillard
c04037d5aa cli: sys.stdout may be None
Summary:
On Windows, if edenfsctl is started by pythonw, sys.stdout will be None,
check if it is before calling isatty on it.

Reviewed By: fanzeyi

Differential Revision: D21732282

fbshipit-source-id: f0a63094f2c53b026c388f4e5b58433be4397ba9
2020-05-27 11:44:39 -07:00
Xavier Deguillard
f71b9d6381 error: remove unecessary newlines
Summary:
The FormatMessage API isn't very well documented in adding \r\n at the end of
the generated message, and the bit of code that needs to be used to remove
these is not very clear either.

We won't get gratuitous empty lines in the log with this.

Reviewed By: chadaustin

Differential Revision: D21663502

fbshipit-source-id: 203ff5015da6f3cebf7eaee9a8f989db342d096a
2020-05-27 08:53:24 -07:00
TJ Yin
65d6a4d886 Remove thrift setters
Summary:
Thrift setter API is deprecated since it doesn't bring any value over direct assignment. Removing it can reduce build-time and make our codebase more consistent.

If result of `s.set_foo(bar)` is unused, this diff replaces

    s.set_foo(bar);

with

    s.foo_ref() = bar;

Otherwise, it replaces

    s.set_foo(bar)

with

    s.foo_ref().emplace(bar)

Reviewed By: chadaustin

Differential Revision: D21712029

fbshipit-source-id: 3a332b4bf6fac6b3cf396d34e6d5ca4849181a6d
2020-05-26 12:38:37 -07:00
Yedidya Feldblum
ed2c4a65ba Add missing includes of folly/synchronization/Baton.h
Summary: Add missing includes of `folly/synchronization/Baton.h`.

Differential Revision: D21716396

fbshipit-source-id: 8c8fb818f3083b4fe04fd1c62923d7ba698dcedd
2020-05-25 23:13:35 -07:00
Sukwon Chung
abaa62ad33 Handle inaccessible files in redirections in eden du
Summary:
1. Add directory existence checking logic before checking "legacy_bind_mounts_dir"
2. Still print the disk consumption returned by the du command when it fails with an error invoking du -skxc

Reviewed By: chadaustin

Differential Revision: D21683421

fbshipit-source-id: 531b6b289e9ffa445ed691611c9cbf22f393e742
2020-05-21 22:20:17 -07:00
generatedunixname89002005307016
f9358e566a suppress errors in eden - batch 1
Summary:
This diff is auto-generated to upgrade the Pyre version and suppress errors in eden. The upgrade will affect Pyre local configurations in the following directories:
```
eden
```

Differential Revision: D21687853

fbshipit-source-id: baf0d9bc33f86da63ea289690faca6cf4d566588
2020-05-21 19:32:35 -07:00
Zeyi (Rice) Fan
9e87d4da4b check if the file exist locally before pushing to the request queue
Summary: This function won't go ask remote server and is able to produce a result very quick. This avoids the waiting time in the queue.

Reviewed By: chadaustin

Differential Revision: D21586511

fbshipit-source-id: db3793cc4e4e493d1beb6837c0bd91358e7e845f
2020-05-21 16:32:42 -07:00
Zeyi (Rice) Fan
d2facf6118 always use hgcache for data fetching
Summary: Reading from hgcache directly has been rolled out for quite a while now. Let's remove the configuration and make it default behavior.

Reviewed By: chadaustin

Differential Revision: D21585482

fbshipit-source-id: 7f30e262642adf58388a0580aa5a63595fa89155
2020-05-21 16:32:41 -07:00
Chad Austin
e687d9426c fix oss linux build
Summary:
gcc and clang disagree here, so explicitly construct a Future from the
unique_ptr.

Reviewed By: genevievehelsel

Differential Revision: D21687654

fbshipit-source-id: 338174f5d4d051f509faace6e48d1c0fb4d898e1
2020-05-21 12:04:45 -07:00
Genevieve Helsel
f799ca8981 suggest graceful restart in eden doctor version check
Summary: I've updated most messages to suggest a graceful restart, but I overlooked this instance and we got a user question about this. So lets update this message here as well.

Reviewed By: chadaustin

Differential Revision: D21681035

fbshipit-source-id: 32bf5e75b9ad1d98bcd70427101aabeee0be5046
2020-05-21 09:38:58 -07:00
Chad Austin
b653d9cc86 fix gcc compilation issues
Summary: Fix some RVO warnings and a compilation error when compiling with gcc.

Reviewed By: xavierd

Differential Revision: D21481738

fbshipit-source-id: 0621f5886df40c24ef1a6a68ccd957e38f2f4122
2020-05-20 15:49:02 -07:00
Xavier Deguillard
6cdc2782b3 cli: add a startservice.ps1 script
Summary:
This script deals with obtaining the right privilege to start the EdenFS
service. This effectively enables `edenfsctl start`.

Reviewed By: wez

Differential Revision: D21585739

fbshipit-source-id: 7b835434d865fa4c4c8473e13665ae669fd86108
2020-05-19 13:00:54 -07:00
Chad Austin
c2f85710d3 build with Rust datapack support on all platforms
Summary: Now that Rust libraries can be linked into fbcode binaries with mode/mac, enable Rust datapack on all platforms.

Reviewed By: xavierd

Differential Revision: D21241075

fbshipit-source-id: ae2abee25a5ad7b9db9ac5e6b8687c5f79376926
2020-05-19 11:53:51 -07:00
Genevieve Helsel
c8402345af redirect PrivHelper stdin to /dev/null to fully daemonize
Summary: EdenFS doesnt daemonize correctly due to the privhelper not closing fd 0 (see http://www.faqs.org/faqs/unix-faq/programmer/faq/). This redirects stdin to /dev/null/ in order to do so.

Reviewed By: xavierd

Differential Revision: D21602545

fbshipit-source-id: 0aeb589efbf214ef22c0db039fbb6a436a71e360
2020-05-18 10:11:18 -07:00
Adam Simpkins
145320fe96 check in some high-level design documentation for EdenFS
Summary:
This checks in some design documents based on the "EdenFS Internals"
presentation that I've given internally a few times.

Reviewed By: wez

Differential Revision: D21519530

fbshipit-source-id: 3f79d38e8ccf994b2ef303d491809a91fa5b6d95
2020-05-15 18:08:47 -07:00
Xavier Deguillard
3f0dcccd42 mount: unify EdenMount::initialize
Summary:
Next step in unifying the mount path, let's make the initialize the same in
Windows and unices. The only difference is now limited to the .eden directory
which we will be able to implement once regular users can create symlinks.

For the takeover code, the #ifdef is pushed down to the actual code that does
it, this allows the rest of the code to not have to bother about Windows vs
other platforms.

Reviewed By: wez

Differential Revision: D21517478

fbshipit-source-id: d40ca2694d23031ff98e319071e610efa306008f
2020-05-15 13:14:55 -07:00
Xavier Deguillard
b90a9504f0 win: improve getFileSha1 to not trigger a stack overflow
Summary:
In order to build a StringPiece from a C-string, the length of the that
string needs to be known, and a constexp strlen is performed on it. That
strlen is however a recursive one, causing the stack to blow up on big file.

Interestingly enough, this also means that binary files potentially had a
wrong sha1 being computed, potentially causing `hg status` to report some
files as being modified, while they aren't. By switching to using a vector
instead of a string, the intent should of this should be more obvious.

Reviewed By: simpkins

Differential Revision: D21551331

fbshipit-source-id: 2dc1f08d96f49d310593e0e934a03215be2b5cbb
2020-05-13 11:44:30 -07:00
Genevieve Helsel
234383d086 remove version check from redirect fixup
Summary: Nothing should be running with this version, so this check is not needed anymore!

Reviewed By: chadaustin, wez

Differential Revision: D21513269

fbshipit-source-id: 698c9d84e87461cd0484ef997f44dc9169e87a25
2020-05-12 15:43:31 -07:00
Xavier Deguillard
9ffc383307 mount: enable registerStats for Windows
Summary:
While not all stats are supported on Windows, most of them can, let's enable
them. This is a first step in unifying the mount path for Windows and Unices.

Reviewed By: chadaustin

Differential Revision: D21514732

fbshipit-source-id: 00fd89b7499f8ae18c089f98bc18cd43f68538fa
2020-05-12 13:04:27 -07:00
Xavier Deguillard
ea98578570 model: report symlink/executable as regular files on Windows
Summary:
While this isn't the right fix, this is what shipped in our packages, for the
sake of being able to reproduce the package, let's land this as it is. A
future change will remove this ifdef.

Below is pkaush original description:
In Eden Windows we treat all the files as regular files and don't have a
concept of symlinks and executable files. Fixing the TreeEntryType::getType()
to return REGULAR_FILE for executable file and symlink.

Reviewed By: wez

Differential Revision: D20481051

fbshipit-source-id: 0b0c4d7aea28134383ef45aeafc02930b420286b
2020-05-12 08:46:35 -07:00
Genevieve Helsel
12c5a2d221 doctor - fixup redirections
Summary: `eden doctor` should probably fix misconfigured redirections. this is mostly copy pasted from the `eden redirect fixup` command.

Reviewed By: wez

Differential Revision: D21487225

fbshipit-source-id: 69e7fcb446cbc42966cabb6d80ab716533da50a9
2020-05-11 22:13:06 -07:00
Alvaro Leiva Geisse
675b83557e add extra 2 extra type hints for systemd Manager
Summary: add two methods calls as typehints (no real code change).

Reviewed By: zeroxoneb

Differential Revision: D21337646

fbshipit-source-id: 8079883f7f989251965d3308c5374f097023b57a
2020-05-11 20:52:13 -07:00
Jessica Gomes
50022171c9 add uptime field to DaemonInfo
Summary:
- Added uptime field to DaemonInfo thrift struct
- Created startTime member variable in EdenServer
- Made appropriate refactoring changes to EdenMain and EdenServer
- Changed main.py and util.py to use the new uptime value

Reviewed By: genevievehelsel

Differential Revision: D21471140

fbshipit-source-id: 8868de667dfb95de93e3e71b90c0412fb3825388
2020-05-11 11:42:15 -07:00
Xavier Deguillard
1d10a0e1a0 config: add the TomlConfigTest.cpp to CMake
Summary: All the tests are passing.

Reviewed By: wez

Differential Revision: D21319018

fbshipit-source-id: 26335f39d39bdc379c00e65942c2cc7c6853089b
2020-05-09 08:46:36 -07:00
Xavier Deguillard
8220cac785 config: add FileChangeMonitorTest to the CMake build
Summary:
The disabled tests are due to the st_mtime stored in the struct stat only
having a second granularity (as expected), but the tests are changing these
files faster than that, causing them to fail. I'll attempt to fix the file
change detection mechanism on a later diff.

Reviewed By: wez

Differential Revision: D21319025

fbshipit-source-id: a3f2d62a3ce56fea37a62bfad73306ac1556f772
2020-05-09 08:46:35 -07:00
Xavier Deguillard
dd9ec5dffd config: add EdenConfigTest.cpp to CMake
Summary:
Same as the previous one, paths are different on Windows, and thus we need to
test against a different path.

Reviewed By: wez

Differential Revision: D21319021

fbshipit-source-id: 849c86574e69c3f638ea180c3b594aaeae2970ad
2020-05-09 08:46:35 -07:00