2001-09-25 16:49:28 +04:00
/*
2004-03-30 23:35:44 +04:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2007-08-21 00:55:30 +04:00
* Copyright ( C ) 2004 - 2007 Red Hat , Inc . All rights reserved .
2001-09-25 16:49:28 +04:00
*
2004-03-30 23:35:44 +04:00
* 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
2007-08-21 00:55:30 +04:00
* of the GNU Lesser General Public License v .2 .1 .
2004-03-30 23:35:44 +04:00
*
2007-08-21 00:55:30 +04:00
* You should have received a copy of the GNU Lesser General Public License
2004-03-30 23:35:44 +04:00
* along with this program ; if not , write to the Free Software Foundation ,
2016-01-21 13:49:46 +03:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
2001-09-25 16:49:28 +04:00
*/
# ifndef _LVM_DEVICE_H
# define _LVM_DEVICE_H
2018-05-14 12:30:20 +03:00
# include "lib/uuid/uuid.h"
2005-10-17 03:03:59 +04:00
2003-07-05 02:34:56 +04:00
# include <fcntl.h>
2001-10-03 16:41:29 +04:00
2003-07-05 02:34:56 +04:00
# define DEV_REGULAR 0x00000002 /* Regular file? */
2024-09-02 14:09:00 +03:00
# define DEV_ALLOCATED 0x00000004 /* malloc used */
2004-12-10 19:01:35 +03:00
# define DEV_OPENED_RW 0x00000008 /* Opened RW */
2005-10-04 01:10:41 +04:00
# define DEV_OPENED_EXCL 0x00000010 /* Opened EXCL */
# define DEV_O_DIRECT 0x00000020 /* Use O_DIRECT */
# define DEV_O_DIRECT_TESTED 0x00000040 /* DEV_O_DIRECT is reliable */
2016-03-17 15:45:14 +03:00
# define DEV_OPEN_FAILURE 0x00000080 /* Has last open failed? */
2016-03-16 16:01:26 +03:00
# define DEV_USED_FOR_LV 0x00000100 /* Is device used for an LV */
# define DEV_ASSUMED_FOR_LV 0x00000200 /* Is device assumed for an LV */
2016-05-12 03:05:52 +03:00
# define DEV_NOT_O_NOATIME 0x00000400 /* Don't use O_NOATIME */
2018-02-07 00:18:11 +03:00
# define DEV_IN_BCACHE 0x00000800 /* dev fd is open and used in bcache */
2018-02-13 17:58:35 +03:00
# define DEV_BCACHE_EXCL 0x00001000 /* bcache_fd should be open EXCL */
2022-08-30 23:10:52 +03:00
# define DEV_ADDED_SYS_WWID 0x00002000 /* wwid has been added from sysfs wwid file */
# define DEV_ADDED_VPD_WWIDS 0x00004000 /* wwids have been added from vpd_pg83 */
2018-06-20 19:32:45 +03:00
# define DEV_BCACHE_WRITE 0x00008000 /* bcache_fd is open with RDWR */
2018-12-07 23:35:22 +03:00
# define DEV_SCAN_FOUND_LABEL 0x00010000 /* label scan read dev and found label */
2019-05-21 19:58:01 +03:00
# define DEV_IS_MD_COMPONENT 0x00020000 /* device is an md component */
2021-04-17 00:01:19 +03:00
# define DEV_IS_NVME 0x00040000 /* set if dev is nvme */
# define DEV_MATCHED_USE_ID 0x00080000 /* matched an entry from cmd->use_devices */
2021-10-13 22:13:54 +03:00
# define DEV_SCAN_FOUND_NOLABEL 0x00100000 /* label_scan read, passed filters, but no lvm label */
2022-02-10 23:00:25 +03:00
# define DEV_SCAN_NOT_READ 0x00200000 /* label_scan not able to read dev */
2002-04-24 22:20:51 +04:00
2014-12-12 14:55:41 +03:00
/*
* Support for external device info .
* Any new external device info source needs to be
* registered using EXT_REGISTER macro in dev - ext . c .
*/
2015-11-07 19:17:37 +03:00
typedef enum dev_ext_e {
2014-12-12 14:55:41 +03:00
DEV_EXT_NONE ,
DEV_EXT_UDEV ,
DEV_EXT_NUM
} dev_ext_t ;
struct dev_ext {
int enabled ;
dev_ext_t src ;
void * handle ;
} ;
2022-08-30 23:10:52 +03:00
# define DEV_ID_TYPE_SYS_WWID 1
# define DEV_ID_TYPE_SYS_SERIAL 2
# define DEV_ID_TYPE_MPATH_UUID 3
# define DEV_ID_TYPE_MD_UUID 4
# define DEV_ID_TYPE_LOOP_FILE 5
# define DEV_ID_TYPE_CRYPT_UUID 6
# define DEV_ID_TYPE_LVMLV_UUID 7
# define DEV_ID_TYPE_DEVNAME 8
2022-09-01 00:05:07 +03:00
# define DEV_ID_TYPE_WWID_NAA 9
# define DEV_ID_TYPE_WWID_EUI 10
# define DEV_ID_TYPE_WWID_T10 11
2022-08-30 23:10:52 +03:00
2022-09-01 00:05:07 +03:00
/* Max length of WWID_NAA, WWID_EUI, WWID_T10 */
2022-06-06 22:04:20 +03:00
# define DEV_WWID_SIZE 128
2022-08-30 23:10:52 +03:00
/*
* A wwid read from :
* / sys / dev / block / % d : % d / device / wwid
* / sys / dev / block / % d : % d / wwid
* / sys / dev / block / % d : % d / device / vpd_pg83
*/
2022-06-06 22:04:20 +03:00
struct dev_wwid {
2022-08-30 23:10:52 +03:00
struct dm_list list ; /* dev->wwids */
int type ; /* 1,2,3 for NAA,EUI,T10 */
char id [ DEV_WWID_SIZE ] ; /* includes prefix naa.,eui.,t10. */
2022-06-06 22:04:20 +03:00
} ;
device usage based on devices file
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
2020-06-23 21:25:41 +03:00
/*
* A device ID of a certain type for a device .
* A struct device may have multiple dev_id structs on dev - > ids .
* One of them will be the one that ' s used , pointed to by dev - > id .
*/
struct dev_id {
2022-08-30 23:10:52 +03:00
struct dm_list list ; /* dev->ids */
device usage based on devices file
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
2020-06-23 21:25:41 +03:00
uint16_t idtype ; /* DEV_ID_TYPE_ */
char * idname ; /* id string determined by idtype */
} ;
/*
* A device listed in devices file that lvm should use .
* Each entry in the devices file is represented by a struct dev_use .
* The structs are kept on cmd - > use_devices .
* idtype / idname / pvid / part are set when reading the devices file .
* du - > dev is set when a struct dev_use is matched to a struct device .
*/
struct dev_use {
struct dm_list list ;
struct device * dev ;
int part ;
uint16_t idtype ;
char * idname ;
char * devname ;
char * pvid ;
} ;
2022-11-01 00:14:01 +03:00
struct dev_use_list {
struct dm_list list ;
struct dev_use * du ;
} ;
2001-10-03 16:41:29 +04:00
/*
* All devices in LVM will be represented by one of these .
* pointer comparisons are valid .
*/
struct device {
2014-05-29 11:41:03 +04:00
struct dm_list aliases ; /* struct dm_str_list */
2022-06-06 22:04:20 +03:00
struct dm_list wwids ; /* struct dev_wwid, used for multipath component detection */
device usage based on devices file
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
2020-06-23 21:25:41 +03:00
struct dm_list ids ; /* struct dev_id, different entries for different idtypes */
struct dev_id * id ; /* points to the the ids entry being used for this dev */
2001-10-03 16:41:29 +04:00
dev_t dev ;
2001-11-14 13:01:52 +03:00
/* private */
int fd ;
2003-07-05 02:34:56 +04:00
int open_count ;
2019-07-26 22:21:08 +03:00
int physical_block_size ; /* From BLKPBSZGET: lowest possible sector size that the hardware can operate on without reverting to read-modify-write operations */
int logical_block_size ; /* From BLKSSZGET: lowest possible block size that the storage device can address */
2009-05-20 15:09:49 +04:00
int read_ahead ;
2018-02-13 17:58:35 +03:00
int bcache_fd ;
bcache: use indirection table for fd
Add a "device index" (di) for each device, and use this
in the bcache api to the rest of lvm. This replaces the
file descriptor (fd) in the api. The rest of lvm uses
new functions bcache_set_fd(), bcache_clear_fd(), and
bcache_change_fd() to control which fd bcache uses for
io to a particular device.
. lvm opens a dev and gets and fd.
fd = open(dev);
. lvm passes fd to the bcache layer and gets a di
to use in the bcache api for the dev.
di = bcache_set_fd(fd);
. lvm uses bcache functions, passing di for the dev.
bcache_write_bytes(di, ...), etc.
. bcache translates di to fd to do io.
. lvm closes the device and clears the di/fd bcache state.
close(fd);
bcache_clear_fd(di);
In the bcache layer, a di-to-fd translation table
(int *_fd_table) is added. When bcache needs to
perform io on a di, it uses _fd_table[di].
In the following commit, lvm will make use of the new
bcache_change_fd() function to change the fd that
bcache uses for the dev, without dropping cached blocks.
2020-09-17 17:40:18 +03:00
int bcache_di ;
device usage based on devices file
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
2020-06-23 21:25:41 +03:00
int part ; /* partition number */
2002-04-24 22:20:51 +04:00
uint32_t flags ;
2020-07-20 20:48:36 +03:00
uint32_t filtered_flags ;
2016-01-15 18:41:27 +03:00
unsigned size_seqno ;
uint64_t size ;
2003-07-05 02:34:56 +04:00
uint64_t end ;
2014-12-12 14:55:41 +03:00
struct dev_ext ext ;
2018-05-21 22:20:19 +03:00
const char * duplicate_prefer_reason ;
2002-11-18 17:01:16 +03:00
2016-03-16 16:01:26 +03:00
const char * vgid ; /* if device is an LV */
const char * lvid ; /* if device is an LV */
char pvid [ ID_LEN + 1 ] ; /* if device is a PV */
2005-04-06 17:47:41 +04:00
char _padding [ 7 ] ;
2001-10-03 16:41:29 +04:00
} ;
2018-04-20 18:43:50 +03:00
/*
* All I / O is annotated with the reason it is performed .
*/
typedef enum dev_io_reason {
DEV_IO_SIGNATURES = 0 , /* Scanning device signatures */
DEV_IO_LABEL , /* LVM PV disk label */
DEV_IO_MDA_HEADER , /* Text format metadata area header */
DEV_IO_MDA_CONTENT , /* Text format metadata area content */
DEV_IO_MDA_EXTRA_HEADER , /* Header of any extra metadata areas on device */
DEV_IO_MDA_EXTRA_CONTENT , /* Content of any extra metadata areas on device */
DEV_IO_FMT1 , /* Original LVM1 metadata format */
DEV_IO_POOL , /* Pool metadata format */
DEV_IO_LV , /* Content written to an LV */
DEV_IO_LOG /* Logging messages */
} dev_io_reason_t ;
2002-01-15 13:24:48 +03:00
struct device_list {
2008-11-04 01:14:30 +03:00
struct dm_list list ;
2002-01-15 13:24:48 +03:00
struct device * dev ;
} ;
2022-11-07 20:38:46 +03:00
struct device_id_list {
struct dm_list list ;
struct device * dev ;
char pvid [ ID_LEN + 1 ] ;
} ;
2018-04-20 18:43:50 +03:00
struct device_area {
struct device * dev ;
uint64_t start ; /* Bytes */
uint64_t size ; /* Bytes */
} ;
2014-12-12 14:55:41 +03:00
/*
* Support for external device info .
*/
const char * dev_ext_name ( struct device * dev ) ;
int dev_ext_enable ( struct device * dev , dev_ext_t src ) ;
int dev_ext_disable ( struct device * dev ) ;
struct dev_ext * dev_ext_get ( struct device * dev ) ;
int dev_ext_release ( struct device * dev ) ;
2016-01-15 18:41:27 +03:00
/*
* Increment current dev_size_seqno .
* This is used to control lifetime
* of cached device size .
*/
void dev_size_seqno_inc ( void ) ;
2001-10-03 16:41:29 +04:00
/*
2001-11-14 13:01:52 +03:00
* All io should use these routines .
2001-10-03 16:41:29 +04:00
*/
2019-07-26 22:21:08 +03:00
int dev_get_direct_block_sizes ( struct device * dev , unsigned int * physical_block_size ,
unsigned int * logical_block_size ) ;
2015-03-03 17:37:17 +03:00
int dev_get_size ( struct device * dev , uint64_t * size ) ;
2009-05-20 15:09:49 +04:00
int dev_get_read_ahead ( struct device * dev , uint32_t * read_ahead ) ;
2011-04-13 01:59:01 +04:00
int dev_discard_blocks ( struct device * dev , uint64_t offset_bytes , uint64_t size_bytes ) ;
2001-11-14 13:01:52 +03:00
2003-07-05 02:34:56 +04:00
/* Use quiet version if device number could change e.g. when opening LV */
int dev_open ( struct device * dev ) ;
int dev_open_quiet ( struct device * dev ) ;
2005-04-07 16:17:46 +04:00
int dev_open_flags ( struct device * dev , int flags , int direct , int quiet ) ;
2011-05-24 17:36:57 +04:00
int dev_open_readonly ( struct device * dev ) ;
int dev_open_readonly_quiet ( struct device * dev ) ;
2001-11-14 13:01:52 +03:00
int dev_close ( struct device * dev ) ;
2003-11-14 20:55:39 +03:00
int dev_close_immediate ( struct device * dev ) ;
2001-11-14 13:01:52 +03:00
2006-04-19 19:33:07 +04:00
int dev_fd ( struct device * dev ) ;
const char * dev_name ( const struct device * dev ) ;
2002-11-18 17:01:16 +03:00
2003-07-05 02:34:56 +04:00
void dev_flush ( struct device * dev ) ;
devices: rework libudev usage
related to config settings:
obtain_device_info_from_udev (controls if lvm gets
a list of devices from readdir /dev or from libudev)
external_device_info_source (controls if lvm asks
libudev for device information)
. Make the obtain_device_list_from_udev setting
affect only the choice of readdir /dev vs libudev.
The setting no longer controls if udev is used for
device type checks.
. Change obtain_device_list_from_udev default to 0.
This helps avoid boot timeouts due to slow libudev
queries, avoids reported failures from
udev_enumerate_scan_devices, and avoids delays from
"device not initialized in udev database" errors.
Even without errors, for a system booting with 1024 PVs,
lvm2-pvscan times improve from about 100 sec to 15 sec,
and the pvscan command from about 64 sec to about 4 sec.
. For external_device_info_source="none", remove all
libudev device info queries, and use only lvm
native device info.
. For external_device_info_source="udev", first check
lvm native device info, then check libudev info.
. Remove sleep/retry loop when attempting libudev
queries for device info. udev info will simply
be skipped if it's not immediately available.
. Only set up a libdev connection if it will be used by
obtain_device_list_from_udev/external_device_info_source.
. For native multipath component detection, use
/etc/multipath/wwids. If a device has a wwid
matching an entry in the wwids file, then it's
considered a multipath component. This is
necessary to natively detect multipath
components when the mpath device is not set up.
2021-06-09 01:12:09 +03:00
int dev_mpath_init ( const char * config_wwids_file ) ;
void dev_mpath_exit ( void ) ;
2022-06-06 22:04:20 +03:00
int parse_vpd_ids ( const unsigned char * vpd_data , int vpd_datalen , struct dm_list * ids ) ;
2023-07-13 13:32:44 +03:00
int format_t10_id ( const unsigned char * in , size_t in_bytes , unsigned char * out , size_t out_bytes ) ;
int format_general_id ( const char * in , size_t in_bytes , unsigned char * out , size_t out_bytes ) ;
int parse_vpd_serial ( const unsigned char * in , char * out , size_t outsize ) ;
devices: rework libudev usage
related to config settings:
obtain_device_info_from_udev (controls if lvm gets
a list of devices from readdir /dev or from libudev)
external_device_info_source (controls if lvm asks
libudev for device information)
. Make the obtain_device_list_from_udev setting
affect only the choice of readdir /dev vs libudev.
The setting no longer controls if udev is used for
device type checks.
. Change obtain_device_list_from_udev default to 0.
This helps avoid boot timeouts due to slow libudev
queries, avoids reported failures from
udev_enumerate_scan_devices, and avoids delays from
"device not initialized in udev database" errors.
Even without errors, for a system booting with 1024 PVs,
lvm2-pvscan times improve from about 100 sec to 15 sec,
and the pvscan command from about 64 sec to about 4 sec.
. For external_device_info_source="none", remove all
libudev device info queries, and use only lvm
native device info.
. For external_device_info_source="udev", first check
lvm native device info, then check libudev info.
. Remove sleep/retry loop when attempting libudev
queries for device info. udev info will simply
be skipped if it's not immediately available.
. Only set up a libdev connection if it will be used by
obtain_device_list_from_udev/external_device_info_source.
. For native multipath component detection, use
/etc/multipath/wwids. If a device has a wwid
matching an entry in the wwids file, then it's
considered a multipath component. This is
necessary to natively detect multipath
components when the mpath device is not set up.
2021-06-09 01:12:09 +03:00
2022-11-07 20:38:46 +03:00
/* dev_util */
int device_id_list_remove ( struct dm_list * devices , struct device * dev ) ;
struct device_id_list * device_id_list_find_dev ( struct dm_list * devices , struct device * dev ) ;
int device_list_remove ( struct dm_list * devices , struct device * dev ) ;
struct device_list * device_list_find_dev ( struct dm_list * devices , struct device * dev ) ;
2023-11-08 20:46:38 +03:00
char * strdup_pvid ( char * pvid ) ;
2002-11-18 17:01:16 +03:00
# endif