return 0;
}
-PeerReplayer::SyncMechanism::SyncMechanism(MountRef local, MountRef remote, FHandles *fh,
+PeerReplayer::SyncMechanism::SyncMechanism(std::string_view dir_root,
+ MountRef local, MountRef remote, FHandles *fh,
const Peer &peer, const Snapshot ¤t,
boost::optional<Snapshot> prev)
: m_local(local),
m_peer(peer),
m_current(current),
m_prev(prev),
- sdq_lock(ceph::make_mutex("cephfs::mirror::PeerReplayer::SyncMechanism" + stringify(peer.uuid))) {
+ sdq_lock(ceph::make_mutex("cephfs::mirror::PeerReplayer::SyncMechanism" + stringify(peer.uuid))),
+ m_dir_root(dir_root) {
}
PeerReplayer::SyncMechanism::~SyncMechanism() {
PeerReplayer::SnapDiffSync::SnapDiffSync(std::string_view dir_root, MountRef local, MountRef remote,
FHandles *fh, const Peer &peer, const Snapshot ¤t,
boost::optional<Snapshot> prev)
- : SyncMechanism(local, remote, fh, peer, current, prev),
- m_dir_root(dir_root) {
+ : SyncMechanism(dir_root, local, remote, fh, peer, current, prev) {
}
PeerReplayer::SnapDiffSync::~SnapDiffSync() {
mark_crawl_finished();
}
-PeerReplayer::RemoteSync::RemoteSync(MountRef local, MountRef remote, FHandles *fh,
+PeerReplayer::RemoteSync::RemoteSync(std::string_view dir_root,
+ MountRef local, MountRef remote, FHandles *fh,
const Peer &peer, const Snapshot ¤t,
boost::optional<Snapshot> prev)
- : SyncMechanism(local, remote, fh, peer, current, prev) {
+ : SyncMechanism(dir_root, local, remote, fh, peer, current, prev) {
}
PeerReplayer::RemoteSync::~RemoteSync() {
&fh, m_peer, current, prev);
} else {
- syncm = std::make_shared<RemoteSync>(m_local_mount, m_remote_mount, &fh,
- m_peer, current, boost::none);
+ syncm = std::make_shared<RemoteSync>(dir_root, m_local_mount, m_remote_mount,
+ &fh, m_peer, current, boost::none);
}
r = syncm->init_sync();
class SyncMechanism {
public:
- SyncMechanism(MountRef local, MountRef remote, FHandles *fh,
+ SyncMechanism(std::string_view dir_root,
+ MountRef local, MountRef remote, FHandles *fh,
const Peer &peer, /* keep dout happy */
const Snapshot ¤t, boost::optional<Snapshot> prev);
virtual ~SyncMechanism() = 0;
ceph::mutex& get_sdq_lock() {
return sdq_lock;
}
+ std::string_view get_m_dir_root() {
+ return m_dir_root;
+ }
int remote_mkdir(const std::string &epath, const struct ceph_statx &stx);
protected:
std::queue<PeerReplayer::SyncEntry> m_sync_dataq;
int m_in_flight = 0;
bool m_crawl_finished = false;
+ // It's not used in RemoteSync but required to be accessed in datasync threads
+ std::string m_dir_root;
};
class RemoteSync : public SyncMechanism {
public:
- RemoteSync(MountRef local, MountRef remote, FHandles *fh,
+ RemoteSync(std::string_view dir_root,
+ MountRef local, MountRef remote, FHandles *fh,
const Peer &peer, /* keep dout happy */
const Snapshot ¤t, boost::optional<Snapshot> prev);
~RemoteSync();
int next_entry(SyncEntry &entry, std::string *e_name, snapid_t *snapid);
void fini_directory(SyncEntry &entry);
- std::string m_dir_root;
std::map<std::string, std::set<std::string>> m_deleted;
};