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   	
16   	#ifndef CEPH_MOSDFAILURE_H
17   	#define CEPH_MOSDFAILURE_H
18   	
19   	#include "messages/PaxosServiceMessage.h"
20   	
21   	
22   	class MOSDFailure : public PaxosServiceMessage {
23   	private:
24   	  static constexpr int HEAD_VERSION = 4;
25   	  static constexpr int COMPAT_VERSION = 4;
26   	
27   	 public:
28   	  enum {
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
32   	  };
33   	  
34   	  uuid_d fsid;
(1) Event member_decl: Class member declaration for "target_osd".
Also see events: [uninit_member]
35   	  int32_t target_osd;
36   	  entity_addrvec_t target_addrs;
37   	  __u8 flags = 0;
38   	  epoch_t epoch = 0;
39   	  int32_t failed_for = 0;  // known to be failed since at least this long
40   	
(2) Event uninit_member: Non-static class member "target_osd" is not initialized in this constructor nor in any functions that it calls.
Also see events: [member_decl]
41   	  MOSDFailure() : PaxosServiceMessage(MSG_OSD_FAILURE, 0, HEAD_VERSION) { }
42   	  MOSDFailure(const uuid_d &fs, int osd, const entity_addrvec_t& av,
43   		      int duration, epoch_t e)
44   	    : PaxosServiceMessage(MSG_OSD_FAILURE, e, HEAD_VERSION, COMPAT_VERSION),
45   	      fsid(fs),
46   	      target_osd(osd),
47   	      target_addrs(av),
48   	      flags(FLAG_FAILED),
49   	      epoch(e), failed_for(duration) { }
50   	  MOSDFailure(const uuid_d &fs, int osd, const entity_addrvec_t& av,
51   		      int duration,
52   	              epoch_t e, __u8 extra_flags)
53   	    : PaxosServiceMessage(MSG_OSD_FAILURE, e, HEAD_VERSION, COMPAT_VERSION),
54   	      fsid(fs),
55   	      target_osd(osd),
56   	      target_addrs(av),
57   	      flags(extra_flags),
58   	      epoch(e), failed_for(duration) { }
59   	private:
60   	  ~MOSDFailure() override {}
61   	
62   	public:
63   	  int get_target_osd() { return target_osd; }
64   	  const entity_addrvec_t& get_target_addrs() { return target_addrs; }
65   	  bool if_osd_failed() const { 
66   	    return flags & FLAG_FAILED; 
67   	  }
68   	  bool is_immediate() const { 
69   	    return flags & FLAG_IMMEDIATE; 
70   	  }
71   	  epoch_t get_epoch() const { return epoch; }
72   	
73   	  void decode_payload() override {
74   	    auto p = payload.cbegin();
75   	    paxos_decode(p);
76   	    decode(fsid, p);
77   	    if (header.version < 4) {
78   	      entity_inst_t i;
79   	      decode(i, p);
80   	      target_osd = i.name.num();
81   	      target_addrs.v.push_back(i.addr);
82   	    } else {
83   	      decode(target_osd, p);
84   	      decode(target_addrs, p);
85   	    }
86   	    decode(epoch, p);
87   	    decode(flags, p);
88   	    decode(failed_for, p);
89   	  }
90   	
91   	  void encode_payload(uint64_t features) override {
92   	    using ceph::encode;
93   	    paxos_encode();
94   	    if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
95   	      header.version = 3;
96   	      header.compat_version = 3;
97   	      encode(fsid, payload);
98   	      encode(entity_inst_t(entity_name_t::OSD(target_osd),
99   				   target_addrs.legacy_addr()), payload, features);
100  	      encode(epoch, payload);
101  	      encode(flags, payload);
102  	      encode(failed_for, payload);
103  	      return;
104  	    }
105  	    header.version = HEAD_VERSION;
106  	    header.compat_version = COMPAT_VERSION;
107  	    encode(fsid, payload);
108  	    encode(target_osd, payload, features);
109  	    encode(target_addrs, payload, features);
110  	    encode(epoch, payload);
111  	    encode(flags, payload);
112  	    encode(failed_for, payload);
113  	  }
114  	
115  	  std::string_view get_type_name() const override { return "osd_failure"; }
116  	  void print(ostream& out) const override {
117  	    out << "osd_failure("
118  		<< (if_osd_failed() ? "failed " : "recovered ")
119  		<< (is_immediate() ? "immediate " : "timeout ")
120  		<< "osd." << target_osd << " " << target_addrs
121  		<< " for " << failed_for << "sec e" << epoch
122  		<< " v" << version << ")";
123  	  }
124  	private:
125  	  template<class T, typename... Args>
126  	  friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
127  	};
128  	
129  	#endif
130