summaryrefslogtreecommitdiff
path: root/lib/device/dev-cache.h
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2020-06-23 13:25:41 -0500
committerDavid Teigland <teigland@redhat.com>2020-09-17 16:51:10 -0500
commit0bfc49df20d26f7f94b839308a2f6f86417ad07b (patch)
tree71b3af27d4c8de99b724b9f924fcd98c6d755e5c /lib/device/dev-cache.h
parentb0787033023fdc213f3fdd3efc488e70f44e1fcd (diff)
downloadlvm2-dev-dct-deviceid-16.tar.gz
device usage based on devices filedev-dct-deviceid-16
The devices file /etc/lvm/devices/system.devices is a list of devices that lvm can use. The option --devicesfile can specify a different file name with a separate set of devices for lvm to use. This option allows different applications to use lvm on different sets of devices. In most cases (with limited exceptions), lvm will not read or use a device not listed in the devices file. When the devices file is used, the filter-regex is not used and the filter settings in lvm.conf are ignored. filter-deviceid is used when the devices file is enabled and rejects any device that does not match an entry in the devices file. Set use_devicesfile = 0 in lvm.conf or set --devicesfile "" on the command line to disable the use of a devices file. When disabled, lvm will see and use any device on the system that passes the regex filter. A device_id, e.g. wwid or serial number from sysfs, is a unique ID that identifies a device without reading it. Two devices with identical content should have different device_ids in most common cases. The device_id is used in the devices file and is included in VG metadata sections. Each device_id has a device_id_type which indicates where the device_id comes from, e.g. "sys_wwid" means the device_id comes from the sysfs wwid file. Others are sys_serial, mpath_uuid, loop_file, devname. (devname is the device path which is a fallback when no other proper device_id_type is available.) filter-deviceid permits lvm to use only devices on the system that have a device_id matching a devices file entry. Using the device_id, lvm can determine the set of devices to use without reading any devices, so the devices file will constrain lvm in two ways: 1. it limits the devices that lvm will read. 2. it limits the devices that lvm will use. In some uncommon cases, e.g. when devices have no unique ID and device_id has to fall back to using the devname, lvm may need to read all devices on the system to determine which ones correspond to the devices file entries. In this case, the devices file does not limit the devices that lvm reads, but it does limit the devices that lvm uses. pvcreate/vgcreate/vgextend are not constrained by the devices file, and will look outside it to find the new PV. They assign the new PV a device_id and add it to the devices file. It is also possible to explicitly add new PVs to the devices file before using them in pvcreate/etc, in which case these commands would not need to access devices outside the devices file. vgimportdevices VG looks at all devices on the system to find an existing VG and add its devices to the devices file. The command is not limited by an existing devices file. The command will also add device_ids to the VG metadata if the VG does not yet include device_ids. vgimportdevices -a imports devices for all accessible VGs. Since vgimportdevices does not limit itself to devices in an existing devices file, the lvm.conf regex filter applies. Adding --foreign will import devices for foreign VGs, but device_ids are not added to foreign VGs. Incomplete VGs are not imported. The lvmdevices command manages the devices file. The primary purpose is to edit the devices file, but it will read PV headers to find/check PVIDs. (It does not read, process or modify VG metadata.) lvmdevices . Displays devices file entries. lvmdevices --check . Checks devices file entries. lvmdevices --update . Updates devices file entries. lvmdevices --adddev <devname> . Adds devices_file entry (reads pv header). lvmdevices --deldev <devname> . Removes devices file entry. lvmdevices --addpvid <pvid> . Reads pv header of all devices to find <pvid>, and if found adds devices file entry. lvmdevices --delpvid <pvid> . Removes devices file entry. The vgimportclone command has a new option --importdevices that does the equivalent of vgimportdevices with the cloned devices that are being imported. The devices are "uncloned" (new vgname and pvids) while at the same time adding the devices to the devices file. This allows cloned PVs to be imported without duplicate PVs ever appearing on the system. TODO: device_id_type for other special devices (md, nbd, drbd) dmeventd run commands with --devicesfile dmeventd.devices OTHER: allow operations with duplicate pvs if device id and size match only one dev shortsystemid crc of systemid and written in pv header use shortsystemid for new filter and orphan PV ownership command to set boot flag on devices file entries needed for boot vgchange -ay option to use devices file entries with boot flag
Diffstat (limited to 'lib/device/dev-cache.h')
-rw-r--r--lib/device/dev-cache.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 46c86c27a..bba7bfac7 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -28,13 +28,12 @@ struct cmd_context;
struct dev_filter {
int (*passes_filter) (struct cmd_context *cmd, struct dev_filter *f, struct device *dev, const char *use_filter_name);
void (*destroy) (struct dev_filter *f);
- void (*wipe) (struct dev_filter *f);
+ void (*wipe) (struct cmd_context *cmd, struct dev_filter *f, struct device *dev, const char *use_filter_name);
void *private;
unsigned use_count;
const char *name;
};
-int dev_cache_index_devs(void);
struct dm_list *dev_cache_get_dev_list_for_vgid(const char *vgid);
struct dm_list *dev_cache_get_dev_list_for_lvid(const char *lvid);
@@ -74,4 +73,10 @@ void dev_cache_failed_path(struct device *dev, const char *path);
bool dev_cache_has_md_with_end_superblock(struct dev_types *dt);
+int get_sysfs_value(const char *path, char *buf, size_t buf_size, int error_if_no_value);
+
+int setup_devices_file(struct cmd_context *cmd);
+int setup_devices(struct cmd_context *cmd);
+int setup_device(struct cmd_context *cmd, const char *devname);
+
#endif