Commit Graph

1083 Commits

Author SHA1 Message Date
Adam Simpkins
70abf56f40 add an option to leave behind the integration test directory
Summary:
Update the integration tests so that they do not delete the temporary test
directories if the environment variable `EDEN_TEST_NO_CLEANUP` is set.

This makes it easier to manually examine the repository state after a test
fails.

Reviewed By: chadaustin

Differential Revision: D6986217

fbshipit-source-id: 727321c2c3da4d19d9edf8ed20b2aca3449779de
2018-02-15 11:41:28 -08:00
Adam Simpkins
ab05c494b9 update the integration tests to run hg from the local repository
Summary:
Update the logic for how the Eden integration tests find the hg binary:
- Use the contents of the EDEN_HG_BINARY environment variable if set.  When
  running tests via `buck test` buck will pass the hg.par output location in
  this variable.
- If EDEN_HG_BINARY is not set, use libfb.py.pathutils to find the location of
  the //scm/hg:hg rule output.  This makes sure the integration tests still
  prefer this par path even when run manually without EDEN_HG_BINARY set.  This
  is convenient when running individual tests not through buck.

If for some reason the hg python_binary() output cannot be found then we still
search through $PATH for hg.real or hg as usual.  For internal fbsource builds
we generally shouldn't hit this fallback case, though.

Reviewed By: wez, quark-zju

Differential Revision: D6986221

fbshipit-source-id: 982cb99112405a674dbc45df4ada73a990536489
2018-02-15 11:41:28 -08:00
Chad Austin
c366a48e24 Entry::isDir is redundant with isDirectory
Summary: I should have caught this before...

Reviewed By: wez

Differential Revision: D6995395

fbshipit-source-id: 08efd0aacb051f2b1754930b311e3a42afc3c538
2018-02-14 22:26:00 -08:00
Adam Simpkins
faa8266d90 remove an undefined method declaration from HgRepo
Summary:
Remove the declaration of HgRepo::initHg(), which is never used or defined
anywhere.  (There is a public HgRepo::hgInit() method.)

Reviewed By: chadaustin

Differential Revision: D6996812

fbshipit-source-id: 1ad15f624b3839ccb8a2005f3bcf0897563f82f5
2018-02-14 22:06:53 -08:00
Adam Simpkins
c1f6fd0eb0 work around bogus KeyErrors thrown by mercurial
Summary:
Several parts of the mercurial remotefilelog and treemanifest code can
incorrectly throw KeyErrors when accessing legitimate objects that do exist.
This appears to occur if the data was created since the mercurial code on the
server side started.

These KeyErrors are often generated on the server-side of a pull or
prefetchtrees operation.  We can't workaround these by invalidating caches on
our local repository object.  The only way that I've been able to work around
these bogus KeyErrors is by completely recreating the repo object before
retrying.

Our code now generally attempts to load data 3 times: if the initial attempt
fails we call `repo.invalidate()` and then retry.  If that retry fails we then
try destroying and recreating the entire repo object and then try again.

Ideally it would be nicer to fix mercurial itself not to throw KeyErrors for
data that does exist.  However that seems somewhat more complicated.

this_is_fine

Reviewed By: wez

Differential Revision: D6986220

fbshipit-source-id: 57905dd25e11c4858822020b44185a6f83ecd363
2018-02-14 22:06:53 -08:00
Adam Simpkins
cf0edfa1da call markForRefresh() on the datapack store after calling prefetchtrees
Summary:
Explicitly mark the UnionDatapackStore as needing a refresh after we have
fetched data from the server.  Otherwise we may not be able to find the tree
data that we just fetched.

Reviewed By: wez

Differential Revision: D6986219

fbshipit-source-id: c50b92ee4242665c7f5770f87a5dbab17698b8b9
2018-02-14 22:06:53 -08:00
Adam Simpkins
0673ce8ac7 update hg_import_helper to work with recent treemanifest changes
Summary:
Recent changes to the treemanifest extension removed the
treemanifest.prefetchtrees() function, and replaced moved this functionality to
a repo.prefetchtrees() function instead.

Update the Eden extension to call `repo.prefetchtrees()` if it is available.

Reviewed By: wez

Differential Revision: D6986218

fbshipit-source-id: 02e07ab5194f311e49d8ecb4755d79d55acb080c
2018-02-14 22:06:53 -08:00
Chad Austin
8f77f03df3 take Dir& instead of Dir* in saveOverlayDir
Summary:
Another small refactoring that I don't want mixed into my
bigger diffs.

Reviewed By: wez

Differential Revision: D6927482

fbshipit-source-id: 28cc60dfdffb50921a5ef9cca4e2814b90d3b701
2018-02-14 18:08:49 -08:00
Chad Austin
4dadbde38a introduce a MappedDiskVector type
Summary:
Introduces a persistent non-durable storage mechanism backed
by a memory-mapped file with fixed-length records.

Reviewed By: simpkins

Differential Revision: D6877217

fbshipit-source-id: 0ddacb4137cfe43e67c822dce4064356cdf515b5
2018-02-14 17:37:15 -08:00
Chad Austin
191e86aece eliminate some mode_t uses
Summary:
There were places we were acquiring a lock unnecessarily.  In
addition, I'm looking at reducing the number of places where we store
the full mode_t to see if we can get away with dirtype_t or something
similar.

Reviewed By: wez

Differential Revision: D6972140

fbshipit-source-id: bb29a4473f3056e39596600d22e67374ca484735
2018-02-12 17:55:57 -08:00
Wez Furlong
8ecd58130b fixup messaging in eden daemon --takeover
Summary:
We would immediately satisfy the health check and
tell the user that the system is healthy and show the pid of
the prior incarnation rather than the one for the instance
that we just launched.

This diff refactors the health checking code so that we can
share the implementation between the cli and the integration
tests; the integration tests already had code to do the right
thing for this.

Reviewed By: simpkins

Differential Revision: D6944989

fbshipit-source-id: 7c0f02c875b1b81f8f1b7521add67928200b27ed
2018-02-12 12:21:12 -08:00
Wez Furlong
8a77f57ea3 delete flakey test_unload_free_inodes_age
Summary:
chadaustin is going to think about how to test this
in unit tests intestead :-p

Reviewed By: chadaustin

Differential Revision: D6951788

fbshipit-source-id: 137f285f3a1f080ce43392a621c73640ce3a9bf7
2018-02-09 12:13:56 -08:00
Wez Furlong
3c8a6f624e typo fix in comment
Summary: as above

fbshipit-source-id: 64c6d699f5ab8d476b9c3d776ed53d28621fc095
2018-02-09 11:06:06 -08:00
Wez Furlong
3903de8e2f allow integration tests to select a storage engine
Summary:
This makes the default `memory` for speed and minimal
flakiness, but allows a test to select a different engine where
appropriate (eg: restart and remount tests).

Reviewed By: chadaustin

Differential Revision: D6944207

fbshipit-source-id: 1fb11387beda02d059a796dad5a42d56ddcf6e88
2018-02-08 20:06:55 -08:00
Wez Furlong
252a954b96 LocalStoreTest now covers all 3 storage implementations
Summary:
refactor this test so that we can apply it to any LocalStore
implementation, and have it run against the Memory, Rocks and SQLite
implementations.

Reviewed By: chadaustin, simpkins

Differential Revision: D6919455

fbshipit-source-id: cc93042b95833b175955e6395c84cf41238a90d2
2018-02-08 20:06:55 -08:00
Wez Furlong
eaeaf8f23c add SqliteLocalStore
Summary:
Adds a SQLite storage implementation and makes it the
default engine for integration tests; this requires fewer resources
to run and the integration tests thus run faster and more reliably.

In the future we may add a configuration option to remember the
storage engine that was used as it is currently not "safe" to switch
from one to the other because the hgproxyhash data cannot be
recreated without re-importing a revision.

Reviewed By: simpkins

Differential Revision: D6919456

fbshipit-source-id: 3afbfafb190cca0e3c797cd9b7cd051768575a8c
2018-02-08 20:06:55 -08:00
Adam Simpkins
58fa81ebf2 report a reasonable value in stat.st_blocks for files
Summary:
Update FileInode so that getattr() and setattr() both return a reasonable value
in st_blocks.

Previously we always returned 0 in st_blocks, which caused applications like
`du` to always report files as using 0 space in Eden mounts.  Now we compute
st_blocks based on st_size, so that `du` will report reasonable estimates for
when scanning the size of subdirectories inside an Eden mount.

Reviewed By: chadaustin

Differential Revision: D6932098

fbshipit-source-id: bd29e46821176e510f420e6e2b6ce480b80d50ff
2018-02-08 19:36:03 -08:00
Adam Simpkins
70b75b4164 rename EdenServer::state_ to runState_
Summary:
Rename the existing `state_` variable to `runState_` to help distinguish it
from the new `serverState_` variable.

The information in `runState_` is all related to whether the EdenServer object
is starting, shutting down, or running normally.

Reviewed By: wez

Differential Revision: D6929864

fbshipit-source-id: ad7af381a8a291b12db9308668c7616ebd9b7f39
2018-02-08 19:36:03 -08:00
Adam Simpkins
fe1c35f781 move the privhelper APIs into a PrivHelper class
Summary:
Move all of the privhelper functionality into a PrivHelper class.  The
ServerState object now stores the PrivHelper object to use, rather than having
a global singleton.

This will make it easier to stub out the PrivHelper functionality during unit
tests.

Reviewed By: wez

Differential Revision: D6929862

fbshipit-source-id: e3edcb0a03ba9afdf34554cb961fd74557cdd6e3
2018-02-08 19:36:03 -08:00
Adam Simpkins
fd2aa6a596 remove the --thrift_address command line flag
Summary:
Drop the --thrift_address flag, and always create the thrift socket using a
fixed name under the `.eden` directory.  The location of the `.eden` directory
is still configurable with the `--edenDir` argument.

There isn't really much benefit to making the socket path be configurable
separately from the .eden directory path, and it adds to the code complexity.
For instance, while you can tell eden to listen on a TCP socket instead of a
Unix domain socket, that functionality has been broken since D4637285
introduced a `CHECK()` statement that crashes the code when using a TCP socket.

Reviewed By: wez

Differential Revision: D6929863

fbshipit-source-id: ee5f7341d01d3ce522cae936ef3c133bba3f18f7
2018-02-08 19:36:03 -08:00
Adam Simpkins
bc93fd13b6 update diff code to use previously retrieved UserInfo
Summary:
Update EdenMount::diff() to use the UserInfo object stored in the shared
ServerState rather than calling UserInfo::lookup() on each diff operation.

Reviewed By: wez

Differential Revision: D6929865

fbshipit-source-id: a68ab1fa9eb345b59972e67c3aac258b4dbcdab5
2018-02-08 19:36:03 -08:00
Adam Simpkins
265b17d188 add a new ServerState class to store process-wide state
Summary:
Add a new ServerState class to store process-wide state that is shared across
multiple mounts.  Up until now we have passed around the shared state data as
separate variables.

This is intentionally separate from the existing EdenServer class to allow unit
tests to create EdenMount objects without an EdenServer object.

Reviewed By: wez

Differential Revision: D6929861

fbshipit-source-id: 5f22efb6d79dfd70031be1dc37f494c2ad8af902
2018-02-08 16:43:22 -08:00
Chad Austin
d93594e2c9 rename restart_test to takeover_test
Summary:
To me, restart implied shutting down the daemon and restarting it
again.  Perhaps instead of `eden daemon --takeover` we should have
`eden restart`.  But if people typed `eden restart` I imagine they're
trying to debug a problem, so that's probably not the right verb.

Reviewed By: wez

Differential Revision: D6929166

fbshipit-source-id: d568a1940d67f755e4c3656098c58fc81e0a3156
2018-02-08 11:10:51 -08:00
Wez Furlong
2e660e0d45 remove FuseChannel::threadsStoppingFuture
Summary:
We no longer need this and I believe that this was contributing
to this source of flakiness in our CI; this stack trace triggers when
we get an aborted or short read from the kernel:

```
*** Aborted at 1517827659 (Unix time, try 'date -d 1517827659') ***
*** Signal 11 (SIGSEGV) (0x2d0) received by PID 153706 (pthread TID 0x7f63ea37d700) (linux TID 160573) (maybe from PID 720, UID 0) (code: address not mapped to object), stack trace: ***
    @ 0000000002abfa2d folly::symbolizer::(anonymous namespace)::signalHandler(int, siginfo_t*, void*)
                       ./folly/experimental/symbolizer/SignalHandler.cpp:413
    @ 00007f646e96dacf (unknown)
    @ 00007f646e96aa20 __pthread_kill
    @ 0000000001873748 facebook::eden::fusell::FuseChannel::requestSessionExit()
                       ./eden/fs/fuse/FuseChannel.cpp:483
    @ 000000000187d2f7 facebook::eden::fusell::FuseChannel::processSession()
                       ./eden/fs/fuse/FuseChannel.cpp:656
    @ 000000000187dab9 facebook::eden::fusell::FuseChannel::fuseWorkerThread(unsigned long)
                       ./eden/fs/fuse/FuseChannel.cpp:493
    @ 00007f646f267170 execute_native_thread_routine
    @ 00007f646e9637a8 start_thread
    @ 00007f646e047a7c __clone
```

my theory is that we're allowing shutdownImpl to free things out from under other
threads before they've all seen this signal and wound down fully.  This is slightly
speculative in that I haven't managed to reproduce this stack trace on my devserver.

We don't really need this additional signal any longer.

Reviewed By: simpkins

Differential Revision: D6907734

