Whamcloud - gitweb
LU-13499 obd: fix printing of client connection UUID 43/38443/2
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 1 May 2020 08:02:22 +0000 (02:02 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 14 May 2020 05:39:34 +0000 (05:39 +0000)
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: 604c266a175b7 ("LU-11803 obd: replace class_uuid with linux kernel version")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I05325646cd632a09997d6632a483909629ce7057
Reviewed-on: https://review.whamcloud.com/38443
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.super@gmail.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/llite_lib.c
lustre/obdclass/obd_mount.c
lustre/osd-ldiskfs/osd_scrub.c

index d2168de..41cf4aa 100644 (file)
@@ -1104,7 +1104,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);
 
index 5edc929..6616d49 100644 (file)
@@ -410,7 +410,7 @@ int lustre_start_mgc(struct super_block *sb)
                GOTO(out_free, rc = -ENOMEM);
 
        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,
index ed25083..7ad1f8d 100644 (file)
@@ -2623,7 +2623,7 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev)
                RETURN(obj ? PTR_ERR(obj) : -ENOENT);
 
 #ifndef HAVE_S_UUID_AS_UUID_T
-       memcpy(dev->od_uuid.b, sb->s_uuid, UUID_SIZE);
+       memcpy(dev->od_uuid.b, sb->s_uuid, sizeof(dev->od_uuid));
 #else
        uuid_copy(&dev->od_uuid, &sb->s_uuid);
 #endif