FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 09-17-2011, 03:01 AM
Benjamin Marzinski
 
Default multipath: don't set queue_if_no_path without multipathd

If multipathd is not running, when all paths to a device have failed, there's
no way for them to automatically get restored. If the device is set to queue,
whatever is accessing it will hang forever. This can lead to problems if it
happens at boot-up. This patch unsets queue_if_no_path for all devices created
when multipathd is not running. When multipathd starts, it will automatically
get reset queue_if_no_path to the proper value. This new behaviour can be
overridden using the new "-q" option to multipath.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/config.h | 1 +
libmultipath/configure.c | 13 ++++++++++++-
libmultipath/file.c | 32 ++++++++++++++++++++++++++++++++
libmultipath/file.h | 1 +
multipath/main.c | 8 ++++++--
5 files changed, 52 insertions(+), 3 deletions(-)

Index: multipath-tools-110831/libmultipath/config.h
================================================== =================
--- multipath-tools-110831.orig/libmultipath/config.h
+++ multipath-tools-110831/libmultipath/config.h
@@ -93,6 +93,7 @@ struct config {
int fast_io_fail;
unsigned int dev_loss;
int find_multipaths;
+ int allow_queueing;
uid_t uid;
gid_t gid;
mode_t mode;
Index: multipath-tools-110831/libmultipath/configure.c
================================================== =================
--- multipath-tools-110831.orig/libmultipath/configure.c
+++ multipath-tools-110831/libmultipath/configure.c
@@ -36,6 +36,7 @@
#include "prio.h"
#include "util.h"
#include "finder.h"
+#include "file.h"

extern int
setup_map (struct multipath * mpp, char * params, int params_size)
@@ -569,7 +570,17 @@ coalesce_paths (struct vectors * vecs, v
if (r == DOMAP_DRY)
continue;

- if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) {
+ if (!conf->daemon && !conf->allow_queueing &&
+ !pidfile_check(DEFAULT_PIDFILE)) {
+ 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 if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) {
if (mpp->no_path_retry == NO_PATH_RETRY_FAIL) {
condlog(3, "%s: unset queue_if_no_path feature",
mpp->alias);
Index: multipath-tools-110831/multipath/main.c
================================================== =================
--- multipath-tools-110831.orig/multipath/main.c
+++ multipath-tools-110831/multipath/main.c
@@ -80,7 +80,7 @@ usage (char * progname)
{
fprintf (stderr, VERSION_STRING);
fprintf (stderr, "Usage:
");
- fprintf (stderr, " %s [-c] [-d] [-r] [-v lvl] [-p pol] [-b fil] [dev]
", progname);
+ fprintf (stderr, " %s [-c] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]
", progname);
fprintf (stderr, " %s -l|-ll|-f [-v lvl] [-b fil] [dev]
", progname);
fprintf (stderr, " %s -F [-v lvl]
", progname);
fprintf (stderr, " %s -t
", progname);
@@ -94,6 +94,7 @@ usage (char * progname)
" -f flush a multipath device map
"
" -F flush all multipath device maps
"
" -c check if a device should be a path in a multipath device
"
+ " -q allow queue_if_no_path when multipathd is not running
"
" -d dry run, do not create or update devmaps
"
" -t dump internal hardware table
"
" -r force devmap reload
"
@@ -413,7 +414,7 @@ main (int argc, char *argv[])
condlog(0, "multipath tools need sysfs mounted");
exit(1);
}
- while ((arg = getopt(argc, argv, ":dchl::FfM:v:b:Brt")) != EOF ) {
+ while ((arg = getopt(argc, argv, ":dchl::FfM:v:b:Brtq")) != EOF ) {
switch(arg) {
case 1: printf("optarg : %s
",optarg);
break;
@@ -433,6 +434,9 @@ main (int argc, char *argv[])
case 'c':
conf->dry_run = 2;
break;
+ case 'q':
+ conf->allow_queueing = 1;
+ break;
case 'd':
if (!conf->dry_run)
conf->dry_run = 1;
Index: multipath-tools-110831/libmultipath/file.c
================================================== =================
--- multipath-tools-110831.orig/libmultipath/file.c
+++ multipath-tools-110831/libmultipath/file.c
@@ -176,3 +176,35 @@ fail:
close(fd);
return -1;
}
+
+int pidfile_check(const char *file)
+{
+ int fd;
+ struct flock lock;
+
+ fd = open(file, O_RDONLY);
+ if (fd < 0) {
+ if (errno == ENOENT)
+ return 0;
+ condlog(0, "Cannot open pidfile, %s : %s", file,
+ strerror(errno));
+ return -1;
+ }
+ 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, "Cannot check lock on pidfile, %s : %s", file,
+ strerror(errno));
+ return -1;
+ }
+ close(fd);
+ if (lock.l_type == F_UNLCK)
+ return 0;
+ return 1;
+}
+
+
+
Index: multipath-tools-110831/libmultipath/file.h
================================================== =================
--- multipath-tools-110831.orig/libmultipath/file.h
+++ multipath-tools-110831/libmultipath/file.h
@@ -7,5 +7,6 @@

#define FILE_TIMEOUT 30
int open_file(char *file, int *can_write, char *header);
+int pidfile_check(const char *file);

#endif /* _FILE_H */

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 
Old 09-26-2011, 02:50 PM
Benjamin Marzinski
 
Default multipath: don't set queue_if_no_path without multipathd

If multipathd is not running, when all paths to a device have failed, there's
no way for them to automatically get restored. If the device is set to queue,
whatever is accessing it will hang forever. This can lead to problems if it
happens at boot-up. This patch unsets queue_if_no_path for all devices created
when multipathd is not running. When multipathd starts, it will automatically
get reset queue_if_no_path to the proper value. This new behaviour can be
overridden using the new "-q" option to multipath.

This version of the patch contacts multipathd's client socket to tell if it's
running.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/config.h | 1 +
libmultipath/configure.c | 40 +++++++++++++++++++++++++++++++++++++++-
multipath/main.c | 8 ++++++--
3 files changed, 46 insertions(+), 3 deletions(-)

Index: multipath-tools-110916/libmultipath/config.h
================================================== =================
--- multipath-tools-110916.orig/libmultipath/config.h
+++ multipath-tools-110916/libmultipath/config.h
@@ -92,6 +92,7 @@ struct config {
int attribute_flags;
int fast_io_fail;
unsigned int dev_loss;
+ int allow_queueing;
uid_t uid;
gid_t gid;
mode_t mode;
Index: multipath-tools-110916/libmultipath/configure.c
================================================== =================
--- multipath-tools-110916.orig/libmultipath/configure.c
+++ multipath-tools-110916/libmultipath/configure.c
@@ -35,6 +35,7 @@
#include "alias.h"
#include "prio.h"
#include "util.h"
+#include "uxsock.h"

extern int
setup_map (struct multipath * mpp, char * params, int params_size)
@@ -448,6 +449,34 @@ deadmap (struct multipath * mpp)
return 1; /* dead */
}

+int check_daemon(void)
+{
+ int fd;
+ char *reply;
+ size_t len;
+ int ret = 0;
+
+ fd = ux_socket_connect(DEFAULT_SOCKET);
+ if (fd == -1)
+ return 0;
+
+ if (send_packet(fd, "show daemon", 12) != 0)
+ goto out;
+ if (recv_packet(fd, &reply, &len) != 0)
+ goto out;
+
+ if (strstr(reply, "shutdown"))
+ goto out_free;
+
+ ret = 1;
+
+out_free:
+ FREE(reply);
+out:
+ close(fd);
+ return ret;
+}
+
extern int
coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_reload)
{
@@ -555,7 +584,16 @@ coalesce_paths (struct vectors * vecs, v
if (r == DOMAP_DRY)
continue;

- if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) {
+ if (!conf->daemon && !conf->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");
+ }
+ else if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) {
if (mpp->no_path_retry == NO_PATH_RETRY_FAIL) {
condlog(3, "%s: unset queue_if_no_path feature",
mpp->alias);
Index: multipath-tools-110916/multipath/main.c
================================================== =================
--- multipath-tools-110916.orig/multipath/main.c
+++ multipath-tools-110916/multipath/main.c
@@ -79,7 +79,7 @@ usage (char * progname)
{
fprintf (stderr, VERSION_STRING);
fprintf (stderr, "Usage:
");
- fprintf (stderr, " %s [-d] [-r] [-v lvl] [-p pol] [-b fil] [dev]
", progname);
+ fprintf (stderr, " %s [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]
", progname);
fprintf (stderr, " %s -l|-ll|-f [-v lvl] [-b fil] [dev]
", progname);
fprintf (stderr, " %s -F [-v lvl]
", progname);
fprintf (stderr, " %s -t
", progname);
@@ -92,6 +92,7 @@ usage (char * progname)
" -ll show multipath topology (maximum info)
"
" -f flush a multipath device map
"
" -F flush all multipath device maps
"
+ " -q allow queue_if_no_path when multipathd is not running
"
" -d dry run, do not create or update devmaps
"
" -t dump internal hardware table
"
" -r force devmap reload
"
@@ -397,7 +398,7 @@ main (int argc, char *argv[])
condlog(0, "multipath tools need sysfs mounted");
exit(1);
}
- while ((arg = getopt(argc, argv, ":dhl::FfM:v:b:Brt")) != EOF ) {
+ while ((arg = getopt(argc, argv, ":dhl::FfM:v:b:Brtq")) != EOF ) {
switch(arg) {
case 1: printf("optarg : %s
",optarg);
break;
@@ -414,6 +415,9 @@ main (int argc, char *argv[])
case 'B':
conf->bindings_read_only = 1;
break;
+ case 'q':
+ conf->allow_queueing = 1;
+ break;
case 'd':
conf->dry_run = 1;
break;

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 

Thread Tools




All times are GMT. The time now is 07:03 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org