Commit Graph

1249 Commits

Author SHA1 Message Date
Adam Simpkins
011cc21e52 update privhelper code to use the UnixSocket helper class
Summary:
This updates the privhelper code to use the UnixSocket class for performing
I/O.  This reduces the number of separate implementations of code we have for
sending file descriptors across Unix domain sockets, and also makes the
privhelper APIs non-blocking.

This will make it easier to clean up some of the initialization ordering in
the future.  It will also make it easier to send file descriptors to the
privhelper server, instead of just receiving them.  This may be helpful for
passing a file descriptor to use for logging to the privhelper process, which
will make it easier to fork the privhelper before logging redirection has
occurred.

Reviewed By: bolinfest

Differential Revision: D8053422

fbshipit-source-id: 1f8fdf22afc797eead0213be1352ea530762140d
2018-06-11 18:32:25 -07:00
Adam Simpkins
5305edefc1 update PrivHelper APIs to return Futures
Summary:
Up until now all of the privhelper APIs have been blocking calls.  This
changes the privhelper functions to return Futures, and updates all users of
these APIs to be able to handle the results using Futures.

One benefit of this change is that all existing mount points are remounted in
parallel now during startup, rather than being mounted serially.  The old code
performed a blocking `get()` call on the future returned by
`EdenServer::mount()`.

The privhelper calls themselves are still blocking for now--they block until
complete and always return completed Future objects.  I will update the
privhelper code in a subsequent diff to actually make it asynchronous.

Reviewed By: bolinfest

Differential Revision: D8053421

fbshipit-source-id: 342d38697f67518f6ca96a37c12dd9812ddb151d
2018-06-11 18:32:25 -07:00
Adam Simpkins
0dfd415251 fix setting PATH in C++ hg tests
Summary:
Update the HgRepo class to pass through the original $PATH environment
variable.  Previously it was incorrectly setting $PATH to the repository path.

Reviewed By: chadaustin

Differential Revision: D8359187

fbshipit-source-id: ce9ce374d70c325aa45b5fd643c3d55d30d34cdc
2018-06-11 16:51:12 -07:00
Adam Simpkins
743d44a015 remove eden/fs/service/DEFS
Summary:
This file contained one helper function that didn't really save us much code.
This simply removes it for now.

Reviewed By: wez

Differential Revision: D8329592

fbshipit-source-id: 5172ac0746fc051288c76522c6c3d5ac4097f588
2018-06-11 14:16:19 -07:00
Adam Simpkins
e46df786ca clean up Facebook-specific code in DEFS files
Summary:
This removes the `is_facebook_internal()` function from eden/DEFS, and updates
code that was using it.

The open source build uses CMake rather than buck now, so the DEFS files are
currently only used for Facebook-internal builds.  `is_facebook_internal()` is
therefore always true when the DEFS file is being used.

Reviewed By: chadaustin, wez

Differential Revision: D8329591

fbshipit-source-id: d154e9453f78dea2e46d0262a0fcbe58844445e3
2018-06-11 14:16:16 -07:00
Wez Furlong
2c830c5e57 improve sparse extension error handling when used with eden
Summary:
Some folks might attempt to load this extension despite it
not being useful with eden.  The extension knows not to hook in to
the repo when eden is in used, but the various commands to manipulate
the sparse config do not.

This diff adds a little helper function to show a more reasonable
error message than an ugly stack trace when attempting to use them.

Reviewed By: simpkins

Differential Revision: D8328229

fbshipit-source-id: d7cc4c7047b11f8da96e26ab70bd522b52546151
2018-06-08 14:55:40 -07:00
Chad Austin
fc49c9c61b Fix opt-tsan build
Summary:
Per
35ba669307,
if the return value of DCHECK_NOT_NULL is expected to be unused,
DCHECK should be used instead.

Reviewed By: strager

Differential Revision: D8336319

fbshipit-source-id: 9ea758502baead8941b274dc0ed38ce59b1cc136
2018-06-08 13:32:38 -07:00
Adam Simpkins
704ff64705 fix setting CHG_BIN in the integration tests
Summary:
Fix the integration tests to set CHG_BIN correctly when run manually rather
than via `buck test`.

