This is an automated DistroBaker update from upstream sources. If you do not know what this is about or would like to opt out, contact the OSCI team. Source: https://src.fedoraproject.org/rpms/device-mapper-multipath.git#26a2cd7a3e189bf91263d17bc8a8c449cc043fb0
		
			
				
	
	
		
			141 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			141 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 | |
| From: Martin Wilck <mwilck@suse.com>
 | |
| Date: Fri, 4 Jan 2019 16:59:49 +0100
 | |
| Subject: [PATCH] multipathd: allow shutdown during configure()
 | |
| 
 | |
| reconfigure() can be a long-running operation; both initial path
 | |
| discovery and initial map setup can take a long time. Allow
 | |
| the main program to indicate that the process should be
 | |
| interrupted if a shutdown signal was received.
 | |
| 
 | |
| We take advantage of the dynamic linker's symbol lookup ordering
 | |
| here. The default implementation of should_exit never returns
 | |
| true, but callers (like multipathd) can override it.
 | |
| 
 | |
| Cc: Chongyun Wu <wu.chongyun@h3c.com>
 | |
| Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
 | |
| Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
 | |
| ---
 | |
|  libmultipath/configure.c |  6 ++++++
 | |
|  libmultipath/discovery.c |  3 +++
 | |
|  libmultipath/util.c      |  5 +++++
 | |
|  libmultipath/util.h      |  1 +
 | |
|  multipathd/main.c        | 17 +++++++++++++++++
 | |
|  5 files changed, 32 insertions(+)
 | |
| 
 | |
| diff --git a/libmultipath/configure.c b/libmultipath/configure.c
 | |
| index d7afc915..1c8aac08 100644
 | |
| --- a/libmultipath/configure.c
 | |
| +++ b/libmultipath/configure.c
 | |
| @@ -1173,6 +1173,12 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
 | |
|  
 | |
|  	vector_foreach_slot (pathvec, pp1, k) {
 | |
|  		int invalid;
 | |
| +
 | |
| +		if (should_exit()) {
 | |
| +			ret = CP_FAIL;
 | |
| +			goto out;
 | |
| +		}
 | |
| +
 | |
|  		/* skip this path for some reason */
 | |
|  
 | |
|  		/* 1. if path has no unique id or wwid blacklisted */
 | |
| diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
 | |
| index c2e1754c..e7084664 100644
 | |
| --- a/libmultipath/discovery.c
 | |
| +++ b/libmultipath/discovery.c
 | |
| @@ -200,6 +200,9 @@ path_discovery (vector pathvec, int flag)
 | |
|  		const char *devtype;
 | |
|  		const char *devpath;
 | |
|  
 | |
| +		if (should_exit())
 | |
| +			break;
 | |
| +
 | |
|  		devpath = udev_list_entry_get_name(entry);
 | |
|  		condlog(4, "Discover device %s", devpath);
 | |
|  		udevice = udev_device_new_from_syspath(udev, devpath);
 | |
| diff --git a/libmultipath/util.c b/libmultipath/util.c
 | |
| index 1748eafe..1f977792 100644
 | |
| --- a/libmultipath/util.c
 | |
| +++ b/libmultipath/util.c
 | |
| @@ -445,3 +445,8 @@ void _log_bitfield_overflow(const char *f, unsigned int bit, unsigned int len)
 | |
|  {
 | |
|  	condlog(0, "%s: bitfield overflow: %u >= %u", f, bit, len);
 | |
|  }
 | |
| +
 | |
| +int should_exit(void)
 | |
| +{
 | |
| +	return 0;
 | |
| +}
 | |
| diff --git a/libmultipath/util.h b/libmultipath/util.h
 | |
| index 2b9703ac..ac19473e 100644
 | |
| --- a/libmultipath/util.h
 | |
| +++ b/libmultipath/util.h
 | |
| @@ -27,6 +27,7 @@ int parse_prkey(const char *ptr, uint64_t *prkey);
 | |
|  int parse_prkey_flags(const char *ptr, uint64_t *prkey, uint8_t *flags);
 | |
|  int safe_write(int fd, const void *buf, size_t count);
 | |
|  void set_max_fds(rlim_t max_fds);
 | |
| +int should_exit(void);
 | |
|  
 | |
|  #define KERNEL_VERSION(maj, min, ptc) ((((maj) * 256) + (min)) * 256 + (ptc))
 | |
|  #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
 | |
| diff --git a/multipathd/main.c b/multipathd/main.c
 | |
| index eedc6c10..fa53e963 100644
 | |
| --- a/multipathd/main.c
 | |
| +++ b/multipathd/main.c
 | |
| @@ -141,6 +141,11 @@ static inline enum daemon_status get_running_state(void)
 | |
|  	return st;
 | |
|  }
 | |
|  
 | |
| +int should_exit(void)
 | |
| +{
 | |
| +	return get_running_state() == DAEMON_SHUTDOWN;
 | |
| +}
 | |
| +
 | |
|  /*
 | |
|   * global copy of vecs for use in sig handlers
 | |
|   */
 | |
| @@ -2570,6 +2575,9 @@ configure (struct vectors * vecs)
 | |
|  		goto fail;
 | |
|  	}
 | |
|  
 | |
| +	if (should_exit())
 | |
| +		goto fail;
 | |
| +
 | |
|  	conf = get_multipath_config();
 | |
|  	pthread_cleanup_push(put_multipath_config, conf);
 | |
|  	vector_foreach_slot (vecs->pathvec, pp, i){
 | |
| @@ -2586,6 +2594,9 @@ configure (struct vectors * vecs)
 | |
|  		goto fail;
 | |
|  	}
 | |
|  
 | |
| +	if (should_exit())
 | |
| +		goto fail;
 | |
| +
 | |
|  	/*
 | |
|  	 * create new set of maps & push changed ones into dm
 | |
|  	 * In the first call, use FORCE_RELOAD_WEAK to avoid making
 | |
| @@ -2600,6 +2611,9 @@ configure (struct vectors * vecs)
 | |
|  		goto fail;
 | |
|  	}
 | |
|  
 | |
| +	if (should_exit())
 | |
| +		goto fail;
 | |
| +
 | |
|  	/*
 | |
|  	 * may need to remove some maps which are no longer relevant
 | |
|  	 * e.g., due to blacklist changes in conf file
 | |
| @@ -2611,6 +2625,9 @@ configure (struct vectors * vecs)
 | |
|  
 | |
|  	dm_lib_release();
 | |
|  
 | |
| +	if (should_exit())
 | |
| +		goto fail;
 | |
| +
 | |
|  	sync_maps_state(mpvec);
 | |
|  	vector_foreach_slot(mpvec, mpp, i){
 | |
|  		if (remember_wwid(mpp->wwid) == 1)
 | |
| -- 
 | |
| 2.17.2
 | |
| 
 |