]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MDiscoverReply.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
16 #ifndef CEPH_MDISCOVERREPLY_H
17 #define CEPH_MDISCOVERREPLY_H
19 #include "msg/Message.h"
20 #include "include/filepath.h"
27 * MDiscoverReply - return new replicas (of inodes, dirs, dentries)
29 * we group returned items by (dir, dentry, inode). each
30 * item in each set shares an index (it's "depth").
32 * we can start and end with any type.
33 * no_base_dir = true if the first group has an inode but no dir
34 * no_base_dentry = true if the first group has an inode but no dentry
35 * they are false if there is no returned data, ie the first group is empty.
37 * we also return errors:
38 * error_flag_dn(std::string) - the specified dentry dne
39 * error_flag_dir - the last item wasn't a dir, so we couldn't continue.
42 * dir_auth_hint - where we think the dir auth is
44 * depth() gives us the number of depth units/indices for which we have
45 * information. this INCLUDES those for which we have errors but no data.
47 * see MDCache::handle_discover, handle_discover_reply.
50 * so basically, we get
61 * ...and trail off however we want.
66 class MDiscoverReply
: public MessageInstance
<MDiscoverReply
> {
70 static constexpr int HEAD_VERSION
= 2;
72 // info about original request
75 bool wanted_base_dir
= false;
76 bool wanted_xlocked
= false;
77 snapid_t wanted_snapid
;
80 bool flag_error_dn
= false;
81 bool flag_error_dir
= false;
82 std::string error_dentry
; // dentry that was not found (to trigger waiters on asker)
83 bool unsolicited
= false;
85 mds_rank_t dir_auth_hint
= 0;
91 enum { DIR, DENTRY
, INODE
};
94 inodeno_t
get_base_ino() const { return base_ino
; }
95 frag_t
get_base_dir_frag() const { return base_dir_frag
; }
96 bool get_wanted_base_dir() const { return wanted_base_dir
; }
97 bool get_wanted_xlocked() const { return wanted_xlocked
; }
98 snapid_t
get_wanted_snapid() const { return wanted_snapid
; }
100 bool is_flag_error_dn() const { return flag_error_dn
; }
101 bool is_flag_error_dir() const { return flag_error_dir
; }
102 const std::string
& get_error_dentry() const { return error_dentry
; }
104 int get_starts_with() const { return starts_with
; }
106 mds_rank_t
get_dir_auth_hint() const { return dir_auth_hint
; }
108 bool is_unsolicited() const { return unsolicited
; }
109 void mark_unsolicited() { unsolicited
= true; }
111 void set_base_dir_frag(frag_t df
) { base_dir_frag
= df
; }
114 MDiscoverReply() : MessageInstance(MSG_MDS_DISCOVERREPLY
, HEAD_VERSION
) { }
115 MDiscoverReply(const MDiscover
&dis
) :
116 MessageInstance(MSG_MDS_DISCOVERREPLY
, HEAD_VERSION
),
117 base_ino(dis
.get_base_ino()),
118 base_dir_frag(dis
.get_base_dir_frag()),
119 wanted_base_dir(dis
.wants_base_dir()),
120 wanted_xlocked(dis
.wants_xlocked()),
121 wanted_snapid(dis
.get_snapid()),
122 flag_error_dn(false),
123 flag_error_dir(false),
125 dir_auth_hint(CDIR_AUTH_UNKNOWN
),
128 header
.tid
= dis
.get_tid();
130 MDiscoverReply(dirfrag_t df
) :
131 MessageInstance(MSG_MDS_DISCOVERREPLY
, HEAD_VERSION
),
133 base_dir_frag(df
.frag
),
134 wanted_base_dir(false),
135 wanted_xlocked(false),
136 wanted_snapid(CEPH_NOSNAP
),
137 flag_error_dn(false),
138 flag_error_dir(false),
140 dir_auth_hint(CDIR_AUTH_UNKNOWN
),
145 ~MDiscoverReply() override
{}
148 std::string_view
get_type_name() const override
{ return "discover_reply"; }
149 void print(ostream
& out
) const override
{
150 out
<< "discover_reply(" << header
.tid
<< " " << base_ino
<< ")";
154 bool is_empty() const {
155 return trace
.length() == 0 &&
158 dir_auth_hint
== CDIR_AUTH_UNKNOWN
;
161 // void set_flag_forward() { flag_forward = true; }
162 void set_flag_error_dn(std::string_view dn
) {
163 flag_error_dn
= true;
166 void set_flag_error_dir() {
167 flag_error_dir
= true;
169 void set_dir_auth_hint(int a
) {
172 void set_error_dentry(std::string_view dn
) {
178 void decode_payload() override
{
179 auto p
= payload
.cbegin();
181 decode(base_dir_frag
, p
);
182 decode(wanted_base_dir
, p
);
183 decode(wanted_xlocked
, p
);
184 decode(wanted_snapid
, p
);
185 decode(flag_error_dn
, p
);
186 decode(flag_error_dir
, p
);
187 decode(error_dentry
, p
);
188 decode(dir_auth_hint
, p
);
189 decode(unsolicited
, p
);
191 decode(starts_with
, p
);
194 void encode_payload(uint64_t features
) override
{
196 encode(base_ino
, payload
);
197 encode(base_dir_frag
, payload
);
198 encode(wanted_base_dir
, payload
);
199 encode(wanted_xlocked
, payload
);
200 encode(wanted_snapid
, payload
);
201 encode(flag_error_dn
, payload
);
202 encode(flag_error_dir
, payload
);
203 encode(error_dentry
, payload
);
204 encode(dir_auth_hint
, payload
);
205 encode(unsolicited
, payload
);
207 encode(starts_with
, payload
);
208 encode(trace
, payload
);