mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Better structure layout for device_info
Save some relocation entries and use directly char[]. Since we do not need yes more then 127 partitions per device, use just int8_t. Move lvm_type_filter_destroy into local static function.
This commit is contained in:
parent
78d8e56a8e
commit
0d3ce181e1
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.96 -
|
Version 2.02.96 -
|
||||||
================================
|
================================
|
||||||
|
Better structure layout for device_info in dev_subsystem_name().
|
||||||
Change message severity for creation of VG over uninitialised devices.
|
Change message severity for creation of VG over uninitialised devices.
|
||||||
Fix error path for failing toolcontext creation.
|
Fix error path for failing toolcontext creation.
|
||||||
Fix warn msg for thin pool chunk size and update man for chunksize (2.02.89).
|
Fix warn msg for thin pool chunk size and update man for chunksize (2.02.89).
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
struct dev_filter {
|
struct dev_filter {
|
||||||
int (*passes_filter) (struct dev_filter * f, struct device * dev);
|
int (*passes_filter) (struct dev_filter * f, struct device * dev);
|
||||||
void (*destroy) (struct dev_filter * f);
|
void (*destroy) (struct dev_filter * f);
|
||||||
unsigned use_count;
|
|
||||||
void *private;
|
void *private;
|
||||||
|
unsigned use_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||||
* Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
|
* Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* This file is part of LVM2.
|
* This file is part of LVM2.
|
||||||
*
|
*
|
||||||
@ -36,8 +36,8 @@ static struct {
|
|||||||
} _partitions[NUMBER_OF_MAJORS];
|
} _partitions[NUMBER_OF_MAJORS];
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char name[15];
|
||||||
const int max_partitions;
|
const int8_t max_partitions;
|
||||||
} device_info_t;
|
} device_info_t;
|
||||||
|
|
||||||
static int _md_major = -1;
|
static int _md_major = -1;
|
||||||
@ -107,7 +107,7 @@ const char *dev_subsystem_name(const struct device *dev)
|
|||||||
*
|
*
|
||||||
* The list can be supplemented with devices/types in the config file.
|
* The list can be supplemented with devices/types in the config file.
|
||||||
*/
|
*/
|
||||||
static const device_info_t device_info[] = {
|
static const device_info_t _device_info[] = {
|
||||||
{"ide", 64}, /* IDE disk */
|
{"ide", 64}, /* IDE disk */
|
||||||
{"sd", 16}, /* SCSI disk */
|
{"sd", 16}, /* SCSI disk */
|
||||||
{"md", 1}, /* Multiple Disk driver (SoftRAID) */
|
{"md", 1}, /* Multiple Disk driver (SoftRAID) */
|
||||||
@ -136,7 +136,7 @@ static const device_info_t device_info[] = {
|
|||||||
{"mmc", 16}, /* MMC block device */
|
{"mmc", 16}, /* MMC block device */
|
||||||
{"blkext", 1}, /* Extended device partitions */
|
{"blkext", 1}, /* Extended device partitions */
|
||||||
{"fio", 16}, /* Fusion */
|
{"fio", 16}, /* Fusion */
|
||||||
{NULL, 0}
|
{"", 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int _passes_lvm_type_device_filter(struct dev_filter *f __attribute__((unused)),
|
static int _passes_lvm_type_device_filter(struct dev_filter *f __attribute__((unused)),
|
||||||
@ -220,7 +220,7 @@ static int _scan_proc_dev(const char *proc, const struct dm_config_node *cn)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(line, 80, pd) != NULL) {
|
while (fgets(line, sizeof(line), pd) != NULL) {
|
||||||
i = 0;
|
i = 0;
|
||||||
while (line[i] == ' ')
|
while (line[i] == ' ')
|
||||||
i++;
|
i++;
|
||||||
@ -269,13 +269,13 @@ static int _scan_proc_dev(const char *proc, const struct dm_config_node *cn)
|
|||||||
|
|
||||||
/* Go through the valid device names and if there is a
|
/* Go through the valid device names and if there is a
|
||||||
match store max number of partitions */
|
match store max number of partitions */
|
||||||
for (j = 0; device_info[j].name != NULL; j++) {
|
for (j = 0; _device_info[j].name[0]; j++) {
|
||||||
dev_len = strlen(device_info[j].name);
|
dev_len = strlen(_device_info[j].name);
|
||||||
if (dev_len <= strlen(line + i) &&
|
if (dev_len <= strlen(line + i) &&
|
||||||
!strncmp(device_info[j].name, line + i, dev_len) &&
|
!strncmp(_device_info[j].name, line + i, dev_len) &&
|
||||||
(line_maj < NUMBER_OF_MAJORS)) {
|
(line_maj < NUMBER_OF_MAJORS)) {
|
||||||
_partitions[line_maj].max_partitions =
|
_partitions[line_maj].max_partitions =
|
||||||
device_info[j].max_partitions;
|
_device_info[j].max_partitions;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -342,6 +342,14 @@ int major_is_scsi_device(int major)
|
|||||||
return (_partitions[major].flags & PARTITION_SCSI_DEVICE) ? 1 : 0;
|
return (_partitions[major].flags & PARTITION_SCSI_DEVICE) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _lvm_type_filter_destroy(struct dev_filter *f)
|
||||||
|
{
|
||||||
|
if (f->use_count)
|
||||||
|
log_error(INTERNAL_ERROR "Destroying lvm_type filter while in use %u times.", f->use_count);
|
||||||
|
|
||||||
|
dm_free(f);
|
||||||
|
}
|
||||||
|
|
||||||
struct dev_filter *lvm_type_filter_create(const char *proc,
|
struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||||
const struct dm_config_node *cn)
|
const struct dm_config_node *cn)
|
||||||
{
|
{
|
||||||
@ -353,7 +361,7 @@ struct dev_filter *lvm_type_filter_create(const char *proc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
f->passes_filter = _passes_lvm_type_device_filter;
|
f->passes_filter = _passes_lvm_type_device_filter;
|
||||||
f->destroy = lvm_type_filter_destroy;
|
f->destroy = _lvm_type_filter_destroy;
|
||||||
f->use_count = 0;
|
f->use_count = 0;
|
||||||
f->private = NULL;
|
f->private = NULL;
|
||||||
|
|
||||||
@ -364,11 +372,3 @@ struct dev_filter *lvm_type_filter_create(const char *proc,
|
|||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lvm_type_filter_destroy(struct dev_filter *f)
|
|
||||||
{
|
|
||||||
if (f->use_count)
|
|
||||||
log_error(INTERNAL_ERROR "Destroying lvm_type filter while in use %u times.", f->use_count);
|
|
||||||
|
|
||||||
dm_free(f);
|
|
||||||
}
|
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
struct dev_filter *lvm_type_filter_create(const char *proc,
|
struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||||
const struct dm_config_node *cn);
|
const struct dm_config_node *cn);
|
||||||
|
|
||||||
void lvm_type_filter_destroy(struct dev_filter *f);
|
|
||||||
|
|
||||||
int dm_major(void);
|
int dm_major(void);
|
||||||
int md_major(void);
|
int md_major(void);
|
||||||
int blkext_major(void);
|
int blkext_major(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user