mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lv_type: simplier macro usage
Use more simple macros - as there is likely not going to happen any macro replacement - so use more effient structure layout.
This commit is contained in:
parent
429ab45a1c
commit
5b7e30da76
@ -64,7 +64,8 @@ static const struct lv_prop lv_props[LVP_COUNT + 1] = {
|
|||||||
/* create table of lv type names, e.g. linear and corresponding enum from lv_types.h */
|
/* create table of lv type names, e.g. linear and corresponding enum from lv_types.h */
|
||||||
|
|
||||||
static const struct lv_type lv_types[LVT_COUNT + 1] = {
|
static const struct lv_type lv_types[LVT_COUNT + 1] = {
|
||||||
#define lvt(a, b, c) { # a, a, b, c },
|
{ "" },
|
||||||
|
#define lvt(a) { # a, a ## _LVT },
|
||||||
#include "lv_types.h"
|
#include "lv_types.h"
|
||||||
#undef lvt
|
#undef lvt
|
||||||
};
|
};
|
||||||
|
@ -256,10 +256,8 @@ struct lv_prop {
|
|||||||
/* see global lv_types[] */
|
/* see global lv_types[] */
|
||||||
|
|
||||||
struct lv_type {
|
struct lv_type {
|
||||||
const char enum_name[30]; /* "foo_LVT" */
|
const char name[30]; /* "foo" */
|
||||||
uint16_t lvt_enum; /* foo_LVT */
|
uint16_t lvt_enum; /* foo_LVT */
|
||||||
const char name[32]; /* "foo" */
|
|
||||||
int (*fn) (struct cmd_context *cmd, struct logical_volume *lv); /* lv_is_foo() */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,9 +46,11 @@ enum {
|
|||||||
|
|
||||||
/* define enums for LV types, foo_LVT */
|
/* define enums for LV types, foo_LVT */
|
||||||
enum {
|
enum {
|
||||||
#define lvt(a, b, c) a ,
|
LVT_NONE,
|
||||||
|
#define lvt(a) a ## _LVT ,
|
||||||
#include "lv_types.h"
|
#include "lv_types.h"
|
||||||
#undef lvt
|
#undef lvt
|
||||||
|
LVT_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -1,39 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2024 Red Hat, Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is part of LVM2.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use,
|
||||||
|
* modify, copy, or redistribute it subject to the terms and conditions
|
||||||
|
* of the GNU Lesser General Public License v.2.1.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LV types used in command definitions. The type strings are used
|
* LV types used in command definitions. The type strings are used
|
||||||
* as LV suffixes, e.g. LV_type or LV_type1_type2.
|
* as LV suffixes, e.g. LV_type or LV_type1_type2.
|
||||||
*
|
*
|
||||||
* The final NULL arg can be replaced with lv_is_type() functions
|
* Update toollib.c:_lv_is_type() when adding new XXXXX_LVT test
|
||||||
* if the current lv_is_type #defines become functions and are
|
|
||||||
* moved to tools.h
|
|
||||||
*
|
|
||||||
* Until then, the lv_is_type() functions are called indirectly
|
|
||||||
* through _lv_is_type().
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lvt(LVT_NONE, "", NULL)
|
/* enum value 0 means none */
|
||||||
lvt(linear_LVT, "linear", NULL)
|
lvt(linear)
|
||||||
lvt(striped_LVT, "striped", NULL)
|
lvt(striped)
|
||||||
lvt(snapshot_LVT, "snapshot", NULL) /* lv_is_cow, lv_is_thick_snapshot */
|
lvt(snapshot) /* lv_is_cow, lv_is_thick_snapshot */
|
||||||
lvt(thin_LVT, "thin", NULL)
|
lvt(thin)
|
||||||
lvt(thinpool_LVT, "thinpool", NULL)
|
lvt(thinpool)
|
||||||
lvt(cache_LVT, "cache", NULL)
|
lvt(cache)
|
||||||
lvt(cachepool_LVT, "cachepool", NULL)
|
lvt(cachepool)
|
||||||
lvt(vdo_LVT, "vdo", NULL)
|
lvt(vdo)
|
||||||
lvt(vdopool_LVT, "vdopool", NULL)
|
lvt(vdopool)
|
||||||
lvt(vdopooldata_LVT, "vdopooldata", NULL)
|
lvt(vdopooldata)
|
||||||
lvt(mirror_LVT, "mirror", NULL)
|
lvt(mirror)
|
||||||
lvt(raid_LVT, "raid", NULL) /* any raid type */
|
lvt(raid) /* any raid type */
|
||||||
lvt(raid0_LVT, "raid0", NULL)
|
lvt(raid0)
|
||||||
lvt(raid1_LVT, "raid1", NULL)
|
lvt(raid1)
|
||||||
lvt(raid4_LVT, "raid4", NULL)
|
lvt(raid4)
|
||||||
lvt(raid5_LVT, "raid5", NULL)
|
lvt(raid5)
|
||||||
lvt(raid6_LVT, "raid6", NULL)
|
lvt(raid6)
|
||||||
lvt(raid10_LVT, "raid10", NULL)
|
lvt(raid10)
|
||||||
lvt(error_LVT, "error", NULL)
|
lvt(writecache)
|
||||||
lvt(zero_LVT, "zero", NULL)
|
lvt(integrity)
|
||||||
lvt(writecache_LVT, "writecache", NULL)
|
lvt(error)
|
||||||
lvt(integrity_LVT, "integrity", NULL)
|
lvt(zero)
|
||||||
lvt(LVT_COUNT, "", NULL)
|
|
||||||
|
|
||||||
|
@ -2933,10 +2933,7 @@ static int _lv_types_match(struct cmd_context *cmd, struct logical_volume *lv, u
|
|||||||
* in tools.h
|
* in tools.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!type->fn)
|
|
||||||
match = _lv_is_type(cmd, lv, lvt_enum);
|
match = _lv_is_type(cmd, lv, lvt_enum);
|
||||||
else
|
|
||||||
match = type->fn(cmd, lv);
|
|
||||||
|
|
||||||
if (match)
|
if (match)
|
||||||
found_a_match = 1;
|
found_a_match = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user