Whamcloud - gitweb
LU-7892 utils: removed deprecated create_iam.c 65/55265/4
authorMaximilian Dilger <mdilger@whamcloud.com>
Thu, 30 May 2024 16:18:48 +0000 (12:18 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 10 Jun 2024 06:14:23 +0000 (06:14 +0000)
Removed create_iam.c and all found references. The OI is now created
by osd-ldiskfs, so it is safe to remove create_iam.c

Signed-off-by: Max Dilger <mdilger@whamcloud.com>
Change-Id: Ibbc89ecfbfbebf6f61d93d4a784b509977ccb3c2
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55265
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/osd-ldiskfs/osd_iam_lfix.c
lustre/osd-ldiskfs/osd_iam_lvar.c
lustre/utils/create_iam.c [deleted file]

index 1070ce6..995b553 100644 (file)
@@ -5393,7 +5393,6 @@ LC_MDS_MAX_THREADS
 
 # lustre/utils/gss/gss_util.c
 # lustre/utils/llog_reader.c
-# lustre/utils/create_iam.c
 # lustre/utils/libiam.c
 AC_CHECK_HEADERS([netdb.h endian.h])
 
index c8ff819..02e410d 100644 (file)
  */
 
 enum {
-       IAM_LEAF_HEADER_MAGIC = 0x1976 /* This is duplicated in
-                                        * lustre/utils/create_iam.c */
+       IAM_LEAF_HEADER_MAGIC = 0x1976
 };
 
-/* This is duplicated in lustre/utils/create_iam.c */
 struct iam_leaf_head {
        __le16 ill_magic;
        __le16 ill_count;
@@ -542,7 +540,6 @@ static const struct iam_leaf_operations iam_lfix_leaf_ops = {
  */
 
 enum {
-       /* This is duplicated in lustre/utils/create_iam.c */
        /*
         * Then shalt thou see the dew-BEDABBLED wretch
         * Turn, and return, indenting with the way;
@@ -554,7 +551,6 @@ enum {
        IAM_LFIX_ROOT_MAGIC = 0xbedabb1edULL /* d01efull */
 };
 
-/* This is duplicated in lustre/utils/create_iam.c */
 struct iam_lfix_root {
        __le64  ilr_magic;
        __le16  ilr_keysize;
index cff6e63..38bdf99 100644 (file)
  */
 
 enum {
-       /* This is duplicated in lustre/utils/create_iam.c */
        IAM_LVAR_LEAF_MAGIC = 0x1973
 };
 
-/* This is duplicated in lustre/utils/create_iam.c */
 struct lvar_leaf_header {
        __le16 vlh_magic; /* magic number IAM_LVAR_LEAF_MAGIC */
        __le16 vlh_used;  /* used bytes, including header */
@@ -63,10 +61,8 @@ struct lvar_leaf_header {
  * Entries are ordered in key order.
  */
 
-/* This is duplicated in lustre/utils/create_iam.c */
 typedef u32 lvar_hash_t;
 
-/* This is duplicated in lustre/utils/create_iam.c */
 struct lvar_leaf_entry {
        __le32 vle_hash;
        __le16 vle_keysize;
@@ -102,7 +98,6 @@ static inline int e_keysize(const struct lvar_leaf_entry *ent)
        return le16_to_cpu(ent->vle_keysize);
 }
 
-/* This is duplicated in lustre/utils/create_iam.c */
 enum {
        LVAR_PAD   = 4,
        LVAR_ROUND = LVAR_PAD - 1
@@ -771,12 +766,10 @@ static const struct iam_leaf_operations lvar_leaf_ops = {
  */
 
 enum {
-       /* This is duplicated in lustre/utils/create_iam.c */
        /* egrep -i '^o?x?[olabcdef]*$' /usr/share/dict/words */
        IAM_LVAR_ROOT_MAGIC = 0xb01dface
 };
 
-/* This is duplicated in lustre/utils/create_iam.c */
 struct lvar_root {
        __le32 vr_magic;
        __le16 vr_recsize;
diff --git a/lustre/utils/create_iam.c b/lustre/utils/create_iam.c
deleted file mode 100644 (file)
index c0fa50f..0000000
+++ /dev/null
@@ -1,368 +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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- *
- * lustre/utils/create_iam.c
- *
- * User-level tool for creation of iam files.
- *
- * Author: Wang Di <wangdi@clusterfs.com>
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <endian.h>
-#include <errno.h>
-
-#include <sys/types.h>
-
-void usage(void)
-{
-       printf(
-              "usage: create_iam [-h] [-k <keysize>] [-r recsize] [-b <blocksize] [-p <ptrsize>] [-v]\n");
-}
-
-enum {
-       IAM_LFIX_ROOT_MAGIC = 0xbedabb1edULL,
-       IAM_LVAR_ROOT_MAGIC = 0xb01dface
-};
-
-struct iam_lfix_root {
-       u_int64_t  ilr_magic;
-       u_int16_t  ilr_keysize;
-       u_int16_t  ilr_recsize;
-       u_int16_t  ilr_ptrsize;
-       u_int16_t  ilr_indirect_levels;
-};
-
-enum {
-       IAM_LEAF_HEADER_MAGIC = 0x1976,
-       IAM_LVAR_LEAF_MAGIC   = 0x1973
-};
-
-struct iam_leaf_head {
-       u_int16_t ill_magic;
-       u_int16_t ill_count;
-};
-
-struct dx_countlimit {
-       u_int16_t limit;
-       u_int16_t count;
-};
-
-typedef __u32 lvar_hash_t;
-
-struct lvar_leaf_header {
-       u_int16_t vlh_magic; /* magic number IAM_LVAR_LEAF_MAGIC */
-       u_int16_t vlh_used;  /* used bytes, including header */
-};
-
-struct lvar_root {
-       u_int32_t vr_magic;
-       u_int16_t vr_recsize;
-       u_int16_t vr_ptrsize;
-       u_int8_t  vr_indirect_levels;
-       u_int8_t  vr_padding0;
-       u_int16_t vr_padding1;
-};
-
-struct lvar_leaf_entry {
-       u_int32_t vle_hash;
-       u_int16_t vle_keysize;
-       u_int8_t  vle_key[0];
-};
-
-enum {
-       LVAR_PAD   = 4,
-       LVAR_ROUND = LVAR_PAD - 1
-};
-
-/**
- * Stores \a val at \a dst, where the latter is possibly unaligned. Uses
- * memcpy(). This macro is needed to avoid dependency of user level tools on
- * the kernel headers.
- */
-#define STORE_UNALIGNED(val, dst)                      \
-({                                                     \
-       typeof(val) __val = (val);                      \
-                                                       \
-       BUILD_BUG_ON(sizeof(val) != sizeof(*(dst)));    \
-       memcpy(dst, &__val, sizeof(*(dst)));            \
-})
-
-static void lfix_root(void *buf,
-                     int blocksize, int keysize, int ptrsize, int recsize)
-{
-       struct iam_lfix_root *root;
-       struct dx_countlimit *limit;
-       void *entry;
-
-       root = buf;
-       *root = (typeof(*root)) {
-               .ilr_magic           = cpu_to_le64(IAM_LFIX_ROOT_MAGIC),
-               .ilr_keysize         = cpu_to_le16(keysize),
-               .ilr_recsize         = cpu_to_le16(recsize),
-               .ilr_ptrsize         = cpu_to_le16(ptrsize),
-               .ilr_indirect_levels = 0
-       };
-
-       limit = (void *)(root + 1);
-       *limit = (typeof(*limit)){
-               /*
-                * limit itself + one pointer to the leaf.
-                */
-               .count = cpu_to_le16(2),
-               .limit = (blocksize - sizeof(*root)) / (keysize + ptrsize)
-       };
-
-       entry = root + 1;
-       /*
-        * Skip over @limit.
-        */
-       entry += keysize + ptrsize;
-
-       /*
-        * Entry format is <key> followed by <ptr>. In the minimal tree
-        * consisting of a root and single node, <key> is a minimal possible
-        * key.
-        *
-        * XXX: this key is hard-coded to be a sequence of 0's.
-        */
-       entry += keysize;
-       /* now @entry points to <ptr> */
-       if (ptrsize == 4)
-               STORE_UNALIGNED(cpu_to_le32(1), (u_int32_t *)entry);
-       else
-               STORE_UNALIGNED(cpu_to_le64(1), (u_int64_t *)entry);
-}
-
-static void lfix_leaf(void *buf,
-                     int blocksize, int keysize, int ptrsize, int recsize)
-{
-       struct iam_leaf_head *head;
-
-       /* form leaf */
-       head = buf;
-       *head = (struct iam_leaf_head) {
-               .ill_magic = cpu_to_le16(IAM_LEAF_HEADER_MAGIC),
-               /*
-                * Leaf contains an entry with the smallest possible key
-                * (created by zeroing).
-                */
-               .ill_count = cpu_to_le16(1),
-       };
-}
-
-static void lvar_root(void *buf,
-                     int blocksize, int keysize, int ptrsize, int recsize)
-{
-       struct lvar_root *root;
-       struct dx_countlimit *limit;
-       void *entry;
-       int isize;
-
-       isize = sizeof(lvar_hash_t) + ptrsize;
-       root = buf;
-       *root = (typeof(*root)) {
-               .vr_magic            = cpu_to_le32(IAM_LVAR_ROOT_MAGIC),
-               .vr_recsize          = cpu_to_le16(recsize),
-               .vr_ptrsize          = cpu_to_le16(ptrsize),
-               .vr_indirect_levels  = 0
-       };
-
-       limit = (void *)(root + 1);
-       *limit = (typeof(*limit)){
-               /*
-                * limit itself + one pointer to the leaf.
-                */
-               .count = cpu_to_le16(2),
-               .limit = (blocksize - sizeof(*root)) / isize
-       };
-
-       entry = root + 1;
-       /*
-        * Skip over @limit.
-        */
-       entry += isize;
-
-       /*
-        * Entry format is <key> followed by <ptr>. In the minimal tree
-        * consisting of a root and single node, <key> is a minimal possible
-        * key.
-        *
-        * XXX: this key is hard-coded to be a sequence of 0's.
-        */
-       entry += sizeof(lvar_hash_t);
-       /* now @entry points to <ptr> */
-       if (ptrsize == 4)
-               STORE_UNALIGNED(cpu_to_le32(1), (u_int32_t *)entry);
-       else
-               STORE_UNALIGNED(cpu_to_le64(1), (u_int64_t *)entry);
-}
-
-static int lvar_esize(int namelen, int recsize)
-{
-       return (offsetof(struct lvar_leaf_entry, vle_key) +
-               namelen + recsize + LVAR_ROUND) & ~LVAR_ROUND;
-}
-
-static void lvar_leaf(void *buf,
-                     int blocksize, int keysize, int ptrsize, int recsize)
-{
-       struct lvar_leaf_header *head;
-
-       /* form leaf */
-       head = buf;
-       *head = (typeof(*head)) {
-               .vlh_magic = cpu_to_le16(IAM_LVAR_LEAF_MAGIC),
-               .vlh_used  = cpu_to_le16(sizeof(*head) + lvar_esize(0, recsize))
-       };
-}
-
-enum iam_fmt_t {
-       FMT_LFIX,
-       FMT_LVAR
-};
-
-int main(int argc, char **argv)
-{
-       int rc;
-       int opt;
-       int blocksize = 4096;
-       int keysize   = 8;
-       int recsize   = 8;
-       int ptrsize   = 4;
-       int verbose   = 0;
-       void *buf;
-       char *fmtstr = "lfix";
-       enum iam_fmt_t fmt;
-
-       do {
-               opt = getopt(argc, argv, "hb:k:r:p:vf:");
-               switch (opt) {
-               case 'v':
-                       verbose++;
-               case -1:
-                       break;
-               case 'b':
-                       blocksize = atoi(optarg);
-                       break;
-               case 'k':
-                       keysize = atoi(optarg);
-                       break;
-               case 'r':
-                       recsize = atoi(optarg);
-                       break;
-               case 'p':
-                       ptrsize = atoi(optarg);
-                       break;
-               case 'f':
-                       fmtstr = optarg;
-                       break;
-               case '?':
-               default:
-                       fprintf(stderr, "Unable to parse options.");
-               case 'h':
-                       usage();
-                       return 0;
-               }
-       } while (opt != -1);
-
-       if (ptrsize != 4 && ptrsize != 8) {
-               fprintf(stderr,
-                       "Invalid ptrsize (%i). Only 4 and 8 are supported\n",
-                       ptrsize);
-               return 1;
-       }
-
-       if (blocksize <= 100 || keysize < 1 || recsize < 0) {
-               fprintf(stderr, "Too small record, key or block block\n");
-               return 1;
-       }
-
-       if (keysize + recsize + sizeof(struct iam_leaf_head) > blocksize / 3) {
-               fprintf(stderr, "Too large (record, key) or too small block\n");
-               return 1;
-       }
-
-       if (!strcmp(fmtstr, "lfix")) {
-               fmt = FMT_LFIX;
-       } else if (!strcmp(fmtstr, "lvar")) {
-               fmt = FMT_LVAR;
-       } else {
-               fprintf(stderr, "Wrong format `%s'\n", fmtstr);
-               return 1;
-       }
-
-       if (verbose > 0) {
-               fprintf(stderr,
-                       "fmt: %s, key: %i, rec: %i, ptr: %i, block: %i\n",
-                       fmtstr, keysize, recsize, ptrsize, blocksize);
-       }
-       buf = malloc(blocksize);
-       if (!buf) {
-               fprintf(stderr, "Unable to allocate %i bytes\n", blocksize);
-               return 1;
-       }
-
-       memset(buf, 0, blocksize);
-
-       if (fmt == FMT_LFIX)
-               lfix_root(buf, blocksize, keysize, ptrsize, recsize);
-       else
-               lvar_root(buf, blocksize, keysize, ptrsize, recsize);
-
-       rc = write(1, buf, blocksize);
-       if (rc != blocksize) {
-               fprintf(stderr, "Unable to write root node: %m (%i)\n", rc);
-               free(buf);
-               return 1;
-       }
-
-       /* form leaf */
-       memset(buf, 0, blocksize);
-
-       if (fmt == FMT_LFIX)
-               lfix_leaf(buf, blocksize, keysize, ptrsize, recsize);
-       else
-               lvar_leaf(buf, blocksize, keysize, ptrsize, recsize);
-
-       rc = write(1, buf, blocksize);
-       free(buf);
-       if (rc != blocksize) {
-               fprintf(stderr, "Unable to write leaf node: %m (%i)\n", rc);
-               return 1;
-       }
-       if (verbose > 0)
-               fprintf(stderr,
-                       "Don't forget to umount/mount before accessing iam from the kernel!\n");
-       return 0;
-}