Reviewed By: wez, quark-zju

Differential Revision: D8329593

fbshipit-source-id: 79fa3c9e9538e4b30a98ef777515527562e1ac1b
2018-06-08 13:32:38 -07:00
Wez Furlong
c2aa83a8a7 hg_import_helper close the old repo object before unreferencing it
Summary:
In some cases we decide to reopen the repo speculatively to see if a
missing cache invalidation was preventing us from importing some data.  We're
seeing some leaky behavior and so we're now trying to use the `close` method to
see if that helps clean some things up.

Reviewed By: strager

Differential Revision: D8323584

fbshipit-source-id: 7b022edd58f4ac555b508c1e181677ddc7bc60a4
2018-06-07 17:57:01 -07:00
Wez Furlong
e97a82685d fix hg co master
Summary:
We need to explicitly move the continuation to the right thread.

I don't know why our tests didn't catch this case, and I'm just throwing
up the diff to unblock the other one I'm working on.

Reviewed By: chadaustin

Differential Revision: D8323051

fbshipit-source-id: e7c39a086ced5dc6487c8f6014132e856c91af46
2018-06-07 17:57:01 -07:00
Chad Austin
e74577e7d6 fix opt build
Summary: D8108728 broke the opt build. Move-return the tree.

Reviewed By: simpkins

Differential Revision: D8319220

fbshipit-source-id: c3f81dfed3d160fce92bf1a82c52cb5d16e5199d
2018-06-07 13:50:11 -07:00
Chad Austin
74de9c13a8 recover from a commit2tree entry existing without the corresponding tree
Summary:
When testing D8108649 I accidentally deleted all of my trees
but didn't delete my commit2tree mapping. This diff allows Eden to
recover from that situation.

Reviewed By: wez

Differential Revision: D8108728

fbshipit-source-id: 94a9393294ca259303026c297683dac4b3ecfac4
2018-06-06 14:36:32 -07:00
Wez Furlong
71feeea52e pass down CHG path from above
Summary:
I've been troubleshooting eden integration test failures on my
devserver and traced it to some slightly off behavior in the telemetry
wrapper.

The wrapper was setting `CHGHG` to `hg.real` rather than the computed
path to the `hg.real` executable.  In the eden integration tests this
path is the buck generated `hg.par`.  The problem this caused was running
the installed hg.real rather than the one from the test environment
and this caused resolution of the eden extension to fail.

Once I fixed that up I found that chg had detected a problem with the
paths to the hg executable that were being used; we were picking up `chg`
from the system path and had a similar issue to above.

I introduced an environmental variable `CHG_BIN` to hold the desired path
and set it to the buck built `chg` binary.

In the process of this I found that `chg` was triggering a UBSAN issue
by passing a nullptr as the second argument to `memcpy`.  I've included
the trivial fix for that in this diff also.

Reviewed By: quark-zju

Differential Revision: D8274636

fbshipit-source-id: 7ee0740cbfb447ab41b9e08308767d42790ba296
2018-06-05 13:44:28 -07:00
Wez Furlong
127218fc9f allow hg_import_helper to gracefully degrade when remotefile is not in use
Summary:
I didn't consider this when I added the prefetch stuff, and it is
currently causing the watchman eden integration tests to fail.  It was bisected
to the watchman prefetch diff.

Reviewed By: chadaustin

Differential Revision: D8275074

fbshipit-source-id: 0a2c6d8680b07157de26dafe437551c7314b86df
2018-06-05 13:44:28 -07:00
Durham Goode
562262bc30 treemanifest: move ManifestEntry node behind an accessor
Summary:
Previously the ManifestEntry node field was public and consumers could
read it directly. This required that the node field be updated manually, which
added complications to other code paths. In a future diff we'll be simplifying
the SubTreeIterator code to not require setting node, and to do so we make node
calculated in this accessor.

Reviewed By: quark-zju

Differential Revision: D8156807

