]> git.proxmox.com Git - ceph.git/blame - ceph/src/mds/events/ESlaveUpdate.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / mds / events / ESlaveUpdate.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15#ifndef CEPH_MDS_ESLAVEUPDATE_H
16#define CEPH_MDS_ESLAVEUPDATE_H
17
11fdf7f2
TL
18#include <string_view>
19
7c673cae
FG
20#include "../LogEvent.h"
21#include "EMetaBlob.h"
22
23/*
24 * rollback records, for remote/slave updates, which may need to be manually
25 * rolled back during journal replay. (or while active if master fails, but in
26 * that case these records aren't needed.)
27 */
28struct link_rollback {
29 metareqid_t reqid;
30 inodeno_t ino;
31 bool was_inc;
32 utime_t old_ctime;
33 utime_t old_dir_mtime;
34 utime_t old_dir_rctime;
11fdf7f2 35 bufferlist snapbl;
7c673cae
FG
36
37 link_rollback() : ino(0), was_inc(false) {}
38
39 void encode(bufferlist& bl) const;
11fdf7f2 40 void decode(bufferlist::const_iterator& bl);
7c673cae
FG
41 void dump(Formatter *f) const;
42 static void generate_test_instances(list<link_rollback*>& ls);
43};
44WRITE_CLASS_ENCODER(link_rollback)
45
46/*
47 * this is only used on an empty dir with a dirfrag on a remote node.
48 * we are auth for nothing. all we need to do is relink the directory
49 * in the hierarchy properly during replay to avoid breaking the
50 * subtree map.
51 */
52struct rmdir_rollback {
53 metareqid_t reqid;
54 dirfrag_t src_dir;
55 string src_dname;
56 dirfrag_t dest_dir;
57 string dest_dname;
11fdf7f2 58 bufferlist snapbl;
7c673cae
FG
59
60 void encode(bufferlist& bl) const;
11fdf7f2 61 void decode(bufferlist::const_iterator& bl);
7c673cae
FG
62 void dump(Formatter *f) const;
63 static void generate_test_instances(list<rmdir_rollback*>& ls);
64};
65WRITE_CLASS_ENCODER(rmdir_rollback)
66
67struct rename_rollback {
68 struct drec {
69 dirfrag_t dirfrag;
70 utime_t dirfrag_old_mtime;
71 utime_t dirfrag_old_rctime;
72 inodeno_t ino, remote_ino;
73 string dname;
74 char remote_d_type;
75 utime_t old_ctime;
76
77 drec() : remote_d_type((char)S_IFREG) {}
78
79 void encode(bufferlist& bl) const;
11fdf7f2 80 void decode(bufferlist::const_iterator& bl);
7c673cae
FG
81 void dump(Formatter *f) const;
82 static void generate_test_instances(list<drec*>& ls);
83 };
84 WRITE_CLASS_MEMBER_ENCODER(drec)
85
86 metareqid_t reqid;
87 drec orig_src, orig_dest;
88 drec stray; // we know this is null, but we want dname, old mtime/rctime
89 utime_t ctime;
11fdf7f2
TL
90 bufferlist srci_snapbl;
91 bufferlist desti_snapbl;
7c673cae
FG
92
93 void encode(bufferlist& bl) const;
11fdf7f2 94 void decode(bufferlist::const_iterator& bl);
7c673cae
FG
95 void dump(Formatter *f) const;
96 static void generate_test_instances(list<rename_rollback*>& ls);
97};
98WRITE_CLASS_ENCODER(rename_rollback::drec)
99WRITE_CLASS_ENCODER(rename_rollback)
100
101
102class ESlaveUpdate : public LogEvent {
103public:
104 const static int OP_PREPARE = 1;
105 const static int OP_COMMIT = 2;
106 const static int OP_ROLLBACK = 3;
107
108 const static int LINK = 1;
109 const static int RENAME = 2;
110 const static int RMDIR = 3;
111
112 /*
113 * we journal a rollback metablob that contains the unmodified metadata
114 * too, because we may be updating previously dirty metadata, which
115 * will allow old log segments to be trimmed. if we end of rolling back,
116 * those updates could be lost.. so we re-journal the unmodified metadata,
117 * and replay will apply _either_ commit or rollback.
118 */
119 EMetaBlob commit;
120 bufferlist rollback;
121 string type;
122 metareqid_t reqid;
123 mds_rank_t master;
124 __u8 op; // prepare, commit, abort
125 __u8 origop; // link | rename
126
127 ESlaveUpdate() : LogEvent(EVENT_SLAVEUPDATE), master(0), op(0), origop(0) { }
11fdf7f2
TL
128 ESlaveUpdate(MDLog *mdlog, std::string_view s, metareqid_t ri, int mastermds, int o, int oo) :
129 LogEvent(EVENT_SLAVEUPDATE),
7c673cae
FG
130 type(s),
131 reqid(ri),
132 master(mastermds),
133 op(o), origop(oo) { }
134
135 void print(ostream& out) const override {
136 if (type.length())
137 out << type << " ";
138 out << " " << (int)op;
139 if (origop == LINK) out << " link";
140 if (origop == RENAME) out << " rename";
141 out << " " << reqid;
142 out << " for mds." << master;
143 out << commit;
144 }
145
146 EMetaBlob *get_metablob() override { return &commit; }
147
148 void encode(bufferlist& bl, uint64_t features) const override;
11fdf7f2 149 void decode(bufferlist::const_iterator& bl) override;
7c673cae
FG
150 void dump(Formatter *f) const override;
151 static void generate_test_instances(list<ESlaveUpdate*>& ls);
152
153 void replay(MDSRank *mds) override;
154};
155WRITE_CLASS_ENCODER_FEATURES(ESlaveUpdate)
156
157#endif