]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mds/PurgeQueue.h
aed66c94ebcdda1f9ae34c25dd96fa2eea383e01
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) 2015 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 PURGE_QUEUE_H_
16 #define PURGE_QUEUE_H_
18 #include "include/compact_set.h"
19 #include "mds/MDSMap.h"
20 #include "osdc/Journaler.h"
24 * Descriptor of the work associated with purging a file. We record
25 * the minimal amount of information from the inode such as the size
26 * and layout: all other un-needed inode metadata (times, permissions, etc)
32 enum Action
: uint8_t {
43 compact_set
<int64_t> old_pools
;
48 : action(NONE
), ino(0), size(0)
51 void encode(bufferlist
&bl
) const;
52 void decode(bufferlist::iterator
&p
);
54 WRITE_CLASS_ENCODER(PurgeItem
)
59 // How many items have been finished by PurgeQueue
67 * A persistent queue of PurgeItems. This class both writes and reads
68 * to the queue. There is one of these per MDS rank.
70 * Note that this class does not take a reference to MDSRank: we are
71 * independent of all the metadata structures and do not need to
72 * take mds_lock for anything.
78 const mds_rank_t rank
;
81 int64_t metadata_pool
;
83 // Don't use the MDSDaemon's Finisher and Timer, because this class
84 // operates outside of MDSDaemon::mds_lock
89 std::unique_ptr
<PerfCounters
> logger
;
95 // Map of Journaler offset to PurgeItem
96 std::map
<uint64_t, PurgeItem
> in_flight
;
98 // Throttled allowances
99 uint64_t ops_in_flight
;
101 // Dynamic op limit per MDS based on PG count
102 uint64_t max_purge_ops
;
104 uint32_t _calculate_ops(const PurgeItem
&item
) const;
108 // How many bytes were remaining when drain() was first called,
109 // used for indicating progress.
110 uint64_t drain_initial
;
112 // Has drain() ever been called on this instance?
115 // recover the journal write_pos (drop any partial written entry)
116 void _recover(Context
*completion
);
119 * @return true if we were in a position to try and consume something:
120 * does not mean we necessarily did.
124 // Do we currently have a flush timer event waiting?
125 Context
*delayed_flush
;
128 const PurgeItem
&item
,
130 void _execute_item_complete(
139 void create_logger();
141 // Write an empty queue, use this during MDS rank creation
142 void create(Context
*completion
);
144 // Read the Journaler header for an existing queue and start consuming
145 void open(Context
*completion
);
147 // Submit one entry to the work queue. Call back when it is persisted
148 // to the queue (there is no callback for when it is executed)
149 void push(const PurgeItem
&pi
, Context
*completion
);
151 // If the on-disk queue is empty and we are not currently processing
153 bool is_idle() const;
156 * Signal to the PurgeQueue that you would like it to hurry up and
157 * finish consuming everything in the queue. Provides progress
160 * @param progress: bytes consumed since we started draining
161 * @param progress_total: max bytes that were outstanding during purge
162 * @param in_flight_count: number of file purges currently in flight
164 * @returns true if drain is complete
168 uint64_t *progress_total
,
169 size_t *in_flight_count
);
171 void update_op_limit(const MDSMap
&mds_map
);
173 void handle_conf_change(const struct md_config_t
*conf
,
174 const std::set
<std::string
> &changed
,
175 const MDSMap
&mds_map
);
180 const int64_t metadata_pool_
,