]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
f67539c2 TL |
19 | #include <memory> |
20 | #include <string> | |
11fdf7f2 | 21 | #include <string_view> |
94b18763 | 22 | |
f67539c2 TL |
23 | #include "include/ceph_assert.h" |
24 | ||
25 | namespace ceph { | |
26 | class Formatter; | |
27 | }; | |
28 | ||
7c673cae FG |
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: | |
11fdf7f2 | 37 | ScrubHeader(std::string_view tag_, bool is_tag_internal_, bool force_, |
aee94f69 | 38 | bool recursive_, bool repair_, bool scrub_mdsdir_ = false) |
11fdf7f2 | 39 | : tag(tag_), is_tag_internal(is_tag_internal_), force(force_), |
aee94f69 | 40 | recursive(recursive_), repair(repair_), scrub_mdsdir(scrub_mdsdir_) {} |
7c673cae FG |
41 | |
42 | // Set after construction because it won't be known until we've | |
43 | // started resolving path and locking | |
f67539c2 | 44 | void set_origin(inodeno_t ino) { origin = ino; } |
7c673cae FG |
45 | |
46 | bool get_recursive() const { return recursive; } | |
47 | bool get_repair() const { return repair; } | |
48 | bool get_force() const { return force; } | |
aee94f69 | 49 | bool get_scrub_mdsdir() const { return scrub_mdsdir; } |
11fdf7f2 | 50 | bool is_internal_tag() const { return is_tag_internal; } |
f67539c2 TL |
51 | inodeno_t get_origin() const { return origin; } |
52 | const std::string& get_tag() const { return tag; } | |
7c673cae | 53 | |
b32b8144 FG |
54 | bool get_repaired() const { return repaired; } |
55 | void set_repaired() { repaired = true; } | |
56 | ||
f67539c2 TL |
57 | void set_epoch_last_forwarded(unsigned epoch) { epoch_last_forwarded = epoch; } |
58 | unsigned get_epoch_last_forwarded() const { return epoch_last_forwarded; } | |
59 | ||
60 | void inc_num_pending() { ++num_pending; } | |
61 | void dec_num_pending() { | |
62 | ceph_assert(num_pending > 0); | |
63 | --num_pending; | |
64 | } | |
65 | unsigned get_num_pending() const { return num_pending; } | |
66 | ||
7c673cae FG |
67 | protected: |
68 | const std::string tag; | |
11fdf7f2 | 69 | bool is_tag_internal; |
7c673cae FG |
70 | const bool force; |
71 | const bool recursive; | |
72 | const bool repair; | |
aee94f69 | 73 | const bool scrub_mdsdir; |
f67539c2 | 74 | inodeno_t origin; |
b32b8144 FG |
75 | |
76 | bool repaired = false; // May be set during scrub if repairs happened | |
f67539c2 TL |
77 | unsigned epoch_last_forwarded = 0; |
78 | unsigned num_pending = 0; | |
7c673cae FG |
79 | }; |
80 | ||
11fdf7f2 TL |
81 | typedef std::shared_ptr<ScrubHeader> ScrubHeaderRef; |
82 | typedef std::shared_ptr<const ScrubHeader> ScrubHeaderRefConst; | |
7c673cae FG |
83 | |
84 | #endif // SCRUB_HEADER_H_ |