Skip to content

Commit edd96f9

Browse files
committed
include/unordered_{map,set}: remove, use std directly instead
This is only an alias for the `std` classes anyway. This effectively reverts commit 8e86720 which added these aliases, probably because C++11 was new and not all compilers supported it properly, but that was 12 years ago and we're onl C++20 meanwhile. Signed-off-by: Max Kellermann <[email protected]>
1 parent 4aa6ff9 commit edd96f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+167
-234
lines changed

doc/dev/network-encoding.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Lists are represented as an element count followed by that many elements.
136136
The size of the elements in the list are not necessarily uniform.
137137

138138
Lists are used to encode ``std::list``, ``std::vector``, ``std::deque``,
139-
``std::set`` and ``ceph::unordered_set``.
139+
``std::set`` and ``std::unordered_set``.
140140

141141
Blob
142142
----
@@ -179,8 +179,8 @@ Maps are a list of pairs.
179179
ceph_pair<K,V> entries[length];
180180
}
181181

182-
Maps are used to encode ``std::map``, ``std::multimap`` and
183-
``ceph::unordered_map``.
182+
Maps are used to encode ``std::map``, ``std::multimap``,
183+
``std::unordered_map`` and ``std::unordered_multimap``.
184184

185185
Complex Types
186186
=============

fusetrace/fusetrace_ll.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
#endif
3131
#include <time.h>
3232

33-
34-
#include "include/unordered_map.h"
3533
#include "include/hash_namespace.h"
3634

3735
#ifndef __LP64__
@@ -50,6 +48,7 @@ CEPH_HASH_NAMESPACE_END
5048
#include <fstream>
5149
#include <map>
5250
#include <set>
51+
#include <unordered_map>
5352
using namespace std;
5453

5554
#include "common/ceph_mutex.h"
@@ -87,7 +86,7 @@ struct Inode {
8786
};
8887

8988
Inode *root = 0;
90-
ceph::unordered_map<ino_t, Inode*> inode_map;
89+
std::unordered_map<ino_t, Inode*> inode_map;
9190

