]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDFailure.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_MOSDFAILURE_H
17 #define CEPH_MOSDFAILURE_H
19 #include "messages/PaxosServiceMessage.h"
22 class MOSDFailure
: public PaxosServiceMessage
{
24 static const int HEAD_VERSION
= 3;
25 static const int COMPAT_VERSION
= 3;
29 FLAG_ALIVE
= 0, // use this on its own to mark as "I'm still alive"
30 FLAG_FAILED
= 1, // if set, failure; if not, recovery
31 FLAG_IMMEDIATE
= 2, // known failure, not a timeout
35 entity_inst_t target_osd
;
38 int32_t failed_for
= 0; // known to be failed since at least this long
40 MOSDFailure() : PaxosServiceMessage(MSG_OSD_FAILURE
, 0, HEAD_VERSION
) { }
41 MOSDFailure(const uuid_d
&fs
, const entity_inst_t
& f
, int duration
, epoch_t e
)
42 : PaxosServiceMessage(MSG_OSD_FAILURE
, e
, HEAD_VERSION
, COMPAT_VERSION
),
43 fsid(fs
), target_osd(f
),
45 epoch(e
), failed_for(duration
) { }
46 MOSDFailure(const uuid_d
&fs
, const entity_inst_t
& f
, int duration
,
47 epoch_t e
, __u8 extra_flags
)
48 : PaxosServiceMessage(MSG_OSD_FAILURE
, e
, HEAD_VERSION
, COMPAT_VERSION
),
49 fsid(fs
), target_osd(f
),
51 epoch(e
), failed_for(duration
) { }
53 ~MOSDFailure() override
{}
56 entity_inst_t
get_target() { return target_osd
; }
57 bool if_osd_failed() const {
58 return flags
& FLAG_FAILED
;
60 bool is_immediate() const {
61 return flags
& FLAG_IMMEDIATE
;
63 epoch_t
get_epoch() const { return epoch
; }
65 void decode_payload() override
{
66 bufferlist::iterator p
= payload
.begin();
69 ::decode(target_osd
, p
);
72 ::decode(failed_for
, p
);
75 void encode_payload(uint64_t features
) override
{
77 ::encode(fsid
, payload
);
78 ::encode(target_osd
, payload
, features
);
79 ::encode(epoch
, payload
);
80 ::encode(flags
, payload
);
81 ::encode(failed_for
, payload
);
84 const char *get_type_name() const override
{ return "osd_failure"; }
85 void print(ostream
& out
) const override
{
87 << (if_osd_failed() ? "failed " : "recovered ")
88 << (is_immediate() ? "immediate " : "timeout ")
89 << target_osd
<< " for " << failed_for
<< "sec e" << epoch
90 << " v" << version
<< ")";