]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/ScrubHeader.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / mds / ScrubHeader.h
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) 2016 Red Hat Inc
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 SCRUB_HEADER_H_
17 #define SCRUB_HEADER_H_
18
19 #include <memory>
20 #include <string>
21 #include <string_view>
22
23 #include "include/ceph_assert.h"
24
25 namespace ceph {
26 class Formatter;
27 };
28
29 class CInode;
30
31 /**
32 * Externally input parameters for a scrub, associated with the root
33 * of where we are doing a recursive scrub
34 */
35 class ScrubHeader {
36 public:
37 ScrubHeader(std::string_view tag_, bool is_tag_internal_, bool force_,
38 bool recursive_, bool repair_)
39 : tag(tag_), is_tag_internal(is_tag_internal_), force(force_),
40 recursive(recursive_), repair(repair_) {}
41
42 // Set after construction because it won't be known until we've
43 // started resolving path and locking
44 void set_origin(inodeno_t ino) { origin = ino; }
45
46 bool get_recursive() const { return recursive; }
47 bool get_repair() const { return repair; }
48 bool get_force() const { return force; }
49 bool is_internal_tag() const { return is_tag_internal; }
50 inodeno_t get_origin() const { return origin; }
51 const std::string& get_tag() const { return tag; }
52
53 bool get_repaired() const { return repaired; }
54 void set_repaired() { repaired = true; }
55
56 void set_epoch_last_forwarded(unsigned epoch) { epoch_last_forwarded = epoch; }
57 unsigned get_epoch_last_forwarded() const { return epoch_last_forwarded; }
58
59 void inc_num_pending() { ++num_pending; }
60 void dec_num_pending() {
61 ceph_assert(num_pending > 0);
62 --num_pending;
63 }
64 unsigned get_num_pending() const { return num_pending; }
65
66 protected:
67 const std::string tag;
68 bool is_tag_internal;
69 const bool force;
70 const bool recursive;
71 const bool repair;
72 inodeno_t origin;
73
74 bool repaired = false; // May be set during scrub if repairs happened
75 unsigned epoch_last_forwarded = 0;
76 unsigned num_pending = 0;
77 };
78
79 typedef std::shared_ptr<ScrubHeader> ScrubHeaderRef;
80 typedef std::shared_ptr<const ScrubHeader> ScrubHeaderRefConst;
81
82 #endif // SCRUB_HEADER_H_