1    	// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2    	// vim: ts=8 sw=2 smarttab
3    	
4    	#ifndef CEPH_CACHE_SIMPLE_POLICY_H
5    	#define CEPH_CACHE_SIMPLE_POLICY_H
6    	
7    	#include "common/ceph_context.h"
8    	#include "common/ceph_mutex.h"
9    	#include "include/lru.h"
10   	#include "Policy.h"
11   	
12   	#include <unordered_map>
13   	#include <string>
14   	
15   	namespace ceph {
16   	namespace immutable_obj_cache {
17   	
18   	class SimplePolicy : public Policy {
19   	 public:
20   	  SimplePolicy(CephContext *cct, uint64_t block_num, uint64_t max_inflight,
21   	               double watermark);
22   	  ~SimplePolicy();
23   	
24   	  cache_status_t lookup_object(std::string file_name);
25   	  cache_status_t get_status(std::string file_name);
26   	
27   	  void update_status(std::string file_name,
28   	                     cache_status_t new_status,
29   	                     uint64_t size = 0);
30   	
31   	  int evict_entry(std::string file_name);
32   	
33   	  void get_evict_list(std::list<std::string>* obj_list);
34   	
35   	  uint64_t get_free_size();
36   	  uint64_t get_promoting_entry_num();
37   	  uint64_t get_promoted_entry_num();
38   	  std::string get_evict_entry();
39   	
40   	 private:
41   	  cache_status_t alloc_entry(std::string file_name);
42   	
43   	  class Entry : public LRUObject {
44   	   public:
45   	    cache_status_t status;
(2) Event uninit_member: Non-static class member "size" is not initialized in this constructor nor in any functions that it calls.
Also see events: [member_decl]
46   	    Entry() : status(OBJ_CACHE_NONE) {}
47   	    std::string file_name;
(1) Event member_decl: Class member declaration for "size".
Also see events: [uninit_member]
48   	    uint64_t size;
49   	  };
50   	
51   	  CephContext* cct;
52   	  double m_watermark;
53   	  uint64_t m_max_inflight_ops;
54   	  uint64_t m_max_cache_size;
55   	  std::atomic<uint64_t> inflight_ops = 0;
56   	
57   	  std::unordered_map<std::string, Entry*> m_cache_map;
58   	  ceph::shared_mutex m_cache_map_lock =
59   	    ceph::make_shared_mutex("rbd::cache::SimplePolicy::m_cache_map_lock");
60   	
61   	  std::atomic<uint64_t> m_cache_size;
62   	
63   	  LRU m_promoted_lru;
64   	};
65   	
66   	}  // namespace immutable_obj_cache
67   	}  // namespace ceph
68   	#endif  // CEPH_CACHE_SIMPLE_POLICY_H
69