]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mds/OpenFileTable.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2018 Red Hat
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.
15 #ifndef OPEN_FILE_TABLE_H
16 #define OPEN_FILE_TABLE_H
21 #include "MDSContext.h"
27 struct ObjectOperation
;
32 explicit OpenFileTable(MDSRank
*m
);
35 void add_inode(CInode
*in
);
36 void remove_inode(CInode
*in
);
37 void add_dirfrag(CDir
*dir
);
38 void remove_dirfrag(CDir
*dir
);
39 void notify_link(CInode
*in
);
40 void notify_unlink(CInode
*in
);
41 bool is_any_dirty() const { return !dirty_items
.empty(); }
43 void commit(MDSContext
*c
, uint64_t log_seq
, int op_prio
);
44 uint64_t get_committed_log_seq() const { return committed_log_seq
; }
45 bool is_any_committing() const { return num_pending_commit
> 0; }
47 void load(MDSContext
*c
);
48 bool is_loaded() const { return load_done
; }
49 void wait_for_load(MDSContext
*c
) {
50 ceph_assert(!load_done
);
51 waiting_for_load
.push_back(c
);
54 bool prefetch_inodes();
55 bool is_prefetched() const { return prefetch_state
== DONE
; }
56 void wait_for_prefetch(MDSContext
*c
) {
57 ceph_assert(!is_prefetched());
58 waiting_for_prefetch
.push_back(c
);
61 bool should_log_open(CInode
*in
);
63 void note_destroyed_inos(uint64_t seq
, const std::vector
<inodeno_t
>& inos
);
64 void trim_destroyed_inos(uint64_t seq
);
67 friend class C_IO_OFT_Recover
;
68 friend class C_IO_OFT_Load
;
69 friend class C_IO_OFT_Save
;
70 friend class C_IO_OFT_Journal
;
71 friend class C_OFT_OpenInoFinish
;
73 uint64_t MAX_ITEMS_PER_OBJ
= g_conf().get_val
<uint64_t>("osd_deep_scrub_large_omap_object_key_threshold");
74 static const unsigned MAX_OBJECTS
= 1024; // (1024 * osd_deep_scrub_large_omap_object_key_threshold) items at most
76 static const int DIRTY_NEW
= -1;
77 static const int DIRTY_UNDEF
= -2;
79 unsigned num_pending_commit
= 0;
80 void _encode_header(bufferlist
& bl
, int j_state
);
81 void _commit_finish(int r
, uint64_t log_seq
, MDSContext
*fin
);
82 void _journal_finish(int r
, uint64_t log_seq
, MDSContext
*fin
,
83 std::map
<unsigned, std::vector
<ObjectOperation
> >& ops
);
85 void get_ref(CInode
*in
, frag_t fg
=-1U);
86 void put_ref(CInode
*in
, frag_t fg
=-1U);
88 object_t
get_object_name(unsigned idx
) const;
90 void _reset_states() {
92 omap_num_items
.resize(0);
93 journal_state
= JOURNAL_NONE
;
94 loaded_journals
.clear();
95 loaded_anchor_map
.clear();
97 void _read_omap_values(const std::string
& key
, unsigned idx
, bool first
);
98 void _load_finish(int op_r
, int header_r
, int values_r
,
99 unsigned idx
, bool first
, bool more
,
100 bufferlist
&header_bl
,
101 std::map
<std::string
, bufferlist
> &values
);
102 void _recover_finish(int r
);
104 void _open_ino_finish(inodeno_t ino
, int r
);
105 void _prefetch_inodes();
106 void _prefetch_dirfrags();
108 void _get_ancestors(const Anchor
& parent
,
109 std::vector
<inode_backpointer_t
>& ancestors
,
110 mds_rank_t
& auth_hint
);
114 version_t omap_version
= 0;
116 unsigned omap_num_objs
= 0;
117 std::vector
<unsigned> omap_num_items
;
119 std::map
<inodeno_t
, OpenedAnchor
> anchor_map
;
121 std::map
<inodeno_t
, int> dirty_items
; // ino -> dirty state
123 uint64_t committed_log_seq
= 0;
124 uint64_t committing_log_seq
= 0;
131 int journal_state
= 0;
133 std::vector
<std::map
<std::string
, bufferlist
> > loaded_journals
;
134 std::map
<inodeno_t
, RecoveredAnchor
> loaded_anchor_map
;
135 MDSContext::vec waiting_for_load
;
136 bool load_done
= false;
144 unsigned prefetch_state
= 0;
145 unsigned num_opening_inodes
= 0;
146 MDSContext::vec waiting_for_prefetch
;
148 std::map
<uint64_t, std::vector
<inodeno_t
> > logseg_destroyed_inos
;
149 std::set
<inodeno_t
> destroyed_inos_set
;
151 std::unique_ptr
<PerfCounters
> logger
;