From 20621c761b787cd7b08a9d0abc0fc362f0bb0122 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 31 Mar 2023 17:38:38 -0600 Subject: [PATCH] LU-16655 scrub: change sf_uuid to guid_t Change the type of sf_uuid from uuid_t to guid_t. The sizes are identical, but the benefit is that guid_t is usable in userspace with the header, unlike uuid_t. Change the accessors to use the corresponding guid_*() functions, but no functional changes are needed. Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I3048cfee20a5e4ea2c0c2203d22eb76c1437577b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50496 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 22 ----------- libcfs/include/libcfs/linux/Makefile.am | 2 +- libcfs/include/libcfs/linux/linux-uuid.h | 63 -------------------------------- lustre/autoconf/lustre-core.m4 | 22 ----------- lustre/include/lustre_scrub.h | 10 ++--- lustre/llite/llite_lib.c | 2 +- lustre/obdclass/obd_mount.c | 9 +++-- lustre/obdclass/scrub.c | 14 +++---- lustre/osd-ldiskfs/osd_internal.h | 18 ++++----- lustre/osd-ldiskfs/osd_scrub.c | 8 +--- lustre/osd-zfs/osd_internal.h | 2 +- lustre/osd-zfs/osd_scrub.c | 2 +- 12 files changed, 32 insertions(+), 142 deletions(-) delete mode 100644 libcfs/include/libcfs/linux/linux-uuid.h diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index bb4325a..b3cadf9 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -1130,26 +1130,6 @@ AC_DEFUN([LIBCFS_CPUS_READ_LOCK], [ ]) # LIBCFS_CPUS_READ_LOCK # -# Kernel version 4.12-rc3 f9727a17db9bab71ddae91f74f11a8a2f9a0ece6 -# renamed uuid_be to uuid_t -# -AC_DEFUN([LIBCFS_SRC_UUID_T], [ - LB2_LINUX_TEST_SRC([uuid_t], [ - #include - ],[ - uuid_t uuid; - - memset(uuid.b, 0, 16); - ]) -]) -AC_DEFUN([LIBCFS_UUID_T], [ - AC_MSG_CHECKING([if 'uuid_t' exist]) - LB2_LINUX_TEST_RESULT([uuid_t], [ - AC_DEFINE(HAVE_UUID_T, 1, ['uuid_t' exist]) - ]) -]) # LIBCFS_UUID_T - -# # Kernel version 4.12-rc3 commit fd851a3cdc196bfc1d229b5f22369069af532bf8 # introduce processor.h # @@ -2367,7 +2347,6 @@ AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [ LIBCFS_SRC_RHT_BUCKET_VAR # 4.12 LIBCFS_SRC_CPUS_READ_LOCK - LIBCFS_SRC_UUID_T LIBCFS_SRC_WAIT_QUEUE_TASK_LIST_RENAME LIBCFS_SRC_WAIT_BIT_QUEUE_ENTRY_EXISTS LIBCFS_SRC_MEMALLOC_NORECLAIM @@ -2511,7 +2490,6 @@ AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [ LIBCFS_RHT_BUCKET_VAR # 4.12 LIBCFS_CPUS_READ_LOCK - LIBCFS_UUID_T LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME LIBCFS_WAIT_BIT_QUEUE_ENTRY_EXISTS LIBCFS_MEMALLOC_NORECLAIM diff --git a/libcfs/include/libcfs/linux/Makefile.am b/libcfs/include/libcfs/linux/Makefile.am index 1633093..3ecad9f 100644 --- a/libcfs/include/libcfs/linux/Makefile.am +++ b/libcfs/include/libcfs/linux/Makefile.am @@ -1,4 +1,4 @@ EXTRA_DIST = linux-misc.h linux-fs.h linux-mem.h linux-time.h linux-cpu.h \ - linux-list.h linux-hash.h linux-uuid.h linux-wait.h linux-net.h \ + linux-list.h linux-hash.h linux-wait.h linux-net.h \ generic-radix-tree.h glob.h refcount.h processor.h xarray.h \ linux-fortify-string.h diff --git a/libcfs/include/libcfs/linux/linux-uuid.h b/libcfs/include/libcfs/linux/linux-uuid.h deleted file mode 100644 index df877c0..0000000 --- a/libcfs/include/libcfs/linux/linux-uuid.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2017, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - */ - -#ifndef __LIBCFS_LINUX_UUID_H__ -#define __LIBCFS_LINUX_UUID_H__ - -#include - -#define UUID_SIZE 16 - -/* - * The original linux UUID code had uuid_be and uuid_le. - * Later uuid_le was changed to guid_t and uuid_be - * to uuid_t. See for details kernel commit: - * - * f9727a17db9bab71ddae91f74f11a8a2f9a0ece6 - */ -#ifndef HAVE_UUID_T -typedef struct { - __u8 b[UUID_SIZE]; -} uuid_t; - -static inline void uuid_copy(uuid_t *dst, uuid_t *src) -{ - memcpy(dst, src, sizeof(uuid_t)); -} - -static inline bool uuid_equal(const uuid_t *u1, const uuid_t *u2) -{ - return memcmp(u1, u2, sizeof(uuid_t)) == 0; -} - -#endif - -#endif /* __LIBCFS_LINUX_UUID_H__ */ diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f3bdf14..988ef71 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2354,26 +2354,6 @@ AC_DEFUN([LC_HAVE_GET_INODE_USAGE], [ ]) # LC_HAVE_GET_INODE_USAGE # -# Kernel version 4.12-rc3 85787090a21eb749d8b347eaf9ff1a455637473c -# changed struct super_block s_uuid into a proper uuid_t -# -AC_DEFUN([LC_SRC_SUPER_BLOCK_S_UUID], [ - LB2_LINUX_TEST_SRC([super_block_s_uuid], [ - #include - ],[ - struct super_block sb; - - uuid_parse(NULL, &sb.s_uuid); - ]) -]) -AC_DEFUN([LC_SUPER_BLOCK_S_UUID], [ - AC_MSG_CHECKING([if 'struct super_block' s_uuid is uuid_t]) - LB2_LINUX_TEST_RESULT([super_block_s_uuid], [ - AC_DEFINE(HAVE_S_UUID_AS_UUID_T, 1, ['s_uuid' is an uuid_t]) - ]) -]) # LC_SUPER_BLOCK_S_UUID - -# # LC_SUPER_SETUP_BDI_NAME # # Kernel version 4.12 commit 9594caf216dc0fe3e318b34af0127276db661241 @@ -3689,7 +3669,6 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ # 4.12 LC_SRC_CURRENT_TIME - LC_SRC_SUPER_BLOCK_S_UUID LC_SRC_SUPER_SETUP_BDI_NAME LC_SRC_BI_STATUS @@ -3931,7 +3910,6 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ # 4.12 LC_CURRENT_TIME - LC_SUPER_BLOCK_S_UUID LC_SUPER_SETUP_BDI_NAME LC_BI_STATUS diff --git a/lustre/include/lustre_scrub.h b/lustre/include/lustre_scrub.h index 2861256..02d531d 100644 --- a/lustre/include/lustre_scrub.h +++ b/lustre/include/lustre_scrub.h @@ -33,7 +33,7 @@ #ifndef _LUSTRE_SCRUB_H # define _LUSTRE_SCRUB_H -#include +#include #include #include @@ -187,7 +187,7 @@ enum auto_scrub { struct scrub_file { /* 128-bit uuid for volume. */ - uuid_t sf_uuid; + guid_t sf_uuid; /* See 'enum scrub_flags'. */ __u64 sf_flags; @@ -347,15 +347,15 @@ struct lustre_index_restore_unit { char liru_name[0]; }; -void scrub_file_init(struct lustre_scrub *scrub, uuid_t uuid); -void scrub_file_reset(struct lustre_scrub *scrub, uuid_t uuid, u64 flags); +void scrub_file_init(struct lustre_scrub *scrub, guid_t uuid); +void scrub_file_reset(struct lustre_scrub *scrub, guid_t uuid, u64 flags); int scrub_file_load(const struct lu_env *env, struct lustre_scrub *scrub); int scrub_file_store(const struct lu_env *env, struct lustre_scrub *scrub); bool scrub_needs_check(struct lustre_scrub *scrub, const struct lu_fid *fid, u64 index); int scrub_checkpoint(const struct lu_env *env, struct lustre_scrub *scrub); int scrub_thread_prep(const struct lu_env *env, struct lustre_scrub *scrub, - uuid_t uuid, u64 start); + guid_t uuid, u64 start); int scrub_thread_post(const struct lu_env *env, struct lustre_scrub *scrub, int result); int scrub_start(int (*threadfn)(void *data), struct lustre_scrub *scrub, diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 4ed4fec..492a93f 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 95f06e7..04ddbc5 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -40,15 +40,16 @@ #define D_MOUNT (D_SUPER|D_CONFIG/*|D_WARNING */) #define PRINT_CMD CDEBUG -#include -#include #include -#include +#include #include + +#include +#include +#include #include #include #include -#include /**************** config llog ********************/ diff --git a/lustre/obdclass/scrub.c b/lustre/obdclass/scrub.c index 6b5fac9..dadeb12 100644 --- a/lustre/obdclass/scrub.c +++ b/lustre/obdclass/scrub.c @@ -47,7 +47,7 @@ static inline struct dt_device *scrub_obj2dev(struct dt_object *obj) static void scrub_file_to_cpu(struct scrub_file *des, struct scrub_file *src) { - uuid_copy(&des->sf_uuid, &src->sf_uuid); + guid_copy(&des->sf_uuid, &src->sf_uuid); des->sf_flags = le64_to_cpu(src->sf_flags); des->sf_magic = le32_to_cpu(src->sf_magic); des->sf_status = le16_to_cpu(src->sf_status); @@ -81,7 +81,7 @@ static void scrub_file_to_cpu(struct scrub_file *des, struct scrub_file *src) static void scrub_file_to_le(struct scrub_file *des, struct scrub_file *src) { - uuid_copy(&des->sf_uuid, &src->sf_uuid); + guid_copy(&des->sf_uuid, &src->sf_uuid); des->sf_flags = cpu_to_le64(src->sf_flags); des->sf_magic = cpu_to_le32(src->sf_magic); des->sf_status = cpu_to_le16(src->sf_status); @@ -113,18 +113,18 @@ static void scrub_file_to_le(struct scrub_file *des, struct scrub_file *src) memcpy(des->sf_oi_bitmap, src->sf_oi_bitmap, SCRUB_OI_BITMAP_SIZE); } -void scrub_file_init(struct lustre_scrub *scrub, uuid_t uuid) +void scrub_file_init(struct lustre_scrub *scrub, guid_t uuid) { struct scrub_file *sf = &scrub->os_file; memset(sf, 0, sizeof(*sf)); - uuid_copy(&sf->sf_uuid, &uuid); + guid_copy(&sf->sf_uuid, &uuid); sf->sf_magic = SCRUB_MAGIC_V2; sf->sf_status = SS_INIT; } EXPORT_SYMBOL(scrub_file_init); -void scrub_file_reset(struct lustre_scrub *scrub, uuid_t uuid, u64 flags) +void scrub_file_reset(struct lustre_scrub *scrub, guid_t uuid, u64 flags) { struct scrub_file *sf = &scrub->os_file; @@ -132,7 +132,7 @@ void scrub_file_reset(struct lustre_scrub *scrub, uuid_t uuid, u64 flags) "%#llx, add flags = %#llx\n", scrub->os_name, sf->sf_flags, flags); - uuid_copy(&sf->sf_uuid, &uuid); + guid_copy(&sf->sf_uuid, &uuid); sf->sf_magic = SCRUB_MAGIC_V2; sf->sf_status = SS_INIT; sf->sf_flags |= flags; @@ -298,7 +298,7 @@ int scrub_checkpoint(const struct lu_env *env, struct lustre_scrub *scrub) EXPORT_SYMBOL(scrub_checkpoint); int scrub_thread_prep(const struct lu_env *env, struct lustre_scrub *scrub, - uuid_t uuid, u64 start) + guid_t uuid, u64 start) { struct scrub_file *sf = &scrub->os_file; u32 flags = scrub->os_start_flags; diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index 1b0bfb6..e694e7b 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -323,21 +323,21 @@ struct osd_device { atomic_t od_r_in_flight; atomic_t od_w_in_flight; - struct mutex od_otable_mutex; - struct osd_otable_it *od_otable_it; - struct osd_scrub od_scrub; - struct list_head od_ios_list; + struct mutex od_otable_mutex; + struct osd_otable_it *od_otable_it; + struct osd_scrub od_scrub; + struct list_head od_ios_list; /* service name associated with the osd device */ - char od_svname[MAX_OBD_NAME]; - char od_mntdev[MAX_OBD_NAME]; - uuid_t od_uuid; + char od_svname[MAX_OBD_NAME]; + char od_mntdev[MAX_OBD_NAME]; + guid_t od_uuid; /* quota slave instance for inode */ - struct qsd_instance *od_quota_slave_md; + struct qsd_instance *od_quota_slave_md; /* quota slave instance for block */ - struct qsd_instance *od_quota_slave_dt; + struct qsd_instance *od_quota_slave_dt; /* osd seq instance */ struct lu_client_seq *od_cl_seq; diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 0b7a885..cf1b429 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -2654,11 +2654,7 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev, if (IS_ERR_OR_NULL(obj)) RETURN(obj ? PTR_ERR(obj) : -ENOENT); -#ifndef HAVE_S_UUID_AS_UUID_T - memcpy(dev->od_uuid.b, sb->s_uuid, sizeof(dev->od_uuid)); -#else - uuid_copy(&dev->od_uuid, &sb->s_uuid); -#endif + guid_copy(&dev->od_uuid, (guid_t *)&sb->s_uuid); scrub->os_obj = obj; rc = scrub_file_load(env, scrub); if (rc == -ENOENT || rc == -EFAULT) { @@ -2681,7 +2677,7 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev, } else if (rc < 0) { GOTO(cleanup_obj, rc); } else { - if (!uuid_equal(&sf->sf_uuid, &dev->od_uuid)) { + if (!guid_equal(&sf->sf_uuid, &dev->od_uuid)) { CDEBUG(D_LFSCK, "%s: UUID has been changed from %pU to %pU\n", osd_dev2name(dev), &sf->sf_uuid, &dev->od_uuid); diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index 4e20832..23a63e4 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -364,7 +364,7 @@ struct osd_device { enum lustre_index_backup_policy od_index_backup_policy; char od_mntdev[128]; char od_svname[128]; - uuid_t od_uuid; + guid_t od_uuid; int od_connects; int od_index; diff --git a/lustre/osd-zfs/osd_scrub.c b/lustre/osd-zfs/osd_scrub.c index d4dbd61..2ce5992 100644 --- a/lustre/osd-zfs/osd_scrub.c +++ b/lustre/osd-zfs/osd_scrub.c @@ -1369,7 +1369,7 @@ int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev, } else if (rc < 0) { GOTO(cleanup_obj, rc); } else { - if (!uuid_equal(&sf->sf_uuid, &dev->od_uuid)) { + if (!guid_equal(&sf->sf_uuid, &dev->od_uuid)) { CDEBUG(D_LFSCK, "%s: UUID has been changed from %pU to %pU\n", osd_name(dev), &sf->sf_uuid, &dev->od_uuid); -- 1.8.3.1