Commit Graph

2361 Commits

Author SHA1 Message Date
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