From: Michal Skalski Date: Wed, 29 Jan 2020 00:29:58 +0000 (+0100) Subject: OSD: Allow 64-char hostname to be added as the "host" in CRUSH X-Git-Tag: v14.2.8~25^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7b595aa65f6d45086055d3fbd1d6d6b4dfacc17d;p=ceph.git OSD: Allow 64-char hostname to be added as the "host" in CRUSH On Linux system it is possible to set 64 character length hostname when HOST_NAME_MAX is set to 64. It means that if we execute gethostname function we should expect HOST_NAME_MAX characters + 1 for null character ending hostname string as described here: http://man7.org/linux/man-pages/man2/sethostname.2.html With the current code on host with 64 long hostname osd during start updates crush map with host=unknown_host. Signed-off-by: Michal Skalski (cherry picked from commit 5201048bbb16d6b4833585b9998c9d0364aaeac4) --- diff --git a/src/crush/CrushLocation.cc b/src/crush/CrushLocation.cc index a73a739c785c6..2032bf71c98fe 100644 --- a/src/crush/CrushLocation.cc +++ b/src/crush/CrushLocation.cc @@ -105,7 +105,7 @@ int CrushLocation::init_on_startup() // start with a sane default char hostname[HOST_NAME_MAX + 1]; - int r = gethostname(hostname, sizeof(hostname)-1); + int r = gethostname(hostname, sizeof(hostname)); if (r < 0) strcpy(hostname, "unknown_host"); // use short hostname