fbshipit-source-id: e1908b2149bc0ec8fb1279e37b8a66988ff125c6
2018-06-04 18:08:35 -07:00
Andrew Gallagher
9c966a2539 buck macros: remove output_subdir parameter
Summary: This parameter was only supported for fbbuild.

Reviewed By: yfeldblum

Differential Revision: D8246482

fbshipit-source-id: 95db878a34dce5694639364f2838bb4cccd723d3
2018-06-02 10:51:10 -07:00
Sergey Zhupanov
d5f2b60e1d Fixed Eden warnings-turned-errors revealed by @mode/opt build.
Summary: Disabled annoying and useless missing braces warnings and fixed a couple assigned-but-not-used warnings.

Reviewed By: aary

Differential Revision: D8242771

fbshipit-source-id: 09e55f028f3aaac25fe78d4d1f0edf663fc020b1
2018-06-01 16:32:21 -07:00
Chad Austin
a45699a32e remove hg store test main.cpp
Summary:
Preparation for adding an HgBackingStore test.

Per @[1077184107:simpkins], use_hg_tree_manifest defaults on and folly::logging is automatically initialized now, so we can just remove main() entirely.

Reviewed By: wez

Differential Revision: D8226799

fbshipit-source-id: 5b5038bc311f62c1ef9ed943f57ce8f7d68bdc89
2018-06-01 15:48:07 -07:00
Chad Austin
aba341244a remove Allocator template parameter from PathMap
Summary:
We don't use the Allocator template parameter and it makes forward
declaring PathMap harder, so remove it.

Reviewed By: simpkins

Differential Revision: D8231982

fbshipit-source-id: 5c0faed8f61dc7699c8bb6660292f255feb10e29
2018-06-01 12:23:31 -07:00
Chad Austin
a3c17b2c1b fit DirEntry in four words
Summary:
While I'm in here, borrow the top two bits from mode_t for hasHash_
and hasInodePointer_, making DirEntry fit in four words.

Eventually I want to replace mode_t with dtype_t, but that can't be
done until migration to the InodeMetadataTable is mostly complete. If
I made this change too early, we might lose some of the mode bits
specified when creating a file. If said mode bits resulted in a change
to u+x, the file could look changed relative to source control.

I updated some of the DirEntry documentation while I was at it.

Reviewed By: simpkins

Differential Revision: D7941582

fbshipit-source-id: f62e58f3737c1189ea17cd434b6fef14af359e0a
2018-06-01 12:23:30 -07:00
Chad Austin
feb2da11d6 update mtime on directories when renaming
Summary:
This fixes a bug simpkins pointed out in D6891479 - we weren't
updating mtime and ctime on renames.

Reviewed By: simpkins

Differential Revision: D7937303

fbshipit-source-id: 08fd8f4fe5d99d33e9f7629965d6146330c8f35b
2018-06-01 11:39:01 -07:00
Chad Austin
043aee80a0 ensure that inodes access and update metadata while their corresponding locks are held
Summary:
Per code review feedback from D6891479, this diff enforces that
metadata writes and reads are done while the corresponding inode's
state lock is held.

Reviewed By: simpkins

Differential Revision: D7884463

fbshipit-source-id: d0e7a95415c280441276452ece7233d4cbf5e942
2018-06-01 11:39:01 -07:00
Sergey Zhupanov
419a57b1bc Enabled additional compiler warnings in Eden.
Summary:
1. Enabled a number of additional C++ compiler warnings in Eden.
2. Fixed warnings-turned-errors that resulted from this change.

Reviewed By: simpkins

Differential Revision: D8132543

fbshipit-source-id: 2290ffaaab55024d582e29201a1bcaa1152e6b3e
2018-06-01 11:39:01 -07:00
Chad Austin
e939a6a821 Split Dir into its own type and move TreeInodeState out of TreeInode
Summary:
Like D7867399, split TreeInode's synchronized state into a top-level
class. This is a step towards using the type system to perform
lock-safe metadata updates.

Reviewed By: simpkins

Differential Revision: D7882648

