<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="generator" content="Osso Notes">
    <title></title></head>
<body>
<p>I fear you sent twice the patch to disable queueing.
<br>
<br>Cheers,
<br>cvaroqui
<br>
<br>> The oom_adj procfs interface is deprecated. I've added support for using
<br>> the new oom_score_adj interface.   The code still falls back to using
<br>> oom_adj if oom_score_adj doesn't exist.
<br>> 
<br>> Signed-off-by: Benjamin Marzinski <<a href="mailto:bmarzins@redhat.com">bmarzins@redhat.com</a>>
<br>> ---
<br>>   libmultipath/Makefile       |       2 
<br>>   libmultipath/config.h       |       1 
<br>>   libmultipath/configure.c |     13 +++++-
<br>>   libmultipath/pidfile.c     |     95
<br>> +++++++++++++++++++++++++++++++++++++++++++++++ libmultipath/pidfile.h  
<br>> |       2   multipath/main.c                 |       8 ++-
<br>>   multipathd/Makefile           |       2 
<br>>   multipathd/main.c               |       2 
<br>>   multipathd/pidfile.c         |     67 ---------------------------------
<br>>   multipathd/pidfile.h         |       1 
<br>>   10 files changed, 119 insertions(+), 74 deletions(-)
<br>> 
<br>> Index: multipath-tools-110916/libmultipath/config.h
<br>> ===================================================================
<br>> --- multipath-tools-110916.orig/libmultipath/config.h
<br>> +++ multipath-tools-110916/libmultipath/config.h
<br>> @@ -92,6 +92,7 @@ struct config {
<br>>       int attribute_flags;
<br>>       int fast_io_fail;
<br>>       unsigned int dev_loss;
<br>> +    int allow_queueing;
<br>>       uid_t uid;
<br>>       gid_t gid;
<br>>       mode_t mode;
<br>> Index: multipath-tools-110916/libmultipath/configure.c
<br>> ===================================================================
<br>> --- multipath-tools-110916.orig/libmultipath/configure.c
<br>> +++ multipath-tools-110916/libmultipath/configure.c
<br>> @@ -35,6 +35,7 @@
<br>>   #include "alias.h"
<br>>   #include "prio.h"
<br>>   #include "util.h"
<br>> +#include "pidfile.h"
<br>>  
<br>>   extern int
<br>>   setup_map (struct multipath * mpp, char * params, int params_size)
<br>> @@ -555,7 +556,17 @@ coalesce_paths (struct vectors * vecs, v
<br>>           if (r == DOMAP_DRY)
<br>>               continue;
<br>>  
<br>> -        if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) {
<br>> +        if (!conf->daemon && !conf->allow_queueing &&
<br>> +               !pidfile_check(DEFAULT_PIDFILE)) {
<br>> +            if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF &&
<br>> +                   mpp->no_path_retry != NO_PATH_RETRY_FAIL)
<br>> +                condlog(3, "%s: multipathd not running, unset "
<br>> +                    "queue_if_no_path feature", mpp->alias);
<br>> +            if (!dm_queue_if_no_path(mpp->alias, 0))
<br>> +                remove_feature(&mpp->features,
<br>> +                                 "queue_if_no_path");
<br>> +        }
<br>> +        else if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) {
<br>>               if (mpp->no_path_retry == NO_PATH_RETRY_FAIL) {
<br>>                   condlog(3, "%s: unset queue_if_no_path feature",
<br>>                       mpp->alias);
<br>> Index: multipath-tools-110916/multipath/main.c
<br>> ===================================================================
<br>> --- multipath-tools-110916.orig/multipath/main.c
<br>> +++ multipath-tools-110916/multipath/main.c
<br>> @@ -79,7 +79,7 @@ usage (char * progname)
<br>>   {
<br>>       fprintf (stderr, VERSION_STRING);
<br>>       fprintf (stderr, "Usage:\n");
<br>> -    fprintf (stderr, "   %s [-d] [-r] [-v lvl] [-p pol] [-b fil] [dev]\n",
<br>> progname); +    fprintf (stderr, "   %s [-d] [-r] [-v lvl] [-p pol] [-b fil]
<br>> [-q] [dev]\n", progname);     fprintf (stderr, "   %s -l|-ll|-f [-v lvl] [-b
<br>> fil] [dev]\n", progname);     fprintf (stderr, "   %s -F [-v lvl]\n",
<br>> progname);     fprintf (stderr, "   %s -t\n", progname);
<br>> @@ -92,6 +92,7 @@ usage (char * progname)
<br>>           "   -ll         show multipath topology (maximum info)\n" \
<br>>           "   -f           flush a multipath device map\n" \
<br>>           "   -F           flush all multipath device maps\n" \
<br>> +        "   -q           allow queue_if_no_path when multipathd is not running\n"\
<br>>           "   -d           dry run, do not create or update devmaps\n" \
<br>>           "   -t           dump internal hardware table\n" \
<br>>           "   -r           force devmap reload\n" \
<br>> @@ -397,7 +398,7 @@ main (int argc, char *argv[])
<br>>           condlog(0, "multipath tools need sysfs mounted");
<br>>           exit(1);
<br>>       }
<br>> -    while ((arg = getopt(argc, argv, ":dhl::FfM:v:p:b:Brt")) != EOF ) {
<br>> +    while ((arg = getopt(argc, argv, ":dhl::FfM:v:p:b:Brtq")) != EOF ) {
<br>>           switch(arg) {
<br>>           case 1: printf("optarg : %s\n",optarg);
<br>>               break;
<br>> @@ -414,6 +415,9 @@ main (int argc, char *argv[])
<br>>           case 'B':
<br>>               conf->bindings_read_only = 1;
<br>>               break;
<br>> +        case 'q':
<br>> +            conf->allow_queueing = 1;
<br>> +            break;
<br>>           case 'd':
<br>>               conf->dry_run = 1;
<br>>               break;
<br>> Index: multipath-tools-110916/multipathd/pidfile.c
<br>> ===================================================================
<br>> --- multipath-tools-110916.orig/multipathd/pidfile.c
<br>> +++ /dev/null
<br>> @@ -1,67 +0,0 @@
<br>> -#include <sys/types.h> /* for pid_t */
<br>> -#include <sys/stat.h>   /* for open */
<br>> -#include <signal.h>       /* for kill() */
<br>> -#include <errno.h>         /* for ESHRC */
<br>> -#include <stdio.h>         /* for f...() */
<br>> -#include <string.h>       /* for memset() */
<br>> -#include <stdlib.h>       /* for atoi() */
<br>> -#include <unistd.h>       /* for unlink() */
<br>> -#include <fcntl.h>         /* for fcntl() */
<br>> -
<br>> -#include <debug.h>
<br>> -
<br>> -#include "pidfile.h"
<br>> -
<br>> -int pidfile_create(const char *pidFile, pid_t pid)
<br>> -{
<br>> -    char buf[20];
<br>> -    struct flock lock;
<br>> -    int fd, value;
<br>> -
<br>> -    if((fd = open(pidFile, O_WRONLY | O_CREAT,
<br>> -                     (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0) {
<br>> -        condlog(0, "Cannot open pidfile [%s], error was [%s]",
<br>> -            pidFile, strerror(errno));
<br>> -        return 1;
<br>> -    }
<br>> -    lock.l_type = F_WRLCK;
<br>> -    lock.l_start = 0;
<br>> -    lock.l_whence = SEEK_SET;
<br>> -    lock.l_len = 0;
<br>> -
<br>> -    if (fcntl(fd, F_SETLK, &lock) < 0) {
<br>> -        if (errno != EACCES && errno != EAGAIN)
<br>> -            condlog(0, "Cannot lock pidfile [%s], error was [%s]",
<br>> -                pidFile, strerror(errno));
<br>> -        else
<br>> -            condlog(0, "process is already running");
<br>> -        goto fail;
<br>> -    }
<br>> -    if (ftruncate(fd, 0) < 0) {
<br>> -        condlog(0, "Cannot truncate pidfile [%s], error was [%s]",
<br>> -            pidFile, strerror(errno));
<br>> -        goto fail;
<br>> -    }
<br>> -    memset(buf, 0, sizeof(buf));
<br>> -    snprintf(buf, sizeof(buf)-1, "%u", pid);
<br>> -    if (write(fd, buf, strlen(buf)) != strlen(buf)) {
<br>> -        condlog(0, "Cannot write pid to pidfile [%s], error was [%s]",
<br>> -            pidFile, strerror(errno));
<br>> -        goto fail;
<br>> -    }
<br>> -    if ((value = fcntl(fd, F_GETFD, 0)) < 0) {
<br>> -        condlog(0, "Cannot get close-on-exec flag from pidfile [%s], "
<br>> -            "error was [%s]", pidFile, strerror(errno));
<br>> -        goto fail;
<br>> -    }
<br>> -    value |= FD_CLOEXEC;
<br>> -    if (fcntl(fd, F_SETFD, value) < 0) {
<br>> -        condlog(0, "Cannot set close-on-exec flag from pidfile [%s], "
<br>> -            "error was [%s]", pidFile, strerror(errno));
<br>> -        goto fail;
<br>> -    }
<br>> -    return 0;
<br>> -fail:
<br>> -    close(fd);
<br>> -    return 1;
<br>> -}
<br>> Index: multipath-tools-110916/multipathd/pidfile.h
<br>> ===================================================================
<br>> --- multipath-tools-110916.orig/multipathd/pidfile.h
<br>> +++ /dev/null
<br>> @@ -1 +0,0 @@
<br>> -int pidfile_create(const char *pidFile, pid_t pid);
<br>> Index: multipath-tools-110916/libmultipath/Makefile
<br>> ===================================================================
<br>> --- multipath-tools-110916.orig/libmultipath/Makefile
<br>> +++ multipath-tools-110916/libmultipath/Makefile
<br>> @@ -15,7 +15,7 @@ OBJS = memory.o parser.o vector.o devmap
<br>>                 pgpolicies.o debug.o regex.o defaults.o uevent.o \
<br>>                 switchgroup.o uxsock.o print.o alias.o log_pthread.o \
<br>>                 log.o configure.o structs_vec.o sysfs.o prio.o checkers.o \
<br>> -             lock.o waiter.o
<br>> +             lock.o waiter.o pidfile.o
<br>>  
<br>>   LIBDM_API_FLUSH = $(shell grep -Ecs
<br>> '^[a-z]*[[:space:]]+dm_task_no_flush' /usr/include/libdevmapper.h) 
<br>> Index: multipath-tools-110916/libmultipath/pidfile.c
<br>> ===================================================================
<br>> --- /dev/null
<br>> +++ multipath-tools-110916/libmultipath/pidfile.c
<br>> @@ -0,0 +1,95 @@
<br>> +#include <sys/types.h> /* for pid_t */
<br>> +#include <sys/stat.h>   /* for open */
<br>> +#include <signal.h>       /* for kill() */
<br>> +#include <errno.h>         /* for ESHRC */
<br>> +#include <stdio.h>         /* for f...() */
<br>> +#include <string.h>       /* for memset() */
<br>> +#include <stdlib.h>       /* for atoi() */
<br>> +#include <unistd.h>       /* for unlink() */
<br>> +#include <fcntl.h>         /* for fcntl() */
<br>> +
<br>> +#include "debug.h"
<br>> +#include "pidfile.h"
<br>> +
<br>> +int pidfile_create(const char *pidFile, pid_t pid)
<br>> +{
<br>> +    char buf[20];
<br>> +    struct flock lock;
<br>> +    int fd, value;
<br>> +
<br>> +    if((fd = open(pidFile, O_WRONLY | O_CREAT,
<br>> +                     (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0) {
<br>> +        condlog(0, "Cannot open pidfile [%s], error was [%s]",
<br>> +            pidFile, strerror(errno));
<br>> +        return 1;
<br>> +    }
<br>> +    lock.l_type = F_WRLCK;
<br>> +    lock.l_start = 0;
<br>> +    lock.l_whence = SEEK_SET;
<br>> +    lock.l_len = 0;
<br>> +
<br>> +    if (fcntl(fd, F_SETLK, &lock) < 0) {
<br>> +        if (errno != EACCES && errno != EAGAIN)
<br>> +            condlog(0, "Cannot lock pidfile [%s], error was [%s]",
<br>> +                pidFile, strerror(errno));
<br>> +        else
<br>> +            condlog(0, "process is already running");
<br>> +        goto fail;
<br>> +    }
<br>> +    if (ftruncate(fd, 0) < 0) {
<br>> +        condlog(0, "Cannot truncate pidfile [%s], error was [%s]",
<br>> +            pidFile, strerror(errno));
<br>> +        goto fail;
<br>> +    }
<br>> +    memset(buf, 0, sizeof(buf));
<br>> +    snprintf(buf, sizeof(buf)-1, "%u", pid);
<br>> +    if (write(fd, buf, strlen(buf)) != strlen(buf)) {
<br>> +        condlog(0, "Cannot write pid to pidfile [%s], error was [%s]",
<br>> +            pidFile, strerror(errno));
<br>> +        goto fail;
<br>> +    }
<br>> +    if ((value = fcntl(fd, F_GETFD, 0)) < 0) {
<br>> +        condlog(0, "Cannot get close-on-exec flag from pidfile [%s], "
<br>> +            "error was [%s]", pidFile, strerror(errno));
<br>> +        goto fail;
<br>> +    }
<br>> +    value |= FD_CLOEXEC;
<br>> +    if (fcntl(fd, F_SETFD, value) < 0) {
<br>> +        condlog(0, "Cannot set close-on-exec flag from pidfile [%s], "
<br>> +            "error was [%s]", pidFile, strerror(errno));
<br>> +        goto fail;
<br>> +    }
<br>> +    return 0;
<br>> +fail:
<br>> +    close(fd);
<br>> +    return 1;
<br>> +}
<br>> +
<br>> +int pidfile_check(const char *file)
<br>> +{
<br>> +    int fd;
<br>> +    struct flock lock;
<br>> +
<br>> +    fd = open(file, O_RDONLY);
<br>> +    if (fd < 0) {
<br>> +        if (errno == ENOENT)
<br>> +            return 0;
<br>> +        condlog(0, "Cannot open pidfile, %s : %s", file,
<br>> +                strerror(errno));
<br>> +        return -1;
<br>> +    }
<br>> +    lock.l_type = F_WRLCK;
<br>> +    lock.l_start = 0;
<br>> +    lock.l_whence = SEEK_SET;
<br>> +    lock.l_len = 0;
<br>> +
<br>> +    if (fcntl(fd, F_GETLK, &lock) < 0) {
<br>> +        condlog(0, "Cannot check lock on pidfile, %s : %s", file,
<br>> +                strerror(errno));
<br>> +        return -1;
<br>> +    }
<br>> +    close(fd);
<br>> +    if (lock.l_type == F_UNLCK)
<br>> +        return 0;
<br>> +    return 1;
<br>> +}
<br>> Index: multipath-tools-110916/libmultipath/pidfile.h
<br>> ===================================================================
<br>> --- /dev/null
<br>> +++ multipath-tools-110916/libmultipath/pidfile.h
<br>> @@ -0,0 +1,2 @@
<br>> +int pidfile_create(const char *pidFile, pid_t pid);
<br>> +int pidfile_check(const char *file);
<br>> Index: multipath-tools-110916/multipathd/Makefile
<br>> ===================================================================
<br>> --- multipath-tools-110916.orig/multipathd/Makefile
<br>> +++ multipath-tools-110916/multipathd/Makefile
<br>> @@ -19,7 +19,7 @@ LDFLAGS += -lpthread -ldevmapper -lreadl
<br>>   #
<br>>   # object files
<br>>   #
<br>> -OBJS = main.o pidfile.o uxlsnr.o uxclnt.o cli.o cli_handlers.o
<br>> +OBJS = main.o uxlsnr.o uxclnt.o cli.o cli_handlers.o
<br>>  
<br>>  
<br>>   #
<br>> Index: multipath-tools-110916/multipathd/main.c
<br>> ===================================================================
<br>> --- multipath-tools-110916.orig/multipathd/main.c
<br>> +++ multipath-tools-110916/multipathd/main.c
<br>> @@ -49,9 +49,9 @@
<br>>   #include <prio.h>
<br>>   #include <pgpolicies.h>
<br>>   #include <uevent.h>
<br>> +#include <pidfile.h>
<br>>  
<br>>   #include "main.h"
<br>> -#include "pidfile.h"
<br>>   #include "uxlsnr.h"
<br>>   #include "uxclnt.h"
<br>>   #include "cli.h"
<br><br></p>
</body>
</html>