Commit Graph

11 Commits

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