return 0;
}
-PeerReplayer::SyncMechanism::SyncMechanism(std::string_view dir_root,
+PeerReplayer::SyncMechanism::SyncMechanism(PeerReplayer& peer_replayer, 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_replayer(peer_replayer),
+ m_dir_root(dir_root),
+ m_local(local),
m_remote(remote),
m_fh(fh),
m_peer(peer),
m_current(current),
m_prev(prev),
- sdq_lock(ceph::make_mutex("cephfs::mirror::PeerReplayer::SyncMechanism" + stringify(peer.uuid))),
- m_dir_root(dir_root) {
+ sdq_lock(ceph::make_mutex("cephfs::mirror::PeerReplayer::SyncMechanism" + stringify(peer.uuid))) {
}
PeerReplayer::SyncMechanism::~SyncMechanism() {
return callback(block.num_blocks, block.b);
}
-PeerReplayer::SnapDiffSync::SnapDiffSync(std::string_view dir_root, MountRef local, MountRef remote,
- FHandles *fh, const Peer &peer, const Snapshot ¤t,
+PeerReplayer::SnapDiffSync::SnapDiffSync(PeerReplayer& peer_replayer, std::string_view dir_root,
+ MountRef local, MountRef remote, FHandles *fh,
+ const Peer &peer, const Snapshot ¤t,
boost::optional<Snapshot> prev)
- : SyncMechanism(dir_root, local, remote, fh, peer, current, prev) {
+ : SyncMechanism(peer_replayer, dir_root, local, remote, fh, peer, current, prev) {
}
PeerReplayer::SnapDiffSync::~SnapDiffSync() {
mark_crawl_finished(ret);
}
-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(dir_root, local, remote, fh, peer, current, prev) {
+PeerReplayer::RemoteSync::RemoteSync(PeerReplayer& peer_replayer, std::string_view dir_root,
+ MountRef local, MountRef remote, FHandles *fh,
+ const Peer &peer, const Snapshot ¤t,
+ boost::optional<Snapshot> prev)
+ : SyncMechanism(peer_replayer, dir_root, local, remote, fh, peer, current, prev) {
}
PeerReplayer::RemoteSync::~RemoteSync() {
std::shared_ptr<SyncMechanism> syncm;
if (fh.p_mnt == m_local_mount) {
- syncm = std::make_shared<SnapDiffSync>(dir_root, m_local_mount, m_remote_mount,
- &fh, m_peer, current, prev);
-
+ syncm = std::make_shared<SnapDiffSync>(*this, dir_root, m_local_mount, m_remote_mount,
+ &fh, m_peer, current, prev);
} else {
- syncm = std::make_shared<RemoteSync>(dir_root, m_local_mount, m_remote_mount,
+ syncm = std::make_shared<RemoteSync>(*this, dir_root, m_local_mount, m_remote_mount,
&fh, m_peer, current, boost::none);
}
class SyncMechanism {
public:
- 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);
+ explicit SyncMechanism(PeerReplayer& peer_replayer, 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;
virtual int init_sync() = 0;
int remote_mkdir(const std::string &epath, const struct ceph_statx &stx);
protected:
+ PeerReplayer& m_peer_replayer;
+ // It's not used in RemoteSync but required to be accessed in datasync threads
+ std::string m_dir_root;
MountRef m_local;
MountRef m_remote;
FHandles *m_fh;
bool m_sync_done = false;
bool m_datasync_error = false;
int m_datasync_errno = 0;
- // 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(std::string_view dir_root,
+ RemoteSync(PeerReplayer& peer_replayer, std::string_view dir_root,
MountRef local, MountRef remote, FHandles *fh,
const Peer &peer, /* keep dout happy */
const Snapshot ¤t, boost::optional<Snapshot> prev);
class SnapDiffSync : public SyncMechanism {
public:
- SnapDiffSync(std::string_view dir_root, MountRef local, MountRef remote,
- FHandles *fh, const Peer &peer, const Snapshot ¤t,
+ SnapDiffSync(PeerReplayer& peer_replayer, std::string_view dir_root, MountRef local,
+ MountRef remote, FHandles *fh, const Peer &peer, const Snapshot ¤t,
boost::optional<Snapshot> prev);
~SnapDiffSync();