From patchwork Mon May 25 22:08:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11569579 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5AAD090 for ; Mon, 25 May 2020 22:10:17 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 427EA2075F for ; Mon, 25 May 2020 22:10:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 427EA2075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 7DD9C2474B5; Mon, 25 May 2020 15:09:32 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 629FC2482F2 for ; Mon, 25 May 2020 15:08:37 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 3A34910058C4; Mon, 25 May 2020 18:08:27 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 392E0498; Mon, 25 May 2020 18:08:27 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 25 May 2020 18:08:00 -0400 Message-Id: <1590444502-20533-24-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1590444502-20533-1-git-send-email-jsimmons@infradead.org> References: <1590444502-20533-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 23/45] lustre: obd: fix printing of client connection UUID X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Andreas Dilger The client connection UUID sent to the servers (ASCII format) was being truncated to only 16 bytes in size, like '595f3c6a-20ae-4' instead of a full UUID like '18ae0f9a-4b09-4599-8ced-0f2126eab425'. This was caused by using UUID_SIZE to limit the size of the "%pU" string printed to avoid overflowing the target buffer, but in fact UUID_SIZE is the size of the binary uuid_t (16 bytes) instead of the size of struct obd_uuid (40 bytes) where the ASCII version of the UUID is stored. Fix this to use sizeof(target) rather than an external constant, which is exactly why sizeof(target) should always be used. The usage in osd_scrub.c is not actually broken, but it is still better to use sizeof(target) to avoid future inconsistencies. Fixes: e991811757a4f ("lustre: obd: replace class_uuid with linux kernel version") WC-bug-id: https://jira.whamcloud.com/browse/LU-13499 Lustre-commit: 9abdf96e56e23 ("LU-13499 obd: fix printing of client connection UUID") Signed-off-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/38443 Reviewed-by: James Simmons Reviewed-by: Arshad Hussain Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/llite_lib.c | 2 +- fs/lustre/obdclass/obd_mount.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c index 83b95ce..da7604f 100644 --- a/fs/lustre/llite/llite_lib.c +++ b/fs/lustre/llite/llite_lib.c @@ -1046,7 +1046,7 @@ int ll_fill_super(struct super_block *sb) /* UUID handling */ generate_random_uuid(uuid.b); - snprintf(sbi->ll_sb_uuid.uuid, UUID_SIZE, "%pU", uuid.b); + snprintf(sbi->ll_sb_uuid.uuid, sizeof(sbi->ll_sb_uuid), "%pU", uuid.b); CDEBUG(D_CONFIG, "llite sb uuid: %s\n", sbi->ll_sb_uuid.uuid); diff --git a/fs/lustre/obdclass/obd_mount.c b/fs/lustre/obdclass/obd_mount.c index 84ce93b..13e6521 100644 --- a/fs/lustre/obdclass/obd_mount.c +++ b/fs/lustre/obdclass/obd_mount.c @@ -339,7 +339,7 @@ int lustre_start_mgc(struct super_block *sb) } generate_random_uuid(uuidc.b); - snprintf(uuid->uuid, UUID_SIZE, "%pU", uuidc.b); + snprintf(uuid->uuid, sizeof(*uuid), "%pU", uuidc.b); /* Start the MGC */ rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,