diff options
author | David Teigland <teigland@redhat.com> | 2020-06-23 13:25:41 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2020-07-29 16:19:40 -0500 |
commit | 6c9f830db61c70be0b50b0342847c21bbaf9cbbd (patch) | |
tree | 4112d56baaf533416f7fac54f0410cfe1030c971 /lib/commands/toolcontext.h | |
parent | b0787033023fdc213f3fdd3efc488e70f44e1fcd (diff) | |
download | lvm2-dev-dct-deviceid-8.tar.gz |
device usage based on devices_file and device_iddev-dct-deviceid-8
devices_file, e.g. /etc/lvm/lvm_devices.dat,
is a list of devices that lvm can use.
Option --devicesfile can sepecify a different file
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 devices_file.
When the devices_file is used, the filter-regex is
not used and the filter settings in lvm.conf are
ignored. lvm uses the devices_file to control access
to devices using the new filter-deviceid.
Setting --devicesfile to "" on the command line, or
devicesfile to "" in lvm.conf will disable the use
of the devices_file and filter-deviceid. This
allows lvm to see and use any device on the system.
In this case lvm will fall back to using filter-regex
and the filter config settings in lvm.conf.
device_id, e.g. wwid or serial number from sysfs,
is a unique ID that identifies a device without
reading it, and which will change if the device
is copied to another. 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 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 devices_file before using
them in pvcreate/etc, in which case these commands
would not need to access devices outside devices_file.
(A config setting may be added to control the ability
of these commands to search outside 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.
TODO:
pvchange --deviceidupdate PV
vgchange --deviceidupdate VG
duplicate PV resolution using device_id
vgimportclone needs to update device_file
pvchange --uuid needs to update device_file
search for pvid when no wwid is available and PV is missing
device_id_type for md devices
shortsystemid crc of systemid and written in pv header
use shortsystemid for new filter and orphan PV ownership
dmeventd and lvmpolld with devices file
Diffstat (limited to 'lib/commands/toolcontext.h')
-rw-r--r-- | lib/commands/toolcontext.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h index c09558a42..9a3cdb21e 100644 --- a/lib/commands/toolcontext.h +++ b/lib/commands/toolcontext.h @@ -182,13 +182,20 @@ struct cmd_context { unsigned pvscan_recreate_hints:1; /* enable special case hint handling for pvscan --cache */ unsigned scan_lvs:1; unsigned wipe_outdated_pvs:1; + unsigned enable_devices_file:1; /* command is using devices file */ + unsigned create_edit_devices_file:1; /* command expects to create and/or edit devices file */ + unsigned edit_devices_file:1; /* command expects to edit devices file */ + unsigned skip_filter_deviceid:1; /* disable filter-deviceid */ + unsigned filter_regex_with_devices_file:1; /* use filter-regex even when devices file is enabled */ /* * Devices and filtering. */ struct dev_filter *filter; struct dm_list hints; + struct dm_list use_device_ids; const char *md_component_checks; + const char *devices_file; /* * Configuration. @@ -220,6 +227,7 @@ struct cmd_context { char system_dir[PATH_MAX]; char dev_dir[PATH_MAX]; char proc_dir[PATH_MAX]; + char devices_file_path[PATH_MAX]; /* * Reporting. @@ -275,4 +283,6 @@ struct format_type *get_format_by_name(struct cmd_context *cmd, const char *form const char *system_id_from_string(struct cmd_context *cmd, const char *str); +int set_devices_file(struct cmd_context *cmd, const char *name); + #endif |