From c582580b114e6e9343258c232aefc6db3c87ba18 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 8 Mar 2021 14:44:14 +0800 Subject: [PATCH] common/lockdeps: use vector to allocate follows and follows_bt on heap this allows us to increase MAX_LOCKS without being limited by the size of .bss segment. as cephfs plans to use a large number of locks for finer grained inode lock. Signed-off-by: Kefu Chai --- src/common/lockdep.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc index c5223590097da..687d99d4953ab 100644 --- a/src/common/lockdep.cc +++ b/src/common/lockdep.cc @@ -41,7 +41,7 @@ static std::map lock_refs; static std::bitset free_ids; // bit set = free static ceph::unordered_map > held; static std::vector> follows(MAX_LOCKS); // follows[a][b] means b taken after a -static ceph::BackTrace *follows_bt[MAX_LOCKS][MAX_LOCKS]; +static std::vector> follows_bt(MAX_LOCKS); unsigned current_maxid; int last_freed_id = -1; static bool free_ids_inited; @@ -94,10 +94,10 @@ void lockdep_unregister_ceph_context(CephContext *cct) held.clear(); lock_names.clear(); lock_ids.clear(); - // FIPS zeroization audit 20191115: these memsets are not security related. std::for_each(follows.begin(), std::next(follows.begin(), current_maxid), [](auto& follow) { follow.reset(); }); - memset((void*)&follows_bt[0][0], 0, sizeof(ceph::BackTrace*) * current_maxid * MAX_LOCKS); + std::for_each(follows_bt.begin(), std::next(follows_bt.begin(), current_maxid), + [](auto& follow_bt) { follow_bt = {}; }); } pthread_mutex_unlock(&lockdep_mutex); } -- 2.39.5