fbshipit-source-id: 27262df8ed9137c8478c68ebf4c4f13878655754
2018-06-01 09:38:45 -07:00
Chad Austin
84b577b5f1 fit Dir Entry in five words
Summary:
Eden will often have a significant number of trees loaded - this saves
8 bytes per entry per loaded TreeInode. It also makes it clear that
once an inode pointer is assigned, the inode number is redundant.

Reviewed By: simpkins

Differential Revision: D7869662

fbshipit-source-id: 21a8266ff5189d3ba9cb614a325cc9d8c3ca305e
2018-06-01 09:38:45 -07:00
Chad Austin
8bda0847d3 prep for shrinking Entry to 5 words
Summary:
Shrinking Entry to five words was a bit tricky with some subtle
situations, so I split it into two diffs to verify the tests passed
after each stage.

This diff replaces folly::Optional<Hash> with a boolean and Hash.

Reviewed By: simpkins

Differential Revision: D7869502

fbshipit-source-id: 2df109472d9565e96e8621407f62a63b4f1dbcad
2018-06-01 09:38:45 -07:00
Chad Austin
99c18dd319 Move FileInode::State into its own top-level class
Summary:
FileInode and TreeInode's State classes are complicated enough that
they deserve to be lifted out. In addition, this is necessary for
using the type system to enforce that contents locks are held in
InodeBase's metadata accessors.

Reviewed By: simpkins

Differential Revision: D7867399

fbshipit-source-id: 6ce082149ba02099487e8caed33a7bd8510dfebb
2018-06-01 09:38:45 -07:00
Chad Austin
48a8c2c806 make LocalStore::getBlobMetadata return a Future
Summary:
Have getBlobMetadata always return a Future. It's a little unfortunate
that this will always allocate, but it sounds like we might decide to
put all RocksDB access on a background thread to increase CPU
parallelism.

Reviewed By: bolinfest

Differential Revision: D8101464

fbshipit-source-id: 6e9ec95050c366c7c57519e3f68b311470b2addd
2018-06-01 09:38:45 -07:00
Orvid King
dc5d2e9856 Change calls from collectAll to collectAllSemiFuture
Summary: We are changing `folly::collectAll` to return `SemiFuture` rather than `Future` and this is needed as an interim step. After all calls to `collectAll` are changed to `collectAllSemiFuture`, we'll be renaming it back to `collectAll`.

Reviewed By: yfeldblum

Differential Revision: D8210974

fbshipit-source-id: e4a7464f4a1c3ede157b8377a4df97d943001f60
2018-05-31 23:24:59 -07:00
Chad Austin
5fa02fa46f make LocalStore::getTree return a Future
Summary:
Remove getTreeFuture and have getTree always return a Future. It's a
little unfortunate that this will always allocate, but it sounds like
we might decide to put all RocksDB access on a background thread to
increase CPU parallelism.

Reviewed By: bolinfest

Differential Revision: D8101430

fbshipit-source-id: e12b7ab07b3468114a58753768655c107265b8af
2018-05-31 21:19:40 -07:00
Chad Austin
cfdb61d3bc make LocalStore::getBlob return a Future
Summary:
Remove getBlobFuture and have getBlob always return a Future. It's a
little unfortunate that this will always allocate, but it sounds like
we might decide to put all RocksDB access on a background thread to
increase CPU parallelism.

Reviewed By: bolinfest

Differential Revision: D8101402

fbshipit-source-id: d6cbbd7fe4fe55bad661c9158297db2f03f7d352
2018-05-31 20:46:11 -07:00
Chad Austin
5b6bb343f0 add test verifying flush_cache works after a graceful restart
Summary:
I kept running into issues trying to get graceful restart and
flush_cache to work together in the hg integration suite, so add a
test to ensure flush_cache succeeds after a graceful restart in the
main integration suite.

Also, to make the test's output easier to follow, add logging when
invalidating inodes.

Reviewed By: simpkins

Differential Revision: D8215961

