2017-11-20 02:18:27 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <folly/File.h>
|
|
|
|
#include <folly/futures/Promise.h>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-01-10 09:00:50 +03:00
|
|
|
#include "eden/fs/fuse/FuseTypes.h"
|
2018-01-10 09:00:53 +03:00
|
|
|
#include "eden/fs/fuse/gen-cpp2/handlemap_types.h"
|
2017-11-20 02:18:27 +03:00
|
|
|
#include "eden/fs/utils/PathFuncs.h"
|
|
|
|
|
|
|
|
namespace folly {
|
|
|
|
class IOBuf;
|
|
|
|
class exception_wrapper;
|
|
|
|
} // namespace folly
|
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
|
|
|
|
2018-01-10 09:00:53 +03:00
|
|
|
class SerializedFileHandleMap;
|
|
|
|
|
2017-11-20 02:18:27 +03:00
|
|
|
/**
|
|
|
|
* TakeoverData contains the data exchanged between processes during
|
|
|
|
* graceful mount point takeover.
|
|
|
|
*/
|
|
|
|
class TakeoverData {
|
|
|
|
public:
|
|
|
|
struct MountInfo {
|
|
|
|
MountInfo(
|
2018-01-10 09:00:52 +03:00
|
|
|
AbsolutePathPiece mountPath,
|
|
|
|
AbsolutePathPiece stateDirectory,
|
2017-11-20 02:18:27 +03:00
|
|
|
const std::vector<AbsolutePath>& bindMountPaths,
|
2018-01-10 09:00:50 +03:00
|
|
|
folly::File fd,
|
2018-01-10 09:00:53 +03:00
|
|
|
fuse_init_out connInfo,
|
|
|
|
SerializedFileHandleMap&& fileHandleMap)
|
2018-01-10 09:00:52 +03:00
|
|
|
: mountPath{mountPath},
|
|
|
|
stateDirectory{stateDirectory},
|
2018-01-10 09:00:50 +03:00
|
|
|
bindMounts{bindMountPaths},
|
|
|
|
fuseFD{std::move(fd)},
|
2018-01-10 09:00:53 +03:00
|
|
|
connInfo{connInfo},
|
|
|
|
fileHandleMap{std::move(fileHandleMap)} {}
|
2017-11-20 02:18:27 +03:00
|
|
|
|
2018-01-10 09:00:52 +03:00
|
|
|
AbsolutePath mountPath;
|
|
|
|
AbsolutePath stateDirectory;
|
2017-11-20 02:18:27 +03:00
|
|
|
std::vector<AbsolutePath> bindMounts;
|
|
|
|
folly::File fuseFD;
|
2018-01-10 09:00:50 +03:00
|
|
|
fuse_init_out connInfo;
|
2018-01-10 09:00:53 +03:00
|
|
|
SerializedFileHandleMap fileHandleMap;
|
2017-11-20 02:18:27 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Serialize the TakeoverData into a buffer that can be sent to a remote
|
|
|
|
* process.
|
|
|
|
*
|
|
|
|
* This includes all data except for file descriptors. The file descriptors
|
|
|
|
* must be sent separately.
|
|
|
|
*/
|
2018-01-06 00:34:25 +03:00
|
|
|
folly::IOBuf serialize();
|
2017-11-20 02:18:27 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Serialize an exception.
|
|
|
|
*/
|
2018-01-06 00:34:25 +03:00
|
|
|
static folly::IOBuf serializeError(const folly::exception_wrapper& ew);
|
2017-11-20 02:18:27 +03:00
|
|
|
|
|
|
|
/**
|
2018-01-06 00:34:25 +03:00
|
|
|
* Deserialize the TakeoverData from a buffer.
|
2017-11-20 02:18:27 +03:00
|
|
|
*/
|
2018-01-06 00:34:25 +03:00
|
|
|
static TakeoverData deserialize(const folly::IOBuf* buf);
|
2017-11-20 02:18:27 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The main eden lock file that prevents two edenfs processes from running at
|
|
|
|
* the same time.
|
|
|
|
*/
|
|
|
|
folly::File lockFile;
|
|
|
|
|
2017-11-20 02:18:31 +03:00
|
|
|
/**
|
|
|
|
* The thrift server socket.
|
|
|
|
*/
|
|
|
|
folly::File thriftSocket;
|
|
|
|
|
2017-11-20 02:18:27 +03:00
|
|
|
/**
|
|
|
|
* The list of mount points.
|
|
|
|
*/
|
|
|
|
std::vector<MountInfo> mountPoints;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The takeoverComplete promise will be fulfilled by the TakeoverServer code
|
|
|
|
* once the TakeoverData has been sent to the remote process.
|
|
|
|
*/
|
|
|
|
folly::Promise<folly::Unit> takeoverComplete;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Message type values.
|
|
|
|
* If we ever need to include more information in the takeover data in the
|
|
|
|
* future we can do so by adding new message types here, and deprecating the
|
|
|
|
* older formats once we have upgraded all servers to use the new format.
|
|
|
|
*/
|
|
|
|
enum MessageType : uint32_t {
|
|
|
|
ERROR = 1,
|
|
|
|
MOUNTS = 2,
|
|
|
|
};
|
2018-01-06 00:34:25 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The length of the serialized header.
|
|
|
|
* This is just a 4-byte message type field.
|
|
|
|
*/
|
|
|
|
static constexpr uint32_t kHeaderLength = sizeof(uint32_t);
|
2017-11-20 02:18:27 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|