9291
bool make_inode_path(string &buf, Inode *in)
9392
{

src/client/Client.cc

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ void Client::dump_inode(Formatter *f, Inode *in, set<Inode*>& did, bool disconne
524524
did.insert(in);
525525
if (in->dir) {
526526
ldout(cct, 1) << " dir " << in->dir << " size " << in->dir->dentries.size() << dendl;
527-
for (ceph::unordered_map<string, Dentry*>::iterator it = in->dir->dentries.begin();
527+
for (auto it = in->dir->dentries.begin();
528528
it != in->dir->dentries.end();
529529
++it) {
530530
ldout(cct, 1) << " " << in->ino << " dn " << it->first << " " << it->second << " ref " << it->second->ref << dendl;
@@ -552,9 +552,7 @@ void Client::dump_cache(Formatter *f)
552552
dump_inode(f, root.get(), did, true);
553553

554554
// make a second pass to catch anything disconnected
555-
for (ceph::unordered_map<vinodeno_t, Inode*>::iterator it = inode_map.begin();
556-
it != inode_map.end();
557-
++it) {
555+
for (auto it = inode_map.begin(); it != inode_map.end(); ++it) {
558556
if (did.count(it->second))
559557
continue;
560558
dump_inode(f, it->second, did, true);
@@ -1876,7 +1874,7 @@ int Client::verify_reply_trace(int r, MetaSession *session,
18761874
bufferlist extra_bl;
18771875
inodeno_t created_ino;
18781876
bool got_created_ino = false;
1879-
ceph::unordered_map<vinodeno_t, Inode*>::iterator p;
1877+
std::unordered_map<vinodeno_t, Inode*>::iterator p;
18801878

18811879
extra_bl = reply->get_extra_bl();
18821880
if (extra_bl.length() >= 8) {
@@ -2858,9 +2856,7 @@ void Client::_handle_full_flag(int64_t pool)
28582856
// field with -ENOSPC as long as we're sure all the ops we cancelled were
28592857
// affecting this pool, and all the objectsets we're purging were also
28602858
// in this pool.
2861-
for (unordered_map<vinodeno_t,Inode*>::iterator i = inode_map.begin();
2862-
i != inode_map.end(); ++i)
2863-
{
2859+
for (auto i = inode_map.begin(); i != inode_map.end(); ++i) {
28642860
Inode *inode = i->second;
28652861
if (inode->oset.dirty_or_tx
28662862
&& (pool == -1 || inode->layout.pool_id == pool)) {
@@ -3178,10 +3174,8 @@ void Client::send_reconnect(MetaSession *session)
31783174
bool allow_multi = session->mds_features.test(CEPHFS_FEATURE_MULTI_RECONNECT);
31793175

31803176
// i have an open session.
3181-
ceph::unordered_set<inodeno_t> did_snaprealm;
3182-
for (ceph::unordered_map<vinodeno_t, Inode*>::iterator p = inode_map.begin();
3183-
p != inode_map.end();
3184-
++p) {
3177+
std::unordered_set<inodeno_t> did_snaprealm;
3178+
for (auto p = inode_map.begin(); p != inode_map.end(); ++p) {
31853179
Inode *in = p->second;
31863180
auto it = in->caps.find(mds);
31873181
if (it != in->caps.end()) {
@@ -4726,7 +4720,7 @@ void Client::_invalidate_kernel_dcache()
47264720

47274721
if (can_invalidate_dentries) {
47284722
if (dentry_invalidate_cb && root->dir) {
4729-
for (ceph::unordered_map<string, Dentry*>::iterator p = root->dir->dentries.begin();
4723+
for (auto p = root->dir->dentries.begin();
47304724
p != root->dir->dentries.end();
47314725
++p) {
47324726
if (p->second->inode)
@@ -10208,7 +10202,7 @@ int Client::_lookup_vino(vinodeno_t vino, const UserPerm& perms, Inode **inode)
1020810202

1020910203
int r = make_request(req, perms, NULL, NULL, rand() % mdsmap->get_num_in_mds());
1021010204
if (r == 0 && inode != NULL) {
10211-
unordered_map<vinodeno_t,Inode*>::iterator p = inode_map.find(vino);
10205+
auto p = inode_map.find(vino);
1021210206
ceph_assert(p != inode_map.end());
1021310207
*inode = p->second;
1021410208
_ll_get(*inode);
@@ -13244,7 +13238,7 @@ int Client::ll_lookup_vino(
1324413238
ldout(cct, 3) << __func__ << " " << vino << dendl;
1324513239

1324613240
// Check the cache first
13247-
unordered_map<vinodeno_t,Inode*>::iterator p = inode_map.find(vino);
13241+
auto p = inode_map.find(vino);
1324813242
if (p != inode_map.end()) {
1324913243
*inode = p->second;
1325013244
_ll_get(*inode);
@@ -13400,10 +13394,8 @@ void Client::_ll_drop_pins()
1340013394
{
1340113395
ldout(cct, 10) << __func__ << dendl;
1340213396
std::set<InodeRef> to_be_put; //this set will be deconstructed item by item when exit
13403-
ceph::unordered_map<vinodeno_t, Inode*>::iterator next;
13404-
for (ceph::unordered_map<vinodeno_t, Inode*>::iterator it = inode_map.begin();
13405-
it != inode_map.end();
13406-
it = next) {
13397+
std::unordered_map<vinodeno_t, Inode*>::iterator next;
13398+
for (auto it = inode_map.begin(); it != inode_map.end(); it = next) {
1340713399
Inode *in = it->second;
1340813400
next = it;
1340913401
++next;
@@ -13480,7 +13472,7 @@ Inode *Client::ll_get_inode(ino_t ino)
1348013472
std::scoped_lock lock(client_lock);
1348113473

1348213474
vinodeno_t vino = _map_faked_ino(ino);
13483-
unordered_map<vinodeno_t,Inode*>::iterator p = inode_map.find(vino);
13475+
auto p = inode_map.find(vino);
1348413476
if (p == inode_map.end())
1348513477
return NULL;
1348613478
Inode *in = p->second;
@@ -13499,7 +13491,7 @@ Inode *Client::ll_get_inode(vinodeno_t vino)
1349913491

1350013492
std::scoped_lock lock(client_lock);
1350113493

13502-
unordered_map<vinodeno_t,Inode*>::iterator p = inode_map.find(vino);
13494+
auto p = inode_map.find(vino);
1350313495
if (p == inode_map.end())
1350413496
return NULL;
1350513497
Inode *in = p->second;

src/client/Client.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include "include/interval_set.h"
2929
#include "include/lru.h"
3030
#include "include/types.h"
31-
#include "include/unordered_map.h"
32-
#include "include/unordered_set.h"
3331
#include "include/cephfs/metrics/Types.h"
3432
#include "mds/mdstypes.h"
3533
#include "mds/MDSAuthCaps.h"
@@ -50,6 +48,8 @@
5048
#include <set>
5149
#include <string>
5250
#include <thread>
51+
#include <unordered_map>
52+
#include <unordered_set>
5353

5454
using std::set;
5555
using std::map;
@@ -1876,16 +1876,16 @@ class Client : public Dispatcher, public md_config_obs_t {
18761876

18771877
// file handles, etc.
18781878
interval_set<int> free_fd_set; // unused fds
1879-
ceph::unordered_map<int, Fh*> fd_map;
1879+
std::unordered_map<int, Fh*> fd_map;
18801880
set<Fh*> ll_unclosed_fh_set;
1881-
ceph::unordered_set<dir_result_t*> opened_dirs;
1881+
std::unordered_set<dir_result_t*> opened_dirs;
18821882
uint64_t fd_gen = 1;
18831883

18841884
bool mount_aborted = false;
18851885
bool blocklisted = false;
18861886

1887-
ceph::unordered_map<vinodeno_t, Inode*> inode_map;
1888-
ceph::unordered_map<ino_t, vinodeno_t> faked_ino_map;
1887+
std::unordered_map<vinodeno_t, Inode*> inode_map;
1888+
std::unordered_map<ino_t, vinodeno_t> faked_ino_map;
18891889
interval_set<ino_t> free_faked_inos;
18901890
ino_t last_used_faked_ino;
18911891
ino_t last_used_faked_root;
@@ -1903,7 +1903,7 @@ class Client : public Dispatcher, public md_config_obs_t {
19031903

19041904
xlist<Inode*> delayed_list;
19051905
int num_flushing_caps = 0;
1906-
ceph::unordered_map<inodeno_t,SnapRealm*> snap_realms;
1906+
std::unordered_map<inodeno_t, SnapRealm*> snap_realms;
19071907
std::map<std::string, std::string> metadata;
19081908

19091909
ceph::coarse_mono_time last_auto_reconnect;

src/client/Dir.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define CEPH_CLIENT_DIR_H
33

44
#include <string>
5+
#include <unordered_map>
56
#include <vector>
67

78
class Dentry;
@@ -10,7 +11,7 @@ struct Inode;
1011
class Dir {
1112
public:
1213
Inode *parent_inode; // my inode
13-
ceph::unordered_map<std::string, Dentry*> dentries;
14+
std::unordered_map<std::string, Dentry*> dentries;
1415
unsigned num_null_dentries = 0;
1516

1617
std::vector<Dentry*> readdir_cache;

src/client/SyntheticClient.cc

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <iostream>
1818
#include <sstream>
19+
#include <unordered_map>
1920

2021

2122
#include "common/config.h"
@@ -1014,12 +1015,12 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
10141015

10151016
utime_t start = ceph_clock_now();
10161017

1017-
ceph::unordered_map<int64_t, int64_t> open_files;
1018-
ceph::unordered_map<int64_t, dir_result_t*> open_dirs;
1018+
std::unordered_map<int64_t, int64_t> open_files;
1019+
std::unordered_map<int64_t, dir_result_t*> open_dirs;
10191020

1020-
ceph::unordered_map<int64_t, Fh*> ll_files;
1021-
ceph::unordered_map<int64_t, dir_result_t*> ll_dirs;
1022-
ceph::unordered_map<uint64_t, int64_t> ll_inos;
1021+
std::unordered_map<int64_t, Fh*> ll_files;
1022+
std::unordered_map<int64_t, dir_result_t*> ll_dirs;
1023+
std::unordered_map<uint64_t, int64_t> ll_inos;
10231024

10241025
Inode *i1, *i2;
10251026

@@ -1514,27 +1515,19 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
15141515
dout(10) << "trace finished on line " << t.get_line() << dendl;
15151516

15161517
// close open files
1517-
for (ceph::unordered_map<int64_t, int64_t>::iterator fi = open_files.begin();
1518-
fi != open_files.end();
1519-
++fi) {
1518+
for (auto fi = open_files.begin(); fi != open_files.end(); ++fi) {
15201519
dout(1) << "leftover close " << fi->second << dendl;
15211520
if (fi->second > 0) client->close(fi->second);
15221521
}
1523-
for (ceph::unordered_map<int64_t, dir_result_t*>::iterator fi = open_dirs.begin();
1524-
fi != open_dirs.end();
1525-
++fi) {
1522+
for (auto fi = open_dirs.begin(); fi != open_dirs.end(); ++fi) {
15261523
dout(1) << "leftover closedir " << fi->second << dendl;
15271524
if (fi->second != 0) client->closedir(fi->second);
15281525
}
1529-
for (ceph::unordered_map<int64_t,Fh*>::iterator fi = ll_files.begin();
1530-
fi != ll_files.end();
1531-
++fi) {
1526+
for (auto fi = ll_files.begin(); fi != ll_files.end(); ++fi) {
15321527
dout(1) << "leftover ll_release " << fi->second << dendl;
15331528
if (fi->second) client->ll_release(fi->second);
15341529
}
1535-
for (ceph::unordered_map<int64_t,dir_result_t*>::iterator fi = ll_dirs.begin();
1536-
fi != ll_dirs.end();
1537-
++fi) {
1530+
for (auto fi = ll_dirs.begin(); fi != ll_dirs.end(); ++fi) {
15381531
dout(1) << "leftover ll_releasedir " << fi->second << dendl;
15391532
if (fi->second) client->ll_releasedir(fi->second);
15401533
}
@@ -1594,8 +1587,8 @@ int SyntheticClient::full_walk(string& basedir)
15941587
frag_info_t empty;
15951588
statq.push_back(empty);
15961589

1597-
ceph::unordered_map<inodeno_t, int> nlink;
1598-
ceph::unordered_map<inodeno_t, int> nlink_seen;
1590+
std::unordered_map<inodeno_t, int> nlink;
1591+
std::unordered_map<inodeno_t, int> nlink_seen;
15991592

16001593
UserPerm perms = client->pick_my_perms();
16011594
while (!dirq.empty()) {
@@ -1674,7 +1667,7 @@ int SyntheticClient::full_walk(string& basedir)
16741667
}
16751668
}
16761669

1677-
for (ceph::unordered_map<inodeno_t,int>::iterator p = nlink.begin(); p != nlink.end(); ++p) {
1670+
for (auto p = nlink.begin(); p != nlink.end(); ++p) {
16781671
if (nlink_seen[p->first] != p->second)
16791672
dout(0) << p->first << " nlink " << p->second << " != " << nlink_seen[p->first] << "seen" << dendl;
16801673
}

src/client/fuse_ll.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
#include "fuse_ll.h"
4747
#include <fuse_lowlevel.h>
4848

49+
#include <unordered_map>
50+
4951
#define dout_context g_ceph_context
5052

5153
#define FINO_INO(x) ((x) & ((1ull<<48)-1ull))
@@ -77,14 +79,14 @@
7779
* reserved for CEPH_SNAPDIR.
7880
*/
7981
struct ceph_fuse_fake_inode_stag {
80-
ceph::unordered_map<uint64_t,int> snap_stag_map; // <snapid, stagid>
81-
ceph::unordered_map<int, uint64_t> stag_snap_map; // <stagid, snapid>
82+
std::unordered_map<uint64_t, int> snap_stag_map; // <snapid, stagid>
83+
std::unordered_map<int, uint64_t> stag_snap_map; // <stagid, snapid>
8284
int last_stag = 1;
8385
};
8486

8587
using namespace std;
8688

87-
static const ceph::unordered_map<int,int> cephfs_errno_to_system_errno = {
89+
static const std::unordered_map<int, int> cephfs_errno_to_system_errno = {
8890
{EBLOCKLISTED, ESHUTDOWN},
8991
{EPERM, EPERM},
9092
{ESTALE, ESTALE},
@@ -182,7 +184,7 @@ class CephFuse::Handle {
182184
ceph::mutex stag_lock = ceph::make_mutex("fuse_ll.cc stag_lock");
183185

184186
// a map of <ceph ino, fino stag/snapid map>
185-
ceph::unordered_map<uint64_t, struct ceph_fuse_fake_inode_stag> g_fino_maps;
187+
std::unordered_map<uint64_t, struct ceph_fuse_fake_inode_stag> g_fino_maps;
186188

187189
pthread_key_t fuse_req_key = 0;
188190
void set_fuse_req(fuse_req_t);

src/cls/2pc_queue/cls_2pc_queue_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "include/types.h"
66

7+
#include <unordered_map>
8+
79
struct cls_2pc_reservation
810
{
911
using id_t = uint32_t;
@@ -50,7 +52,7 @@ struct cls_2pc_reservation
5052
};
5153
WRITE_CLASS_ENCODER(cls_2pc_reservation)
5254

53-
using cls_2pc_reservations = ceph::unordered_map<cls_2pc_reservation::id_t, cls_2pc_reservation>;
55+
using cls_2pc_reservations = std::unordered_map<cls_2pc_reservation::id_t, cls_2pc_reservation>;
5456

5557
struct cls_2pc_urgent_data
5658
{

src/common/LogEntry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <fmt/format.h>
1919

2020
#include "include/types.h" // for version_t
21-
#include "include/unordered_set.h"
2221
#include "include/utime.h"
2322
#include "include/utime_fmt.h"
2423
#include "msg/msg_fmt.h"
@@ -32,6 +31,7 @@
3231
#include <list>
3332
#include <map>
3433
#include <string>
34+
#include <unordered_set>
3535

3636
namespace ceph {
3737
class Formatter;
@@ -161,7 +161,7 @@ struct LogSummary {
161161
// channel -> [(seq#, entry), ...]
162162
std::map<std::string,std::list<std::pair<uint64_t,LogEntry>>> tail_by_channel;
163163
uint64_t seq = 0;
164-
ceph::unordered_set<LogEntryKey> keys;
164+
std::unordered_set<LogEntryKey> keys;
165165

166166
// ---- quincy+ ----
167167
LRUSet<LogEntryKey> recent_keys;

0 commit comments

Comments
 (0)