fbshipit-source-id: 0f0138b631a7201fc9a4a1c93c2cde846e869cbd
2018-02-07 17:36:11 -08:00
Chad Austin
0783ffe211 pass InodeTimestamps straight to createHeader
Summary: Small refactoring I should have done with the previous diff.

Reviewed By: simpkins

Differential Revision: D6927152

fbshipit-source-id: 1dcda01134c3d63c62169c5728dba24ca0eebd68
2018-02-07 15:17:51 -08:00
Wez Furlong
a0fb6d9d05 split RocksDbLocalStore out from LocalStore
Summary:
This enables dropping in alternative implementations
of LocalStore and adds a MemoryLocalStore implementation for
use in our tests.

This diff doesn't change the default storage option for the
eden server.  I'll look at adding such an option in a follow up diff.

Reviewed By: chadaustin

Differential Revision: D6910413

fbshipit-source-id: 018bf04e0bff101e1f0ab35e8580ca2a2622e5ef
2018-02-07 11:54:16 -08:00
Adam Simpkins
4fb0ac3809 logging: update LoggerDB::get() to return a reference
Summary:
Change `LoggerDB::get()` to a reference instead of a pointer since this
function can never return null.

Reviewed By: yfeldblum

Differential Revision: D6893206

fbshipit-source-id: af47063918a79c851fd39b838d6c63755166e033
2018-02-06 12:51:07 -08:00
Wez Furlong
b5c47a9ed7 adjust expectations for inode unload integration test
Summary: This should make it less flaky

Reviewed By: simpkins

Differential Revision: D6908454

fbshipit-source-id: 07622b469ec635972290c3a4e5d1ed4b05ddd51a
2018-02-05 22:08:54 -08:00
Adam Simpkins
2d7949f46d update hg_import_helper.py startup behavior to more closely match hg
Summary:
Update hg_import_helper.py to parse the repository's .hg/hgrc file, but then
create the repository object with a fresh UI object that has not parsed that
config yet.

This more closely mimic's the behavior of mercurial's dispatch code invoked
when starting the `hg` command line.  This behavior is required to ensure that
secondary repository objects that get created end up with the correct
configuration, and do not have settings from the original repository's hgrc
file.

The mercurial behavior of parsing the original repository's hgrc file twice
dates back to rHG741f64dfc04d1.

Reviewed By: quark-zju

Differential Revision: D6909449

fbshipit-source-id: 85073ab6ade4ab70247d48bc670c9924e9e6841f
2018-02-05 21:53:46 -08:00
Wez Furlong
72243b218a remove hypothesis timeout setting
Summary:
This was causing flakiness in the form of premature timeouts
generating failure status.  Looking at the docs for hypothesis, this
option is deprecated and slated to be replaced with an infinite timeout
in the future:

http://hypothesis.readthedocs.io/en/latest/settings.html#hypothesis.settings.timeout

Those docs suggest using `hypothesis.unlimited` instead, but I couldn't import
that symbol (maybe our version is too old?) so I'm just using 0 which means
that no timeout will be applied.

Reviewed By: simpkins

Differential Revision: D6908200

fbshipit-source-id: 1143d4745fc84d9c14b29ff5a2906a4e776d14fe
2018-02-05 19:35:55 -08:00
Adam Simpkins
d900cc70ff short circuit diff operations for non-materialized trees
Summary:
Update `TreeInode::diff()` to check if its hash matches the source control tree
it is being compared to, and return early if they are identical.

I'm surprised that I forgot to include this initially when implementing
`TreeInode::diff()`

This makes `hg status` faster when a large number of unmodified directories
have been loaded.

Reviewed By: chadaustin

Differential Revision: D6890615

fbshipit-source-id: 561630d0220b4875dbf3678161cdb41a8aa4fc82
2018-02-05 16:08:09 -08:00
Adam Simpkins
e2c1034d26 slight refactoring of TreeInode::diff()
Summary:
This re-orders some of the code in `TreeInode::diff()` slightly.  This should
not affect the behavior of the code.

This moves the `isIgnored` check inside the main `contents_.wlock()` block.
This reduces the number of places where we grab the lock, and will help keep
things simple for an upcoming diff where I need to add some more checks in this
code with the lock held.

This also changes `inodeFuture` to use the new `Future::makeEmpty()`
constructor rather than having to use an `Optional<Future>`

Reviewed By: chadaustin

Differential Revision: D6890616

fbshipit-source-id: 354bbf6a6be6d356fd23e6c0fb6b534679bbe0bb
2018-02-05 16:08:09 -08:00
Wez Furlong
f5bf949b79 sanity check that the pid is not us for fuse requests
Summary: We don't think this is happening, but let's test it!

Reviewed By: simpkins

Differential Revision: D6888038

fbshipit-source-id: 754b2ec8f78ff513fd350a74505915e2a1e9ba3e
2018-02-02 19:38:05 -08:00
Chad Austin
8801f19064 convenience constructors for InodeTimestamps
Summary: Small things I've needed in later diffs.

Reviewed By: wez

Differential Revision: D6877755

fbshipit-source-id: c9002eb0b92dbd8fe9c4f636d2ca79b25cde331f
2018-02-01 16:24:37 -08:00
Chad Austin
20f7a10bfd split InodeTimestamps into its own file
Summary:
While working on timestamp storage, the fact that
InodeTimestamps was a member of InodeBase kept getting in the way.
Make it its own type.

Reviewed By: simpkins

Differential Revision: D6862835

fbshipit-source-id: 91d8984764f0586b9fa52e961eb5606a530e0416
2018-02-01 12:34:15 -08:00
Adam Simpkins
00a232d868 make Clock::getRealtime() const
Summary: This API seems like it should be const, as it does not modify the clock.

Reviewed By: chadaustin, zhupanov

Differential Revision: D6869719

fbshipit-source-id: c8bf4ccab34538b59e6baeedd0b0ff88b328236e
2018-02-01 11:19:15 -08:00
Andrew Gallagher
458ed4af7e Re-run autodeps on all opt-in TARGETS
Reviewed By: luciang

Differential Revision: D6862884

fbshipit-source-id: 731aa9c1e0deac12f3354dd86950aa24923f5cdf
2018-01-31 20:07:10 -08:00
Wez Furlong
afac32487a enable integration tests on sandcastle
Summary:
A little bit of plumbing to enable the watchman<->eden integration tests on sandcastle.

I noticed that we were still referencing the lame thrift par that I removed a little while back,
so let's clean that up.

Reviewed By: simpkins

Differential Revision: D6863221

fbshipit-source-id: 026f3d316d9ac52fe359cedc4e3c88394ec5c7c4
2018-01-31 15:53:40 -08:00
Wez Furlong
89c0c2cb90 clean up fuse init processing
Summary:
This diff moves the mount-time initialization handling
out of the main loop.  This rationale for this is:

* We don't (and shouldn't!) need to process FUSE_INIT for takeover
  processing, and this structure allows us to make stronger assertions
  about our state.
* we can avoid spinning up multiple threads in the (rare!) case that
  the FUSE_INIT fails
* It is now a little harder for exceptions during initialization to
  escape our notice.

In rearranging this stuff, I found a race condition in the worker thread
shutdown; we could erroneously emit a completion event before all of
the threads had been torn down and this resulted in sporadic integration
test failures hitting the assertion for the number of joined threads
in the destructor.

Reviewed By: simpkins

Differential Revision: D6766330

fbshipit-source-id: 32afb5a7c739c75aebfdb0a8f896eec5f41ad33f
2018-01-31 15:08:42 -08:00
Chad Austin
e9765e7c37 have eden doctor unmount unconnected mounts
Summary:
If we fail to lstat a mount because the FUSE daemon is
unconnected, go ahead and unmount it.

Reviewed By: simpkins

Differential Revision: D6848115

fbshipit-source-id: df797b15956db24c4ac87dc6d4cd0a7177dd20ef
2018-01-31 11:48:21 -08:00
Wez Furlong
53b84df124 allow running integration tests on sandcastle
Summary:
This is a fairly minimal attempt at asking sandcastle to
run our tests as root.  This is inspired by D6608746 but is for
the moment pretty coarse; I just want to see how successful this
is before finishing this off nicely, which means splitting our
contbuild config into two pieces along similar lines as D6608746;
one piece would run the tests as usual without root privileges
whilst the other would run just the integration tests with root
privs.

Reviewed By: chadaustin

Differential Revision: D6612669

fbshipit-source-id: 9a730b02424e939dd3509310b6265d50d1102e77
2018-01-31 11:48:21 -08:00
Wez Furlong
7ab70a5493 adjust setattr expectations when run as root
Summary: Rather than EPERM we get EACCESS when running as root

Reviewed By: chadaustin

Differential Revision: D6853303

fbshipit-source-id: c6743c8d036a24255d2d31c560034c972a0253c7
2018-01-30 21:50:39 -08:00
Wez Furlong
f82026e4fb don't throw in the version check if eden is not installed
Summary:
in our sandcastle environment, eden is not currently
installed and the tests that look at the version are throwing
an error when the rpm query fails.

Don't do that!

Reviewed By: simpkins

Differential Revision: D6853305

fbshipit-source-id: d17cb1fb0253ef5ae5000695b6ec5bcda4a6a448
2018-01-30 21:50:39 -08:00
Wez Furlong
d6adcfc058 add fsattr utility for testing purposes
Summary:
This is the spiritual successor to D3302706 which originally
wanted to solve this by adding a python extension.  That would prove
to be too painful for the opensource build so it was shelved.

We now need to be able to run our tests in an environment that doesn't
have the `attr` rpm installed so this is a good time to fix this
in a more portable way.

This diff adds a little wrapper around the functions that we already
have for consuming extended attribute information and augments them
with another to list attributes.

The utility emits output in json format and is intended to be fed
directly into the helper functions we have in `fs.py`.

Reviewed By: chadaustin

Differential Revision: D6851182

fbshipit-source-id: 3d1d1a351f2e01405645d45658d1c8bc61a659a4
2018-01-30 21:50:39 -08:00
Chad Austin
d0823ab865 unbox Dir Entries
Summary:
Dir's contents were represented as a vector of 64-bit
pointers to 48-byte structs.  This change removes that layer of
indirection, reducing memory usage and slightly pessimizing insertion.

The diff is mostly mechanical outside of the TreeInode.h changes and
calls to emplace..

I'll run memory tests tomorrow, though it's a gamble as to whether
private bytes will show a difference.  I may need to shrink the Entry
struct too.

Reviewed By: wez

Differential Revision: D6804957

fbshipit-source-id: b126656dbc7951565e74b6401adde6353e809056
2018-01-30 15:11:55 -08:00
Wez Furlong
a3b148fddb add thrift takeover serialization
Summary:
This adds version 3 nee 2 of the takeover serialization,
which uses thrift to represent the data.  Even though it is logically
version 2 I'm naming it version 3 because we're taking advantage of
the MessageType values from Version 1 which allowed numerical values
1 or 2 to represent different data types.

In this diff we now formalize that first word as the protocol version
and to avoid ambiguity are starting the new version value at 3.  I
did briefly consider using the name Version2 to refer to this and setting
the value in the enum to 3, but I didn't want to become known for
API hate crimes against my fellow engineers.

Reviewed By: simpkins

Differential Revision: D6733406

fbshipit-source-id: e2067365e4e8b388490440fd73ab504544011846
2018-01-30 14:21:18 -08:00
Wez Furlong
be130bc880 add version handshake to takeover protocol
Summary:
Whilst chatting with simpkins we realized that we lost
the handshake portion of the takeover protocol during a refactor.

The handshake is important for a couple of reasons:

1. It prevents unmounting and loosing all the mounts in the case
   that sometime decides to netcat or otherwise connect to the
   socket
2. It gives us an opportunity to short circuit any heavy lifting
   if we know that it will be impossible to succeed.
3. It allows us to rollback to earlier builds with older versions
   of the takeover protocol.

This diff adds a little bit of machinery to enable passing a set of supported
takeover protocol version numbers.  The intent is to retain support for
the two of these at a time; any time we change the encoding/protocol
for takeover we'll bump the version number and add supporting code
to handle the new format, retaining support for the prior version.

Retaining the ability to handle the prior version allows us to downgrade
to an earlier build gracefully if/when the need arises.

I opted to do this here rather than by bumping the `kProtocolID`
constant in `UnixSocket.h` becase we're not really changing the
lowest level of the protocol; just the takeover specific portions.

I haven't actually changed the takeover serialization in this diff,
but do have some work on that happening in D6733406; that diff will
be amended to take advantage and demonstrate how this versioning
scheme works.

A key thing to note about the implementation of this diff is that
the client sends the version number to the server, but doesn't
add any explicit version encoding in the response we receive.
This is deliberate and allows us to upgrade prior builds to
this new scheme.  I'll add a more definitive check for this
situation when I actually rev the format in the following diff.

Reviewed By: simpkins

Differential Revision: D6743065

fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-30 14:21:18 -08:00
Chad Austin
a06f12e6b0 avoid a strlen in DirHandle
Summary:
Tiny thing I noticed when reading code.  Keep the entry name
as a StringPiece rather than bouncing through char*.

Reviewed By: zhupanov

Differential Revision: D6820080

fbshipit-source-id: 884e55f74094f44012efbe44b86d8e5903300967
2018-01-30 13:35:49 -08:00
Chad Austin
144a47d1ae fix status/diff when symlinks change
Summary:
isSameAs calls getSha1 which was failing on symlinks.  The
original concern was that asking for the SHA-1 of a symlink is
ambiguous: do you want the hash of the symlink or the target?  But we
already check for whether you are requesting the SHA-1 of a symlink in
EdenServiceHandler, so it's redundant and incorrect to check in
FileInode too.

Reviewed By: simpkins

Differential Revision: D6847489

fbshipit-source-id: 13966da06bcde75c5c568e09fef14e735de47cfb
2018-01-30 13:35:49 -08:00
Chad Austin
00d6bcc115 allow eden mount and eden unmount to take multiple paths
Summary: A minor convenience for mass mounting and unmounting.

Reviewed By: simpkins

Differential Revision: D6803003

fbshipit-source-id: 16c0d6982ba0ce2dba9900ee15013fcec8bc5ad5
2018-01-29 11:36:19 -08:00
Michael Bolin
7673f16536 Add support for a more complete set of options to hg status.
Summary:
This adds support for the following flags for `hg status` in the Rust wrapper:

* `--all`
* `--modified`
* `--added`
* `--removed`
* `--deleted`
* `--clean`
* `--unknown`
* `--ignored`
* `--no-status`
* `--copies`

There is now a `create_print_config()` function that takes the parsed arguments
and distills them into a `PrintConfig`, which describes the net configuration
as a result of all the flags. (Note that some flags can interfere with each other,
e.g., `--no-status` forces `--copies` to be disabled.)

While here, I cleaned up a bunch of duplication in the code that prints the
status to stdout. Much of the duplication in the old implementation has been
encapsulated in a closure within the new `print_status()` function.
This also made it easier to implement `--copies` for all of the different status
types.

Incidentally, this helps us specify `listIgnored` correctly when calling the
`getScmStatus()` Thrift method as we now keep track of whether the user
specified `--ignored`. This is particularly important for the Eden integration
test suite because its `assert_status()` helper method calls
`hg status --print0 -mardui` by default, so `buck test eden/...` makes much
greater use of the Rust wrapper than it did before.

Reviewed By: wez

Differential Revision: D6770916

fbshipit-source-id: fea1a159addca6d16caa1b7019dc11dc2dcb3e1b
2018-01-26 17:52:14 -08:00
Chad Austin
697eb8a6fd run clang-format across eden
Summary:
```
find . \( -iname '*.cpp' -o -iname '*.h' \) -exec arc lint --apply-patches {} +
```

Differential Revision: D6820436

fbshipit-source-id: 173c0e3b5c023c1c9276f34e17d732f1dd161892
2018-01-26 11:20:31 -08:00
Chad Austin
13176097df bring back fbstring for PathComponent - reduces PathMap memory usage
Summary:
In my benchmarks, using fbstring over std::string for PathMap is
worthwhile.  There are a lot of entries stored in PathMap and the fact
that fbstring is a word smaller than std::string adds up.

Differential Revision: D6820204

fbshipit-source-id: 1ac34a81828891eb8125b13a074de6ed9715edad
2018-01-26 10:51:58 -08:00
Sergey Zhupanov
ec9ff7e3ef Add comments about postponed umask/permissions for mkdir and mknod
Summary:
Added comments linking to the task with discussion of why we are postponing
proper handling of umask and permissions in general for mkdir and mknod.

Reviewed By: wez

Differential Revision: D6808696

fbshipit-source-id: a6d74ea08448c8578282dc146ac81da187d4409c
2018-01-25 20:51:16 -08:00
Chad Austin
7a909f6168 avoid a crash in eden doctor if any active mounts are unconfigured
Summary:
My stale mounts check regressed eden doctor's handling of
unconfigured mounts.  For now, just skip them, and add a test that
eden doctor doesn't crash.

Reviewed By: simpkins

Differential Revision: D6801445

fbshipit-source-id: 65d2f9028af651ef487a7ce6c334f387b541492d
2018-01-25 15:14:58 -08:00
Chad Austin
916f069b91 bring back eden doctor's stale mounts check - filter by st_uid and st_dev instead of path
Summary:
The prior implementation of StaleMountsCheck filtered by path
and did not correctly handle seeing the same FUSE mount multiple times
in the mount table. This occurred when an Eden mount was created
underneath a bind mount.

Now it only unmounts mounts where st_dev does not match the st_dev of
any active mounts, and where st_uid matches the current user.

Reviewed By: simpkins

Differential Revision: D6787618

fbshipit-source-id: 24e0f156cb74822500d91205349c0e6638c0340c
2018-01-25 15:14:58 -08:00
Wez Furlong
067439b613 update eden to target the treemanifest source of truth
Summary:
Now that we've moved the hg source around, update eden
to point to the source of truth rather than the synced subdir.

I spoke with andrewjcg about the use of header_namespace here;
it is required to be able to reference the headers without changing
the code under scm/hg to be relative to the fbcode root.  We can't
change that code in that way because it has to build standalone
for the opensource consumers.

Remove the duplicated code while we're in here to make sure
that we're not accidentally referencing it anywhere.

Reviewed By: simpkins

Differential Revision: D6792969

fbshipit-source-id: ec55e98c0bde2488c213b1fd9f8baae9868a350c
2018-01-25 14:35:32 -08:00
Chad Austin
8219f5c60a have eden stats show file and tree counts
Summary:
It's interesting to see the total number of loaded files
vs. trees when the loaded inode count is high.

Reviewed By: wez

Differential Revision: D6765874

fbshipit-source-id: 178b30184428bd5cf5e005eb475e4f5a1476c385
2018-01-24 15:29:16 -08:00
Chad Austin
adce4eba1e fix determining which inodes can be unloaded
Summary:
I'm not sure what was wrong with the old code, but I
simplified and clarified all of the time math and now `eden debug
unload` behaves as I'd expect it should.

Reviewed By: simpkins

Differential Revision: D6764962

fbshipit-source-id: 3ed359d4ab4652e95d1538a0982c24185999351c
2018-01-24 15:29:16 -08:00
Chad Austin
c0acea995d remove rdev from state and don't pretend we support it for now
Summary:
rdev doesn't add any value yet. We can add it back if we want
to implement support.

Reviewed By: simpkins

Differential Revision: D6792346

fbshipit-source-id: ce16317074f1daa456737c55804da8fb7f2b7a94
2018-01-24 13:36:05 -08:00
Wez Furlong
3b2fbf93c1 factor out FuseChannel buffer size
Summary: This makes it easier to separate out the fuse initialization logic in a follow on diff.

Reviewed By: simpkins

Differential Revision: D6766329

fbshipit-source-id: 178d97e2302bc283c701039494e4477285abc0af
2018-01-24 11:34:48 -08:00
Wez Furlong
056d7f4917 slightly simplify FuseChannel initialization
Summary:
This slightly improves the code in EdenMount by having
just a single call to the FuseChannel constructor with an optional
`fuse_init_out` instance that we can use to determine if we are
performing a takeover or not.

Reviewed By: simpkins

Differential Revision: D6766328

fbshipit-source-id: ece140a1572e2934a3e35bfe25b83af910346c18
2018-01-24 11:34:48 -08:00
Adam Simpkins
27ef593f70 add type annotations to all functions in commit_test.py
Summary: Add type annotations to the test functions in this file.

Reviewed By: chadaustin

Differential Revision: D6789863

fbshipit-source-id: d298a388b5ea03fcf25047937e747051c8fa682b
2018-01-23 20:50:29 -08:00
Adam Simpkins
4abb5f6720 add integration tests for running "hg commit <path>"
Summary:
Test running `hg commit` with a path argument.  This currently fails if the
path refers to a directory rather than a file.

Reviewed By: chadaustin

Differential Revision: D6789862

fbshipit-source-id: 054ee26ea0fdb843cc12d5e8ac3c3d34b9308017
2018-01-23 20:50:29 -08:00
Sergey Zhupanov
ae0f9c1aa6 Minor stylistic changes.
Summary: Minor stylistic changes that were done during constification but factored out.

Reviewed By: chadaustin

Differential Revision: D6774976

fbshipit-source-id: d18cd339153cf16ff69be0de5f3eb019a4baa1a0
2018-01-23 14:52:34 -08:00
Sergey Zhupanov
25e74d5712 Fixing opt build lint warning introduced by a previously landed revision.
Summary: Added folly::assume_unreachable() to quell the false positive warning.

Reviewed By: wez

Differential Revision: D6787186

fbshipit-source-id: 400695f8cda915557cf4999b1b998a5aefc558f0
2018-01-23 11:49:11 -08:00
Sergey Zhupanov
a7a0eb430d Refactor if processing of enum class as switch for safety and compile time support
Summary:
The value we get is of enum class, so it is guaranteed to be in the valid set.
Omitting default we get compiler support if we ever expand the set of values.
Throw becomes obviated, because it becomes unreachable.

Reviewed By: simpkins

Differential Revision: D6771224

fbshipit-source-id: 039f0545d20649193b3fb74981ee7f027f31fd8e
2018-01-22 20:07:32 -08:00
Sergey Zhupanov
5f98c49a19 Stop ignoring errors in dir creation in EdenMount::performBindMounts()
Summary: Switch from error-code-based to exception-based boost call to ensure errors are caught.

Reviewed By: simpkins

Differential Revision: D6771193

fbshipit-source-id: 592867c097c2af580f5b992b01e2c1b6c4a12ca4
2018-01-22 17:55:24 -08:00
Sergey Zhupanov
7c1dac9a29 Replaced unnecessary memset calls with C++11 struct = {} init syntax.
Summary: Replaced memset used to 0-init structs with POD fields with = {} init.

Reviewed By: simpkins

Differential Revision: D6770868

fbshipit-source-id: 190205a277e3c73711813bc515b860b107d41f83
2018-01-22 17:55:24 -08:00
Sergey Zhupanov
1d219b5dc2 Removed unnecessary check and dir creation in edenclient.py for clone.
Summary: removed check for target dir of eden clone in edenclient

Reviewed By: simpkins

Differential Revision: D6770615

fbshipit-source-id: 4f480c2a494673179d92c0571082b9be895cf51b
2018-01-22 17:04:40 -08:00
Chad Austin
7ad29f79d4 temporarily disable the StaleMountsCheck - it's unmounting active mounts
Summary:
bolinfest has observed `eden doctor` unmounting active mounts, so disable
that check until this is resolved.

Reviewed By: bolinfest

Differential Revision: D6768284

fbshipit-source-id: 21add1fa283f8631055019dae99819d04e179d5e
2018-01-20 10:35:20 -08:00
Adam Simpkins
78262a0cf6 add some additional checks to the hg update --merge test
Summary:
Update the `hg update --merge` to test marking the change resolved and
committing the result.

Reviewed By: wez

Differential Revision: D6757299

fbshipit-source-id: c147e6ff8b63e364f96d2ce8a2094dd809d8da7d
2018-01-19 15:51:47 -08:00
Adam Simpkins
6cec539d3f fix dirstate.normallookup() behavior
Summary:
Fix `dirstate.normallookup()` to behave like `dirstate.normal()`, since our
`dirstate.status()` function does not handle "unsure" files that need to be
checked on disk.

This was previously causing problems after running `hg commit -i`.

We ideally should probably have some additional changes here to avoid making an
filesystem `lstat()` call even in the `dirstate.normal()`, but that can wait
until later.

Reviewed By: bolinfest

Differential Revision: D6746814

fbshipit-source-id: c1623415fc3a923b0b7878be651db3ad8fbb2aff
2018-01-19 15:16:09 -08:00
Carl Meyer
43fa3cbcd8 better fix for type error
Summary:
On closer investigation, I realized that the typechecker is
complaining about a real problem here, that was apparently hidden by
the stubs. The problem is explained in
https://our.intern.facebook.com/intern/dex/qa/1596320410425583/

It's not safe to `import thrift` followed by accessing
`thrift.Thrift.TException`; it only happens to work at runtime if some
intervening code has explicitly imported `thrift.Thrift` submodule for
you.

This diff fixes the code to be safer and also make mypy happy.

Reviewed By: chadaustin

Differential Revision: D6761089

fbshipit-source-id: 5c6fdfa0bef893c4aea17ade8e7bfacaf7c0c8cc
2018-01-19 14:51:36 -08:00
Wez Furlong
ff7cf0e6a0 have doctor suggest running a takeover restart
Summary: as above

Reviewed By: bolinfest

Differential Revision: D6763283

fbshipit-source-id: 8963d35e7f34d9d764e166a156faea7c34e999e4
2018-01-19 14:51:36 -08:00
Michael Bolin
f9581c080d Remove code for migrating the old ~/local/.eden/clients/*/ directory.
Summary:
As noted by the TODO, enough time has passed since the migration to the new
directory layout has been available that we should feel comfortable deleting the
migration code.

Reviewed By: wez

Differential Revision: D6762457

fbshipit-source-id: 9b4a9ad1a0204878a419362c8cfbdcbb500b1aee
2018-01-19 13:06:10 -08:00
Michael Bolin
b77b390c9f Remove support for old dirstate format.
Summary:
We've been using the new format for long enough that I don't think we need to
keep the old migration code around anymore. I didn't add support for it in
D6717211, so I think we're better off just killing it at this point.

Reviewed By: wez

Differential Revision: D6762271

fbshipit-source-id: d7590f3402f2ac23446aa1858ea58eeae676c153
2018-01-19 13:06:10 -08:00
Michael Bolin
b6639e37a5 Updated Rust wrapper so that hg status works again in Eden.
Summary:
The storage format for dirstate data in Eden changed substantially in D6179950.
Although `status.rs` was modified as part of that change, it was only updated to
make it so the rust wrapper still compiled, but it did not maintain the
correctness of the overall function.

This revision is a port of the logic in `eden/py/dirstate.py` and
`eden/hg/eden/EdenThriftClient.py` so that the Python code in the Eden/Hg
extension behaves the same as that of the Rust wrapper.

The current implementation of `hg status` in Rust does not relativize paths to `$PWD`, so
it always behaves as if `--root-relative` was specified. This should be fixed in a
follow-up revision.

Reviewed By: jsgf

Differential Revision: D6717211

fbshipit-source-id: ca900e251d392a77c07cb7305c4d4a62def1c7ab
2018-01-19 12:35:46 -08:00
Chad Austin
b6b2a08998 unmount stale edenfs mounts in eden doctor
Summary:
If the Eden process dies or malfunctions, it's possible to end up with stale
edenfs mounts on the system.  Change `eden doctor` to correct them.

Reviewed By: simpkins

Differential Revision: D6659193

fbshipit-source-id: d9fcf2e68663295e4f43b2c11fd4503a1dfac038
2018-01-19 11:06:51 -08:00
Sergey Zhupanov
c2eb5f3f3f Added integration test validating umask is properly set on file creation by touch.
Summary: Added integration test validating umask is properly set on file creation by touch.

Reviewed By: wez

Differential Revision: D6749557

fbshipit-source-id: adb89ec996148ede95bdb23399745b39504ae8db
2018-01-18 21:23:21 -08:00
Adam Simpkins
319b991379 rename stdout_charset to encoding for hg() and git() functions
Summary:
Rename the `stdout_charset` parameter to `encoding` now that we also use this
for encoding the stdin contents.

Reviewed By: wez

Differential Revision: D6757300

fbshipit-source-id: f79fc760e0f9fdcd6af559fcdad34976aaf16412
2018-01-18 20:24:08 -08:00
Adam Simpkins
6ed5a601cc improve passing stdin to hg in integration tests
Summary:
Update the `hg split` tests to pass input to the split command using
the `input` argument to `subprocess.run()` rather than running the command
through the shell and using a shell "here document".

Reviewed By: bolinfest, chadaustin

Differential Revision: D6746815

fbshipit-source-id: b607c554a249f702758dcad2ac4d863d1c1c7bad
2018-01-18 20:24:08 -08:00
Adam Simpkins
98f636911c log a message just before normal shutdown
Summary:
Add a log message on successful shutdown, just so that Eden's shutdown point is
easily identifiable in the log files.

Reviewed By: wez

Differential Revision: D6757386

fbshipit-source-id: f19a37c2ec9ae64fff99d40201d80e5f8faeaea5
2018-01-18 19:57:23 -08:00
Adam Simpkins
0b7ec94162 update hg extension to work with mercurial changes
Summary:
Update the eden hg extension to check for the remotefilenames extension both as
`remotefilenames` and as `hgext.remotefilenames`.

Reviewed By: bolinfest, quark-zju

Differential Revision: D6755872

fbshipit-source-id: 261e473c7194d67c69e1a008bf16d563a87fba67
2018-01-18 18:36:48 -08:00
Sergey Zhupanov
6ae3b840f8 Added --version implementation to eden.
Summary:
Added --version to main.py, including -v and version.
It prints both installed and running version (as per Wez's suggestion), and accounts for the possibilities that eden may not be running at all, or dev version may be running.

Reviewed By: wez

Differential Revision: D6724204

fbshipit-source-id: 5085f53a00a557f759a23fe41fb57189c9ad6a7e
2018-01-18 15:48:17 -08:00
Chad Austin
5419bb19d0 make typecheck pass (work around updated typeshed without thrift stubs)
Summary:
D6738525 and D6731821 (https://github.com/python/typeshed/pull/1827)
broke type checking on Eden's Python.  This works around removing the thrift
stubs.

Reviewed By: carljm

Differential Revision: D6745233

fbshipit-source-id: 760f7ee199698a0a570a993f16b45c833910aade
2018-01-17 19:06:03 -08:00
Wez Furlong
29578f9cca daemon should chdir / to avoid circular issues
Summary:
akushner mentioned that he saw a hang when performing
a graceful restart and we realized that his cwd was inside the
mount point that he was taking over.  While this doesn't guarantee
problems (I've run it this way almost exclusively with no issues)
it feels like a potential problem to hold a reference to a file
descriptor within a fuse mount that we are ourselves going to
manage: it seems likely that we could end up deadlocking if
we were to attempt any IO on such a descriptor.

This diff seeks to head off this particular case by simply
chdiring to `/` very early on startup.  This is typically
something that is handled by the `daemonize` function in
old school unix code.

Reviewed By: simpkins

Differential Revision: D6740547

fbshipit-source-id: 986004e9ed6cfa493ad55c5cdbca1805fc0f7768
2018-01-17 13:41:19 -08:00
Sergey Zhupanov
ea2994c045 Misc cleanup of cpp files in eden/fs/fuse/
Summary: Misc cleanup (mainly constification).

Reviewed By: simpkins

Differential Revision: D6720987

fbshipit-source-id: c9c719fce93d413857c48c61e0c920319e865209
2018-01-17 13:41:19 -08:00
Wez Furlong
9cbdc5ff68 add missing doc comment
Summary: Missed this earlier

Reviewed By: simpkins

Differential Revision: D6737596

fbshipit-source-id: 1745c1ffee6c11bcf462c53bb13265ebd99fa753
2018-01-17 12:22:01 -08:00
Wez Furlong
0cd02dc285 move InodeMap serialization to new takeover.thrift file
Summary:
This is moving some files around in preparation for
moving TakeoverData to using thrift for its serialization

Reviewed By: simpkins

Differential Revision: D6733405

fbshipit-source-id: 235ba237546f8ef606de8445db45683ce38a2d2c
2018-01-17 11:51:30 -08:00
Sergey Zhupanov
09f8707b81 Minor refactor replacing if with switch and a loop control comparison.
Summary: Minor refactor replacing if with switch and a loop control comparison.

Reviewed By: wez

Differential Revision: D6730849

fbshipit-source-id: 69ac7be9fae3be6274b56dd2baea433ed2437f7c
2018-01-16 18:48:08 -08:00
Sergey Zhupanov
0b4fea5374 change eden clone to check out master commit in both git and hg.
Summary:
Changed `eden clone` to check out master commit in both git and hg.
Previously, it checked out the current commit for the repo.

Reviewed By: simpkins

Differential Revision: D6663754

fbshipit-source-id: 92b185ccca5d082dc2bde9c8b191c82a2a4f06b4
2018-01-13 14:26:32 -08:00
Wez Furlong
ca3a259bdc allow loading unlinked inodes
Summary:
This implements a TODO/FATAL that is important for
graceful restarts to be useful in my "acid test" scenario,
which is to perform a graceful restart while buck build is
running.

Reviewed By: simpkins

Differential Revision: D6700189

fbshipit-source-id: dec1b818ebc9e907841bc127ee08c953b59d6487
2018-01-12 12:35:35 -08:00
Adam Simpkins
fe4905e299 fix long lines in basic_test.py
Summary:
Fix lines longer than 80 characters, and also reduce the number of times the
initial directory listing is repeated throughout this file.

Reviewed By: wez

Differential Revision: D6710372

fbshipit-source-id: bdb02cbebabeff7d7c6c88aebee7ebab1865535b
2018-01-11 22:27:33 -08:00
Adam Simpkins
95be9a2eec fix statfs() results to return a non-zero maximum name length
Summary:
Update the statfs() code to return non-zero values for namelen and frsize.

Returning 0 for namelen was causing problems for programs that checked
`pathconf(path, _PC_NAME_MAX)` and tried to honor this value.  For instance,
GNU patch would try to generate files with a 0-length name since we indicated
the maximum name length was 0.

I haven't investigated too closely, but this behavior might have broken only
recently when we stopped using libfuse.  libfuse may have been setting this to
255 for us.  I didn't see code in libfuse that would do this, but I'm fairly
sure GNU patch was working correctly very recently.

Reviewed By: wez

Differential Revision: D6710370

fbshipit-source-id: fc9a0320cd7c1eb2545219a3ec123c2f0644fb5d
2018-01-11 22:27:33 -08:00
Wez Furlong
9bb3db9ee4 stop journal subscribers prior to shutting down thrift
Summary:
This avoids the long delay and the `Cpp2Worker.cpp:281] Failed to join
outstanding requests.` message from showing up in the eden logs during shutdown
and graceful restart.

Reviewed By: chadaustin

Differential Revision: D6693117

fbshipit-source-id: 3c56314f288a596264cddae0d8bbab66ab19e9fe
2018-01-10 13:13:50 -08:00
Wez Furlong
530346887d split EdenMount::{create,initialize} -> safer takeover mounting
Summary:
Previously, `EdenMount::create` would implicitly call
`EdenMount::initialize` which would load the root inode and the `.eden` magical
directory.  That's fine for the fresh mount case, but in the case of the
graceful restart we need to take the opportunity to apply the `InodeMap`
from the old process before we start muddying its state.

This diff breaks out the `initialize` method from the `create` method and
makes the mount code call it after potentially loading the `InodeMap` from
the takeover data.

In addition, this diff removes the the `root->loadMaterializedChildren()`
call from the mount initialization code.  It is no longer required to do
this eagerly and it makes things simpler and our memory profile a little
smaller to defer this (I haven't measured how much that impacts things).

Reviewed By: simpkins

Differential Revision: D6691182

fbshipit-source-id: 52033a6d64105b658314a919f69dbfcd4eea242b
2018-01-10 13:13:50 -08:00
Wez Furlong
7daecf237d refactor mount/takeover code into a single flow
Summary:
This removes the duplicated logic and makes it a little
bit easier to follow the initialization sequence.

It doesn't change the behavior, just moves some code around.

Reviewed By: simpkins

Differential Revision: D6691180

fbshipit-source-id: 2068dbe56ebe9a6136d69689997aec8dedd32be0
2018-01-10 13:13:50 -08:00
Wez Furlong
c82616c564 refactor takeoverAll() -> unmountAll()
Summary:
This is the "simple" threading through of a `doTakeover`
flag and the return of `Optional<TakeoverData>` in the unmount code.

Reviewed By: simpkins

Differential Revision: D6691181

fbshipit-source-id: 4a384787783c16085f2e9964964023ba07cefca3
2018-01-09 22:23:12 -08:00
Wez Furlong
014789b4ca open file handles now survive graceful restart
Summary:
I'm so-so on a bit of the implementation here, but it works!

I had to change the `takeoverPromise` from the `pair<fuseDevice, connInfo>`
to a new helper struct because we now have three distinct pieces of data
to pass out of EdenMount to build up the overall TakeoverData.

The key change in this diff is that we have to release all of the file handles
we're maintaining in the `FileHandleMap` prior to shutting down the `InodeMap`,
otherwise the `InodeMap` will never complete (it waits for all inodes to be
unreferenced, and that cannot happen while there are open file handles).  I've
made the `FileHandleMap` serialization and clearing contingent on performing a
takeover shutdown because that feels like the safest thing to do wrt. not
losing any pending writes.

Reviewed By: simpkins

Differential Revision: D6672437

fbshipit-source-id: 7b1f0f8e7ff09dbed850c7737383ecdf1e5ff0c7
2018-01-09 22:23:11 -08:00
Wez Furlong
490e6adcf5 inform PrivHelper of takeover; graceful restarts now work!
Summary:
This is the key portion that makes the graceful restart
function.  This diff connects almost all of the moving pieces together;
it informs the priv helper about the takeover mount and transfers
the InodeMap information into the new generation of the eden server.

It doesn't yet load the fileHandleMap (will tackle that in a follow up diff)

Reviewed By: simpkins

Differential Revision: D6670903

fbshipit-source-id: 1770d99eb1477440a6c1deed83b0da55b9c1bbe4
2018-01-09 22:23:10 -08:00
Wez Furlong
ef214c6c4f serialize the InodeMap
Summary:
this isn't how we really want to do this long term, it's
just the most expedient short term implementation.

This diff provides an implementation of the `InodeMap::save()` which
was previously a stub method; the new implementation returns a thrift
structure that encompasses the unloaded inodes in the map, and adds
a corresponding load() method that performs the reverse transformation.

The struct is serialized into the Takeover data.

This diff doesn't hook up the real serialized data to EdenServer; that will happen
in a follow-on diff.

The way that we actually want to handle this longer term is to store the
`numFuseReferences` field into the overlay file on disk, but to do so we
will need to add a mountGeneration field alongside it and ensure that we
always write out the correct information at the correct times.  In addition,
we'd need to add equivalent data to TreeInode::Entry and add accessors that
safely return the correct values in the correct situations.

In the interest of getting something working, I've just dumped this code in
here.

I've also placed the thrift structure for this in `fuse/handlemap.thrift`;
this is a slight layering violation but one that feels "OK" in light of
the imminent refactor of the Takeover data struct to be its own thrift
struct anyway.

Reviewed By: simpkins

Differential Revision: D6670904

fbshipit-source-id: 11a0918954c741935c587e46fcb0e38849010de1
2018-01-09 22:23:10 -08:00
Wez Furlong
65b2d3c4b1 serialize FileHandleMap into TakeoverData
Summary:
This puts the data into the takeover information during takeover
shutdown, but doesn't do anything to pull it out again (that will be in a follow on diff).

The serialization stuff could be done a little bit more efficiently (since we
will perform an extra thrift serialization step just to compute the length, and
repeat it again later), but we're planning on replacing this with thrift
serializing soon, once simpkins diff stack lands, so I'm not losing sleep over
it.

Reviewed By: simpkins

Differential Revision: D6668846

fbshipit-source-id: e6d01428bd506a9e93b427db499770fce0a0983a
2018-01-09 22:23:08 -08:00
Wez Furlong
1c2a4c3f93 add client configuration path to TakeoverData
Summary:
This fulfils a TODO but doesn't do anything useful
with that data at this time.

Reviewed By: simpkins

Differential Revision: D6552750

fbshipit-source-id: 0c441fd0c2ab43785b4d98c4ca6ff643a20629e0
2018-01-09 22:23:07 -08:00
Wez Furlong
8689b37221 connect the fuse device information to the takeover data
Summary:
This adds some plumbing to thread the fuse device descriptor and
negotiated capabilities through to the takeover code.

I initially wanted to just make the
unmount future yield the device descriptor, but since that uses
`SharedPromise` it is not compatible with a move-only type like
`folly:File`, so I added an optional promise to deal with just that.

I'm also populating the takeover mount information (path, bind mounts)
for each mount point.

Reviewed By: simpkins

Differential Revision: D6494509

fbshipit-source-id: a90684292dc1d8e06ce2c0721eadd8d393377f33
2018-01-09 22:23:04 -08:00
Andrew Gallagher
ebab5e09b9 Run autodeps on stale opt-in TARGETS
Reviewed By: luciang, meyering

Differential Revision: D6685618

fbshipit-source-id: 9e0e01a8cbc47f00225fd8445dcc4c35b4e43ffb
2018-01-09 15:12:08 -08:00
Wez Furlong
6db8db6dfd use ENOTTY to report unsupported ioctl, fix listxattr
Summary:
The unix `patch` command attempts to issue an `FS_IOC_GETFLAGS`
ioctl and blows up when we return `ENOSYS`.  The man page for ioctl says:

```
   ENOTTY The specified request does not apply to the kind of object that
   the file descriptor fd references.
```

so let's return that error code to ioctl.

In addition, the integration test I added for this trips up when it calls
`llistxattr` on the file; turns out we don't need to insert the
`fuse_getxattr_out` when we're returning the attribute list and that it
is only needed when measuring up the required length, so let's move
things around to resolve this and make it clearer.

Reviewed By: chadaustin

Differential Revision: D6685568

fbshipit-source-id: 81963ffe9af30db5634e5e96b7a8aa1485859d65
2018-01-09 12:33:20 -08:00
Chad Austin
b0fac29b0b enable python typechecking from buck
Summary: Turn on check_types for CLI's python_binary.

Reviewed By: simpkins

Differential Revision: D6668636

fbshipit-source-id: abde1e1cedf2a5104cdaa5433377b1d2adc372fd
2018-01-08 12:10:19 -08:00
Chad Austin
453f3aa507 fix typo in comment
Summary: A prior shelve contained this fix but never got landed.

Reviewed By: wez

Differential Revision: D6676206

fbshipit-source-id: b8c733be663ff56e1a0625f09ec505891d430084
2018-01-08 11:51:29 -08:00
Wez Furlong
7c6d65c432 remove stale comment
Summary:
this comment is not accurate since removing libfuse.
The good news is that doing that meant that I didn't need to
touch DirList when removing libfuse.

Reviewed By: chadaustin

Differential Revision: D6672533

fbshipit-source-id: 54216685b03b8f6dd7ee96b7bc38bb91d1b33366
2018-01-08 10:31:35 -08:00
Sergey Zhupanov
0d6c3a31cd Changed TreeInode::loadGitIgnoreThenDiff() to properly handle symlinks to gitignore.
Summary: Added TreeInode::loadGitIgnoreThenDiff() symlink handling with tests.

Reviewed By: simpkins

Differential Revision: D6659654

fbshipit-source-id: 293c913ea56b5b770a051efd78e1e57497c360bd
2018-01-05 15:51:04 -08:00
Sergey Zhupanov
a3ef94a011 Added EdenMount::resolveSymlink(InodePtr pInode) with tests.
Summary: EdenMount::resolveSymlink(InodePtr pInode) resolves symlink to INodePtr.

Reviewed By: simpkins

Differential Revision: D6659644

fbshipit-source-id: 8be9ca06b08bf9730ff961e55c3ee747d5f45707
2018-01-05 15:35:42 -08:00
Wez Furlong
a7d7ae92d3 InodeBase::incFuseRefcount allows arbitrary count
Summary:
We'll need a way to twiddle the refcount by more than
increment at a time for graceful restart.  This mirrors the
same pattern we use to forget() by an arbitrary number.

Reviewed By: chadaustin

Differential Revision: D6668809

fbshipit-source-id: 6e5dc33b5e40f98f01293c89152bfe1e0879f572
2018-01-05 14:22:22 -08:00
Wez Furlong
15c7604d06 remove unused thrift struct
Summary: We forgot to remove this when we moved to be fully inode based in the overlay

Reviewed By: chadaustin

Differential Revision: D6668810

fbshipit-source-id: b79af85a4bbbcefd9227ad69bb8d57b5274cdaed
2018-01-05 14:22:20 -08:00
Adam Simpkins
83ebf3b228 minor improvements to EDEN_BUG()
Summary:
Switch from glog to folly logging.  Also derive from folly::ColdClass to
indicate that the `EdenBug` class is only ever created on unexpected code
paths.

Reviewed By: wez

Differential Revision: D6609613

fbshipit-source-id: 33621c7bafc946df245224da9b6a559e3dfd58d6
2018-01-05 13:53:23 -08:00
Adam Simpkins
9e162c71ca add type annotations to edenclient.py
Summary: Update this module with python type annotations.

Reviewed By: chadaustin

Differential Revision: D6665271

fbshipit-source-id: c24adacfeb20340fe55839b3ca65654dec1fb12c
2018-01-05 13:53:23 -08:00
Adam Simpkins
009d94353b fix integration tests after eden list output changes
Summary:
Update the integration tests to understand the new `eden list` output format
changes introduced in D6661303.

Reviewed By: chadaustin

Differential Revision: D6665272

fbshipit-source-id: 13f65a7a66f997e6b8135436811fe3fc396eb38f
2018-01-05 13:53:23 -08:00
Adam Simpkins
6f67546602 update the takeover code to use the new UnixSocket helper class
Summary:
Update the TakeoverClient and TakeoverServer code to use the new UnixSocket
helper class for exchanging messages, file descriptors, and credential
information.

This does not change the message serialization code much yet, it merely changes
the code to use the UnixSocket class for I/O.

Reviewed By: wez

Differential Revision: D6494979

fbshipit-source-id: 3129fe8605b1b3b7a24e6e84e94dccf3ea2b4170
2018-01-05 13:35:46 -08:00
Adam Simpkins
db1f93b2aa add new UnixSocket and UnixSocketFuture helper classes
Summary:
Add new classes that help send data, file descriptors, and credential
information over unix domain sockets.

UnixSocket provides a low-level, raw callback API, similar to that provided by
the classes in folly/io/async/.  UnixSocketFuture is a slightly higher-level
wrapper class that provides a Future-based API on top of this.  I expect that
most places in eden will probably use the UnixSocketFuture API, but callers
that repeatedly wait for new messages (like the privhelper server) may want to
use the raw callback API instead.

This will help simplify several places in eden that communicate over unix
domain sockets.  Both the privhelper code and the takeover code needs to send
file descriptors over unix domain sockets.  They currently each use their own
separate message handling logic for this.  We currently communicate with the
hg_import_helper.py script over a pipe, but this could easily be switched to
use this new UnixSocket class as well.

Reviewed By: wez

Differential Revision: D6494981

fbshipit-source-id: 80bd7f06e5b884fc4148162e1a8a3b478acce209
2018-01-05 13:35:46 -08:00
Chad Austin
40bd37a582 print unhandled's opcode name if known
Summary:
Title says it all. Uses a switch statement so the compiler
might warn if a header's opcode isn't handled.

Reviewed By: wez

Differential Revision: D6664378

fbshipit-source-id: 51986c423c943bf3b51cbd342ea4bdedb5fe1188
2018-01-05 10:25:31 -08:00
Chad Austin
b6eb974860 only log unsupported opcodes once
Summary:
eden doesn't support ioctl which was spamming "unhandled fuse
opcode 39" into the log.  Only log each unhandled opcode once.

Reviewed By: wez

Differential Revision: D6663175

fbshipit-source-id: c1bea671c8fb720ae0ac234c4f187251930a8bee
2018-01-05 10:25:31 -08:00
Sergey Zhupanov
cdc6af4e72 Fixing merge screw-up caught by Adam TYVM
Summary: Fixing merge screw-up in D6597696

Reviewed By: simpkins

Differential Revision: D6662096

fbshipit-source-id: 9d0a615a6991e673c24b591171caf2c7dc19165e
2018-01-04 14:35:26 -08:00
Chad Austin
5a1fae665c have eden list show whether mount points are active or not
Summary:
`eden list` enumerates all of the mounts in the Eden config,
whether or not the daemon is running and whether or not the mount is
currently active or not.  This diff adds an (active) suffix on a mount
if the daemon is running and the mount is currently active.

Reviewed By: simpkins

Differential Revision: D6661303

fbshipit-source-id: c098e90fc9a77f16c723c707cc4da3ee3d4c5abb
2018-01-04 12:12:56 -08:00
Chad Austin
71a5c06d99 tiny: correct a help message
Summary: Unmount defaults to being nondestructive now.

Reviewed By: wez

Differential Revision: D6661448

fbshipit-source-id: ccc74ca9e9721248145d1fc981f209db4d77ba78
2018-01-04 12:12:56 -08:00
Sergey Zhupanov
4f40f9db60 Added TestMount::addSymlink().
Summary: Added TestMount::addSymlink() method which creates a symlink.

Reviewed By: simpkins

Differential Revision: D6659638

fbshipit-source-id: 49c26ca8c5c6783343c1e787b594ccc87f4c03a8
2018-01-04 10:11:38 -08:00
Sergey Zhupanov
14890efd46 Added joinAndNormalize to PathFuncs with test plus minor cleanup.
Summary:
joinAndNormalize() canonicalizes a path string relative to
         a relative path base.

Reviewed By: simpkins

Differential Revision: D6659625

fbshipit-source-id: 0547d93d576fb894b16ad43bec020dc7b9658426
2018-01-04 10:11:38 -08:00
Chad Austin
0f0b0b6b4d remove unnecessary code and a faulty assertion
Summary:
It is no longer correct to assert that state->file is set if O_TRUNC happened
before blob import from hg finished.  It surprises me we never saw a crash
because of that.  Also, the O_TRUNC path after blob import finishes can never
complete a future, so don't try.

Reviewed By: wez

Differential Revision: D6656699

fbshipit-source-id: 5e245fc46185714e5f5d81c2680835a3497747ff
2018-01-03 17:38:48 -08:00
Chad Austin
5f5b317e8b release blob memory when last file handle is closed
Summary:
Today, if a file is ever opened for read, each FileInode keeps a copy
of the data as long as the FileInode is around.  This results in
excessive memory consumption under common mistakes like repo-wide grep
or `hg revert .`.

I will audit all of the state machine transitions and blob accesses
before landing this diff.

Reviewed By: wez

Differential Revision: D6598957

fbshipit-source-id: 1eb4aeb08057ce993a29a86d298e153675fee4a1
2018-01-03 17:38:48 -08:00
Chad Austin
36a51e8ac6 make readIntoBuffer private
Summary:
This came up when I was auditing the rules about when it's
safe to read from a FileInode. read() must only be called while openCount > 0.

Reviewed By: wez

Differential Revision: D6604898

fbshipit-source-id: 829ddc335bd58201c2b456ee544cdc6253ebf66c
2018-01-03 17:38:48 -08:00
Chad Austin
3b2e9b92ca have ensureDataLoaded() return a FileHandle
Summary:
In a follow-on diff, the constraint will be that state->blob
will only be guaranteed valid after ensureDataLoaded() while a
FileHandle is alive.  Thus, ensureDataLoaded() must return a
FileHandle.

Reviewed By: wez

Differential Revision: D6586237

fbshipit-source-id: ccc269d322b8c725c93145df5de2add9a2b90207
2018-01-03 17:38:48 -08:00
Sergey Zhupanov
29c2999a65 Removed all folly::fbstring uses from eden.
Summary: Removed all folly::fbstring uses from eden.

Reviewed By: wez

Differential Revision: D6597696

fbshipit-source-id: 816ea91fad063eccf9e6a46bf5c5e32bc69c6bf7
2018-01-03 16:41:34 -08:00
Giuseppe Ottaviano
4029be5d7b Remove useless comparator
Summary: Drive-by cleanup. `CompareString` is not used anywhere and `std::less<>` would be better anyway.

Reviewed By: wez

Differential Revision: D6655104

fbshipit-source-id: 0fee22172c93335493400e6317d92f9e1e77b40e
2018-01-03 11:25:52 -08:00
Wez Furlong
f51bbd5843 satisfy shadow-compatible-local error
Summary: This is annoying because it isn't actually shadowing and because this isn't picked up in our default mode mode, or in sandcastle.

Reviewed By: chadaustin

Differential Revision: D6656548

fbshipit-source-id: e624cb563d6396c1ab6b93eae14651c16a8c0cd3
2018-01-03 11:06:13 -08:00
Wez Furlong
482d1a1aff move fuse thread pool to FuseChannel
Summary:
Now that we have full control over the fuse session,
moving the threads here makes a lot of sense and makes things
easier from an overall state management perspective.

FuseChannel now provides a future that make it easier for EdenMount to wait
until all the threads and outstanding requests have completed.

There is also a future to determine when the first of the threads
has exited which is used to detect an error condition.  We could
go a bit further with this and have the error condition propagate
out from our dispatcher, but that's a bit further away from my
goal of making the graceful restart stuff work.

I've removed the request counting stuff from Dispatcher as we
can now use the definitive signals from FuseChannel in its place.

Reviewed By: chadaustin

Differential Revision: D6580247

fbshipit-source-id: 6bcc3b8b531d59a3fdd0ca6fd09410ad64f8221a
2018-01-03 09:38:34 -08:00
Wez Furlong
77e0a8f6c2 re-enable FUSE_INTERRUPT support
Summary:
I'm mostly interested in this as the definitive way to know
how many outstanding fuse requests there are, which is important
for synchronization for graceful restart.

An important part of this diff is to use of the `RequestContextScopeGuard`.
Previously, `RequestData::create` would implicitly create a new
`folly::RequestContext` and associate it with the current thread each
time a new request was processed on the fuse worker thread.  Critically,
it would never take any action to remove that association.  What that
meant was that during shutdown some number of fuse worker threads were
extending the lifetime of some fuse requests and that leads either to
an use-after-free (as is the case in this diff stack up until this diff),
or with the stronger synchronization that we desire in graceful restarts,
a deadlock.

Reviewed By: chadaustin

Differential Revision: D6578933

fbshipit-source-id: f82f75e75a398d1f6beacb9466060e7bd99adbc1
2018-01-02 16:36:16 -08:00
Wez Furlong
098b26c6bd FuseChannel switch dispatcher -> map
Summary:
Use a map to lookup the handler for a given opcode.

While we're in here, let's reduce some more boiler plate by factoring
out the code that preps the request and associates it with the stats
histogram by moving that into the opcode map.

Reviewed By: chadaustin

Differential Revision: D6578934

fbshipit-source-id: 9e3f73beb9dc5597f095e81ef21adf1549420e9d
2018-01-02 16:36:16 -08:00
Wez Furlong
6ff492d11c remove dep on libfuse
Summary:
This serves a few purposes:

1. We can avoid some conditional code inside eden if we know that
   we have a specific fuse_kernel.h header implementation.
2. We don't have to figure out a way to propagate the kernel
   capabilities through the graceful restart process.
3. libfuse3 removed the channel/session hooks that we've been
   using thus far to interject ourselves for mounting and
   graceful restarting, so we were already effectively the
   walking dead here.
4. We're now able to take advtange of the latest aspects of
   the fuse kernel interface without being tied to the implementation
   of libfuse2 or libfuse3.  We're interested in the readdirplus
   functionality and will look at enabling that in a future diff.

This may make some things slightly harder for the more immediate
macOS port but I belive that we're in a much better place overall.

This diff is relatively mechanical and sadly is (unavoidably) large.

The main aspects of this diff are:

1. The `fuse_ino_t` type was provided by libfuse so we needed to
   replace it with our own definition.  This has decent penetration
   throughout the codebase.
2. The confusing `fuse_file_info` type that was multi-purpose and
   had fields that were sometimes *in* parameters and sometimes *out*
   parameters has been removed and replaced with a simpler *flags*
   parameter that corresponds to the `open(2)` flags parameter.
   The *out* portions are subsumed by existing file handle metadata
   methods.
3. The fuse parameters returned from variations of the `LOOKUP` opcode
   now return the fuse kernel type for this directly.  I suspect
   that we may need to introduce a compatibility type when we revisit
   the macOS port, but this at least makes this diff slightly simpler.
   You'll notice that some field and symbol name prefixes vary as
   a result of this.
4. Similarly for `setattr`, libfuse separated the kernel data into
   two parameters that were a little awkward to use; we're now just
   passing the kernel data through and this, IMO, makes the interface
   slightly more understandable.
5. The bulk of the code from `Dispatcher.cpp` that shimmed the
   libfuse callbacks into the C++ virtual methods has been removed
   and replaced by a `switch` statement based dispatcher in
   `FuseChannel`.   I'm not married to this being `switch` based
   and may revise this to be driven by an `unordered_map` of
   opcode -> dispatcher method defined in `FuseChannel`.  Regardless,
   `Dispatcher.cpp` is now much slimmer and should be easier to
   replace by rolling it together into `EdenDispatcher.cpp` in
   the future should we desire to do so.
6. This diff disables dispatching `poll` and `ioctl` calls.  We
   didn't make use of them and their interfaces are a bit fiddly.
7. `INTERRUPT` is also disabled here.  I will re-enable it in
   a follow-up diff where I can also revise how we track outstanding
   requests for graceful shutdown.
8. I've imported `fuse_kernel.h` from libfuse.  This is included
   under the permissive 2-clause BSD license that it allows for
   exactly this integration purpose.

Reviewed By: simpkins

Differential Revision: D6576472

fbshipit-source-id: 7cb088af5e06fe27bf22a1bed295c18c17d8006c
2018-01-02 16:36:16 -08:00
Sergey Zhupanov
c61975b275 eden rage prints stats instead of per-inode info to stop crashes.
Summary: eden rage crashes sometimes due to too much inode info in the info dump.  Replacing per-inode info dump with the stats summary from the stats module.

Reviewed By: chadaustin

Differential Revision: D6641312

fbshipit-source-id: 16910aa21306db4e5533217bd2ffb7b37440a807
2018-01-02 14:59:39 -08:00
Wez Furlong
fe3b0a6a70 fix edenfs_logging_settings in integration tests
Summary:
We're unconditionally emitting a `--` above, so the `--`
down here doesn't get stripped out by the logic in `do_daemon`
in the CLI and that renders it invisible to gflags:

Here's our `eden cli` invocation:

```
['/data/users/wez/eden-fbsource/fbcode/buck-out/gen/eden/cli/cli.par', '--config-dir', '/var/tmp/eden_test.15oico01/homedir/local/.eden', '--etc-eden-dir', '/var/tmp/eden_test.15oico01/etc-ed
en', '--home-dir', '/var/tmp/eden_test.15oico01/homedir', 'daemon', '--daemon-binary', '/data/users/wez/eden-fbsource/fbcode/buck-out/gen/eden/fs/service/edenfs', '--foreground', '--', '--num
_hg_import_threads', '2', '--', '--logging=eden.fs.store.hg=DBG9,eden.strace=DBG7']
```

This is what `eden cli` passes to `edenfs`:

```
edenfs_args ['--num_hg_import_threads', '2', '--', '--logging=eden.fs.store.hg=DBG9,eden.strace=DBG7']
```

Reviewed By: bolinfest

Differential Revision: D6628253

fbshipit-source-id: 2c6806e69baff52d14ca64194f1bf7d916833844
2017-12-22 12:36:25 -08:00
Wez Furlong
afee9ce448 FileInode blob import is missing error handling
Summary:
Easy to overlook this; the issue is that we need to explicitly
do something about the error case when we're stitching together Promises
by hand, otherwise we will silently drop exceptions.

Flat manifest imports are failing in `RestartTestHg` in master
at the moment.  That error was silently being swallowed and the test would
hang until it timed out.

This is an uglyish hack to explicitly propagate the error condition so that
that test will error out.

This diff doesn't fix the source of the manifest import issue; that is addressed
in the next diff (turned out to be that the `--takeover` flag was not being
passed correctly)

Reviewed By: bolinfest

Differential Revision: D6627973

fbshipit-source-id: b7093890f543618a11682e939f8802f1309831d4
2017-12-22 12:36:25 -08:00
Philip Jameson
8604b8f5b0 Migrate TARGETS files from @/ to //
Summary:
This is a codemod to change from using @/ to // in basic cases.
- TARGETS files with lines starting with @/ (but excluding @/third-party:
- autodeps lines in source and TARGETS files ( (dep|manual)=@/ ), excluding @/third-party
- Targets in string macros

The only thing left of the old format should be @/third-party:foo:bar

drop-conflicts

Reviewed By: ttsugriy

Differential Revision: D6605465

fbshipit-source-id: ae50de2e1edb3f97c0b839d4021f38d77b7ab64c
2017-12-20 16:57:41 -08:00
Michael Bolin
1cfec17294 Do not run the EdenfsIsLatest eden doctor check when Eden is not running.
Summary: Previously, this would cause a crash when running `eden doctor`. Now fixed.

Reviewed By: simpkins

Differential Revision: D6607211

fbshipit-source-id: a0e077beaf6b7031d57efd72b947e90884369852
2017-12-19 21:50:09 -08:00
Michael Bolin
33dec91a98 Fix if that was supposed to be elif.
Summary:
Encountered a funny situation where running `hg clone src dest` from inside an
Eden mount where `src` was a directory that contained a non-Eden Hg repo would
fail with a stacktrace that ended with:

```
File "/usr/local/fb-mercurial/eden/hgext3rd/eden/__init__.py", line 195, in merge_update
  conflicts = repo.dirstate.eden_client.checkout(
AttributeError: 'dirstate' object has no attribute 'eden_client'
```

This was very confusing because we had this check at the top of the function:

```
if not util.safehasattr(repo.dirstate, 'eden_client'):
    why_not_eden = 'This is not an eden repository.'
```

So it seemed that we already verified that `repo.dirstate.eden_client` must be a
valid attribute. However, we followed this check with a new set of checks, the
final one being:

```
else:
    why_not_eden = None
```

This one had the unintended effect of resetting the value of `why_not_eden` that
we set in the first `if`. Changing the `if` to an `elif` introduces the proper
decision tree.

Reviewed By: simpkins

Differential Revision: D6608867

fbshipit-source-id: 320e69925737135d84f9d6a46a7fb43437cc37e0
2017-12-19 21:50:09 -08:00
Adam Simpkins
e9567ba6d4 improve short-circuiting logic on dry-run checkouts
Summary:
Update the logic for dry-run checkouts to exit early whenever we hit a
directory that is unmodified from the original source control state.  In this
case we can skip this entire subdirectory since we know there cannot be any
conflicts.

This should make dry-run checkout operations much faster in cases where there
are lots of changes between the source and destination source control trees,
but the working directory state has relatively few modified files.

Reviewed By: bolinfest

Differential Revision: D6605282

fbshipit-source-id: b5423749f3d47b10ed8d599ffaa0667c72fbaec2
2017-12-19 20:54:32 -08:00
Michael Bolin
48f727ee3a Use bytes string as string templates, where possible.
Summary:
In making this change, I was hoping to remove `.encode()` calls, but the net
number is zero.

Reviewed By: chadaustin

Differential Revision: D6606997

fbshipit-source-id: ea1851d719aff0bae424f15c94a7cc48b8f516f0
2017-12-19 16:51:27 -08:00
Michael Bolin
6362dff4c1 Include output from doctor, buildinfo, and uptime in eden rage report.
Summary:
This additional debugging info should help when investigating user issues.
While here, I also fixed things up so that `eden rage` does not crash if Eden
is not running (it just prints less information and tells the user).

Reviewed By: chadaustin

Differential Revision: D6599309

fbshipit-source-id: cf5c63dcc6f4dbf224122579c3bd458730629a66
2017-12-19 15:51:12 -08:00
Adam Simpkins
a8cbe6593a reduce calls to JournalDiffCallback::performDiff() during checkout
Summary:
Previously the checkout code always called `JournalDiffCallback::performDiff()`
to get the list of unclean files before starting the checkout operation.  After
the checkout completed it called `JournalDiffCallback::performDiff()` to get
the unclean files after the checkout operation.

Making both diff calls should be unnecessary: the checkout code can only modify
files that were unclean before the checkout (in the case of a `FORCEe` checkout)
or files that were modified between the source and destination source control
trees.  Therefore the `performDiff()` call after checkout completes should be
unnecessary, and can be removed.

This diff also eliminates the initial `performDiff()` call for `DRY_RUN`
checkouts.  We do not add a journal entry at all for `DRY_RUN` operations, so
we can skip this diff computation.

Reviewed By: wez

Differential Revision: D6455969

fbshipit-source-id: 20e0ac0d16d1fde844c1d6165a96611bfb370597
2017-12-19 15:12:20 -08:00
Chad Austin
f00d40b6e1 verify FileHandle is never copied nor moved (it doesn't support it yet)
Summary:
I almost added a copy in a later diff and realized it would
have let me, but done the wrong thing.

Reviewed By: wez

Differential Revision: D6585810

fbshipit-source-id: 15295d04b06df397113be6080e1f2f6b8a473745
2017-12-19 11:35:46 -08:00
Wez Furlong
a54685892b fixup ASAN use-after-free error with fuse request context
Summary:
this is a backport of the same fix from D6578933 and helps
to avoid noise with our new default ASAN enabled build settings.

The root of the problem is that we didn't guarantee to clear the
association between the fuse worker thread and a folly request
associated with a fuse request.  This meant that the lifetime
of the RequestData was being extended until after the EdenMount
was destroyed and then the destructor of RequestData would trigger
an access inside the EdenMount instance.

Adopting the `RequestContextScopeGuard` type helps to avoid this,
at the cost of perhaps prematurely heap allocating a request context
for some opcodes.  D6578933 can avoid that cost.

Reviewed By: chadaustin

Differential Revision: D6602416

fbshipit-source-id: 80785b860af906c0fcf02b42f0235796377c265f
2017-12-19 10:53:38 -08:00
Wez Furlong
e7f5d77f88 fix min vs max for bufsize computation
Summary:
Noticed this bug while working on our own fuse lowlevel stuff.
Taking the min here means that we always tell the kernel to use 4k writes
instead of the larger buffer that we allocate here.

This is also addressed in D6576472

Reviewed By: chadaustin

Differential Revision: D6602417

fbshipit-source-id: d2deaaad7a727433ab021d042e372d06b2acb798
2017-12-19 10:53:38 -08:00
Chad Austin
c57a490e74 only use 2 hg import processes in tests
Summary:
My devvm was running out of memory when running `buck test eden/...`.
Because Buck farms out tests across cores and each Eden integration
test launches 8 hg import daemons, there were over a hundred importer
processes live on the system.

Reviewed By: bolinfest, wez

Differential Revision: D6598276

fbshipit-source-id: d26916af79c24aa73abfa4c3ef9be3178657b6e7
2017-12-18 17:38:08 -08:00
Chad Austin
9a3fa8bd60 replace the system memory info in eden stats with process memory
Summary:
`eden stats` used to show system memory usage which was not very
interesting (and can be gleaned from top).  Instead read the contents
of /proc/self/smaps and sum the Private_Dirty fields to get a number
that more accurately reflects impact on the rest of the system.

Reviewed By: wez

Differential Revision: D6575595

fbshipit-source-id: 9badc5cd5a1b56d3ccb27edd1a2d20ee74ec34ae
2017-12-18 12:00:58 -08:00
Michael Bolin
88d4e2e546 Use correct argument: --queryformat instead of --queryfmt.
Summary:
When I updated D6577031 in response to code review feedback,
I manually tested with `--qf` but at the last minute changed to the
suggested long-form `--queryfmt` without verifying it was the
appropriate name.

Reviewed By: simpkins

Differential Revision: D6579002

fbshipit-source-id: ac2a96e7340099eb83336cb11d16dd711b0d4f9f
2017-12-15 13:06:21 -08:00
Michael Bolin
aa87671ff9 Fix a string vs. bytes issue in Python.
Summary:
I forgot that `subprocess.check_output()` returns a `bytes` instead of a `str`.
This caused `eden doctor` to return false positives because the installed and
running versions of `edenfs` would be the same, but the check would fail because
it was comparing a `bytes` to a `str`.

Reviewed By: simpkins

Differential Revision: D6577031

fbshipit-source-id: 681ea22ef79604a3dfb278d713e5c68c54d8ecd5
2017-12-15 00:20:15 -08:00
Michael Bolin
47607cf33b Introduce eden debug uptime.
Summary:
This reports the difference between what is returned by the `aliveSince()`
Thrift method and the current time.

Reviewed By: chadaustin

Differential Revision: D6566127

fbshipit-source-id: 449103bcb31a87e4efd780299131eb38a45a6bd7
2017-12-14 21:18:14 -08:00
Michael Bolin
b9cff8cf88 eden doctor check to verify that the running Eden matches the installed Eden.
Reviewed By: chadaustin

Differential Revision: D6565974

fbshipit-source-id: eb02615437b860db9507b6f455717350a67f89ee
2017-12-14 21:18:14 -08:00
Sergey Zhupanov
58b472b9d0 Added type identification capability to InodeBase.
Summary: Added type identification capability to InodeBase and its descendants FileInode and TreeInode.

Reviewed By: simpkins

Differential Revision: D6564902

fbshipit-source-id: ce9300102d6d6d1c42616eb1e32042f21f6e6cce
2017-12-14 16:41:39 -08:00
Michael Bolin
bb3994be82 Add an eden debug buildinfo command.
Summary:
`eden debug buildinfo` lists the exported values from the Thrift daemon that
start with `build_`.

Reviewed By: simpkins

Differential Revision: D6565668

fbshipit-source-id: 62009d7a23211765039a5045a517113043b5d8a9
2017-12-14 13:52:12 -08:00
Adam Simpkins
dc10a595ed attempt to resolve symlinks in the eden directory path
Summary:
During edenfs startup, use `realpath()` or `normalizeBestEffort()` to resolve
symlinks in the input configuration paths if possible.

Reviewed By: chadaustin

Differential Revision: D6527494

fbshipit-source-id: 4377099e8c65217fd128c06de77d50f4316f4fc7
2017-12-14 12:41:47 -08:00
Adam Simpkins
f42c51c6eb remove the --rocksPath command line flag
Summary:
The RocksDB location is relative to the .eden directory.  Given that the
location of the .eden directory can be controlled from the command line it
doesn't seem worthwhile to make the RocksDB location independently controllable
too.

Reviewed By: chadaustin

Differential Revision: D6527495

fbshipit-source-id: dab8c22f3f1a74de908ea33d0b20c4115c28ce31
2017-12-14 12:41:47 -08:00
Adam Simpkins
5ef9928f3b add a normalizeBestEffort() function
Summary:
Add a new function that attempts to normalize a path with `realpath()`, but
falls back to `canonicalPath()` if that fails.  This lets us attempt to resolve
symlinks if possible, but still perform best-effort normalization if that
fails.

Reviewed By: chadaustin

Differential Revision: D6527493

fbshipit-source-id: 9137d517452ca7fd825852c1f60ade07f1ee78fa
2017-12-14 12:41:47 -08:00
Michael Bolin
c0f3976d57 Add integration test to verify rebasing a stack with commits works as expected.
Summary:
This attempts to repro an internal bug report, though note the integration test
passes without any changes to Eden. It is possible that the person who reported
the bug was stuck on an old version of the Eden daemon while using a newer
version of the Mercurial extension, which could account for the unexpected
behavior.

Reviewed By: simpkins

Differential Revision: D6536375

fbshipit-source-id: 1bc4c50ee5f616502dc06f8ed0167817c566e179
2017-12-13 17:35:51 -08:00
Chad Austin
bab411092d add an overview doc for our threading strategy
Summary:
For new folks and myself, here's a bit of prose that describes our
threading strategy.

Reviewed By: simpkins

Differential Revision: D6513572

fbshipit-source-id: a48e0152692aa63540f0be27f943fd6f29bb5fb2
2017-12-12 12:51:23 -08:00
Chad Austin
2f22a9f534 introduce a type representing the unbounded eden cpu pool
Summary:
Add EdenCPUThreadPool and UnboundedQueueThreadPool types to make it clearer
that it's always okay for prefetch, deferred diff entry, and hg import to
shuttle work back to the main thread pool.

This diff changes no behavior - it just makes some invariants explicit.

Reviewed By: wez, simpkins

Differential Revision: D6504117

fbshipit-source-id: 3400ad55c00b3719ecba31807fd992442f622cd9
2017-12-12 12:35:35 -08:00
Chad Austin
bbdac6e7fd bump edenfs startup timeout to 60 for integration tests
Summary:
I am seeing occasional timeouts on my smaller devvm when
running `buck test eden/integration/...`.

Reviewed By: bolinfest

Differential Revision: D6541864

fbshipit-source-id: 401deb8b44adae8cc362bbba8b638fe08abb9b1e
2017-12-12 10:52:19 -08:00
Christopher Dykes
65b855227f Ensure explicit dependency on targets < 1600 references
Summary: The same as < 500 references, except this time for targets with < 1600 references.

Reviewed By: yfeldblum

Differential Revision: D6540895

fbshipit-source-id: 40fa46c32abd6bc1c3c652a0396d6478b947f69b
2017-12-12 10:52:17 -08:00
Chad Austin
5eaddd7921 Make sure shutdown() errors propagate to unmount() waiters
Summary: Use SharedPromise::setFuture to make sure errors propagate.

Reviewed By: simpkins

Differential Revision: D6515818

fbshipit-source-id: dee95bccdc086a040ead08e60373cbc7daa4db3f
2017-12-11 18:16:05 -08:00
Christopher Dykes
0b74d03fbd Ensure explicit dependencies on everything < 500 references
Summary: Ensure everything remaining in dependencies of `folly:folly` that has < 500 references is explicit referenced.

Reviewed By: yfeldblum

Differential Revision: D6540137

fbshipit-source-id: 0a2ae5cf775278eedcccdb914688890acd12dab7
2017-12-11 17:51:23 -08:00
Christopher Dykes
c19afa8152 Shift folly:format out of folly:base
Summary: And then, there was 1, left all alone, preventing the whole thing from collapsing in on itself.

Reviewed By: yfeldblum

Differential Revision: D6469584

fbshipit-source-id: 4ea1fbf97ad466bc34f2e682394d328c97e539ba
2017-12-10 15:24:40 -08:00
Christopher Dykes
5056668373 Shift folly:range out of folly:base
Summary: And then there were... 2.

Reviewed By: yfeldblum

Differential Revision: D6469788

fbshipit-source-id: 8a2d2f01f2d1fdbac05922701ba60c494061c8b9
2017-12-10 11:09:38 -08:00
Christopher Dykes
522690a6d0 Shift folly:executor, folly/lang:bits, folly:scope_guard and folly:rw_spin_lock out of folly:base
Summary:
```
foundation/depenendency_management/ensure-explicit-dependencies.sh folly:executor
foundation/depenendency_management/ensure-explicit-dependencies.sh folly:bits
foundation/depenendency_management/ensure-explicit-dependencies.sh folly/lang:bits
foundation/depenendency_management/ensure-explicit-dependencies.sh folly:scope_guard
foundation/depenendency_management/ensure-explicit-dependencies.sh folly:rw_spin_lock
```

Reviewed By: yfeldblum

Differential Revision: D6529842

fbshipit-source-id: fc13ef398402a0323ce4f6cf61d12b30c196ce43
2017-12-09 22:07:31 -08:00
Christopher Dykes
561453dee9 Shift folly:file, folly:exception_wrapper and folly/synchronization:baton out of folly:folly
Summary:
```
foundation/dependency_management/ensure-explicit-deps.sh folly:file
foundation/dependency_management/ensure-explicit-deps.sh folly:exception_wrapper
foundation/dependency_management/ensure-explicit-deps.sh folly/synchronization:baton
```

Reviewed By: yfeldblum

Differential Revision: D6529590

fbshipit-source-id: a08f8bdd01eda3fb28410af55c4dec6b0c5f9399
2017-12-09 17:20:17 -08:00
Sergey Zhupanov
b6394ac357 Added user and general system level gitignore
Summary:
Added to Eden capability to incorporate default user and general system level gitignore files.
NOTE: Work in progress, sending the review out to calibrate/ensure I am on right track.

Reviewed By: simpkins

Differential Revision: D6482863

fbshipit-source-id: 9834ca1a577a9599a1f8cb2243dca4e714866be8
2017-12-08 12:52:51 -08:00
Yedidya Feldblum
418b07c1cc Move folly/Bits.h to folly/lang/
Summary: [Folly] Move `folly/Bits.h` to `folly/lang/`.

Reviewed By: phoad, Orvid

Differential Revision: D6495547

fbshipit-source-id: a93159321df8277f8a4b4f10a5e4e0fc58cb6022
2017-12-08 00:36:31 -08:00
Chad Austin
e19939cf15 fix crash when too many tasks are put on the eden thread pool
Summary:
Use an unbounded queue for edenfs's main thread pool.  This fixes a
crash where DeferredDiffEntry multigets a batch of trees and pushes
the completion callbacks back onto the server thread pool.  If the
server thread pool is bounded and throws when the queue is full, then
the import fails.

There is a slight performance hit relative to LifoSemMPMCQueue but
hopefully it isn't a big deal.  An unbounded lock-free queue would be
nicer.

Reviewed By: simpkins

Differential Revision: D6490979

fbshipit-source-id: bc55dd6526f0ceb9d8b5e43a1a275250a9838aca
2017-12-05 17:52:04 -08:00
Chad Austin
8a6d0592f7 allow returning the open file handle before the load/materialize completes
Summary:
There's no technical reason to block an open() request until the data
load / materialization returns.  This change returns immediately from
open() and then waits if necessary in a subsequent write() call.

Reviewed By: wez

Differential Revision: D6391486

fbshipit-source-id: 862f87e3c3a0d760bacb0f8ca7acc479037fec2f
2017-12-05 11:21:26 -08:00
Chad Austin
d112d63870 remove all direct calls to clock_gettime and system_clock::now
Summary:
Follow-up to comments in D6466209.  All access to the clock goes
through the Clock interface, making time deterministic in unit tests.

Reviewed By: simpkins

Differential Revision: D6477973

fbshipit-source-id: 24e51bdb52d0d079b34d91598d2e787d361f2525
2017-12-05 10:06:50 -08:00
Chad Austin
70f1bba3d6 test that asserts a new file inode's timestamps match the creation time, not the last checkout time
Summary: Follow-up from D6366189. First use of the new FakeClock!

Reviewed By: simpkins

Differential Revision: D6466209

fbshipit-source-id: 4d4d8a9a83df2bee11149e7a0cbddaaf734d0e04
2017-12-05 10:06:50 -08:00
Chad Austin
f91ae520b2 introduce a Clock seam for testability
Summary:
Introduce a Clock seam.  This will allow us to write tests around
ctime, mtime, and atime logic.

Reviewed By: wez

Differential Revision: D6392543

fbshipit-source-id: 1721d76d2364b135b4ef5c078ef60f7f8526259e
2017-12-05 10:06:48 -08:00
Chad Austin
dcba28b47f only call materializeInParent() when the inode state actually transitions to materialized
Summary:
open() called materializeInParent unconditionally, and setattr never
called it, implying it was possible to truncate a file without
materializing the parent.  This change makes sure to precisely call
materializeInParent whenever the state transitions to materialized.

Reviewed By: wez

Differential Revision: D6389794

fbshipit-source-id: 1e740e133a83d5090a6b9801154b7eaeccb07f22
2017-12-05 10:06:47 -08:00
Chad Austin
bb69c9b695 simplify materialization and reduce file reopenings
Summary:
To make the materialization code paths a bit clearer, this decouples
materialization from a blob and truncation.  It also caches opened
files if openCount > 0 in both the truncation and materialization from
blob paths.

Reviewed By: wez

Differential Revision: D6388318

fbshipit-source-id: c95a85f5bdaa405130f2f7260143592cdc90d45e
2017-12-04 15:13:43 -08:00
Stanislau Hlebik
5f6397eb10 eden: make mononoke calls async
Summary:
Make the calls async by using a user-provided event base.

It uses quite scary error management, see the comments for details.

Reviewed By: wez

Differential Revision: D6435696

fbshipit-source-id: a148c57aa116a6dfe6254ac7c14790101b8ecd4f
2017-12-02 09:52:24 -08:00
Michael Bolin
f972117076 Fix a bug in eden doctor.
Summary:
In the initial implementation of `eden doctor`, if you had a mount point like:

    /data/users/mbolin/eden-fbsource

then it looked for a pair of Watchman subscriptions for
`/data/users/mbolin/eden-fbsource` with the names:

    hg-repository-watchman-subscription-primary
    filewatcher-/data/users/mbolin/eden-fbsource

as a heuristic that Nuclide was being used to edit files in that Eden mount.

However, if the user is using Nuclide to edit files in a subdirectory of that
Eden mount (as determined by the Nuclide connection profile), then the
subscriptions look like this:

    hg-repository-watchman-subscription-primary
    filewatcher-/data/users/mbolin/eden-fbsource/<path-to-subdirectory>

In this case, `eden doctor` was returning a false positive because it thought
that the `filewatcher-/data/users/mbolin/eden-fbsource` subscription was missing
when in fact everything was just fine.

This revision changes the logic to look for a subscription to the root or one of
its subdirectories.

(Note: this ignores all push blocking failures!)

Reviewed By: simpkins

Differential Revision: D6467113

fbshipit-source-id: bfe5fafaa388405f2e59e61315c5a2084c8adc56
2017-12-01 18:49:56 -08:00
Michael Bolin
e21344054a Remove trailing whitespace from stats.py output.
Summary:
This makes the `expected_output` in `stats_test.py` cleaner to declare.

(Note: this ignores all push blocking failures!)

Reviewed By: simpkins

Differential Revision: D6465282

fbshipit-source-id: 80b697c84f28a0fece77eb1050c4364b14685c0b
2017-12-01 17:21:35 -08:00
Michael Bolin
bfb89289b2 Upgrade tests to use Python 3.
Summary:
Presumably for historical reasons, we still had some tests hanging around with
`from __future__ import absolute_import` in the header even though all of our
tests should be Python 3. I converted these stragglers and added a smattering of
type annotations to enforce their Python 3-ness.

(Note: this ignores all push blocking failures!)

Reviewed By: simpkins

Differential Revision: D6464805

fbshipit-source-id: 6177d7663ab428a0dbbecb287f340d770679551d
2017-12-01 17:21:35 -08:00
Michael Bolin
8e39d56ad8 Fix a test I broke (eden/integration/info_test.py)
Summary:
In D6446057, I added a new entry to the dict returned by
`config.get_client_info()`. I only ran the cli tests while working on D6446057,
but I should have ran all of the tests because there was an integration test
(`InfoTest`) that verified the return value of this method, so it broke due to
my change.

(Note: this ignores all push blocking failures!)

Reviewed By: simpkins

Differential Revision: D6464806

fbshipit-source-id: 1b0ac0853301ba33e5e948353e4c89c0d97c0d83
2017-12-01 17:21:35 -08:00
Adam Simpkins
1b86627d43 logging: update initialization code to use the new LogConfig logic
Summary:
Replace the initLoggingGlogStyle() function with a more generic initLogging()
function that accepts a log config string to be parsed with parseLogConfig().

Reviewed By: bolinfest, yfeldblum

Differential Revision: D6342086

fbshipit-source-id: fb1bffd11f190b70e03e2ccbf2b30be08d655242
2017-12-01 17:07:56 -08:00
Adam Simpkins
42d5654314 make sure hg update --clean clears merge conflict state
Summary:
Make sure `hg update --clean` clears the merge state data.  In non-clean
updates this is performed in `mercurial.merge.applyupdates()`.  However, we
never call `applyupdates()` on clean updates in eden.

Reviewed By: bolinfest

Differential Revision: D6456720

fbshipit-source-id: b40d02ca0fb677bcde82822a8eafd5fcf926dae6
2017-12-01 16:35:57 -08:00
Michael Bolin
a16c79ee82 Remove fake version numbers from doctor_test.py.
Summary: This is not material to the test, so it's distracting.

Reviewed By: wez

Differential Revision: D6462338

fbshipit-source-id: f289516c7e67891f1fed74df721fa1eb24e5f368
2017-12-01 15:21:26 -08:00
Michael Bolin
7cb7607b94 Introduce eden doctor.
Summary:
`eden doctor` is a new subcommand that attempts to diagnose
issues with Eden and autofix them, as appropriate. There is also
a `--dry-run` flag that will tell the user about issues without attempting
to fix them.

Initially, `eden doctor` checks for the following:
- If Watchman has an `inotify` watcher, `eden doctor` identifies this and
  will attempt to replace it with an `eden` watcher.
- If there are some active Watchman subscriptions that appear to come
  from Nuclide, warn the user if the mission-critical `filewatcher-` subscription
  that watches the entire repo is missing.
- If p1 in `SNAPSHOT` and `.hg/dirstate` do not match, warn the user.

The code for `eden doctor` is organized so that it should be relatively
easy to add new conditions to check for going forward. Admittedly, the
UX could be better by formatting the output (color, boldness, etc.) to
make certain information stand out, but we can improve that in
subsequent revisions.

Note that I had to do a bit of cleanup in `eden/cli/TARGETS` as part of
this revision and I created `eden/cli/test/TARGETS` so the tests have
their own build file.

Reviewed By: chadaustin

Differential Revision: D6446057

fbshipit-source-id: ae23c5996dba4f7f70f118179e5556efc29c31c3
2017-12-01 11:21:30 -08:00
Adam Simpkins
403402d76e also use MNT_DETACH when unmounting
Summary:
Always call `umount2()` with both `MNT_FORCE` and `MNT_DETACH`.  Without
`MNT_DETACH` I see unmount operations still fail or hang in some cases on
edenfs shutdown.  This should hopefully help fully eliminate situations where
disconnected mount points are sometimes left behind when eden shuts down.

Reviewed By: bolinfest, chadaustin

Differential Revision: D6455971

fbshipit-source-id: 5abe456e17a33a0080ad94b4d315540bce0c2f82
2017-11-30 20:35:32 -08:00
Adam Simpkins
f3d9dcbc4d speed up hg update --clean operations
Summary:
Update TreeInode::computeCheckoutActions() to short circuit on non-materialized
directories that are identical to both the destination and source state.  This
speeds up `hg update --clean` operations by allowing us to skip portions of the
tree that do not require changes.

This does not have much effect for update operations without `--clean`: those
already short-circuited the operation in `TreeInode::processCheckoutEntry()`
when the source and destination hashes were the same.  That code cannot
short-circuit in the forced update case, since the forced update may have to
revert local modifications.

Reviewed By: bolinfest

Differential Revision: D6455970

fbshipit-source-id: 393acb3272745751a56e06dba0c7505ff2bfad44
2017-11-30 20:35:32 -08:00
Mark Thomas
62227fce45 add treedirstate to post-clone hook
Summary:
Eden already disables sqldirstate as part of its post-clone hook.  Add
treedirstate to this handling.

Reviewed By: bolinfest

Differential Revision: D6424041

fbshipit-source-id: 889c07ed32f58c50c15de3a9aa3135018c4761a9
2017-11-30 04:06:16 -08:00
Stanislau Hlebik
51d52dddc4 eden: move buf to Tree conversion in a separate function
Summary:
It simplifies next diff a bit.
Also removes unnecessary `makeFuture()` calls.

Reviewed By: wez

Differential Revision: D6435694

fbshipit-source-id: ac00bed90454fef645a4fdad254ba6c8d3bda0ab
2017-11-30 03:21:56 -08:00
Stanislau Hlebik
5b2011e5e6 eden: simplify mononoke backing store tests
Summary: Additional thread for http server is not necessary.

Reviewed By: wez

Differential Revision: D6435695

fbshipit-source-id: b4fc7096a87146f36876bd132db66ab964feba51
2017-11-30 03:21:56 -08:00
Michael Bolin
5e2afa735f Change how the UNTRACKED_ADDED conflict and merges are handled.
Summary:
Previously, we used the Mercurial code `g` when faced with an `UNTRACKED_ADDED`
file conflict, but that was allowing merges to silently succeed that should not
have. This revision changes our logic to use the code `m` for merge, which
unearthed that we were not honoring the user's `update.check` setting properly.

Because we use `update.check=noconflict` internally at Facebook, we changed the
Eden integration tests to default to verifying Hg running with this setting. To
support it properly, we had to port this code from `update.py` in Mercurial to
our own `_determine_actions_for_conflicts()` function:

```
if updatecheck == 'noconflict':
    for f, (m, args, msg) in actionbyfile.iteritems():
        if m not in ('g', 'k', 'e', 'r', 'pr'):
            msg = _("conflicting changes")
            hint = _("commit or update --clean to discard changes")
            raise error.Abort(msg, hint=hint)
```

However, this introduced an interesting issue where the `checkOutRevision()`
Thrift call from Hg would update the `SNAPSHOT` file on the server, but
`.hg/dirstate` would not get updated with the new parents until the update
completed on the client. With the new call to `raise error.Abort` on the client,
we could get in a state where the `SNAPSHOT` file had the hash of the commit
assuming the update succeeded, but `.hg/dirstate` reflected the reality where it
failed.

To that end, we changed `checkOutRevision()` to take a new parameter,
`checkoutMode`, which can take on one of three values: `NORMAL`, `DRY_RUN`, and
`FORCE`. Now if the user tries to do an ordinary `hg update` with
`update.check=noconflict`, we first do a `DRY_RUN` and examine the potential
conflicts. Only if the conflicts should not block the update do we proceed with
a call to `checkOutRevision()` in `NORMAL` mode.

To make this work, we had to make a number of changes to `CheckoutAction`,
`CheckoutContext`, `EdenMount`, and `TreeInode` to keep track of the
`checkoutMode` and ensure that no changes are made to the working copy when a
`DRY_RUN` is in effect.

One minor issue (for which there is a `TODO`) is that a `DRY_RUN` will not
report any `DIRECTORY_NOT_EMPTY` conflicts that may exist. As `TreeInode` is
implemented today, it is a bit messy to report this type of conflict without
modifying the working copy along the way.

Finally, any `UNTRACKED_ADDED` conflict should cause an update to
abort to match the behavior in stock Mercurial if the user has the following
config setting:

```
[commands]
update.check = noconflict
```

Though the original name for this setting was:

```
[experimental]
updatecheck = noconflict
```

Although I am on Mercurial 4.4.1, the `update.check` setting does not seem to
take effect when I run the integration tests, but the `updatecheck` setting
does, so for now, I set both in `hg_extension_test_base.py` with a `TODO` to
remove `updatecheck` once I can get `update.check` to do its job.

Reviewed By: simpkins

Differential Revision: D6366007

fbshipit-source-id: bb3ecb1270e77d59d7d9e7baa36ada61971bbc49
2017-11-29 21:50:34 -08:00
Adam Simpkins
b6a2b19b7c logging: add a LogHandler::getConfig() method
Summary:
Add a method to LogHandler to return its current configuration.  This will
make it possible to query the LoggerDB for its current configuration state.

Reviewed By: bolinfest

Differential Revision: D6200563

fbshipit-source-id: 2b8b9752bbeb26c8aac28d1a73b7e2312fd198c8
2017-11-29 17:50:56 -08:00
Andrew Gallagher
7ad41d0ec4 codemod: add undefined_symbols to rules with improper deps
Reviewed By: yfeldblum

Differential Revision: D6427879

fbshipit-source-id: b91de83b287e999167ca32968f710f1e4fcb4ac8
2017-11-29 17:36:09 -08:00
Adam Simpkins
c9c60762b0 fix flatmanifest import fallback
Summary:
I accidentally broke the flatmanifest fallback code in D6333613 by changing the
exception type thrown for errors received from hg_import_helper.py but not
updating the catch statement in HgImporter::importTreeImpl().

This updates importTreeImpl() to catch the new HgImportPyError type correctly.
I have dropped the check on the error message entirely, since the mercurial
python code can throw a variety of errors that all mean this tree data isn't
available.

Reviewed By: bolinfest

Differential Revision: D6434359

fbshipit-source-id: c62d3c1667681712293873de2b9bf6d9220da767
2017-11-29 14:36:39 -08:00
Adam Simpkins
de556bb722 increase daemon start timeout to 60 seconds
Summary:
Increase the eden daemon start timeout from 5 to 60 seconds.

With the 5 second timeout I sometimes see `buck test eden/...` time out in the
clone integration test which waits for eden to start.  This likely takes longer
than normal when lots of other integration tests are also running in parallel.

Even when simply manually starting eden I have seen it take nearly 60 seconds
to open the RocksDB database.  (I suspect RocksDB performs some extra checking
when opening a DB created by an older version of the code.)  Eden requires the
RocksDB be open before it starts responding successfully to health check
requests.

Reviewed By: wez

Differential Revision: D6434357

fbshipit-source-id: 5f62ff821ecd64f7a1345e611f2299177513e411
2017-11-29 14:36:39 -08:00