mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
83fe6e720f
The LVM devices file lists devices that lvm can use. The default file is /etc/lvm/devices/system.devices, and the lvmdevices(8) command is used to add or remove device entries. If the file does not exist, or if lvm.conf includes use_devicesfile=0, then lvm will not use a devices file. When the devices file is in use, the regex filter is not used, and the filter settings in lvm.conf or on the command line are ignored. LVM records devices in the devices file using hardware-specific IDs, such as the WWID, and attempts to use subsystem-specific IDs for virtual device types. These device IDs are also written in the VG metadata. When no hardware or virtual ID is available, lvm falls back using the unstable device name as the device ID. When devnames are used, lvm performs extra scanning to find devices if their devname changes, e.g. after reboot. When proper device IDs are used, an lvm command will not look at devices outside the devices file, but when devnames are used as a fallback, lvm will scan devices outside the devices file to locate PVs on renamed devices. A config setting search_for_devnames can be used to control the scanning for renamed devname entries. Related to the devices file, the new command option --devices <devnames> allows a list of devices to be specified for the command to use, overriding the devices file. The listed devices act as a sort of devices file in terms of limiting which devices lvm will see and use. Devices that are not listed will appear to be missing to the lvm command. Multiple devices files can be kept in /etc/lvm/devices, which allows lvm to be used with different sets of devices, e.g. system devices do not need to be exposed to a specific application, and the application can use lvm on its own set of devices that are not exposed to the system. The option --devicesfile <filename> is used to select the devices file to use with the command. Without the option set, the default system devices file is used. Setting --devicesfile "" causes lvm to not use a devices file. An existing, empty devices file means lvm will see no devices. The new command vgimportdevices adds PVs from a VG to the devices file and updates the VG metadata to include the device IDs. vgimportdevices -a will import all VGs into the system devices file. LVM commands run by dmeventd not use a devices file by default, and will look at all devices on the system. A devices file can be created for dmeventd (/etc/lvm/devices/dmeventd.devices) If this file exists, lvm commands run by dmeventd will use it. Internal implementaion: - device_ids_read - read the devices file . add struct dev_use (du) to cmd->use_devices for each devices file entry - dev_cache_scan - get /dev entries . add struct device (dev) to dev_cache for each device on the system - device_ids_match - match devices file entries to /dev entries . match each du on cmd->use_devices to a dev in dev_cache, using device ID . on match, set du->dev, dev->id, dev->flags MATCHED_USE_ID - label_scan - read lvm headers and metadata from devices . filters are applied, those that do not need data from the device . filter-deviceid skips devs without MATCHED_USE_ID, i.e. skips /dev entries that are not listed in the devices file . read lvm label from dev . filters are applied, those that use data from the device . read lvm metadata from dev . add info/vginfo structs for PVs/VGs (info is "lvmcache") - device_ids_find_renamed_devs - handle devices with unstable devname ID where devname changed . this step only needed when devs do not have proper device IDs, and their dev names change, e.g. after reboot sdb becomes sdc. . detect incorrect match because PVID in the devices file entry does not match the PVID found when the device was read above . undo incorrect match between du and dev above . search system devices for new location of PVID . update devices file with new devnames for PVIDs on renamed devices . label_scan the renamed devs - continue with command processing
106 lines
3.5 KiB
C
106 lines
3.5 KiB
C
/*
|
|
* Copyright (C) 2013 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
|
|
*/
|
|
|
|
#ifndef _LVM_DEV_TYPE_H
|
|
#define _LVM_DEV_TYPE_H
|
|
|
|
#include "lib/device/device.h"
|
|
#include "lib/display/display.h"
|
|
#include "lib/label/label.h"
|
|
|
|
#define NUMBER_OF_MAJORS 4096
|
|
|
|
#ifdef __linux__
|
|
# include "libdm/misc/kdev_t.h"
|
|
#else
|
|
# define MAJOR(x) major((x))
|
|
# define MINOR(x) minor((x))
|
|
# define MKDEV(x,y) makedev((x),(y))
|
|
#endif
|
|
|
|
#define PARTITION_SCSI_DEVICE (1 << 0)
|
|
|
|
struct dev_type_def {
|
|
int max_partitions; /* 0 means LVM won't use this major number. */
|
|
int flags;
|
|
};
|
|
|
|
struct dev_types {
|
|
int md_major;
|
|
int blkext_major;
|
|
int drbd_major;
|
|
int device_mapper_major;
|
|
int emcpower_major;
|
|
int vxdmp_major;
|
|
int power2_major;
|
|
int dasd_major;
|
|
int loop_major;
|
|
struct dev_type_def dev_type_array[NUMBER_OF_MAJORS];
|
|
};
|
|
|
|
struct dev_types *create_dev_types(const char *proc_dir, const struct dm_config_node *cn);
|
|
|
|
/* Subsystems */
|
|
int dev_subsystem_part_major(struct dev_types *dt, struct device *dev);
|
|
const char *dev_subsystem_name(struct dev_types *dt, struct device *dev);
|
|
int major_is_scsi_device(struct dev_types *dt, int major);
|
|
|
|
/* Signature/superblock recognition with position returned where found. */
|
|
int dev_is_md_component(struct device *dev, uint64_t *sb, int full);
|
|
int dev_is_swap(struct device *dev, uint64_t *signature, int full);
|
|
int dev_is_luks(struct device *dev, uint64_t *signature, int full);
|
|
int dasd_is_cdl_formatted(struct device *dev);
|
|
int udev_dev_is_mpath_component(struct device *dev);
|
|
int udev_dev_is_md_component(struct device *dev);
|
|
|
|
int dev_is_lvm1(struct device *dev, char *buf, int buflen);
|
|
int dev_is_pool(struct device *dev, char *buf, int buflen);
|
|
|
|
/* Signature wiping. */
|
|
#define TYPE_LVM1_MEMBER 0x001
|
|
#define TYPE_LVM2_MEMBER 0x002
|
|
#define TYPE_DM_SNAPSHOT_COW 0x004
|
|
int wipe_known_signatures(struct cmd_context *cmd, struct device *dev, const char *name,
|
|
uint32_t types_to_exclude, uint32_t types_no_prompt,
|
|
int yes, force_t force, int *wiped);
|
|
|
|
/* Type-specific device properties */
|
|
unsigned long dev_md_stripe_width(struct dev_types *dt, struct device *dev);
|
|
int dev_is_md_with_end_superblock(struct dev_types *dt, struct device *dev);
|
|
|
|
/* Partitioning */
|
|
int major_max_partitions(struct dev_types *dt, int major);
|
|
int dev_is_partitioned(struct dev_types *dt, struct device *dev);
|
|
int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result);
|
|
int dev_get_partition_number(struct device *dev, int *num);
|
|
|
|
/* Various device properties */
|
|
unsigned long dev_alignment_offset(struct dev_types *dt, struct device *dev);
|
|
unsigned long dev_minimum_io_size(struct dev_types *dt, struct device *dev);
|
|
unsigned long dev_optimal_io_size(struct dev_types *dt, struct device *dev);
|
|
unsigned long dev_discard_max_bytes(struct dev_types *dt, struct device *dev);
|
|
unsigned long dev_discard_granularity(struct dev_types *dt, struct device *dev);
|
|
|
|
int dev_is_rotational(struct dev_types *dt, struct device *dev);
|
|
|
|
int dev_is_pmem(struct dev_types *dt, struct device *dev);
|
|
|
|
int dev_is_nvme(struct dev_types *dt, struct device *dev);
|
|
|
|
int dev_is_lv(struct device *dev);
|
|
|
|
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size);
|
|
|
|
#endif
|