]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/ScrubHeader.h
import 15.2.0 Octopus source
[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 <string_view>
20
21 class CInode;
22
23 /**
24 * Externally input parameters for a scrub, associated with the root
25 * of where we are doing a recursive scrub
26 */
27 class ScrubHeader {
28 public:
29 ScrubHeader(std::string_view tag_, bool is_tag_internal_, bool force_,
30 bool recursive_, bool repair_, Formatter *f_)
31 : tag(tag_), is_tag_internal(is_tag_internal_), force(force_),
32 recursive(recursive_), repair(repair_), formatter(f_)
33 {
34 ceph_assert(formatter != nullptr);
35 }
36
37 // Set after construction because it won't be known until we've
38 // started resolving path and locking
39 void set_origin(CInode *origin_) { origin = origin_; }
40
41 bool get_recursive() const { return recursive; }
42 bool get_repair() const { return repair; }
43 bool get_force() const { return force; }
44 bool is_internal_tag() const { return is_tag_internal; }
45 CInode *get_origin() const { return origin; }
46 std::string_view get_tag() const { return tag; }
47 Formatter &get_formatter() const { return *formatter; }
48
49 bool get_repaired() const { return repaired; }
50 void set_repaired() { repaired = true; }
51
52 protected:
53 const std::string tag;
54 bool is_tag_internal;
55 const bool force;
56 const bool recursive;
57 const bool repair;
58 Formatter * const formatter;
59 CInode *origin = nullptr;
60
61 bool repaired = false; // May be set during scrub if repairs happened
62 };
63
64 typedef std::shared_ptr<ScrubHeader> ScrubHeaderRef;
65 typedef std::shared_ptr<const ScrubHeader> ScrubHeaderRefConst;
66
67 #endif // SCRUB_HEADER_H_
68