fbshipit-source-id: 33db4292af3969ae23940c3027ba513ed20c53fb
2018-05-31 18:52:27 -07:00
Chad Austin
4411b67d52 Make max inode number calculation O(1) when shutdown is clean
Summary:
Remember the maximum inode number in a file when the Overlay is shut
down cleanly, avoiding a full Overlay scan.

Reviewed By: simpkins

Differential Revision: D7912647

fbshipit-source-id: 8adbafed15259af668a221baa829e1b1f44090d7
2018-05-31 18:46:40 -07:00
Adam Simpkins
4ed626281e add an --if-necessary option to eden start
Summary:
Add a command line option to start edenfs only if there is at least one
Eden checkout already configured.

This makes it easier to automatically start edenfs on system boot only if the
user needs edenfs.

Reviewed By: wez

Differential Revision: D8174819

fbshipit-source-id: bf585b8c5aa719d3b6424567f2e21c1c63850d66
2018-05-31 11:42:45 -07:00
Chad Austin
f4ebdce6c1 make HgImportTest a parameterized test
Reviewed By: wez

Differential Revision: D8216298

fbshipit-source-id: 4e68f4820db4311c402c59906cfff3d3744eab9d
2018-05-31 11:23:21 -07:00
Chad Austin
0e9cc052c8 add compact_local_storage debug command to cli
Summary: Add a debug command to compact the LocalStore's RocksDB.

Reviewed By: bolinfest

Differential Revision: D8108686

fbshipit-source-id: 116a74d4bd70442a4c60e45d551afa60674f121d
2018-05-31 11:23:21 -07:00
Chad Austin
b9f6bf1c14 add clear_local_caches debug command to cli
Summary:
This adds a debug command to blow away all RocksDB information that
can be reproduced from Mercurial. We will use it to help an Eden user
recover from a corrupted blob.

Reviewed By: bolinfest

Differential Revision: D8108649

fbshipit-source-id: 056dec19d51b9e430b3c2a249747b26830cfc875
2018-05-31 11:23:21 -07:00
Chad Austin
a4959ad72e add clearKeySpace method to LocalStore
Summary:
Add a clearCaches function to LocalStore that deletes all data from
LocalStore that could be retrieved from Mercurial.

Reviewed By: wez

Differential Revision: D8101365

fbshipit-source-id: d46d0db94e6f85aaf542d9f6b9b96fbdcc548b57
2018-05-31 11:23:21 -07:00
Chad Austin
5409f230eb have Overlay track nextInodeNumber_ instead of InodeMap
Summary:
The Overlay is the natural home for nextInodeNumber_ now that every
directory allocates inode numbers for its children right away. This
also simplifies serializing nextInodeNumber_ to disk in the following
diff.

Reviewed By: simpkins

Differential Revision: D8192442

fbshipit-source-id: 9b776a73c8d7653002b55985d592b1746e52f878
2018-05-31 01:46:15 -07:00
Chad Austin
d7766f9cce add an explicit Overlay::close()
Summary:
There are a couple benefits to having an explicit Overlay close
method. First, it lets us assert if any code tries to access storage
after EdenMount has started shutting down. Also, it lets us pass
nextInodeNumber_ into Overlay::close() so it can be remembered in the
case of a clean shutdown.

Reviewed By: simpkins

Differential Revision: D8170534

fbshipit-source-id: 14fa607d877df8a3be9e9b0144132c8e8643d98d
2018-05-31 01:46:15 -07:00
Chad Austin
99493cebda add Overlay tests for maxRecordedInodeNumber
Summary:
Before making changes to the way we record the maximum inode number,
cover it with tests.

Reviewed By: simpkins

Differential Revision: D7912059

fbshipit-source-id: 29fdc88bd74c6c07e870017d743d9fd0797baaf3
2018-05-31 01:46:15 -07:00
Chad Austin
0797ee3a35 to satisfy secfs validation suite, limit path components to 255 bytes
Summary:
Most filesystems limit path components to 255. To remain consistent,
let's have Eden do the same, at least for write operations.

Reviewed By: simpkins

Differential Revision: D8151020

