libmultipath: fix multipath -q command logic
PATCH 1/1 libmultipath: fix multipath -q command logic
From: "tang.junhui" <[email protected]>
multipath judged whether multipathd service in running by check_daemon() when executing mutipath commands, check_daemon() try to connect to the multipathd service and execute "show dameon" command. The expected result is that the command will be failed when the service is not running, however, mpath_connect() will activate the multipathd service when the service is not running, so check_daemon() always return with true. Another problem is that multipath command with -q parameter is not processed in coalesce_paths(). This patch fix for those two problems.
--- libmultipath/configure.c | 85 +++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 37 deletions(-)
libmultipath/configure.c +48 -37
@@ -715,36 +715,36 @@ deadmap (struct multipath * mpp)return 1 ;/* dead */ } -int check_daemon (void ) +static int +check_daemon (void ) {int fd; -char *reply; -int ret =0 ; -unsigned int timeout; -struct config *conf; - - fd =mpath_connect (); -if (fd ==-1 ) -return 0 ; +struct flock lock; -if (send_packet (fd,"show daemon" ) !=0 ) - goto out; - conf =get_multipath_config (); - timeout = conf->uxsock_timeout; -put_multipath_config (conf); -if (recv_packet (fd, &reply, timeout) !=0 ) - goto out; - -if (strstr (reply,"shutdown" )) - goto out_free; - - ret =1 ; + fd =open (DEFAULT_PIDFILE ,O_RDONLY ); +if (fd <0 ) { +if (errno ==ENOENT ) +return 0 ; +if (errno ==EMFILE ) +condlog (0 ,"failed to open file, increase max_fds at %s" ,DEFAULT_CONFIGFILE ); +else +condlog (0 ,"can not open pidfile %s: %s" ,DEFAULT_PIDFILE ,strerror (errno)); +return -1 ; + } -out_free: -FREE (reply); -out: -mpath_disconnect (fd); -return ret; + lock.l_type =F_WRLCK ; + lock.l_start =0 ; + lock.l_whence =SEEK_SET ; + lock.l_len =0 ; +if (fcntl (fd,F_GETLK , &lock) <0 ) { +condlog (0 ,"can not get file locker, %s: %s" ,DEFAULT_PIDFILE ,strerror (errno)); +close (fd); +return -1 ; + } +close (fd); +if (lock.l_type ==F_UNLCK ) +return 0 ; +return 1 ; } extern int
@@ -873,17 +873,28 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_rif (r ==DOMAP_DRY )continue ; - conf =get_multipath_config (); - allow_queueing = conf->allow_queueing; -put_multipath_config (conf); -if (!is_daemon && !allow_queueing && !check_daemon ()) { -if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF && - mpp->no_path_retry !=NO_PATH_RETRY_FAIL ) -condlog (3 ,"%s: multipathd not running, unset " -"queue_if_no_path feature" , mpp->alias); -if (!dm_queue_if_no_path (mpp->alias,0 )) -remove_feature (&mpp->features, -"queue_if_no_path" ); +/* run as multipath command and the service is not running */ +if (!is_daemon && !check_daemon ()) { + conf =get_multipath_config (); + allow_queueing = conf->allow_queueing; +put_multipath_config (conf); +/* no -q choice */ +if (!allow_queueing) { +if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF && + mpp->no_path_retry !=NO_PATH_RETRY_FAIL ) +condlog (3 ,"%s: multipathd not running, unset " +"queue_if_no_path feature" , mpp->alias); +if (!dm_queue_if_no_path (mpp->alias,0 )) +remove_feature (&mpp->features, +"queue_if_no_path" ); + }else {/* with -q choice */ +if (mpp->no_path_retry ==NO_PATH_RETRY_UNDEF || + mpp->no_path_retry ==NO_PATH_RETRY_FAIL ) +condlog (3 ,"%s: multipathd not running, set " +"queue_if_no_path feature" , mpp->alias); +if (!dm_queue_if_no_path (mpp->alias,1 )) +add_feature (&mpp->features,"queue_if_no_path" ); + } }else if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF ) {if (mpp->no_path_retry ==NO_PATH_RETRY_FAIL ) {
Signature · 1 line
2.8.1.windows.1
Please have a review for this patch, any comment will be highly appreciated.
发件人: [email protected]
收件人: christophe varoqui <[email protected]>,
抄送: [email protected], [email protected], "tang.junhui"
<[email protected]>
日期: 2016/08/16 19:33
主题: [PATCH] libmultipath: fix multipath -q command logic
From: "tang.junhui" <[email protected]>
multipath judged whether multipathd service in running by check_daemon() when executing
mutipath commands, check_daemon() try to connect to the multipathd service and execute
"show dameon" command. The expected result is that the command will be failed when the
service is not running, however, mpath_connect() will activate the multipathd service when
the service is not running, so check_daemon() always return with true. Another problem is that
multipath command with -q parameter is not processed in coalesce_paths(). This patch fix for
those two problems.
--- libmultipath/configure.c | 85 +++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 37 deletions(-)
libmultipath/configure.c +9 -21
@@ -715,36 +715,36 @@ deadmap (struct multipath * mpp)return 1 ;/* dead */ } -int check_daemon (void ) +static int +check_daemon (void ) {int fd; -char *reply; -int ret =0 ; -unsigned int timeout; -struct config *conf; - - fd =mpath_connect (); -if (fd ==-1 ) -return 0 ; +struct flock lock; -if (send_packet (fd,"show daemon" ) !=0 ) - goto out; - conf =get_multipath_config (); - timeout = conf->uxsock_timeout; -put_multipath_config (conf); -if (recv_packet (fd, &reply, timeout) !=0 ) - goto out; - -if (strstr (reply,"shutdown" )) - goto out_free; - - ret =1 ; + fd =open (DEFAULT_PIDFILE ,O_RDONLY ); +if (fd <0 ) { +if (errno ==ENOENT ) +return 0 ; +if (errno ==EMFILE ) + condlog(0, "failed to
open file, increase max_fds at %s", DEFAULT_CONFIGFILE);
+ else
+ condlog(0, "can not open
pidfile %s: %s", DEFAULT_PIDFILE, strerror(errno));
+ return -1;
+ }
-out_free:
- FREE(reply);
-out:
- mpath_disconnect(fd);
- return ret;
+ lock.l_type = F_WRLCK;
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0;
+ if (fcntl(fd, F_GETLK, &lock) < 0) {+ condlog(0, "can not get file locker, %s:
%s", DEFAULT_PIDFILE, strerror(errno));
+ close(fd);
+ return -1;
+ } + close(fd); + if (lock.l_type == F_UNLCK)
+ return 0;
+ return 1;
}
extern int
@@ -873,17 +873,28 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
if (r == DOMAP_DRY)
continue;- conf = get_multipath_config(); - allow_queueing = conf->allow_queueing; - put_multipath_config(conf); - if (!is_daemon && !allow_queueing &&
!check_daemon()) {
- if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF &&
- mpp->no_path_retry !=NO_PATH_RETRY_FAIL)
- condlog(3, "%s: multipathd not running, unset "
- "queue_if_no_path feature", mpp->alias);
- if
(!dm_queue_if_no_path(mpp->alias, 0))
- remove_feature(&mpp->features,
- "queue_if_no_path");
+ /* run as multipath command and the
service is not running */
+ if (!is_daemon && !check_daemon()) {
+ conf =get_multipath_config();
+ allow_queueing =conf->allow_queueing;
+ put_multipath_config(conf);
+ /* no -q choice */
+ if (!allow_queueing) {
+ if
(mpp->no_path_retry != NO_PATH_RETRY_UNDEF &&
+ mpp->no_path_retry != NO_PATH_RETRY_FAIL)
+ condlog(3, "%s: multipathd not running, unset "
+ "queue_if_no_path feature", mpp->alias);
+ if
(!dm_queue_if_no_path(mpp->alias, 0))
+ remove_feature(&mpp->features,
+ "queue_if_no_path");
+ } else { /* with -q
choice */
+ if
(mpp->no_path_retry == NO_PATH_RETRY_UNDEF ||
+ mpp->no_path_retry == NO_PATH_RETRY_FAIL)
+ condlog(3, "%s: multipathd not running, set "
+ "queue_if_no_path feature", mpp->alias);
+ if
(!dm_queue_if_no_path(mpp->alias, 1))
+ add_feature(&mpp->features, "queue_if_no_path");
+ }
}
else if (mpp->no_path_retry !=
NO_PATH_RETRY_UNDEF) {
if (mpp->no_path_retry == NO_PATH_RETRY_FAIL) {
Signature · 1 line
2.8.1.windows.1
Hannes, Ben,
are you ok with the solution to these two issues.
Seems sane to me.
Thanks,
Christophe
Quoted 182 lines · On Tue, Oct 11, 2016 at 8:46 AM, <[email protected]> wrote:
Please have a review for this patch, any comment will be highly appreciated.
发件人: [email protected]
收件人: christophe varoqui <[email protected]>,
抄送: [email protected], [email protected], "tang.junhui" <
[email protected]>
日期: 2016/08/16 19:33
主题: [PATCH] libmultipath: fix multipath -q command logic
------------------------------From: "tang.junhui" <[email protected]>
multipath judged whether multipathd service in running by
check_daemon()when executing
mutipath commands,check_daemon()try to connect to the multipathd service and execute
"show dameon" command. The expected result is that the command will be failed when the
service is not running, however,mpath_connect()will activate the multipathd service when
the service is not running, socheck_daemon()always return with true. Another problem is that
multipath command with -q parameter is not processed incoalesce_paths(). This patch fix for
those two problems.Signed-off-by tang.junhui <[email protected]>---
libmultipath/configure.c| 85 +++++++++++++++++++++++++++---
------------------1 file changed, 48 insertions(+), 37 deletions(-)libmultipath/configure.c +26
-26@@ -715,36 +715,36 @@ deadmap (struct multipath * mpp) return 1; /* dead */ } -int check_daemon (void ) +static int +check_daemon(void) { int fd; -char *reply; -int ret =0 ; -unsigned int timeout; -struct config *conf; - - fd =mpath_connect (); -if (fd ==-1 ) -return 0 ; + struct flock lock; -if (send_packet (fd,"show daemon" ) !=0 ) - goto out; - conf =get_multipath_config (); - timeout = conf->uxsock_timeout; -put_multipath_config (conf); -if (recv_packet (fd, &reply, timeout) !=0 ) - goto out; - -if (strstr (reply,"shutdown" )) - goto out_free; - - ret =1 ; + fd = open(DEFAULT_PIDFILE, O_RDONLY); + if (fd < 0) { + if (errno == ENOENT) + return 0; + if (errno == EMFILE) + condlog(0, "failed to open file, increase max_fds at %s", DEFAULT_CONFIGFILE); + else + condlog(0, "can not open pidfile %s: %s", DEFAULT_PIDFILE, strerror(errno)); + return -1; + } -out_free: -FREE (reply); -out: -mpath_disconnect (fd); -return ret; + lock.l_type = F_WRLCK; + lock.l_start = 0; + lock.l_whence = SEEK_SET; + lock.l_len = 0; + if (fcntl(fd, F_GETLK, &lock) < 0) { + condlog(0, "can not get file locker, %s: %s", DEFAULT_PIDFILE, strerror(errno)); + close(fd); + return -1; + } + close(fd); + if (lock.l_type == F_UNLCK) + return 0; + return 1;}
extern int
libmultipath/configure.c +0
-0@@ -873,17 +873,28 @@ coalesce_paths (struct vectors * vecs, vector newmp,char * refwwid, int
force_rif (r == DOMAP_DRY) continue;libmultipath/configure.c +0
-4- conf =get_multipath_config (); - allow_queueing = conf->allow_queueing; -put_multipath_config (conf); - if (!is_daemon && !allow_queueing &&!check_daemon()) {
- if (mpp->no_path_retry
!=NO_PATH_RETRY_UNDEF&&
-mpp->no_path_retry
!=NO_PATH_RETRY_FAIL)libmultipath/configure.c +0
-3-condlog (3 ,"%s: multipathd not running, unset " -"queue_if_no_path feature" , mpp->alias); - if(!dm_queue_if_no_path(mpp->alias, 0))
libmultipath/configure.c +1
-2-remove_feature (&mpp->features, -"queue_if_no_path" ); +/* run as multipath command and the service is not running */
libmultipath/configure.c +2
-0+if (!is_daemon && !check_daemon ()) { + conf =
get_multipath_config();
+allow_queueing=conf->allow_queueing;
+put_multipath_config(conf);libmultipath/configure.c +3
-0+/* no -q choice */ +if (!allow_queueing) { + if(
mpp->no_path_retry!=NO_PATH_RETRY_UNDEF&&libmultipath/configure.c +4
-0+ mpp->no_path_retry != NO_PATH_RETRY_FAIL) +condlog (3 ,"%s: multipathd not running, unset " +"queue_if_no_path feature" , mpp->alias); + if(!dm_queue_if_no_path(mpp->alias, 0))
libmultipath/configure.c +3
-0+remove_feature (&mpp->features, +"queue_if_no_path" ); + }else {/* with -q choice */
+ if
(mpp->no_path_retry==NO_PATH_RETRY_UNDEF||libmultipath/configure.c +4
-0+ mpp->no_path_retry == NO_PATH_RETRY_FAIL) +condlog (3 ,"%s: multipathd not running, set " +"queue_if_no_path feature" , mpp->alias); + if(!dm_queue_if_no_path(mpp->alias, 1))
libmultipath/configure.c +2
-0+add_feature (&mpp->features,"queue_if_no_path" ); + } } else if (mpp->no_path_retry !=NO_PATH_RETRY_UNDEF) { if (mpp->no_path_retry==
NO_PATH_RETRY_FAIL) {
--
2.8.1.windows.1
Hello Hannes, Ben,
Could you have a review for this patch, any comment will be highly appreciated.
Thanks,
Tang
发件人: Christophe Varoqui <[email protected]>
收件人: [email protected],
抄送: Bart Van Assche <[email protected]>, device-mapper
development <[email protected]>, [email protected]
日期: 2016/10/11 14:59
主题: Re: [dm-devel] [PATCH] libmultipath: fix multipath -q command
logic
发件人: [email protected]
Hannes, Ben,
are you ok with the solution to these two issues.
Seems sane to me.
Thanks,
Christophe
On Tue, Oct 11, 2016 at 8:46 AM, <[email protected]> wrote:
Please have a review for this patch, any comment will be highly appreciated.
发件人: [email protected]
收件人: christophe varoqui <[email protected]>,
抄送: [email protected], [email protected], "tang.junhui" <
[email protected]>
日期: 2016/08/16 19:33
主题: [PATCH] libmultipath: fix multipath -q command logic
From: "tang.junhui" <[email protected]>
multipath judged whether multipathd service in running by check_daemon() when executing
mutipath commands, check_daemon() try to connect to the multipathd service and execute
"show dameon" command. The expected result is that the command will be failed when the
service is not running, however, mpath_connect() will activate the multipathd service when
the service is not running, so check_daemon() always return with true. Another problem is that
multipath command with -q parameter is not processed in coalesce_paths(). This patch fix for
those two problems.
---libmultipath/configure.c | 85
+++++++++++++++++++++++++++---------------------
1 file changed, 48 insertions(+), 37 deletions(-)
libmultipath/configure.c +0 -0
@@ -715,36 +715,36 @@ deadmap (struct multipath * mpp)return 1 ;/* dead */
}
-int check_daemon(void)
+static int
+check_daemon(void)
{
int fd;
- char *reply;
- int ret = 0;
- unsigned int timeout;
- struct config *conf;-
- fd = mpath_connect();
- if (fd == -1)
- return 0;
+ struct flock lock;
- if (send_packet(fd, "show daemon") != 0)
- goto out;
- conf = get_multipath_config(); - timeout = conf->uxsock_timeout; - put_multipath_config(conf); - if (recv_packet(fd, &reply, timeout) != 0)
- goto out;
-
- if (strstr(reply, "shutdown"))
- goto out_free;
-
- ret = 1;
+ fd = open(DEFAULT_PIDFILE, O_RDONLY);
+ if (fd < 0) {+ if (errno == ENOENT)
+ return 0;
+ if (errno == EMFILE)
+ condlog(0, "failed to
open file, increase max_fds at %s", DEFAULT_CONFIGFILE);
+ else
+ condlog(0, "can not
open pidfile %s: %s", DEFAULT_PIDFILE, strerror(errno));
+ return -1;
+ }
-out_free:
- FREE(reply);
-out:
- mpath_disconnect(fd);
- return ret;
+ lock.l_type = F_WRLCK;
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0;
+ if (fcntl(fd, F_GETLK, &lock) < 0) {+ condlog(0, "can not get file locker,
%s: %s", DEFAULT_PIDFILE, strerror(errno));
+ close(fd);
+ return -1;
+ } + close(fd); + if (lock.l_type == F_UNLCK)
+ return 0;
+ return 1;
}
extern int
@@ -873,17 +873,28 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
if (r == DOMAP_DRY)
continue;- conf = get_multipath_config(); - allow_queueing = conf->allow_queueing; - put_multipath_config(conf); - if (!is_daemon && !allow_queueing &&
!check_daemon()) {
- if (mpp->no_path_retry
!= NO_PATH_RETRY_UNDEF &&
- mpp->no_path_retry
!= NO_PATH_RETRY_FAIL)
-
condlog(3, "%s: multipathd not running, unset "
-
"queue_if_no_path feature", mpp->alias);
- if
(!dm_queue_if_no_path(mpp->alias, 0))
-
remove_feature(&mpp->features,
-
"queue_if_no_path");
+ /* run as multipath command and the
service is not running */
+ if (!is_daemon && !check_daemon()) {
+ conf =get_multipath_config();
+ allow_queueing =conf->allow_queueing;
+put_multipath_config(conf);
+ /* no -q choice */
+ if (!allow_queueing) {
+ if
(mpp->no_path_retry != NO_PATH_RETRY_UNDEF &&
+
mpp->no_path_retry != NO_PATH_RETRY_FAIL)
+
condlog(3, "%s: multipathd not running, unset "
+
"queue_if_no_path feature", mpp->alias);
+ if
(!dm_queue_if_no_path(mpp->alias, 0))
+
remove_feature(&mpp->features,
+
"queue_if_no_path");+ } else { /* with -q
choice */
+ if
(mpp->no_path_retry == NO_PATH_RETRY_UNDEF ||
+
mpp->no_path_retry == NO_PATH_RETRY_FAIL)
+
condlog(3, "%s: multipathd not running, set "
+
"queue_if_no_path feature", mpp->alias);
+ if
(!dm_queue_if_no_path(mpp->alias, 1))
+
add_feature(&mpp->features, "queue_if_no_path");
+ }
}
else if (mpp->no_path_retry !=
NO_PATH_RETRY_UNDEF) {
if (mpp->no_path_retry == NO_PATH_RETRY_FAIL) {
Signature · 7 lines
2.8.1.windows.1 -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Quoted 22 lines · On 10/11/2016 11:17 AM, [email protected] wrote:
Hello Hannes, Ben,
Could you have a review for this patch, any comment will be highly appreciated.Thanks,
Tang发件人: Christophe Varoqui <[email protected]>
收件人: [email protected],
抄送: Bart Van Assche <[email protected]>, device-mapper
development <[email protected]>, [email protected]
日期: 2016/10/11 14:59
主题: Re: [dm-devel] [PATCH] libmultipath: fix multipath -q
command logic
发件人: [email protected]
------------------------------------------------------------------------
Quoted 5 lines
Hannes, Ben,
are you ok with the solution to these two issues.
Seems sane to me.
This actually is only part of the story.
The whole idea of issuing 'multipath' is to check if a given path _should_ be multipathed (as this is typically called from an udev event).
But as it's called from an udev event we cannot rely on the multipath daemon to be started; we might just handle an event which came in before multipathd got started from systemd. So checking for the PID file is not enough, we need to check if the daemon will be started eventually.
And in fact checking the PID file or calling mpath_connect() is equivalent, with the added advantage the mpath_connect() will start the daemon _if enabled by systemd_. So this patch doesn't help much, as it doesn't solve the main problem of figuring out if multipathd _should_ be started.
I've done a patch for checking the '.wants' directories from systemd, but this obviously will only work if the OS is systemd-based. And it's not really perfect, as there are corner-cases where just checking for the .wants directory is not enough.
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Benjamin Marzinski
maintainerQuoted 43 lines · Hannes Reinecke
Quoted 22 lines · On 10/11/2016 11:17 AM, [email protected] wrote:
Hello Hannes, Ben,
Could you have a review for this patch, any comment will be highly appreciated.Thanks,
Tang发件人: Christophe Varoqui <[email protected]>
收件人: [email protected],
抄送: Bart Van Assche <[email protected]>, device-mapper
development <[email protected]>, [email protected]
日期: 2016/10/11 14:59
主题: Re: [dm-devel] [PATCH] libmultipath: fix multipath -q
command logic
发件人: [email protected]
------------------------------------------------------------------------Quoted 5 lines
Hannes, Ben,
are you ok with the solution to these two issues.
Seems sane to me.This actually is only part of the story.
The whole idea of issuing 'multipath' is to check if a given path _should_ be multipathed (as this is typically called from an udev event). But as it's called from an udev event we cannot rely on the multipath daemon to be started; we might just handle an event which came in before multipathd got started from systemd.
So checking for the PID file is not enough, we need to check if the daemon will be started eventually.
And in fact checking the PID file or callingmpath_connect()is equivalent, with the added advantage thempath_connect()will start the daemon_ifenabled bysystemd_.
So this patch doesn't help much, as it doesn't solve the main problem of figuring out if multipathd _should_ be started.
Quoted 4 lines
I've done a patch for checking the '.wants' directories from systemd, but this obviously will only work if the OS is systemd-based.
And it's not really perfect, as there are corner-cases where just checking for the .wants directory is not enough.
I think you are dealing with a different issue. the "-q" option for multipath just overrides the default behaviour of not enabling queue_if_no_path when creating a multipath device is multipathd isn't running. For this, we don't care if multipathd will start running in the future, because if/when multipathd does start up, it will set the queue_if_no_path flag itself. We only care about now, when we know it's not running.
Really, I doubt that anyone ever uses the -q option. So your change in how multipath checks if multipathd is running is fine by me. However, you also changed what the "-q" option does. Previously, it just kept multipath from disabling "queue_if_no_path" on devices that were configured to have it, when multipathd wasn't running. With your code, doesn't it now make all devices set queue_if_no_path if multipathd isn't running, including devices that weren't configured to set it even when multipathd is running? Is there a reason for this? In general, setting "queue_if_no_path" when multiapthd isn't running is a bad idea, since the paths will never come back, and nothing will ever disable the queueing. That's why I said that I doubt anybody uses the option. Forcing all devices to set "queue_if_no_path", even if they weren't configured to, seems even less useful. Or is there actually a use-case that I'm missing here?
-Ben
Quoted 9 lines
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
Hello Ben,
In multipath manual document, multipath -q command is described as:
"-q allow device tables with queue_if_no_path when multiathd is not
running".
However the command does not take effect when we testing it.
About use-case, In my opinion, sometimes we need to stop multipath service temporarily (for example: multipath version upgrade), but we do not want IO interrupt during those times even path down existed, so we can execute “multiath -q” to keep IO queue until we starting service after version upgrade.
Cheers,
Tang
发件人: "Benjamin Marzinski" <[email protected]>
收件人: Hannes Reinecke <[email protected]>,
抄送: Bart Van Assche <[email protected]>, device-mapper
development <[email protected]>, [email protected], [email protected]
日期: 2016/10/12 10:53
主题: Re: [dm-devel] [PATCH] libmultipath: fix multipath -q command
logic
发件人: [email protected]
Quoted 11 lines · Hannes Reinecke
Quoted 10 lines · On 10/11/2016 11:17 AM, [email protected] wrote:
Hello Hannes, Ben,
Could you have a review for this patch, any comment will be highly appreciated.Thanks,
Tang
Quoted 3 lines
Quoted 3 lines
发件人: Christophe Varoqui <[email protected]>
收件人: [email protected],
抄送: Bart Van Assche <[email protected]>,
device-mapper
Quoted 10 lines
Quoted 5 lines
development <[email protected]>, [email protected]
日期: 2016/10/11 14:59
主题: Re: [dm-devel] [PATCH] libmultipath: fix multipath -q
command logic
发件人: [email protected]------------------------------------------------------------------------
Quoted 3 lines
Quoted 8 lines
Quoted 5 lines
Hannes, Ben,
are you ok with the solution to these two issues.
Seems sane to me.This actually is only part of the story.
The whole idea of issuing 'multipath' is to check if a given path
_should_
Quoted 2 lines
be multipathed (as this is typically called from an udev event). But as it's called from an udev event we cannot rely on the multipath
daemon
Quoted 1 line
to be started; we might just handle an event which came in before
multipathd
Quoted 2 lines
got started from systemd.
So checking for the PID file is not enough, we need to check if the
daemon
Quoted 2 lines
will be started eventually.
And in fact checking the PID file or callingmpath_connect()is
equivalent,
Quoted 6 lines
with the added advantage the
mpath_connect()will start the daemon_ifenabled bysystemd_.
So this patch doesn't help much, as it doesn't solve the main problem of figuring out if multipathd _should_ be started.I've done a patch for checking the '.wants' directories from systemd,
but
Quoted 2 lines
this obviously will only work if the OS is systemd-based. And it's not really perfect, as there are corner-cases where just
checking
Quoted 1 line
for the .wants directory is not enough.
I think you are dealing with a different issue. the "-q" option for multipath just overrides the default behaviour of not enabling queue_if_no_path when creating a multipath device is multipathd isn't running. For this, we don't care if multipathd will start running in the future, because if/when multipathd does start up, it will set the queue_if_no_path flag itself. We only care about now, when we know it's not running.
Really, I doubt that anyone ever uses the -q option. So your change in how multipath checks if multipathd is running is fine by me. However, you also changed what the "-q" option does. Previously, it just kept multipath from disabling "queue_if_no_path" on devices that were configured to have it, when multipathd wasn't running. With your code, doesn't it now make all devices set queue_if_no_path if multipathd isn't running, including devices that weren't configured to set it even when multipathd is running? Is there a reason for this? In general, setting "queue_if_no_path" when multiapthd isn't running is a bad idea, since the paths will never come back, and nothing will ever disable the queueing. That's why I said that I doubt anybody uses the option. Forcing all devices to set "queue_if_no_path", even if they weren't configured to, seems even less useful. Or is there actually a use-case that I'm missing here?
-Ben
Quoted 7 lines
Cheers,
Hannes
Signature · 2 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911
74053 688
Quoted 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
Hello Hannes,check_daemon() now is only used to determine whether to set/remove queue_if_no_path feature for
mapped devices, which you said maybe another issue, we are looking forward for your patch.
Thanks,
Tang
发件人: Hannes Reinecke <[email protected]>
收件人: [email protected], [email protected],
抄送: Bart Van Assche <[email protected]>, device-mapper
development <[email protected]>, [email protected]
日期: 2016/10/11 18:42
主题: Re: [dm-devel] [PATCH] libmultipath: fix multipath -q command
logic
发件人: [email protected]
Quoted 22 lines · On 10/11/2016 11:17 AM, [email protected] wrote:
Hello Hannes, Ben,
Could you have a review for this patch, any comment will be highly appreciated.Thanks,
Tang发件人: Christophe Varoqui <[email protected]>
收件人: [email protected],
抄送: Bart Van Assche <[email protected]>, device-mapper
development <[email protected]>, [email protected]
日期: 2016/10/11 14:59
主题: Re: [dm-devel] [PATCH] libmultipath: fix multipath -q
command logic
发件人: [email protected]
------------------------------------------------------------------------
Quoted 5 lines
Hannes, Ben,
are you ok with the solution to these two issues.
Seems sane to me.
This actually is only part of the story.
The whole idea of issuing 'multipath' is to check if a given path _should_ be multipathed (as this is typically called from an udev event). But as it's called from an udev event we cannot rely on the multipath daemon to be started; we might just handle an event which came in before multipathd got started from systemd.
So checking for the PID file is not enough, we need to check if the daemon will be started eventually.
And in fact checking the PID file or calling mpath_connect() is equivalent, with the added advantage the mpath_connect() will start the daemon _if enabled by systemd_.
So this patch doesn't help much, as it doesn't solve the main problem of figuring out if multipathd _should_ be started.
I've done a patch for checking the '.wants' directories from systemd, but this obviously will only work if the OS is systemd-based. And it's not really perfect, as there are corner-cases where just checking for the .wants directory is not enough.
Cheers,
Hannes
Signature · 10 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel