Commit Graph

36 Commits

Author SHA1 Message Date
Matt Glazar
49f4c37b67 Add missing copyright notices
Summary: Internal Facebook infrastructure is nagging me about some files not having a Facebook copyright notice. Add a notice to these files to make the nagging stop.

Reviewed By: simpkins

Differential Revision: D14173944

fbshipit-source-id: 7234431224fcf4f86ea56ca2f9108f47ef959d87
2019-03-07 19:32:39 -08:00
Lee Howes
967e3f8a1c Future::onError replaced with Future::thenError
Summary:
Replace Future::onError with Future::thenError:
 * to remove ambiguous typing
 * to ensure that the executor is not lost and the returned Future is still bound to an executor

See:
https://fb.workplace.com/groups/fbcode/permalink/2002251863144976/
for details.

Reviewed By: yfeldblum

Differential Revision: D13784772

fbshipit-source-id: 1d3ede848b7d31c7a197a21b4ff2b31e840040a5
2019-01-30 09:56:15 -08:00
Wez Furlong
3b5315ca43 eden: handlemap.thrift was removed, but not from cmake build
Summary: overlooked because there is no CI exercising this today

Reviewed By: simpkins

Differential Revision: D13475721

fbshipit-source-id: 3e8fe280ab73d249da374129b37d32cd7e17f472
2018-12-15 13:43:31 -08:00
Chad Austin
008497c69a remove SerializedFileHandleMap
Summary: SerializedFileHandleMap is dead code now.

Reviewed By: strager

Differential Revision: D13381629

fbshipit-source-id: ba872aaf8335d2be68d6af0465bd04e4ca59d578
2018-12-13 12:29:13 -08:00
Chad Austin
fcbabf9fc2 folly::Optional -> std::optional
Summary: Eden's on C++17 so fully cross the rubicon!

Reviewed By: strager

Differential Revision: D10498169

fbshipit-source-id: 90ef7e575db7b9a6f80f818cc9a8e2988bbdca7a
2018-10-23 18:51:59 -07:00
Adam Simpkins
dacc8787f3 convert some deprecated Future::then() calls
Summary:
Convert deprecated `folly::Future::then()` calls to `thenTry()` or
`thenValue()` as appropriate.

Reviewed By: chadaustin

Differential Revision: D10503906

fbshipit-source-id: abc0f6f588ad7edd0dd2576544875f4ad0263b83
2018-10-23 13:42:12 -07:00
Lee Howes
a759b25b7d Future<T>::then Future<T>::then() -> Future<T>::thenValue or thenTry.
Summary:
Part of the larger project to modify Future<T>::then to be r-value qualified and use Future<T>::thenTry or Future<T>::thenValue.

The goal is to disambiguate folly::Future and to improve type and lifetime safety of Future and its methods.

Codemod:
  future<T>.then(callable with operator()(not-a-try)) to future<T>.thenValue(callable with operator()(not-a-try)).
  future<T>.then(callable with operator()()) to future<T>.thenValue(callable with operator()(auto&&)).
  future<T>.then(callable with operator()(auto)) to future<T>.thenValue(callable with operator()(auto)).
  future<T>.then(callable with operator()(folly::Try<T>)) to future<T>.thenTry(callable)

Reviewed By: Orvid

Differential Revision: D10227086

fbshipit-source-id: 1bb31c91cc65e28291e39302627f97801bfde15c
2018-10-07 17:06:49 -07:00
Lee Howes
e8e25257cf Future<T>::then Future<T>::then() -> Future<T>::thenValue or thenTry.
Summary:
Part of the larger project to modify Future<T>::then to be r-value qualified and use Future<T>::thenTry or Future<T>::thenValue.

The goal is to disambiguate folly::Future and to improve type and lifetime safety of Future and its methods.

Codemod:
  future<T>.then(callable with operator()(not-a-try)) to future<T>.thenValue(callable with operator()(not-a-try)).
  future<T>.then(callable with operator()()) to future<T>.thenValue(callable with operator()(auto&&)).
  future<T>.then(callable with operator()(auto)) to future<T>.thenValue(callable with operator()(auto)).
  future<T>.then(callable with operator()(folly::Try<T>)) to future<T>.thenTry(callable)

Reviewed By: Orvid

Differential Revision: D9819578

fbshipit-source-id: f9e31f47354c041ecbf0a90953cbe50ebfda6adc
2018-09-14 17:10:57 -07:00
Chad Austin
7a686d9c8f don't pass next inode number through thrift
Summary:
The desired end state for how next inode number gets passed across
takeover. This should not land as is - the prior diffs need to land
and wait for a while until everyone transitions.

Reviewed By: simpkins

Differential Revision: D8195550

fbshipit-source-id: 2fc40f881cc1a331df95ef99f7e9e4f2e69c8643
2018-08-23 22:55:21 -07:00
Adam Simpkins
19d922b0e6 add integration tests for CLI behavior inside a stale mount
Summary:
Add some integration tests that invoked "eden doctor" and "eden list" inside a
stale mount point, and confirms that they work correctly.  These commands do
fail in dev builds, since python itself does not handle this error.
Fortunately XAR-based python archives avoids this error, so these commands
work in opt mode builds.

Reviewed By: strager

Differential Revision: D8905489

fbshipit-source-id: 0666f8cb0715d61697253bee9fe0bde2f4a3fa15
2018-07-27 18:36:55 -07:00
Lee Howes
2b4e4f861e Future<T>::then 1/n: Future<T>::then(try-task) -> Future<T>::thenTry(task).
Summary:
Overall plan to modify Future<T>::then to be r-value qualified and use
Future<T>::thenTry or Future<T>::thenValue.

1/n: Codemod rvalue-future<T>.then(callable with operator()(Try<T>)) to rvalue-future<T>.thenTry(callable with operator()(Try<T>)).

Reviewed By: simpkins

Differential Revision: D8961903

fbshipit-source-id: ff17b7833d240c221197cdf0bf914b8a39f80b07
2018-07-23 18:51:38 -07:00
Chad Austin
22e46cfe74 standardize on std::chrono_literals
Summary:
This is not at all clear from cppreference.com, but per
https://www.youtube.com/watch?v=dTeKf5Oek2c, it sounds to me like
recommended practice is to either:

`using namespace std::chrono_literals` (or string_literals or
whatever) to pull in a focused set of literals.

or

`using namespace std::literals` to pull in all standard literals.

or

`using namespace std` to pull in everything.

`using namespace std::literals::chrono_literals` is unnecessarily
verbose.

Adopt those standards in Eden.

Reviewed By: simpkins

Differential Revision: D8060944

fbshipit-source-id: 4d9dd4329698b7ff5e5c81b5b28780ca4d81a2a1
2018-05-18 16:51:15 -07:00
Adam Simpkins
684fa29593 update folly::Init to call folly::initLogging()
Summary:
Update the folly::Init code to define a `--logging` command line flag, and call
`folly::initLoggingOrDie()` with the value of this command line during
initialization.

This is similar to the existing code that initializes the glog library.
(Programs can use both glog and folly logging together in the same program, and
I expect that many programs will do so as parts get converted to folly::logging
and parts remain using glog.)

Reviewed By: yfeldblum

Differential Revision: D7827344

fbshipit-source-id: 8aa239fbad43bc0b551cbe40cad7b92fa97fcdde
2018-05-15 12:38:01 -07:00
Chad Austin
72be488e3d add convenient operator literals for the various path piece types
Summary:
I got tired of typing PathComponentPiece{"..."} in tests so here are
some operator literals.

Reviewed By: simpkins

Differential Revision: D7956732

fbshipit-source-id: 85d9f3fd725853a54da9e70fc659bd7eb9e0862c
2018-05-11 14:52:07 -07:00
Chad Austin
04d873a27a add EdenBug::throwException
Summary:
I frequently find myself forgetting how to make the compiler see that
non-moved-from EDEN_BUG's destructor is noreturn, so add a simple
throwException function to it.

Reviewed By: simpkins

Differential Revision: D7834182

fbshipit-source-id: f279b9ca24f90efb4ad3ac318606dbd2dd002665
2018-05-01 16:52:06 -07:00
Adam Simpkins
8e3c09a99a move folly/experimental/logging to folly/logging/
Summary:
Promote the folly logging code out of the experimental subdirectory.
We have been using this for several months in a few projects and are pretty
happy with it so far.

After moving it out of the experimental/ subdirectory I plan to update
folly::Init() to automatically support configuring it via a `--logging` command
line flag (similar to the initialization it already does today for glog).

Reviewed By: yfeldblum, chadaustin

Differential Revision: D7755455

fbshipit-source-id: 052db34c97f7516728f7cbb1a5ad959def2f6efb
2018-04-30 21:29:29 -07:00
Adam Simpkins
dea514bbef add CMake build files
Summary: Add CMakeFiles to build Eden.

Reviewed By: wez

Differential Revision: D7479587

fbshipit-source-id: 7e0b4a756005dadc3af5c13c36ce22d1dcc15071
2018-04-30 14:37:46 -07:00
Chad Austin
1f256dd26e bump takeover receive timeout to five minutes
Summary: Temporary fix to bump the takeover timeout to five minutes

Reviewed By: simpkins

Differential Revision: D7660642

fbshipit-source-id: 5b3a0347aa1443e395e9461d33459c62ffce5b2d
2018-04-18 11:53:01 -07:00
Chad Austin
75b32848c6 refactor UnixSocket in prep for iovec limits
Summary:
UnixSocket traverses the IOBuf chain twice.  Refactor that
into a common function because the next diff caps the size of
individual iovecs.

Reviewed By: simpkins

Differential Revision: D7659062

fbshipit-source-id: 88b7d63669d8189b96434c38a6e499ed3b5ebbe6
2018-04-18 11:31:02 -07:00
Adam Simpkins
19122feb19 add a FOLLY_INIT_LOGGING_CONFIG() helper macro
Summary:
Add a macro to help users define the `getBaseLoggingConfig()` function.

While I would prefer to avoid macros if possible, this seems worthwhile.  This
saves 4 or 5 lines of boilerplate code in each program that sets a custom base
logger setting.  It also reduces the likelihood of a developer accidentally
having a typo in the function name, which would still build successfully but
not have the desired results.

Reviewed By: chadaustin

Differential Revision: D7457652

fbshipit-source-id: 1c316c7ea6949c16bd7b61c0440cc1ee69ecb83e
2018-04-10 11:42:27 -07:00
Adam Simpkins
f5f0f5f9c8 use folly::getBaseLoggingConfig() to set base logging config
Summary:
Set the default logging settings by overriding folly::getBaseLoggingConfig()
rather than by setting a default value for the `--logging` command line
argument.

This has two advantages:
- Custom logging settings supplied in the `--logging` argument will now
  combined with the base logging settings rather than completely replacing
  them.  Previously users had to always add "eden=DBG2" to this argument if
  they did not want to drop this setting.
- This will make it possible to move the definion of the `--logging` flag to
  folly::Init and not lose our custom settings for Eden.

Reviewed By: yfeldblum

Differential Revision: D7348519

fbshipit-source-id: bd9012f387b0460da8bcc9c7c31aef46b1abec5c
2018-03-21 12:37:48 -07:00
Adam Simpkins
90e3a053f4 ensure that we send takeover data from the correct thread
Summary:
The TakeoverServer::ConnHandler code uses a folly::EventBase to drive the
socket I/O, and therefore must perform all I/O from EventBase thread.
This changes ensures that we always call `sendTakeoverData()` from the correct
thread.

Up until now this has happened to work since the future returned by
`EdenServer::startTakeoverShutdown()` happened to always be completed in the
EdenServer main EventBase thread, and this is the same thread used for the
TakeoverServer socket.

This change makes it explicit that this particular code must be run from the
correct EventBase thread.

Reviewed By: chadaustin

Differential Revision: D7297834

fbshipit-source-id: cbace5f63ea13aa62dd53be0b89d59bea2779cf4
2018-03-16 12:35:19 -07:00
Adam Simpkins
21d2b6c46d Remove TARGETS files
Summary:
This removes the TARGETS files from the eden github repository.  The
open source buck build has been failing for several months, since buck
removed support for the thrift_library() rule.

I will potentially take a stab at adding CMake build support for Eden
at some point in the future.

Reviewed By: chadaustin

Differential Revision: D6893233

fbshipit-source-id: e6023094a807cf481ac49998c6f21b213be6c288
2018-02-20 19:57:45 -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
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
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
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
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
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
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
649b4e3ecb send the thrift server socket during graceful takeover
Summary:
Update the TakeoverData to also include the thrift server socket.
Also update EdenServer to set this field when performing a takeover
shutdown.

Reviewed By: bolinfest

Differential Revision: D6038945

fbshipit-source-id: 725faa431b3b55d617ef645c8a7eae080e4fe066
2017-11-19 15:47:30 -08:00
Adam Simpkins
0c3d6232e3 initial code to listen for graceful takeover attempts
Summary:
This adds a new class which listens on a Unix domain socket for clients that
wish to gracefully take over Eden's FUSE mount points.  The goal is to
eventually enable graceful restart functionality for eden.

It would be nice if we could use the existing thrift server socket for this,
but thrift doesn't provide low-enough level APIs so that we can send
credentials and file descriptors over the socket using SCM_CREDENTIALS and
SCM_RIGHTS.  Using our own separate socket is the easiest way to accomplish
this instead.

For now eden just listens on this socket and logs a message when a client
connects; this diff does not yet contain logic for performing mount point
takeover.

Reviewed By: bolinfest

Differential Revision: D5827752

fbshipit-source-id: 928e541efa2546cb612da2699ff0bd822bafaad5
2017-11-19 15:47:20 -08:00