Wrap some code from select_recheck_wwid() in a helper function. A future patch will call this code from a different function.
Signed-off-by: Benjamin Marzinski <bmarz...@redhat.com> --- libmultipath/discovery.c | 12 +++++++++++- libmultipath/discovery.h | 2 +- libmultipath/propsel.c | 4 +--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 846101d0..c4bc6df6 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -2245,7 +2245,7 @@ static ssize_t uid_fallback(struct path *pp, int path_state, return len; } -bool has_uid_fallback(struct path *pp) +static bool has_uid_fallback(const struct path *pp) { /* * Falling back to direct WWID determination is dangerous @@ -2266,6 +2266,16 @@ bool has_uid_fallback(struct path *pp) !strcmp(pp->uid_attribute, "")))); } +bool can_recheck_wwid(const struct path *pp) +{ + /* + * check_path_wwid_change() only works for scsi devices, and it + * is only guaranteed to give the same WWID if the path uses + * the default uid_attribute + */ + return (pp->bus == SYSFS_BUS_SCSI && has_uid_fallback(pp)); +} + int get_uid (struct path * pp, int path_state, struct udev_device *udev, int allow_fallback) diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h index 2b39eb04..2ef1d94b 100644 --- a/libmultipath/discovery.h +++ b/libmultipath/discovery.h @@ -55,7 +55,7 @@ ssize_t sysfs_get_inquiry(struct udev_device *udev, unsigned char *buff, size_t len); int sysfs_get_asymmetric_access_state(struct path *pp, char *buff, int buflen); -bool has_uid_fallback(struct path *pp); +bool can_recheck_wwid(const struct path *pp); int get_uid(struct path * pp, int path_state, struct udev_device *udev, int allow_fallback); bool is_vpd_page_supported(int fd, int pg); diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 664e62fc..367a9839 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -739,9 +739,7 @@ int select_recheck_wwid(struct config *conf, struct path * pp) pp_set_conf(recheck_wwid); pp_set_default(recheck_wwid, DEFAULT_RECHECK_WWID); out: - if (pp->recheck_wwid == RECHECK_WWID_ON && - (pp->bus != SYSFS_BUS_SCSI || - !has_uid_fallback(pp))) { + if (pp->recheck_wwid == RECHECK_WWID_ON && !can_recheck_wwid(pp)) { pp->recheck_wwid = RECHECK_WWID_OFF; origin = "(setting: unsupported by device type/config)"; } -- 2.48.1