Merge pull request #41587 from cfsnyder/bugfix_47738

mgr/DaemonServer.cc: prevent mgr crashes caused by integer underflow that is triggered by large increases to pg_num/pgp_num

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2021-06-04 17:00:48 +08:00 committed by GitHub
commit 04fd0002a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2831,8 +2831,12 @@ void DaemonServer::adjust_pgs()
max_misplaced / 2.0);
unsigned estmax = std::max<unsigned>(
(double)p.get_pg_num() * room, 1u);
unsigned next_min = 0;
if (p.get_pgp_num() > estmax) {
next_min = p.get_pgp_num() - estmax;
}
next = std::clamp(target,
p.get_pgp_num() - estmax,
next_min,
p.get_pgp_num() + estmax);
dout(20) << " room " << room << " estmax " << estmax
<< " delta " << (target-p.get_pgp_num())