fbshipit-source-id: 251da94a076f5765111c8e3d9d8a25c37682e2e3
2018-05-30 23:11:28 -07:00
Adam Simpkins
b9e09a508f add a new status test for restoring a files contents
Summary:
Add a new integration test that modifies a file, commits it, then restores it
to its original contents and creates a new commit with the revert.

This test isn't really exercising any Eden-specific behavior.  The only reason
it is is interesting is that this happened to trigger a bug in the underlying
mercurial cdatapack code that caused the test to fail when run in treemanifest
mode.  The mercurial cdatapack bug is fixed in D8131020

Reviewed By: quark-zju

Differential Revision: D7826284

fbshipit-source-id: 32da2db04452d5df0527f6be00b0c4c1a56c900b
2018-05-30 18:52:52 -07:00
Adam Simpkins
90e4db347b restore logic for finding hg executables in the integration tests
Summary:
Update find_executables.py to be able to find the HG wrapper and binary using
buck rules.  This is necessary in order to be able to run the integration
tests manually rather than via `buck test`.  Without this the tests try to use
`/bin/hg.real` which tests the wrong version of the mercurial code and the
eden extension.

Reviewed By: bolinfest

Differential Revision: D8200168

fbshipit-source-id: d2a68c765c7143bbe613f32eef1268ed567790a7
2018-05-30 13:06:31 -07:00
Yedidya Feldblum
96af55472f CodeMod: future-then-continuation-lvalue-ref
Summary:
CodeMod: `future-then-continuation-lvalue-ref`.

```
buck run mode/opt foundation/clangr:clangr_coordinator -- run foundation/clang/codemods:future-then-continuation-lvalue-ref --dev -p 7 --num-workers=200
```

There is no need to support continuations taking non-const lvalue-ref params; callers can get exactly the same semantics with non-const rvalue-ref params instead. Thsi codemod preserves semantics. Many of these cases could do just as well taking by value, but this codemod preserves semantics.

Reviewed By: Orvid

Differential Revision: D8166008

fbshipit-source-id: 84b635cccce24b6485ffb5b24b98f10422b9a517
2018-05-30 12:32:16 -07:00
Lukasz Langa
deee232d74 Upgrade to 18.5b1
Summary: Mostly empty lines removed and added.  A few bugfixes on excessive line splitting.

Reviewed By: cooperlees

Differential Revision: D8198776

fbshipit-source-id: 4361faf4a2b9347d57fb6e1342c494575f2beb67
2018-05-30 01:11:47 -07:00
Adam Simpkins
40b74b29f8 update hg_import_helper to ask mercurial for subtrees correctly
Summary:
Update the hg_import_helper script to use the `repo._prefetchtrees()` method if
we need to fetch trees for a non-root tree.  The "public"
`repo.prefetchtrees()` API does not allow specifying the path to the tree in
question.

Reviewed By: wez

Differential Revision: D8156733

fbshipit-source-id: 0b0b5e32a84b282d2d76e10c6bdef0cd807f5a73
2018-05-29 13:35:18 -07:00
Michael Bolin
b3bd221428 Use the Rust wrapper for Hg in Eden integration tests, as appropriate.
Reviewed By: wez

Differential Revision: D7657564

fbshipit-source-id: 41445c2233c5ced4b4cfc48c3d1008a4a13d3bb7
2018-05-29 11:24:16 -07:00
Orvid King
5e124cc05f Change calls from collectAll to collectAllSemiFuture
Summary: We are changing `folly::collectAll` to return `SemiFuture` rather than `Future` and this is needed as an interim step. After all calls to `collectAll` are changed to `collectAllSemiFuture`, we'll be renaming it back to `collectAll`.

Reviewed By: yfeldblum

Differential Revision: D8157548

fbshipit-source-id: 27b768ac7ff0d6572bde57f01601045a1fd5d5e5
2018-05-26 14:01:37 -07:00
Wez Furlong
114a993f49 eden: smaller batches for prefetching
Summary: as above

Reviewed By: chadaustin

Differential Revision: D8065372

fbshipit-source-id: 8bf16ea753a9fdfc8516f06d587e6ee27bbcec8c
2018-05-25 13:51:27 -07:00