Whamcloud - gitweb
LU-16655 scrub: change sf_uuid to guid_t 96/50496/2
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 31 Mar 2023 23:38:38 +0000 (17:38 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 18 Apr 2023 03:40:05 +0000 (03:40 +0000)
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 <linux/uuid.h> 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 <adilger@whamcloud.com>
Change-Id: I3048cfee20a5e4ea2c0c2203d22eb76c1437577b
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50496
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
12 files changed:
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/Makefile.am
libcfs/include/libcfs/linux/linux-uuid.h [deleted file]
lustre/autoconf/lustre-core.m4
lustre/include/lustre_scrub.h
lustre/llite/llite_lib.c
lustre/obdclass/obd_mount.c
lustre/obdclass/scrub.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_scrub.c
lustre/osd-zfs/osd_internal.h
lustre/osd-zfs/osd_scrub.c

index bb4325a..b3cadf9 100644 (file)
@@ -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 <linux/uuid.h>
-       ],[
-               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
index 1633093..3ecad9f 100644 (file)
@@ -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 (file)
index df877c0..0000000
+++ /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 <linux/uuid.h>
-
-#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__ */
index f3bdf14..988ef71 100644 (file)
@@ -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 <linux/fs.h>
-       ],[
-               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
 
index 2861256..02d531d 100644 (file)
@@ -33,7 +33,7 @@
 #ifndef _LUSTRE_SCRUB_H
 # define _LUSTRE_SCRUB_H
 
-#include <libcfs/linux/linux-uuid.h>
+#include <linux/uuid.h>
 #include <dt_object.h>
 #include <lustre_net.h>
 
@@ -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,
index 4ed4fec..492a93f 100644 (file)
@@ -42,7 +42,7 @@
 #include <linux/time.h>
 #include <linux/file.h>
 #include <linux/types.h>
-#include <libcfs/linux/linux-uuid.h>
+#include <linux/uuid.h>
 #include <linux/version.h>
 #include <linux/mm.h>
 #include <linux/user_namespace.h>
index 95f06e7..04ddbc5 100644 (file)
 #define D_MOUNT (D_SUPER|D_CONFIG/*|D_WARNING */)
 #define PRINT_CMD CDEBUG
 
-#include <obd.h>
-#include <obd_class.h>
 #include <linux/random.h>
-#include <libcfs/linux/linux-uuid.h>
+#include <linux/uuid.h>
 #include <linux/version.h>
+
+#include <obd.h>
+#include <obd_class.h>
+#include <lustre_crypto.h>
 #include <lustre_log.h>
 #include <lustre_disk.h>
 #include <uapi/linux/lustre/lustre_param.h>
-#include <lustre_crypto.h>
 
 /**************** config llog ********************/
 
index 6b5fac9..dadeb12 100644 (file)
@@ -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;
index 1b0bfb6..e694e7b 100644 (file)
@@ -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;
index 0b7a885..cf1b429 100644 (file)
@@ -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);
index 4e20832..23a63e4 100644 (file)
@@ -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;
index d4dbd61..2ce5992 100644 (file)
@@ -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);