mirror of
				git://sourceware.org/git/lvm2.git
				synced 2025-11-03 08:23:48 +03:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			v2_03_34
			...
			dev-dct-de
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					d479cc96ea | 
@@ -771,7 +771,7 @@ int dm_device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_
 | 
			
		||||
	int only_error_or_zero_target = 1;
 | 
			
		||||
	int r = 0;
 | 
			
		||||
 | 
			
		||||
	if (dm_devs_cache_use() &&
 | 
			
		||||
	if (dm_devs_cache_use(cmd) &&
 | 
			
		||||
	    /* With cache we can avoid status calls for unusable UUIDs */
 | 
			
		||||
	    (dm_dev = dm_devs_cache_get_by_devno(cmd, dev->dev)) &&
 | 
			
		||||
	    !_is_usable_uuid(dev, dm_dev->name, dm_dev->uuid, check.check_reserved, check.check_lv, is_lv))
 | 
			
		||||
@@ -902,7 +902,7 @@ int devno_dm_uuid(struct cmd_context *cmd, int major, int minor,
 | 
			
		||||
	const char *uuid;
 | 
			
		||||
	int r = 0;
 | 
			
		||||
 | 
			
		||||
	if (dm_devs_cache_use()) {
 | 
			
		||||
	if (dm_devs_cache_use(cmd)) {
 | 
			
		||||
		if ((dm_dev = dm_devs_cache_get_by_devno(cmd, MKDEV(major, minor)))) {
 | 
			
		||||
			dm_strncpy(uuid_buf, dm_dev->uuid, uuid_buf_size);
 | 
			
		||||
			return 1;
 | 
			
		||||
@@ -1090,7 +1090,7 @@ int dev_manager_info(struct cmd_context *cmd,
 | 
			
		||||
 | 
			
		||||
	dm_strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
 | 
			
		||||
 | 
			
		||||
	if (dm_devs_cache_use() &&
 | 
			
		||||
	if (dm_devs_cache_use(cmd) &&
 | 
			
		||||
	    !dm_devs_cache_get_by_uuid(cmd, dlid) &&
 | 
			
		||||
	    !dm_devs_cache_get_by_uuid(cmd, old_style_dlid)) {
 | 
			
		||||
		log_debug("Cached as inactive %s.", name);
 | 
			
		||||
@@ -2464,7 +2464,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
 | 
			
		||||
	if (!(dlid = build_dm_uuid(dm->track_pending_delete ? dm->cmd->pending_delete_mem : dm->mem, lv, layer)))
 | 
			
		||||
		return_0;
 | 
			
		||||
 | 
			
		||||
	if (dm_devs_cache_use()) {
 | 
			
		||||
	if (dm_devs_cache_use(dm->cmd)) {
 | 
			
		||||
		if (!(dm_dev = dm_devs_cache_get_by_uuid(dm->cmd, dlid))) {
 | 
			
		||||
			log_debug("Cached as not present %s.", name);
 | 
			
		||||
			return 1;
 | 
			
		||||
@@ -2619,7 +2619,7 @@ static int _pool_callback(struct dm_tree_node *node,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	dm_devs_cache_destroy();
 | 
			
		||||
	dm_devs_cache_destroy(cmd);
 | 
			
		||||
 | 
			
		||||
	log_debug("Running check command on %s", mpath);
 | 
			
		||||
 | 
			
		||||
@@ -4003,7 +4003,7 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv,
 | 
			
		||||
 | 
			
		||||
	/* Drop any cache before DM table manipulation within locked section
 | 
			
		||||
	 * TODO: check if it makes sense to manage cache within lock */
 | 
			
		||||
	dm_devs_cache_destroy();
 | 
			
		||||
	dm_devs_cache_destroy(dm->cmd);
 | 
			
		||||
 | 
			
		||||
	dtree = _create_partial_dtree(dm, lv, laopts->origin_only);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								lib/cache/lvmcache.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								lib/cache/lvmcache.c
									
									
									
									
										vendored
									
									
								
							@@ -3237,11 +3237,11 @@ const char *dev_filtered_reason(struct device *dev)
 | 
			
		||||
	return "device cannot be used";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *devname_error_reason(const char *devname)
 | 
			
		||||
const char *devname_error_reason(struct cmd_context *cmd, const char *devname)
 | 
			
		||||
{
 | 
			
		||||
	struct device *dev;
 | 
			
		||||
 | 
			
		||||
	if ((dev = dev_cache_get_dev_by_name(devname))) {
 | 
			
		||||
	if ((dev = dev_cache_get_by_name(cmd, devname))) {
 | 
			
		||||
		if (dev->filtered_flags)
 | 
			
		||||
			return dev_filtered_reason(dev);
 | 
			
		||||
		if (lvmcache_dev_is_unused_duplicate(dev))
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								lib/cache/lvmcache.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								lib/cache/lvmcache.h
									
									
									
									
										vendored
									
									
								
							@@ -218,7 +218,7 @@ void lvmcache_get_mdas(struct cmd_context *cmd,
 | 
			
		||||
                       struct dm_list *mda_list);
 | 
			
		||||
 | 
			
		||||
const char *dev_filtered_reason(struct device *dev);
 | 
			
		||||
const char *devname_error_reason(const char *devname);
 | 
			
		||||
const char *devname_error_reason(struct cmd_context *cmd, const char *devname);
 | 
			
		||||
 | 
			
		||||
struct metadata_area *lvmcache_get_dev_mda(struct device *dev, int mda_num);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1167,7 +1167,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!dev_cache_add_dir(cv->v.str)) {
 | 
			
		||||
		if (!dev_cache_add_dir(cmd, cv->v.str)) {
 | 
			
		||||
			log_error("Failed to add %s to internal device cache",
 | 
			
		||||
				  cv->v.str);
 | 
			
		||||
			return 0;
 | 
			
		||||
@@ -1899,7 +1899,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
 | 
			
		||||
	_destroy_segtypes(&cmd->segtypes);
 | 
			
		||||
	_destroy_formats(cmd, &cmd->formats);
 | 
			
		||||
 | 
			
		||||
	if (!dev_cache_exit())
 | 
			
		||||
	if (!dev_cache_exit(cmd))
 | 
			
		||||
		stack;
 | 
			
		||||
	_destroy_dev_types(cmd);
 | 
			
		||||
	_destroy_tags(cmd);
 | 
			
		||||
@@ -2028,7 +2028,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
 | 
			
		||||
	_destroy_segtypes(&cmd->segtypes);
 | 
			
		||||
	_destroy_formats(cmd, &cmd->formats);
 | 
			
		||||
	_destroy_filters(cmd);
 | 
			
		||||
	dev_cache_exit();
 | 
			
		||||
	dev_cache_exit(cmd);
 | 
			
		||||
	_destroy_dev_types(cmd);
 | 
			
		||||
	_destroy_tags(cmd);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@
 | 
			
		||||
#include "lib/device/dev-cache.h"
 | 
			
		||||
#include "lib/device/dev-type.h"
 | 
			
		||||
#include "lib/commands/cmd_enum.h"
 | 
			
		||||
#include "base/data-struct/radix-tree.h"
 | 
			
		||||
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
 | 
			
		||||
@@ -222,6 +223,11 @@ struct cmd_context {
 | 
			
		||||
	/*
 | 
			
		||||
	 * Devices and filtering.
 | 
			
		||||
	 */
 | 
			
		||||
	struct dm_list dev_dirs;     /* paths, like /dev, to look for devnames */
 | 
			
		||||
	struct radix_tree *devnames; /* path names in dev_dirs, get struct device from path name */
 | 
			
		||||
	struct radix_tree *devnos;   /* devnos found in dev_dirs, get struct device from devno */
 | 
			
		||||
	struct dm_regex *preferred_names_matcher; /* preferred dev names to display from lvm.conf */
 | 
			
		||||
 | 
			
		||||
	struct dev_filter *filter;
 | 
			
		||||
	struct dm_list use_devices;		/* struct dev_use for each entry in devices file */
 | 
			
		||||
	const char *md_component_checks;
 | 
			
		||||
@@ -230,6 +236,22 @@ struct cmd_context {
 | 
			
		||||
	const char *devicesfile;                /* from --devicesfile option */
 | 
			
		||||
	struct dm_list deviceslist;             /* from --devices option, struct dm_str_list */
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * LV dev index.
 | 
			
		||||
	 */
 | 
			
		||||
	struct dm_hash_table *vgid_index;
 | 
			
		||||
	struct dm_hash_table *lvid_index;
 | 
			
		||||
	struct radix_tree *sysfs_only_devices;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Cache of DM devices.
 | 
			
		||||
	 * Look up struct dm_active_device from devno or dm uuid.
 | 
			
		||||
	 */
 | 
			
		||||
	int use_dm_devs_cache;       /* use this cache or not */
 | 
			
		||||
	struct dm_list *dm_devs;     /* list of dm_active_device */
 | 
			
		||||
	struct radix_tree *dm_uuids; /* dm uuids of dm devices, get entry from dm_devs */
 | 
			
		||||
	struct radix_tree *dm_devnos; /* devnos of dm devices, get entry from dm_devs */
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Configuration.
 | 
			
		||||
	 */
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -36,8 +36,8 @@ struct dev_filter {
 | 
			
		||||
 | 
			
		||||
void dev_init(struct device *dev);
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
struct dm_list *dev_cache_get_dev_list_for_vgid(struct cmd_context *cmd, const char *vgid);
 | 
			
		||||
struct dm_list *dev_cache_get_dev_list_for_lvid(struct cmd_context *cmd, const char *lvid);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The cache of dm devices is enabled when the kernel
 | 
			
		||||
@@ -49,9 +49,9 @@ struct dm_list *dev_cache_get_dev_list_for_lvid(const char *lvid);
 | 
			
		||||
 * have an alternative for when dm_devs_cache_use()
 | 
			
		||||
 * returns 0.
 | 
			
		||||
 */
 | 
			
		||||
int dm_devs_cache_use(void);
 | 
			
		||||
int dm_devs_cache_update(void);
 | 
			
		||||
void dm_devs_cache_destroy(void);
 | 
			
		||||
int dm_devs_cache_use(struct cmd_context *cmd);
 | 
			
		||||
int dm_devs_cache_update(struct cmd_context *cmd);
 | 
			
		||||
void dm_devs_cache_destroy(struct cmd_context *cmd);
 | 
			
		||||
void dm_devs_cache_label_invalidate(struct cmd_context *cmd);
 | 
			
		||||
const struct dm_active_device *
 | 
			
		||||
dm_devs_cache_get_by_devno(struct cmd_context *cmd, dev_t devno);
 | 
			
		||||
@@ -62,38 +62,32 @@ dm_devs_cache_get_by_uuid(struct cmd_context *cmd, const char *dm_uuid);
 | 
			
		||||
 * The global device cache.
 | 
			
		||||
 */
 | 
			
		||||
int dev_cache_init(struct cmd_context *cmd);
 | 
			
		||||
int dev_cache_exit(void);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Returns number of open devices.
 | 
			
		||||
 */
 | 
			
		||||
int dev_cache_check_for_open_devices(void);
 | 
			
		||||
int dev_cache_exit(struct cmd_context *cmd);
 | 
			
		||||
 | 
			
		||||
void dev_cache_scan(struct cmd_context *cmd);
 | 
			
		||||
int dev_cache_has_scanned(void);
 | 
			
		||||
 | 
			
		||||
int dev_cache_add_dir(const char *path);
 | 
			
		||||
int dev_cache_add_dir(struct cmd_context *cmd, const char *path);
 | 
			
		||||
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
 | 
			
		||||
struct device *dev_cache_get_existing(struct cmd_context *cmd, const char *name, struct dev_filter *f);
 | 
			
		||||
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt);
 | 
			
		||||
void dev_cache_verify_aliases(struct cmd_context *cmd, struct device *dev);
 | 
			
		||||
 | 
			
		||||
struct device *dev_cache_get_by_devno(struct cmd_context *cmd, dev_t devno);
 | 
			
		||||
struct device *dev_cache_get_by_name(struct cmd_context *cmd, const char *name);
 | 
			
		||||
struct device *dev_cache_get_by_pvid(struct cmd_context *cmd, const char *pvid);
 | 
			
		||||
void dev_cache_verify_aliases(struct device *dev);
 | 
			
		||||
 | 
			
		||||
struct device *dev_cache_get_dev_by_name(const char *name);
 | 
			
		||||
 | 
			
		||||
void dev_set_preferred_name(struct dm_str_list *sl, struct device *dev);
 | 
			
		||||
void dev_set_preferred_name(struct cmd_context *cmd, struct dm_str_list *sl, struct device *dev);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Object for iterating through the cache.
 | 
			
		||||
 */
 | 
			
		||||
struct dev_iter;
 | 
			
		||||
struct dev_iter *dev_iter_create(struct dev_filter *f, int unused);
 | 
			
		||||
struct dev_iter *dev_iter_create(struct cmd_context *cmd, struct dev_filter *f, int unused);
 | 
			
		||||
void dev_iter_destroy(struct dev_iter *iter);
 | 
			
		||||
struct device *dev_iter_get(struct cmd_context *cmd, struct dev_iter *iter);
 | 
			
		||||
 | 
			
		||||
void dev_cache_failed_path(struct device *dev, const char *path);
 | 
			
		||||
void dev_cache_failed_path(struct cmd_context *cmd, struct device *dev, const char *path);
 | 
			
		||||
 | 
			
		||||
bool dev_cache_has_md_with_end_superblock(struct dev_types *dt);
 | 
			
		||||
bool dev_cache_has_md_with_end_superblock(struct cmd_context *cmd, struct dev_types *dt);
 | 
			
		||||
 | 
			
		||||
int get_sysfs_value(const char *path, char *buf, size_t buf_size, int error_if_no_value);
 | 
			
		||||
int get_sysfs_binary(const char *path, char *buf, size_t buf_size, int *retlen);
 | 
			
		||||
 
 | 
			
		||||
@@ -576,7 +576,7 @@ static int _dev_in_wwid_file(struct cmd_context *cmd, struct device *dev,
 | 
			
		||||
	 * Check the primary device, not the partition.
 | 
			
		||||
	 */
 | 
			
		||||
	if (primary_result == 2) {
 | 
			
		||||
		if (!(dev = dev_cache_get_by_devt(cmd, primary_dev))) {
 | 
			
		||||
		if (!(dev = dev_cache_get_by_devno(cmd, primary_dev))) {
 | 
			
		||||
			log_debug("dev_is_mpath_component %s no primary dev", dev_name(dev));
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -149,6 +149,7 @@ struct device {
 | 
			
		||||
	uint64_t end;
 | 
			
		||||
	struct dev_ext ext;
 | 
			
		||||
	const char *duplicate_prefer_reason;
 | 
			
		||||
	struct cmd_context *cmd;
 | 
			
		||||
 | 
			
		||||
	const char *vgid; /* if device is an LV */
 | 
			
		||||
	const char *lvid; /* if device is an LV */
 | 
			
		||||
 
 | 
			
		||||
@@ -2738,7 +2738,7 @@ void device_ids_match(struct cmd_context *cmd)
 | 
			
		||||
		 */
 | 
			
		||||
		found = 0;
 | 
			
		||||
 | 
			
		||||
		if (!(iter = dev_iter_create(NULL, 0)))
 | 
			
		||||
		if (!(iter = dev_iter_create(cmd, NULL, 0)))
 | 
			
		||||
			continue;
 | 
			
		||||
		while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
			/* skip a dev that's already matched to another entry */
 | 
			
		||||
@@ -2855,7 +2855,7 @@ static void _get_devs_with_serial_numbers(struct cmd_context *cmd, struct dm_lis
 | 
			
		||||
	struct dev_id *id;
 | 
			
		||||
	const char *idname;
 | 
			
		||||
 | 
			
		||||
	if (!(iter = dev_iter_create(NULL, 0)))
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, NULL, 0)))
 | 
			
		||||
		return;
 | 
			
		||||
	while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
		/* if serial has already been read for this dev then use it */
 | 
			
		||||
@@ -3794,7 +3794,7 @@ void device_ids_search(struct cmd_context *cmd, struct dm_list *new_devs,
 | 
			
		||||
	 * filter), in the process of doing this search outside the deviceid
 | 
			
		||||
	 * filter.
 | 
			
		||||
	 */
 | 
			
		||||
	if (!(iter = dev_iter_create(NULL, 0)))
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, NULL, 0)))
 | 
			
		||||
		return;
 | 
			
		||||
	while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
		if (dev->flags & DEV_MATCHED_USE_ID)
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ static int _ignore_mpath_component(struct cmd_context *cmd, struct dev_filter *f
 | 
			
		||||
		 */
 | 
			
		||||
		if ((dev->flags & DEV_MATCHED_USE_ID) && mpath_devno) {
 | 
			
		||||
			if (!get_du_for_devno(cmd, mpath_devno)) {
 | 
			
		||||
				struct device *mpath_dev = dev_cache_get_by_devt(cmd, mpath_devno);
 | 
			
		||||
				struct device *mpath_dev = dev_cache_get_by_devno(cmd, mpath_devno);
 | 
			
		||||
				log_warn("WARNING: devices file is missing %s (%u:%u) using multipath component %s.",
 | 
			
		||||
					 mpath_dev ? dev_name(mpath_dev) : "unknown",
 | 
			
		||||
					 MAJOR(mpath_devno), MINOR(mpath_devno), dev_name(dev));
 | 
			
		||||
 
 | 
			
		||||
@@ -183,7 +183,7 @@ static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
 | 
			
		||||
		if (m >= 0) {
 | 
			
		||||
			if (dm_bit(rf->accept, m)) {
 | 
			
		||||
				if (!first && !cmd->filter_regex_set_preferred_name_disable)
 | 
			
		||||
					dev_set_preferred_name(sl, dev);
 | 
			
		||||
					dev_set_preferred_name(cmd, sl, dev);
 | 
			
		||||
 | 
			
		||||
				return 1;
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -499,7 +499,7 @@ int validate_hints(struct cmd_context *cmd, struct dm_list *hints)
 | 
			
		||||
	 * became stale somehow (e.g. manually copying devices with dd) and
 | 
			
		||||
	 * need to be refreshed.
 | 
			
		||||
	 */
 | 
			
		||||
	if (!(iter = dev_iter_create(NULL, 0)))
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, NULL, 0)))
 | 
			
		||||
		return 0;
 | 
			
		||||
	while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
		if (dm_list_empty(&dev->aliases))
 | 
			
		||||
@@ -877,7 +877,7 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int *
 | 
			
		||||
	/*
 | 
			
		||||
	 * Calculate and compare hash of devices that may be scanned.
 | 
			
		||||
	 */
 | 
			
		||||
	if (!(iter = dev_iter_create(NULL, 0)))
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, NULL, 0)))
 | 
			
		||||
		return 0;
 | 
			
		||||
	while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
		if (cmd->enable_devices_file && !get_du_for_dev(cmd, dev))
 | 
			
		||||
@@ -1049,7 +1049,7 @@ int write_hint_file(struct cmd_context *cmd, int newhints)
 | 
			
		||||
	 * dev flagged DEV_SCAN_FOUND_LABEL
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	if (!(iter = dev_iter_create(NULL, 0))) {
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, NULL, 0))) {
 | 
			
		||||
		ret = 0;
 | 
			
		||||
		goto out_close;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -537,8 +537,8 @@ static int _scan_dev_open(struct device *dev)
 | 
			
		||||
			 */
 | 
			
		||||
			log_debug("Drop alias for %u:%u failed open %s (%d).",
 | 
			
		||||
				  MAJOR(dev->dev), MINOR(dev->dev), name, errno);
 | 
			
		||||
			dev_cache_failed_path(dev, name);
 | 
			
		||||
			dev_cache_verify_aliases(dev);
 | 
			
		||||
			dev_cache_failed_path(dev->cmd, dev, name);
 | 
			
		||||
			dev_cache_verify_aliases(dev->cmd, dev);
 | 
			
		||||
			goto next_name;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -548,8 +548,8 @@ static int _scan_dev_open(struct device *dev)
 | 
			
		||||
		log_warn("Invalid path %s for device %u:%u, trying different path.",
 | 
			
		||||
			 name, MAJOR(dev->dev), MINOR(dev->dev));
 | 
			
		||||
		(void)close(fd);
 | 
			
		||||
		dev_cache_failed_path(dev, name);
 | 
			
		||||
		dev_cache_verify_aliases(dev);
 | 
			
		||||
		dev_cache_failed_path(dev->cmd, dev, name);
 | 
			
		||||
		dev_cache_verify_aliases(dev->cmd, dev);
 | 
			
		||||
		goto next_name;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -899,7 +899,7 @@ int label_scan_for_pvid(struct cmd_context *cmd, char *pvid, struct device **dev
 | 
			
		||||
	 * pass filters, and are those we can use.
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd->filter, 0))) {
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, cmd->filter, 0))) {
 | 
			
		||||
		log_error("Scanning failed to get devices.");
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
@@ -1046,7 +1046,7 @@ int label_scan_vg_online(struct cmd_context *cmd, const char *vgname,
 | 
			
		||||
		dm_list_iterate_items(po, &pvs_online) {
 | 
			
		||||
			if (po->dev)
 | 
			
		||||
				continue;
 | 
			
		||||
			if (!(po->dev = dev_cache_get_by_devt(cmd, po->devno))) {
 | 
			
		||||
			if (!(po->dev = dev_cache_get_by_devno(cmd, po->devno))) {
 | 
			
		||||
				log_error("No device found for %u:%u PVID %s.",
 | 
			
		||||
					  MAJOR(po->devno), MINOR(po->devno), po->pvid);
 | 
			
		||||
				goto bad;
 | 
			
		||||
@@ -1263,7 +1263,7 @@ int label_scan(struct cmd_context *cmd)
 | 
			
		||||
	 * here, before processing the hints file, so that the dm uuid checks
 | 
			
		||||
	 * in hint processing can benefit from the dm uuid cache.)
 | 
			
		||||
	 */
 | 
			
		||||
	if (!dm_devs_cache_update())
 | 
			
		||||
	if (!dm_devs_cache_update(cmd))
 | 
			
		||||
		return_0;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
@@ -1288,7 +1288,7 @@ int label_scan(struct cmd_context *cmd)
 | 
			
		||||
	 */
 | 
			
		||||
	if (cmd->md_component_detection && !cmd->use_full_md_check &&
 | 
			
		||||
	    !strcmp(cmd->md_component_checks, "auto") &&
 | 
			
		||||
	    dev_cache_has_md_with_end_superblock(cmd->dev_types)) {
 | 
			
		||||
	    dev_cache_has_md_with_end_superblock(cmd, cmd->dev_types)) {
 | 
			
		||||
		log_debug("Enable full md component check.");
 | 
			
		||||
		cmd->use_full_md_check = 1;
 | 
			
		||||
	}
 | 
			
		||||
@@ -1299,7 +1299,7 @@ int label_scan(struct cmd_context *cmd)
 | 
			
		||||
	 * Invalidate bcache data for all devs (there will usually be no bcache
 | 
			
		||||
	 * data to invalidate.)
 | 
			
		||||
	 */
 | 
			
		||||
	if (!(iter = dev_iter_create(NULL, 0))) {
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, NULL, 0))) {
 | 
			
		||||
		log_error("Failed to get device list.");
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
@@ -1652,7 +1652,7 @@ void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv
 | 
			
		||||
	if (lv_info(cmd, lv, 0, &lvinfo, 0, 0) && lvinfo.exists) {
 | 
			
		||||
		/* FIXME: Still unclear what is it supposed to find */
 | 
			
		||||
		devt = MKDEV(lvinfo.major, lvinfo.minor);
 | 
			
		||||
		if ((dev = dev_cache_get_by_devt(cmd, devt)))
 | 
			
		||||
		if ((dev = dev_cache_get_by_devno(cmd, devt)))
 | 
			
		||||
			label_scan_invalidate(dev);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -1670,7 +1670,7 @@ void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs)
 | 
			
		||||
 | 
			
		||||
	log_debug("Invalidating devs for any PVs on LVs.");
 | 
			
		||||
 | 
			
		||||
	if (dm_devs_cache_use())
 | 
			
		||||
	if (dm_devs_cache_use(cmd))
 | 
			
		||||
		dm_devs_cache_label_invalidate(cmd);
 | 
			
		||||
	else {
 | 
			
		||||
		dm_list_iterate_items(lvl, lvs)
 | 
			
		||||
@@ -1688,7 +1688,7 @@ void label_scan_drop(struct cmd_context *cmd)
 | 
			
		||||
	struct dev_iter *iter;
 | 
			
		||||
	struct device *dev;
 | 
			
		||||
 | 
			
		||||
	if (!(iter = dev_iter_create(NULL, 0)))
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, NULL, 0)))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
 
 | 
			
		||||
@@ -330,7 +330,7 @@ int vg_write_lock_held(void)
 | 
			
		||||
 | 
			
		||||
int sync_local_dev_names(struct cmd_context* cmd)
 | 
			
		||||
{
 | 
			
		||||
	dm_devs_cache_destroy();
 | 
			
		||||
	dm_devs_cache_destroy(cmd);
 | 
			
		||||
	memlock_unlock(cmd);
 | 
			
		||||
	fs_unlock();
 | 
			
		||||
	return 1;
 | 
			
		||||
 
 | 
			
		||||
@@ -3353,7 +3353,7 @@ int vg_missing_pv_count(const struct volume_group *vg)
 | 
			
		||||
 | 
			
		||||
#define DEV_LIST_DELIM ", "
 | 
			
		||||
 | 
			
		||||
static int _check_devs_used_correspond_with_lv(struct dm_pool *mem, struct dm_list *list, struct logical_volume *lv)
 | 
			
		||||
static int _check_devs_used_correspond_with_lv(struct cmd_context *cmd, struct dm_pool *mem, struct dm_list *list, struct logical_volume *lv)
 | 
			
		||||
{
 | 
			
		||||
	struct device_list *dl;
 | 
			
		||||
	int found_inconsistent = 0;
 | 
			
		||||
@@ -3363,7 +3363,7 @@ static int _check_devs_used_correspond_with_lv(struct dm_pool *mem, struct dm_li
 | 
			
		||||
	int warned_about_no_dev = 0;
 | 
			
		||||
	char *used_devnames = NULL, *assumed_devnames = NULL;
 | 
			
		||||
 | 
			
		||||
	if (!(list = dev_cache_get_dev_list_for_lvid(lv->lvid.s + ID_LEN)))
 | 
			
		||||
	if (!(list = dev_cache_get_dev_list_for_lvid(cmd, lv->lvid.s + ID_LEN)))
 | 
			
		||||
		return 1;
 | 
			
		||||
 | 
			
		||||
	dm_list_iterate_items(dl, list) {
 | 
			
		||||
@@ -3429,7 +3429,7 @@ static int _check_devs_used_correspond_with_lv(struct dm_pool *mem, struct dm_li
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int _check_devs_used_correspond_with_vg(struct volume_group *vg)
 | 
			
		||||
static int _check_devs_used_correspond_with_vg(struct cmd_context *cmd, struct volume_group *vg)
 | 
			
		||||
{
 | 
			
		||||
	struct dm_pool *mem;
 | 
			
		||||
	char vgid[ID_LEN + 1] __attribute__((aligned(8)));
 | 
			
		||||
@@ -3458,7 +3458,7 @@ static int _check_devs_used_correspond_with_vg(struct volume_group *vg)
 | 
			
		||||
		pvl->pv->dev->flags |= DEV_ASSUMED_FOR_LV;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!(list = dev_cache_get_dev_list_for_vgid(vgid)))
 | 
			
		||||
	if (!(list = dev_cache_get_dev_list_for_vgid(cmd, vgid)))
 | 
			
		||||
		return 1;
 | 
			
		||||
 | 
			
		||||
	dm_list_iterate_items(dl, list) {
 | 
			
		||||
@@ -3474,7 +3474,7 @@ static int _check_devs_used_correspond_with_vg(struct volume_group *vg)
 | 
			
		||||
			return_0;
 | 
			
		||||
 | 
			
		||||
		dm_list_iterate_items(lvl, &vg->lvs) {
 | 
			
		||||
			if (!_check_devs_used_correspond_with_lv(mem, list, lvl->lv)) {
 | 
			
		||||
			if (!_check_devs_used_correspond_with_lv(cmd, mem, list, lvl->lv)) {
 | 
			
		||||
				dm_pool_destroy(mem);
 | 
			
		||||
				return_0;
 | 
			
		||||
			}
 | 
			
		||||
@@ -5092,7 +5092,7 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const
 | 
			
		||||
		log_warn("WARNING: One or more devices used as PVs in VG %s have changed sizes.", vg->name);
 | 
			
		||||
 | 
			
		||||
	if (cmd->check_devs_used)
 | 
			
		||||
		_check_devs_used_correspond_with_vg(vg);
 | 
			
		||||
		_check_devs_used_correspond_with_vg(cmd, vg);
 | 
			
		||||
 | 
			
		||||
	if (!_access_vg_lock_type(cmd, vg, lockd_state, &failure)) {
 | 
			
		||||
		/* Either FAILED_LOCK_TYPE or FAILED_LOCK_MODE were set. */
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ static void _search_devs_for_pvids(struct cmd_context *cmd, struct dm_list *sear
 | 
			
		||||
	 * any filters, since we do not want filters to read any of the
 | 
			
		||||
	 * devices yet.
 | 
			
		||||
	 */
 | 
			
		||||
	if (!(iter = dev_iter_create(NULL, 0)))
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, NULL, 0)))
 | 
			
		||||
		return;
 | 
			
		||||
	while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
		/* Skip devs with a valid match to a du. */
 | 
			
		||||
@@ -697,7 +697,7 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
 | 
			
		||||
			if (update_set)
 | 
			
		||||
				dm_list_del(&du->list);
 | 
			
		||||
 | 
			
		||||
			if (!(mpath_dev = dev_cache_get_by_devt(cmd, mpath_devno)))
 | 
			
		||||
			if (!(mpath_dev = dev_cache_get_by_devno(cmd, mpath_devno)))
 | 
			
		||||
				continue;
 | 
			
		||||
 | 
			
		||||
			if (!get_du_for_dev(cmd, mpath_dev)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ static int _get_max_dev_name_len(struct cmd_context *cmd, struct dev_filter *fil
 | 
			
		||||
	struct dev_iter *iter;
 | 
			
		||||
	struct device *dev;
 | 
			
		||||
 | 
			
		||||
	if (!(iter = dev_iter_create(filter, 1))) {
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, filter, 1))) {
 | 
			
		||||
		log_error("dev_iter_create failed");
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
@@ -102,7 +102,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc __attribute__((unused)),
 | 
			
		||||
 | 
			
		||||
	_max_len = _get_max_dev_name_len(cmd, cmd->filter);
 | 
			
		||||
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd->filter, 0))) {
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, cmd->filter, 0))) {
 | 
			
		||||
		log_error("dev_iter_create failed");
 | 
			
		||||
		return ECMD_FAILED;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -3033,7 +3033,7 @@ static int _pvck_mf(struct metadata_file *mf, struct cmd_context *cmd, int argc,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!(dev = dev_cache_get(cmd, pv_name, NULL))) {
 | 
			
		||||
			log_error("Cannot use %s: %s.", pv_name, devname_error_reason(pv_name));
 | 
			
		||||
			log_error("Cannot use %s: %s.", pv_name, devname_error_reason(cmd, pv_name));
 | 
			
		||||
			return ECMD_FAILED;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -3057,7 +3057,7 @@ static int _pvck_mf(struct metadata_file *mf, struct cmd_context *cmd, int argc,
 | 
			
		||||
			dev = dev_cache_get(cmd, pv_name, NULL);
 | 
			
		||||
		}
 | 
			
		||||
		if (!dev && !def) {
 | 
			
		||||
			log_error("Cannot use %s: %s.", pv_name, devname_error_reason(pv_name));
 | 
			
		||||
			log_error("Cannot use %s: %s.", pv_name, devname_error_reason(cmd, pv_name));
 | 
			
		||||
			return ECMD_FAILED;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -3183,7 +3183,7 @@ static int _pvck_mf(struct metadata_file *mf, struct cmd_context *cmd, int argc,
 | 
			
		||||
		pv_name = argv[i];
 | 
			
		||||
 | 
			
		||||
		if (!(dev = dev_cache_get(cmd, argv[i], cmd->filter))) {
 | 
			
		||||
			log_error("Cannot use %s: %s.", pv_name, devname_error_reason(pv_name));
 | 
			
		||||
			log_error("Cannot use %s: %s.", pv_name, devname_error_reason(cmd, pv_name));
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1385,7 +1385,7 @@ static int _pvscan_cache_all(struct cmd_context *cmd, int argc, char **argv,
 | 
			
		||||
	 * The use of filter here will just reuse the existing
 | 
			
		||||
	 * (persistent) filter info label_scan has already set up.
 | 
			
		||||
	 */
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd->filter, 1)))
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, cmd->filter, 1)))
 | 
			
		||||
		return_0;
 | 
			
		||||
 | 
			
		||||
	while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
@@ -1461,7 +1461,7 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
 | 
			
		||||
 | 
			
		||||
	if (cmd->md_component_detection && !cmd->use_full_md_check &&
 | 
			
		||||
	    !strcmp(cmd->md_component_checks, "auto") &&
 | 
			
		||||
	    dev_cache_has_md_with_end_superblock(cmd->dev_types)) {
 | 
			
		||||
	    dev_cache_has_md_with_end_superblock(cmd, cmd->dev_types)) {
 | 
			
		||||
		log_debug("Enable full md component check.");
 | 
			
		||||
		cmd->use_full_md_check = 1;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1777,7 +1777,7 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv,
 | 
			
		||||
		goto out;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd->filter, 1))) {
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, cmd->filter, 1))) {
 | 
			
		||||
		log_error("dev_iter creation failed.");
 | 
			
		||||
		ret_max = ECMD_FAILED;
 | 
			
		||||
		goto out;
 | 
			
		||||
@@ -4201,7 +4201,7 @@ static int _get_arg_devices(struct cmd_context *cmd,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!(dil->dev = dev_cache_get_existing(cmd, sl->str, cmd->filter))) {
 | 
			
		||||
			log_error("Cannot use %s: %s", sl->str, devname_error_reason(sl->str));
 | 
			
		||||
			log_error("Cannot use %s: %s", sl->str, devname_error_reason(cmd, sl->str));
 | 
			
		||||
			ret_max = EINIT_FAILED;
 | 
			
		||||
		} else {
 | 
			
		||||
			memcpy(dil->pvid, dil->dev->pvid, ID_LEN);
 | 
			
		||||
@@ -4235,7 +4235,7 @@ static int _process_other_devices(struct cmd_context *cmd,
 | 
			
		||||
	 * was set by label_scan which did filtering.
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	if (!(iter = dev_iter_create(NULL, 0)))
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, NULL, 0)))
 | 
			
		||||
		return_0;
 | 
			
		||||
 | 
			
		||||
	while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
@@ -5578,7 +5578,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
 | 
			
		||||
	 */
 | 
			
		||||
	dm_list_iterate_items_safe(pd, pd2, &pp->arg_devices) {
 | 
			
		||||
		if (!cmd->filter->passes_filter(cmd, cmd->filter, pd->dev, NULL)) {
 | 
			
		||||
			log_error("Cannot use %s: %s", pd->name, devname_error_reason(pd->name));
 | 
			
		||||
			log_error("Cannot use %s: %s", pd->name, devname_error_reason(cmd, pd->name));
 | 
			
		||||
			dm_list_del(&pd->list);
 | 
			
		||||
			dm_list_add(&pp->arg_fail, &pd->list);
 | 
			
		||||
		}
 | 
			
		||||
@@ -5804,7 +5804,7 @@ do_command:
 | 
			
		||||
 | 
			
		||||
	dm_list_iterate_items_safe(pd, pd2, &pp->arg_process) {
 | 
			
		||||
		if (!cmd->filter->passes_filter(cmd, cmd->filter, pd->dev, NULL)) {
 | 
			
		||||
			log_error("Cannot use %s: %s", pd->name, devname_error_reason(pd->name));
 | 
			
		||||
			log_error("Cannot use %s: %s", pd->name, devname_error_reason(cmd, pd->name));
 | 
			
		||||
			dm_list_del(&pd->list);
 | 
			
		||||
			dm_list_add(&pp->arg_fail, &pd->list);
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -177,7 +177,7 @@ static int _get_other_devs(struct cmd_context *cmd, struct dm_list *new_devs, st
 | 
			
		||||
	struct device_list *devl;
 | 
			
		||||
	int r = 1;
 | 
			
		||||
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd->filter, 0)))
 | 
			
		||||
	if (!(iter = dev_iter_create(cmd, cmd->filter, 0)))
 | 
			
		||||
		return_0;
 | 
			
		||||
 | 
			
		||||
	while ((dev = dev_iter_get(cmd, iter))) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user