|
|
4ae388 |
---
|
|
|
4ae388 |
libmultipath/checkers.c | 23 -
|
|
|
4ae388 |
libmultipath/checkers.h | 5
|
|
|
4ae388 |
libmultipath/checkers/Makefile | 7
|
|
|
4ae388 |
libmultipath/checkers/cciss_tur.c | 5
|
|
|
4ae388 |
libmultipath/checkers/directio.c | 5
|
|
|
4ae388 |
libmultipath/checkers/emc_clariion.c | 5
|
|
|
4ae388 |
libmultipath/checkers/hp_sw.c | 5
|
|
|
4ae388 |
libmultipath/checkers/rbd.c | 652 -----------------------------------
|
|
|
4ae388 |
libmultipath/checkers/rdac.c | 5
|
|
|
4ae388 |
libmultipath/checkers/readsector0.c | 5
|
|
|
4ae388 |
libmultipath/checkers/tur.c | 5
|
|
|
4ae388 |
libmultipath/discovery.c | 112 ------
|
|
|
4ae388 |
libmultipath/hwtable.c | 14
|
|
|
4ae388 |
libmultipath/structs.h | 1
|
|
|
4ae388 |
multipath.conf.annotated | 4
|
|
|
4ae388 |
multipath/multipath.conf.5 | 3
|
|
|
4ae388 |
multipathd/main.c | 13
|
|
|
4ae388 |
17 files changed, 18 insertions(+), 851 deletions(-)
|
|
|
4ae388 |
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers/rbd.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers/rbd.c
|
|
|
4ae388 |
+++ /dev/null
|
|
|
4ae388 |
@@ -1,652 +0,0 @@
|
|
|
4ae388 |
-/*
|
|
|
4ae388 |
- * Copyright (c) 2016 Red Hat
|
|
|
4ae388 |
- * Copyright (c) 2004 Christophe Varoqui
|
|
|
4ae388 |
- *
|
|
|
4ae388 |
- * Code based off of tur.c and ceph's krbd.cc
|
|
|
4ae388 |
- */
|
|
|
4ae388 |
-#define _GNU_SOURCE
|
|
|
4ae388 |
-#include <stdio.h>
|
|
|
4ae388 |
-#include <stdlib.h>
|
|
|
4ae388 |
-#include <string.h>
|
|
|
4ae388 |
-#include <unistd.h>
|
|
|
4ae388 |
-#include <fcntl.h>
|
|
|
4ae388 |
-#include <errno.h>
|
|
|
4ae388 |
-#include <pthread.h>
|
|
|
4ae388 |
-#include <libudev.h>
|
|
|
4ae388 |
-#include <ifaddrs.h>
|
|
|
4ae388 |
-#include <sys/types.h>
|
|
|
4ae388 |
-#include <sys/stat.h>
|
|
|
4ae388 |
-#include <sys/ioctl.h>
|
|
|
4ae388 |
-#include <sys/time.h>
|
|
|
4ae388 |
-#include <sys/wait.h>
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-#include "rados/librados.h"
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-#include "structs.h"
|
|
|
4ae388 |
-#include "checkers.h"
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-#include "../libmultipath/debug.h"
|
|
|
4ae388 |
-#include "../libmultipath/uevent.h"
|
|
|
4ae388 |
-#include "../libmultipath/util.h"
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-struct rbd_checker_context;
|
|
|
4ae388 |
-typedef int (thread_fn)(struct rbd_checker_context *ct, char *msg);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-#define RBD_MSG(msg, fmt, args...) snprintf(msg, CHECKER_MSG_LEN, fmt, ##args);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-#define RBD_FEATURE_EXCLUSIVE_LOCK (1 << 2)
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-struct rbd_checker_context {
|
|
|
4ae388 |
- int rbd_bus_id;
|
|
|
4ae388 |
- char *client_addr;
|
|
|
4ae388 |
- char *config_info;
|
|
|
4ae388 |
- char *snap;
|
|
|
4ae388 |
- char *pool;
|
|
|
4ae388 |
- char *image;
|
|
|
4ae388 |
- char *username;
|
|
|
4ae388 |
- int remapped;
|
|
|
4ae388 |
- int blacklisted;
|
|
|
4ae388 |
- int lock_on_read:1;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- rados_t cluster;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- int state;
|
|
|
4ae388 |
- int running;
|
|
|
4ae388 |
- time_t time;
|
|
|
4ae388 |
- thread_fn *fn;
|
|
|
4ae388 |
- pthread_t thread;
|
|
|
4ae388 |
- pthread_mutex_t lock;
|
|
|
4ae388 |
- pthread_cond_t active;
|
|
|
4ae388 |
- pthread_spinlock_t hldr_lock;
|
|
|
4ae388 |
- int holders;
|
|
|
4ae388 |
- char message[CHECKER_MSG_LEN];
|
|
|
4ae388 |
-};
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-int libcheck_init(struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- struct rbd_checker_context *ct;
|
|
|
4ae388 |
- struct udev_device *block_dev;
|
|
|
4ae388 |
- struct udev_device *bus_dev;
|
|
|
4ae388 |
- struct udev *udev;
|
|
|
4ae388 |
- struct stat sb;
|
|
|
4ae388 |
- const char *block_name, *addr, *config_info, *features_str;
|
|
|
4ae388 |
- const char *image, *pool, *snap, *username;
|
|
|
4ae388 |
- uint64_t features = 0;
|
|
|
4ae388 |
- char sysfs_path[PATH_SIZE];
|
|
|
4ae388 |
- int ret;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ct = malloc(sizeof(struct rbd_checker_context));
|
|
|
4ae388 |
- if (!ct)
|
|
|
4ae388 |
- return 1;
|
|
|
4ae388 |
- memset(ct, 0, sizeof(struct rbd_checker_context));
|
|
|
4ae388 |
- ct->holders = 1;
|
|
|
4ae388 |
- pthread_cond_init(&ct->active, NULL);
|
|
|
4ae388 |
- pthread_mutex_init(&ct->lock, NULL);
|
|
|
4ae388 |
- pthread_spin_init(&ct->hldr_lock, PTHREAD_PROCESS_PRIVATE);
|
|
|
4ae388 |
- c->context = ct;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- /*
|
|
|
4ae388 |
- * The rbd block layer sysfs device is not linked to the rbd bus
|
|
|
4ae388 |
- * device that we interact with, so figure that out now.
|
|
|
4ae388 |
- */
|
|
|
4ae388 |
- if (fstat(c->fd, &sb) != 0)
|
|
|
4ae388 |
- goto free_ct;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- udev = udev_new();
|
|
|
4ae388 |
- if (!udev)
|
|
|
4ae388 |
- goto free_ct;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- block_dev = udev_device_new_from_devnum(udev, 'b', sb.st_rdev);
|
|
|
4ae388 |
- if (!block_dev)
|
|
|
4ae388 |
- goto free_udev;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- block_name = udev_device_get_sysname(block_dev);
|
|
|
4ae388 |
- ret = sscanf(block_name, "rbd%d", &ct->rbd_bus_id);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- udev_device_unref(block_dev);
|
|
|
4ae388 |
- if (ret != 1)
|
|
|
4ae388 |
- goto free_udev;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- snprintf(sysfs_path, sizeof(sysfs_path), "/sys/bus/rbd/devices/%d",
|
|
|
4ae388 |
- ct->rbd_bus_id);
|
|
|
4ae388 |
- bus_dev = udev_device_new_from_syspath(udev, sysfs_path);
|
|
|
4ae388 |
- if (!bus_dev)
|
|
|
4ae388 |
- goto free_udev;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- addr = udev_device_get_sysattr_value(bus_dev, "client_addr");
|
|
|
4ae388 |
- if (!addr) {
|
|
|
4ae388 |
- condlog(0, "rbd%d: Could not find client_addr in rbd sysfs. "
|
|
|
4ae388 |
- "Try updating kernel", ct->rbd_bus_id);
|
|
|
4ae388 |
- goto free_dev;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ct->client_addr = strdup(addr);
|
|
|
4ae388 |
- if (!ct->client_addr)
|
|
|
4ae388 |
- goto free_dev;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- features_str = udev_device_get_sysattr_value(bus_dev, "features");
|
|
|
4ae388 |
- if (!features_str)
|
|
|
4ae388 |
- goto free_addr;
|
|
|
4ae388 |
- features = strtoll(features_str, NULL, 16);
|
|
|
4ae388 |
- if (!(features & RBD_FEATURE_EXCLUSIVE_LOCK)) {
|
|
|
4ae388 |
- condlog(3, "rbd%d: Exclusive lock not set.", ct->rbd_bus_id);
|
|
|
4ae388 |
- goto free_addr;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- config_info = udev_device_get_sysattr_value(bus_dev, "config_info");
|
|
|
4ae388 |
- if (!config_info)
|
|
|
4ae388 |
- goto free_addr;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (!strstr(config_info, "noshare")) {
|
|
|
4ae388 |
- condlog(3, "rbd%d: Only nonshared clients supported.",
|
|
|
4ae388 |
- ct->rbd_bus_id);
|
|
|
4ae388 |
- goto free_addr;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (strstr(config_info, "lock_on_read"))
|
|
|
4ae388 |
- ct->lock_on_read = 1;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ct->config_info = strdup(config_info);
|
|
|
4ae388 |
- if (!ct->config_info)
|
|
|
4ae388 |
- goto free_addr;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- username = strstr(config_info, "name=");
|
|
|
4ae388 |
- if (username) {
|
|
|
4ae388 |
- char *end;
|
|
|
4ae388 |
- int len;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- username += 5;
|
|
|
4ae388 |
- end = strchr(username, ',');
|
|
|
4ae388 |
- if (!end)
|
|
|
4ae388 |
- goto free_info;
|
|
|
4ae388 |
- len = end - username;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ct->username = malloc(len + 1);
|
|
|
4ae388 |
- if (!ct->username)
|
|
|
4ae388 |
- goto free_info;
|
|
|
4ae388 |
- strncpy(ct->username, username, len);
|
|
|
4ae388 |
- ct->username[len] = '\0';
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- image = udev_device_get_sysattr_value(bus_dev, "name");
|
|
|
4ae388 |
- if (!image)
|
|
|
4ae388 |
- goto free_username;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ct->image = strdup(image);
|
|
|
4ae388 |
- if (!ct->image)
|
|
|
4ae388 |
- goto free_info;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- pool = udev_device_get_sysattr_value(bus_dev, "pool");
|
|
|
4ae388 |
- if (!pool)
|
|
|
4ae388 |
- goto free_image;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ct->pool = strdup(pool);
|
|
|
4ae388 |
- if (!ct->pool)
|
|
|
4ae388 |
- goto free_image;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- snap = udev_device_get_sysattr_value(bus_dev, "current_snap");
|
|
|
4ae388 |
- if (!snap)
|
|
|
4ae388 |
- goto free_pool;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (strcmp("-", snap)) {
|
|
|
4ae388 |
- ct->snap = strdup(snap);
|
|
|
4ae388 |
- if (!ct->snap)
|
|
|
4ae388 |
- goto free_pool;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (rados_create(&ct->cluster, NULL) < 0) {
|
|
|
4ae388 |
- condlog(0, "rbd%d: Could not create rados cluster",
|
|
|
4ae388 |
- ct->rbd_bus_id);
|
|
|
4ae388 |
- goto free_snap;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (rados_conf_read_file(ct->cluster, NULL) < 0) {
|
|
|
4ae388 |
- condlog(0, "rbd%d: Could not read rados conf", ct->rbd_bus_id);
|
|
|
4ae388 |
- goto shutdown_rados;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ret = rados_connect(ct->cluster);
|
|
|
4ae388 |
- if (ret < 0) {
|
|
|
4ae388 |
- condlog(0, "rbd%d: Could not connect to rados cluster",
|
|
|
4ae388 |
- ct->rbd_bus_id);
|
|
|
4ae388 |
- goto shutdown_rados;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- udev_device_unref(bus_dev);
|
|
|
4ae388 |
- udev_unref(udev);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- condlog(3, "rbd%d checker init %s %s/%s@%s %s", ct->rbd_bus_id,
|
|
|
4ae388 |
- ct->client_addr, ct->pool, ct->image, ct->snap ? ct->snap : "-",
|
|
|
4ae388 |
- ct->username ? ct->username : "none");
|
|
|
4ae388 |
- return 0;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-shutdown_rados:
|
|
|
4ae388 |
- rados_shutdown(ct->cluster);
|
|
|
4ae388 |
-free_snap:
|
|
|
4ae388 |
- if (ct->snap)
|
|
|
4ae388 |
- free(ct->snap);
|
|
|
4ae388 |
-free_pool:
|
|
|
4ae388 |
- free(ct->pool);
|
|
|
4ae388 |
-free_image:
|
|
|
4ae388 |
- free(ct->image);
|
|
|
4ae388 |
-free_username:
|
|
|
4ae388 |
- if (ct->username)
|
|
|
4ae388 |
- free(ct->username);
|
|
|
4ae388 |
-free_info:
|
|
|
4ae388 |
- free(ct->config_info);
|
|
|
4ae388 |
-free_addr:
|
|
|
4ae388 |
- free(ct->client_addr);
|
|
|
4ae388 |
-free_dev:
|
|
|
4ae388 |
- udev_device_unref(bus_dev);
|
|
|
4ae388 |
-free_udev:
|
|
|
4ae388 |
- udev_unref(udev);
|
|
|
4ae388 |
-free_ct:
|
|
|
4ae388 |
- free(ct);
|
|
|
4ae388 |
- return 1;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-void cleanup_context(struct rbd_checker_context *ct)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- pthread_mutex_destroy(&ct->lock);
|
|
|
4ae388 |
- pthread_cond_destroy(&ct->active);
|
|
|
4ae388 |
- pthread_spin_destroy(&ct->hldr_lock);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- rados_shutdown(ct->cluster);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (ct->username)
|
|
|
4ae388 |
- free(ct->username);
|
|
|
4ae388 |
- if (ct->snap)
|
|
|
4ae388 |
- free(ct->snap);
|
|
|
4ae388 |
- free(ct->pool);
|
|
|
4ae388 |
- free(ct->image);
|
|
|
4ae388 |
- free(ct->config_info);
|
|
|
4ae388 |
- free(ct->client_addr);
|
|
|
4ae388 |
- free(ct);
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-void libcheck_free(struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- if (c->context) {
|
|
|
4ae388 |
- struct rbd_checker_context *ct = c->context;
|
|
|
4ae388 |
- int holders;
|
|
|
4ae388 |
- pthread_t thread;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- pthread_spin_lock(&ct->hldr_lock);
|
|
|
4ae388 |
- ct->holders--;
|
|
|
4ae388 |
- holders = ct->holders;
|
|
|
4ae388 |
- thread = ct->thread;
|
|
|
4ae388 |
- pthread_spin_unlock(&ct->hldr_lock);
|
|
|
4ae388 |
- if (holders)
|
|
|
4ae388 |
- pthread_cancel(thread);
|
|
|
4ae388 |
- else
|
|
|
4ae388 |
- cleanup_context(ct);
|
|
|
4ae388 |
- c->context = NULL;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-static int rbd_is_blacklisted(struct rbd_checker_context *ct, char *msg)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- char *addr_tok, *start, *save;
|
|
|
4ae388 |
- char *cmd[2];
|
|
|
4ae388 |
- char *blklist, *stat;
|
|
|
4ae388 |
- size_t blklist_len, stat_len;
|
|
|
4ae388 |
- int ret;
|
|
|
4ae388 |
- char *end;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- cmd[0] = "{\"prefix\": \"osd blacklist ls\"}";
|
|
|
4ae388 |
- cmd[1] = NULL;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ret = rados_mon_command(ct->cluster, (const char **)cmd, 1, "", 0,
|
|
|
4ae388 |
- &blklist, &blklist_len, &stat, &stat_len);
|
|
|
4ae388 |
- if (ret < 0) {
|
|
|
4ae388 |
- RBD_MSG(msg, "checker failed: mon command failed %d", ret);
|
|
|
4ae388 |
- return ret;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (!blklist || !blklist_len)
|
|
|
4ae388 |
- goto free_bufs;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- /*
|
|
|
4ae388 |
- * parse list of addrs with the format
|
|
|
4ae388 |
- * ipv4:port/nonce date time\n
|
|
|
4ae388 |
- * or
|
|
|
4ae388 |
- * [ipv6]:port/nonce date time\n
|
|
|
4ae388 |
- */
|
|
|
4ae388 |
- ret = 0;
|
|
|
4ae388 |
- for (start = blklist; ; start = NULL) {
|
|
|
4ae388 |
- addr_tok = strtok_r(start, "\n", &save);
|
|
|
4ae388 |
- if (!addr_tok || !strlen(addr_tok))
|
|
|
4ae388 |
- break;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- end = strchr(addr_tok, ' ');
|
|
|
4ae388 |
- if (!end) {
|
|
|
4ae388 |
- RBD_MSG(msg, "checker failed: invalid blacklist %s",
|
|
|
4ae388 |
- addr_tok);
|
|
|
4ae388 |
- break;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- *end = '\0';
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (!strcmp(addr_tok, ct->client_addr)) {
|
|
|
4ae388 |
- ct->blacklisted = 1;
|
|
|
4ae388 |
- RBD_MSG(msg, "%s is blacklisted", ct->client_addr);
|
|
|
4ae388 |
- ret = 1;
|
|
|
4ae388 |
- break;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-free_bufs:
|
|
|
4ae388 |
- rados_buffer_free(blklist);
|
|
|
4ae388 |
- rados_buffer_free(stat);
|
|
|
4ae388 |
- return ret;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-int rbd_check(struct rbd_checker_context *ct, char *msg)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- if (ct->blacklisted || rbd_is_blacklisted(ct, msg) == 1)
|
|
|
4ae388 |
- return PATH_DOWN;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- RBD_MSG(msg, "checker reports path is up");
|
|
|
4ae388 |
- /*
|
|
|
4ae388 |
- * Path may have issues, but the ceph cluster is at least
|
|
|
4ae388 |
- * accepting IO, so we can attempt to do IO.
|
|
|
4ae388 |
- *
|
|
|
4ae388 |
- * TODO: in future versions, we can run other tests to
|
|
|
4ae388 |
- * verify OSDs and networks.
|
|
|
4ae388 |
- */
|
|
|
4ae388 |
- return PATH_UP;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-static int sysfs_write_rbd_bus(const char *which, const char *buf,
|
|
|
4ae388 |
- size_t buf_len)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- char sysfs_path[PATH_SIZE];
|
|
|
4ae388 |
- int fd;
|
|
|
4ae388 |
- int r;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- /* we require newer kernels so single_major should alwayws be there */
|
|
|
4ae388 |
- snprintf(sysfs_path, sizeof(sysfs_path),
|
|
|
4ae388 |
- "/sys/bus/rbd/%s_single_major", which);
|
|
|
4ae388 |
- fd = open(sysfs_path, O_WRONLY);
|
|
|
4ae388 |
- if (fd < 0)
|
|
|
4ae388 |
- return -errno;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- r = safe_write(fd, buf, buf_len);
|
|
|
4ae388 |
- close(fd);
|
|
|
4ae388 |
- return r;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-static int rbd_remap(struct rbd_checker_context *ct)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- char *argv[11];
|
|
|
4ae388 |
- pid_t pid;
|
|
|
4ae388 |
- int ret = 0, i = 0;
|
|
|
4ae388 |
- int status;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- pid = fork();
|
|
|
4ae388 |
- switch (pid) {
|
|
|
4ae388 |
- case 0:
|
|
|
4ae388 |
- argv[i++] = "rbd";
|
|
|
4ae388 |
- argv[i++] = "map";
|
|
|
4ae388 |
- if (ct->lock_on_read)
|
|
|
4ae388 |
- argv[i++] = "-o noshare,lock_on_read";
|
|
|
4ae388 |
- else
|
|
|
4ae388 |
- argv[i++] = "-o noshare";
|
|
|
4ae388 |
- if (ct->username) {
|
|
|
4ae388 |
- argv[i++] = "--id";
|
|
|
4ae388 |
- argv[i++] = ct->username;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- argv[i++] = "--pool";
|
|
|
4ae388 |
- argv[i++] = ct->pool;
|
|
|
4ae388 |
- if (ct->snap) {
|
|
|
4ae388 |
- argv[i++] = "--snap";
|
|
|
4ae388 |
- argv[i++] = ct->snap;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- argv[i++] = ct->image;
|
|
|
4ae388 |
- argv[i] = NULL;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ret = execvp(argv[0], argv);
|
|
|
4ae388 |
- condlog(0, "rbd%d: Error executing rbd: %s", ct->rbd_bus_id,
|
|
|
4ae388 |
- strerror(errno));
|
|
|
4ae388 |
- exit(-1);
|
|
|
4ae388 |
- case -1:
|
|
|
4ae388 |
- condlog(0, "rbd%d: fork failed: %s", ct->rbd_bus_id,
|
|
|
4ae388 |
- strerror(errno));
|
|
|
4ae388 |
- return -1;
|
|
|
4ae388 |
- default:
|
|
|
4ae388 |
- ret = -1;
|
|
|
4ae388 |
- wait(&status);
|
|
|
4ae388 |
- if (WIFEXITED(status)) {
|
|
|
4ae388 |
- status = WEXITSTATUS(status);
|
|
|
4ae388 |
- if (status == 0)
|
|
|
4ae388 |
- ret = 0;
|
|
|
4ae388 |
- else
|
|
|
4ae388 |
- condlog(0, "rbd%d: failed with %d",
|
|
|
4ae388 |
- ct->rbd_bus_id, status);
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- return ret;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-static int sysfs_write_rbd_remove(const char *buf, int buf_len)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- return sysfs_write_rbd_bus("remove", buf, buf_len);
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-static int rbd_rm_blacklist(struct rbd_checker_context *ct)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- char *cmd[2];
|
|
|
4ae388 |
- char *stat, *cmd_str;
|
|
|
4ae388 |
- size_t stat_len;
|
|
|
4ae388 |
- int ret;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ret = asprintf(&cmd_str, "{\"prefix\": \"osd blacklist\", \"blacklistop\": \"rm\", \"addr\": \"%s\"}",
|
|
|
4ae388 |
- ct->client_addr);
|
|
|
4ae388 |
- if (ret == -1)
|
|
|
4ae388 |
- return -ENOMEM;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- cmd[0] = cmd_str;
|
|
|
4ae388 |
- cmd[1] = NULL;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ret = rados_mon_command(ct->cluster, (const char **)cmd, 1, "", 0,
|
|
|
4ae388 |
- NULL, 0, &stat, &stat_len);
|
|
|
4ae388 |
- if (ret < 0) {
|
|
|
4ae388 |
- condlog(1, "rbd%d: repair failed to remove blacklist for %s %d",
|
|
|
4ae388 |
- ct->rbd_bus_id, ct->client_addr, ret);
|
|
|
4ae388 |
- goto free_cmd;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- condlog(1, "rbd%d: repair rm blacklist for %s",
|
|
|
4ae388 |
- ct->rbd_bus_id, ct->client_addr);
|
|
|
4ae388 |
- free(stat);
|
|
|
4ae388 |
-free_cmd:
|
|
|
4ae388 |
- free(cmd_str);
|
|
|
4ae388 |
- return ret;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-static int rbd_repair(struct rbd_checker_context *ct, char *msg)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- char del[17];
|
|
|
4ae388 |
- int ret;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (!ct->blacklisted)
|
|
|
4ae388 |
- return PATH_UP;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (!ct->remapped) {
|
|
|
4ae388 |
- ret = rbd_remap(ct);
|
|
|
4ae388 |
- if (ret) {
|
|
|
4ae388 |
- RBD_MSG(msg, "repair failed to remap. Err %d", ret);
|
|
|
4ae388 |
- return PATH_DOWN;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- ct->remapped = 1;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- snprintf(del, sizeof(del), "%d force", ct->rbd_bus_id);
|
|
|
4ae388 |
- ret = sysfs_write_rbd_remove(del, strlen(del) + 1);
|
|
|
4ae388 |
- if (ret) {
|
|
|
4ae388 |
- RBD_MSG(msg, "repair failed to clean up. Err %d", ret);
|
|
|
4ae388 |
- return PATH_DOWN;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ret = rbd_rm_blacklist(ct);
|
|
|
4ae388 |
- if (ret) {
|
|
|
4ae388 |
- RBD_MSG(msg, "repair could not remove blacklist entry. Err %d",
|
|
|
4ae388 |
- ret);
|
|
|
4ae388 |
- return PATH_DOWN;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ct->remapped = 0;
|
|
|
4ae388 |
- ct->blacklisted = 0;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- RBD_MSG(msg, "has been repaired");
|
|
|
4ae388 |
- return PATH_UP;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-#define rbd_thread_cleanup_push(ct) pthread_cleanup_push(cleanup_func, ct)
|
|
|
4ae388 |
-#define rbd_thread_cleanup_pop(ct) pthread_cleanup_pop(1)
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-void cleanup_func(void *data)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- int holders;
|
|
|
4ae388 |
- struct rbd_checker_context *ct = data;
|
|
|
4ae388 |
- pthread_spin_lock(&ct->hldr_lock);
|
|
|
4ae388 |
- ct->holders--;
|
|
|
4ae388 |
- holders = ct->holders;
|
|
|
4ae388 |
- ct->thread = 0;
|
|
|
4ae388 |
- pthread_spin_unlock(&ct->hldr_lock);
|
|
|
4ae388 |
- if (!holders)
|
|
|
4ae388 |
- cleanup_context(ct);
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-void *rbd_thread(void *ctx)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- struct rbd_checker_context *ct = ctx;
|
|
|
4ae388 |
- int state;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- condlog(3, "rbd%d: thread starting up", ct->rbd_bus_id);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ct->message[0] = '\0';
|
|
|
4ae388 |
- /* This thread can be canceled, so setup clean up */
|
|
|
4ae388 |
- rbd_thread_cleanup_push(ct)
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- /* checker start up */
|
|
|
4ae388 |
- pthread_mutex_lock(&ct->lock);
|
|
|
4ae388 |
- ct->state = PATH_PENDING;
|
|
|
4ae388 |
- pthread_mutex_unlock(&ct->lock);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- state = ct->fn(ct, ct->message);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- /* checker done */
|
|
|
4ae388 |
- pthread_mutex_lock(&ct->lock);
|
|
|
4ae388 |
- ct->state = state;
|
|
|
4ae388 |
- pthread_mutex_unlock(&ct->lock);
|
|
|
4ae388 |
- pthread_cond_signal(&ct->active);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- condlog(3, "rbd%d: thead finished, state %s", ct->rbd_bus_id,
|
|
|
4ae388 |
- checker_state_name(state));
|
|
|
4ae388 |
- rbd_thread_cleanup_pop(ct);
|
|
|
4ae388 |
- return ((void *)0);
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-static void rbd_timeout(struct timespec *tsp)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- struct timeval now;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- gettimeofday(&now, NULL);
|
|
|
4ae388 |
- tsp->tv_sec = now.tv_sec;
|
|
|
4ae388 |
- tsp->tv_nsec = now.tv_usec * 1000;
|
|
|
4ae388 |
- tsp->tv_nsec += 1000000; /* 1 millisecond */
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-static int rbd_exec_fn(struct checker *c, thread_fn *fn)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- struct rbd_checker_context *ct = c->context;
|
|
|
4ae388 |
- struct timespec tsp;
|
|
|
4ae388 |
- pthread_attr_t attr;
|
|
|
4ae388 |
- int rbd_status, r;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (c->sync)
|
|
|
4ae388 |
- return fn(ct, c->message);
|
|
|
4ae388 |
- /*
|
|
|
4ae388 |
- * Async mode
|
|
|
4ae388 |
- */
|
|
|
4ae388 |
- r = pthread_mutex_lock(&ct->lock);
|
|
|
4ae388 |
- if (r != 0) {
|
|
|
4ae388 |
- condlog(2, "rbd%d: mutex lock failed with %d", ct->rbd_bus_id,
|
|
|
4ae388 |
- r);
|
|
|
4ae388 |
- MSG(c, "rbd%d: thread failed to initialize", ct->rbd_bus_id);
|
|
|
4ae388 |
- return PATH_WILD;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (ct->running) {
|
|
|
4ae388 |
- /* Check if checker is still running */
|
|
|
4ae388 |
- if (ct->thread) {
|
|
|
4ae388 |
- condlog(3, "rbd%d: thread not finished",
|
|
|
4ae388 |
- ct->rbd_bus_id);
|
|
|
4ae388 |
- rbd_status = PATH_PENDING;
|
|
|
4ae388 |
- } else {
|
|
|
4ae388 |
- /* checker done */
|
|
|
4ae388 |
- ct->running = 0;
|
|
|
4ae388 |
- rbd_status = ct->state;
|
|
|
4ae388 |
- strncpy(c->message, ct->message, CHECKER_MSG_LEN);
|
|
|
4ae388 |
- c->message[CHECKER_MSG_LEN - 1] = '\0';
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- pthread_mutex_unlock(&ct->lock);
|
|
|
4ae388 |
- } else {
|
|
|
4ae388 |
- /* Start new checker */
|
|
|
4ae388 |
- ct->state = PATH_UNCHECKED;
|
|
|
4ae388 |
- ct->fn = fn;
|
|
|
4ae388 |
- pthread_spin_lock(&ct->hldr_lock);
|
|
|
4ae388 |
- ct->holders++;
|
|
|
4ae388 |
- pthread_spin_unlock(&ct->hldr_lock);
|
|
|
4ae388 |
- setup_thread_attr(&attr, 32 * 1024, 1);
|
|
|
4ae388 |
- r = pthread_create(&ct->thread, &attr, rbd_thread, ct);
|
|
|
4ae388 |
- if (r) {
|
|
|
4ae388 |
- pthread_mutex_unlock(&ct->lock);
|
|
|
4ae388 |
- ct->thread = 0;
|
|
|
4ae388 |
- ct->holders--;
|
|
|
4ae388 |
- condlog(3, "rbd%d failed to start rbd thread, using sync mode",
|
|
|
4ae388 |
- ct->rbd_bus_id);
|
|
|
4ae388 |
- return fn(ct, c->message);
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- pthread_attr_destroy(&attr);
|
|
|
4ae388 |
- rbd_timeout(&tsp;;
|
|
|
4ae388 |
- r = pthread_cond_timedwait(&ct->active, &ct->lock, &tsp;;
|
|
|
4ae388 |
- rbd_status = ct->state;
|
|
|
4ae388 |
- strncpy(c->message, ct->message,CHECKER_MSG_LEN);
|
|
|
4ae388 |
- c->message[CHECKER_MSG_LEN -1] = '\0';
|
|
|
4ae388 |
- pthread_mutex_unlock(&ct->lock);
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (ct->thread &&
|
|
|
4ae388 |
- (rbd_status == PATH_PENDING || rbd_status == PATH_UNCHECKED)) {
|
|
|
4ae388 |
- condlog(3, "rbd%d: thread still running",
|
|
|
4ae388 |
- ct->rbd_bus_id);
|
|
|
4ae388 |
- ct->running = 1;
|
|
|
4ae388 |
- rbd_status = PATH_PENDING;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- return rbd_status;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-void libcheck_repair(struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- struct rbd_checker_context *ct = c->context;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (!ct || !ct->blacklisted)
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
- rbd_exec_fn(c, rbd_repair);
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-int libcheck_check(struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- struct rbd_checker_context *ct = c->context;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (!ct)
|
|
|
4ae388 |
- return PATH_UNCHECKED;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (ct->blacklisted)
|
|
|
4ae388 |
- return PATH_DOWN;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- return rbd_exec_fn(c, rbd_check);
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
Index: multipath-tools-130222/multipathd/main.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/multipathd/main.c
|
|
|
4ae388 |
+++ multipath-tools-130222/multipathd/main.c
|
|
|
4ae388 |
@@ -1291,16 +1291,6 @@ int update_path_groups(struct multipath
|
|
|
4ae388 |
return 0;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-void repair_path(struct path * pp)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- if (pp->state != PATH_DOWN)
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- checker_repair(&pp->checker);
|
|
|
4ae388 |
- if (strlen(checker_message(&pp->checker)))
|
|
|
4ae388 |
- LOG_MSG(1, checker_message(&pp->checker));
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
void
|
|
|
4ae388 |
check_path (struct vectors * vecs, struct path * pp)
|
|
|
4ae388 |
{
|
|
|
4ae388 |
@@ -1421,7 +1411,6 @@ check_path (struct vectors * vecs, struc
|
|
|
4ae388 |
pp->mpp->failback_tick = 0;
|
|
|
4ae388 |
|
|
|
4ae388 |
pp->mpp->stat_path_failures++;
|
|
|
4ae388 |
- repair_path(pp);
|
|
|
4ae388 |
return;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
@@ -1501,7 +1490,7 @@ check_path (struct vectors * vecs, struc
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
pp->state = newstate;
|
|
|
4ae388 |
- repair_path(pp);
|
|
|
4ae388 |
+
|
|
|
4ae388 |
|
|
|
4ae388 |
if (pp->mpp->wait_for_udev)
|
|
|
4ae388 |
return;
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers.c
|
|
|
4ae388 |
@@ -139,13 +139,6 @@ struct checker * add_checker (char * nam
|
|
|
4ae388 |
if (!c->free)
|
|
|
4ae388 |
goto out;
|
|
|
4ae388 |
|
|
|
4ae388 |
- c->repair = (void (*)(struct checker *)) dlsym(c->handle,
|
|
|
4ae388 |
- "libcheck_repair");
|
|
|
4ae388 |
- errstr = dlerror();
|
|
|
4ae388 |
- if (errstr != NULL)
|
|
|
4ae388 |
- condlog(0, "A dynamic linking error occurred: (%s)", errstr);
|
|
|
4ae388 |
- if (!c->repair)
|
|
|
4ae388 |
- goto out;
|
|
|
4ae388 |
done:
|
|
|
4ae388 |
c->fd = 0;
|
|
|
4ae388 |
c->sync = 1;
|
|
|
4ae388 |
@@ -214,21 +207,6 @@ void checker_put (struct checker * dst)
|
|
|
4ae388 |
free_checker(src);
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-void checker_repair (struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- if (!c || !checker_selected(c))
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- c->message[0] = '\0';
|
|
|
4ae388 |
- if (c->disable) {
|
|
|
4ae388 |
- MSG(c, "checker disabled");
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- if (c->repair)
|
|
|
4ae388 |
- c->repair(c);
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
int checker_check (struct checker * c, int path_state)
|
|
|
4ae388 |
{
|
|
|
4ae388 |
int r;
|
|
|
4ae388 |
@@ -297,7 +275,6 @@ void checker_get (struct checker * dst,
|
|
|
4ae388 |
dst->sync = src->sync;
|
|
|
4ae388 |
strncpy(dst->name, src->name, CHECKER_NAME_LEN);
|
|
|
4ae388 |
strncpy(dst->message, src->message, CHECKER_MSG_LEN);
|
|
|
4ae388 |
- dst->repair = src->repair;
|
|
|
4ae388 |
dst->check = src->check;
|
|
|
4ae388 |
dst->init = src->init;
|
|
|
4ae388 |
dst->free = src->free;
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/hwtable.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/hwtable.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/hwtable.c
|
|
|
4ae388 |
@@ -1171,20 +1171,6 @@ static struct hwentry default_hw[] = {
|
|
|
4ae388 |
.checker_name = TUR,
|
|
|
4ae388 |
.dev_loss = 30,
|
|
|
4ae388 |
},
|
|
|
4ae388 |
- {
|
|
|
4ae388 |
- /*
|
|
|
4ae388 |
- * Red Hat
|
|
|
4ae388 |
- *
|
|
|
4ae388 |
- * Maintainer: Mike Christie
|
|
|
4ae388 |
- * Mail: mchristi@redhat.com
|
|
|
4ae388 |
- */
|
|
|
4ae388 |
- .vendor = "Ceph",
|
|
|
4ae388 |
- .product = "RBD",
|
|
|
4ae388 |
- .pgpolicy = FAILOVER,
|
|
|
4ae388 |
- .no_path_retry = NO_PATH_RETRY_FAIL,
|
|
|
4ae388 |
- .checker_name = RBD,
|
|
|
4ae388 |
- .deferred_remove = DEFERRED_REMOVE_ON,
|
|
|
4ae388 |
- },
|
|
|
4ae388 |
/*
|
|
|
4ae388 |
* Generic NVMe devices
|
|
|
4ae388 |
*/
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers/Makefile
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers/Makefile
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers/Makefile
|
|
|
4ae388 |
@@ -14,17 +14,10 @@ LIBS= \
|
|
|
4ae388 |
libcheckhp_sw.so \
|
|
|
4ae388 |
libcheckrdac.so
|
|
|
4ae388 |
|
|
|
4ae388 |
-ifeq ($(shell test -r /usr/include/rados/librados.h && echo 1),1)
|
|
|
4ae388 |
-LIBS += libcheckrbd.so
|
|
|
4ae388 |
-endif
|
|
|
4ae388 |
-
|
|
|
4ae388 |
CFLAGS += -fPIC -I..
|
|
|
4ae388 |
|
|
|
4ae388 |
all: $(LIBS)
|
|
|
4ae388 |
|
|
|
4ae388 |
-libcheckrbd.so: rbd.o
|
|
|
4ae388 |
- $(CC) $(LDFLAGS) $(SHARED_FLAGS) -o $@ $^ -lrados -ludev
|
|
|
4ae388 |
-
|
|
|
4ae388 |
libcheckdirectio.so: libsg.o directio.o
|
|
|
4ae388 |
$(CC) $(LDFLAGS) $(SHARED_FLAGS) -o $@ $^ -laio
|
|
|
4ae388 |
|
|
|
4ae388 |
Index: multipath-tools-130222/multipath.conf.annotated
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/multipath.conf.annotated
|
|
|
4ae388 |
+++ multipath-tools-130222/multipath.conf.annotated
|
|
|
4ae388 |
@@ -97,7 +97,7 @@
|
|
|
4ae388 |
# # scope : multipath & multipathd
|
|
|
4ae388 |
# # desc : the default method used to determine the paths' state
|
|
|
4ae388 |
# # values : readsector0|tur|emc_clariion|hp_sw|directio|rdac|
|
|
|
4ae388 |
-# cciss_tur|hp_tur|rbd
|
|
|
4ae388 |
+# cciss_tur|hp_tur
|
|
|
4ae388 |
# # default : directio
|
|
|
4ae388 |
# #
|
|
|
4ae388 |
# path_checker directio
|
|
|
4ae388 |
@@ -493,7 +493,7 @@
|
|
|
4ae388 |
# # scope : multipathd & multipathd
|
|
|
4ae388 |
# # desc : path checking algorithm to use to check path state
|
|
|
4ae388 |
# # values : readsector0|tur|emc_clariion|hp_sw|directio|rdac|
|
|
|
4ae388 |
-# # cciss_tur|hp_tur|rbd
|
|
|
4ae388 |
+# # cciss_tur|hp_tur
|
|
|
4ae388 |
# #
|
|
|
4ae388 |
# path_checker directio
|
|
|
4ae388 |
#
|
|
|
4ae388 |
Index: multipath-tools-130222/multipath/multipath.conf.5
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/multipath/multipath.conf.5
|
|
|
4ae388 |
+++ multipath-tools-130222/multipath/multipath.conf.5
|
|
|
4ae388 |
@@ -287,9 +287,6 @@ Read the first sector with direct I/O.
|
|
|
4ae388 |
.B none
|
|
|
4ae388 |
Do not check the device, fallback to use the values retrieved from sysfs
|
|
|
4ae388 |
.TP
|
|
|
4ae388 |
-.B rbd
|
|
|
4ae388 |
-Check if the path is in the Ceph blacklist.
|
|
|
4ae388 |
-.TP
|
|
|
4ae388 |
Default value is \fIdirectio\fR.
|
|
|
4ae388 |
.RE
|
|
|
4ae388 |
.TP
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers.h
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers.h
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers.h
|
|
|
4ae388 |
@@ -76,7 +76,6 @@ enum path_check_state {
|
|
|
4ae388 |
#define READSECTOR0 "readsector0"
|
|
|
4ae388 |
#define CCISS_TUR "cciss_tur"
|
|
|
4ae388 |
#define NONE "none"
|
|
|
4ae388 |
-#define RBD "rbd"
|
|
|
4ae388 |
|
|
|
4ae388 |
#define DEFAULT_CHECKER DIRECTIO
|
|
|
4ae388 |
|
|
|
4ae388 |
@@ -107,9 +106,6 @@ struct checker {
|
|
|
4ae388 |
multipath-wide. Use MALLOC if
|
|
|
4ae388 |
you want to stuff data in. */
|
|
|
4ae388 |
int (*check)(struct checker *);
|
|
|
4ae388 |
- void (*repair)(struct checker *); /* called if check returns
|
|
|
4ae388 |
- PATH_DOWN to bring path into
|
|
|
4ae388 |
- usable state */
|
|
|
4ae388 |
int (*init)(struct checker *); /* to allocate the context */
|
|
|
4ae388 |
void (*free)(struct checker *); /* to free the context */
|
|
|
4ae388 |
};
|
|
|
4ae388 |
@@ -129,7 +125,6 @@ void checker_set_async (struct checker *
|
|
|
4ae388 |
void checker_set_fd (struct checker *, int);
|
|
|
4ae388 |
void checker_enable (struct checker *);
|
|
|
4ae388 |
void checker_disable (struct checker *);
|
|
|
4ae388 |
-void checker_repair (struct checker *);
|
|
|
4ae388 |
int checker_check (struct checker *, int);
|
|
|
4ae388 |
int checker_selected (struct checker *);
|
|
|
4ae388 |
char * checker_name (struct checker *);
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers/cciss_tur.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers/cciss_tur.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers/cciss_tur.c
|
|
|
4ae388 |
@@ -63,11 +63,6 @@ void libcheck_free (struct checker * c)
|
|
|
4ae388 |
return;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-void libcheck_repair (struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
extern int
|
|
|
4ae388 |
libcheck_check (struct checker * c)
|
|
|
4ae388 |
{
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers/directio.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers/directio.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers/directio.c
|
|
|
4ae388 |
@@ -116,11 +116,6 @@ void libcheck_free (struct checker * c)
|
|
|
4ae388 |
free(ct);
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-void libcheck_repair (struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
static int
|
|
|
4ae388 |
check_state(int fd, struct directio_context *ct, int sync, int timeout_secs)
|
|
|
4ae388 |
{
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers/emc_clariion.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers/emc_clariion.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers/emc_clariion.c
|
|
|
4ae388 |
@@ -90,11 +90,6 @@ void libcheck_free (struct checker * c)
|
|
|
4ae388 |
free(c->context);
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-void libcheck_repair (struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
int libcheck_check (struct checker * c)
|
|
|
4ae388 |
{
|
|
|
4ae388 |
unsigned char sense_buffer[128] = { 0, };
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers/hp_sw.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers/hp_sw.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers/hp_sw.c
|
|
|
4ae388 |
@@ -44,11 +44,6 @@ void libcheck_free (struct checker * c)
|
|
|
4ae388 |
return;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-void libcheck_repair (struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
static int
|
|
|
4ae388 |
do_inq(int sg_fd, int cmddt, int evpd, unsigned int pg_op,
|
|
|
4ae388 |
void *resp, int mx_resp_len, int noisy, unsigned int timeout)
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers/rdac.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers/rdac.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers/rdac.c
|
|
|
4ae388 |
@@ -139,11 +139,6 @@ void libcheck_free (struct checker * c)
|
|
|
4ae388 |
return;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-void libcheck_repair (struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
static int
|
|
|
4ae388 |
do_inq(int sg_fd, unsigned int pg_op, void *resp, int mx_resp_len,
|
|
|
4ae388 |
unsigned int timeout)
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers/readsector0.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers/readsector0.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers/readsector0.c
|
|
|
4ae388 |
@@ -23,11 +23,6 @@ void libcheck_free (struct checker * c)
|
|
|
4ae388 |
return;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-void libcheck_repair (struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
int libcheck_check (struct checker * c)
|
|
|
4ae388 |
{
|
|
|
4ae388 |
unsigned char buf[4096];
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/checkers/tur.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/checkers/tur.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/checkers/tur.c
|
|
|
4ae388 |
@@ -187,11 +187,6 @@ void libcheck_free (struct checker * c)
|
|
|
4ae388 |
return;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-void libcheck_repair (struct checker * c)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- return;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
#define TUR_MSG(msg, fmt, args...) snprintf(msg, CHECKER_MSG_LEN, fmt, ##args);
|
|
|
4ae388 |
|
|
|
4ae388 |
int
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/discovery.c
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/discovery.c
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/discovery.c
|
|
|
4ae388 |
@@ -922,21 +922,6 @@ nvme_sysfs_pathinfo (struct path * pp)
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
static int
|
|
|
4ae388 |
-rbd_sysfs_pathinfo (struct path * pp)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- sprintf(pp->vendor_id, "Ceph");
|
|
|
4ae388 |
- sprintf(pp->product_id, "RBD");
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- condlog(3, "%s: vendor = %s product = %s", pp->dev, pp->vendor_id,
|
|
|
4ae388 |
- pp->product_id);
|
|
|
4ae388 |
- /*
|
|
|
4ae388 |
- * set the hwe configlet pointer
|
|
|
4ae388 |
- */
|
|
|
4ae388 |
- pp->hwe = find_hwe(conf->hwtable, pp->vendor_id, pp->product_id, NULL);
|
|
|
4ae388 |
- return 0;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-static int
|
|
|
4ae388 |
ccw_sysfs_pathinfo (struct path * pp)
|
|
|
4ae388 |
{
|
|
|
4ae388 |
struct udev_device *parent;
|
|
|
4ae388 |
@@ -1151,8 +1136,6 @@ sysfs_pathinfo(struct path * pp)
|
|
|
4ae388 |
pp->bus = SYSFS_BUS_CCW;
|
|
|
4ae388 |
if (!strncmp(pp->dev,"sd", 2))
|
|
|
4ae388 |
pp->bus = SYSFS_BUS_SCSI;
|
|
|
4ae388 |
- if (!strncmp(pp->dev,"rbd", 3))
|
|
|
4ae388 |
- pp->bus = SYSFS_BUS_RBD;
|
|
|
4ae388 |
if (!strncmp(pp->dev,"nvme", 4))
|
|
|
4ae388 |
pp->bus = SYSFS_BUS_NVME;
|
|
|
4ae388 |
|
|
|
4ae388 |
@@ -1167,9 +1150,6 @@ sysfs_pathinfo(struct path * pp)
|
|
|
4ae388 |
} else if (pp->bus == SYSFS_BUS_CCISS) {
|
|
|
4ae388 |
if (cciss_sysfs_pathinfo(pp))
|
|
|
4ae388 |
return 1;
|
|
|
4ae388 |
- } else if (pp->bus == SYSFS_BUS_RBD) {
|
|
|
4ae388 |
- if (rbd_sysfs_pathinfo(pp))
|
|
|
4ae388 |
- return 1;
|
|
|
4ae388 |
} else if (pp->bus == SYSFS_BUS_NVME) {
|
|
|
4ae388 |
if (nvme_sysfs_pathinfo(pp))
|
|
|
4ae388 |
return 1;
|
|
|
4ae388 |
@@ -1275,55 +1255,6 @@ get_prio (struct path * pp)
|
|
|
4ae388 |
return 0;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
-static int
|
|
|
4ae388 |
-get_rbd_uid(struct path * pp)
|
|
|
4ae388 |
-{
|
|
|
4ae388 |
- struct udev_device *rbd_bus_dev;
|
|
|
4ae388 |
- int ret, rbd_bus_id;
|
|
|
4ae388 |
- const char *pool, *image, *snap;
|
|
|
4ae388 |
- char sysfs_path[PATH_SIZE];
|
|
|
4ae388 |
- uint64_t snap_id, max_snap_id = -3;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ret = sscanf(pp->dev, "rbd%d", &rbd_bus_id);
|
|
|
4ae388 |
- if (ret != 1)
|
|
|
4ae388 |
- return -EINVAL;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- snprintf(sysfs_path, sizeof(sysfs_path), "/sys/bus/rbd/devices/%d",
|
|
|
4ae388 |
- rbd_bus_id);
|
|
|
4ae388 |
- rbd_bus_dev = udev_device_new_from_syspath(conf->udev, sysfs_path);
|
|
|
4ae388 |
- if (!rbd_bus_dev)
|
|
|
4ae388 |
- return -ENODEV;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- ret = -EINVAL;
|
|
|
4ae388 |
- pool = udev_device_get_sysattr_value(rbd_bus_dev, "pool_id");
|
|
|
4ae388 |
- if (!pool)
|
|
|
4ae388 |
- goto free_dev;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- image = udev_device_get_sysattr_value(rbd_bus_dev, "image_id");
|
|
|
4ae388 |
- if (!image)
|
|
|
4ae388 |
- goto free_dev;
|
|
|
4ae388 |
-
|
|
|
4ae388 |
- snap = udev_device_get_sysattr_value(rbd_bus_dev, "snap_id");
|
|
|
4ae388 |
- if (!snap)
|
|
|
4ae388 |
- goto free_dev;
|
|
|
4ae388 |
- snap_id = strtoull(snap, NULL, 19);
|
|
|
4ae388 |
- if (snap_id >= max_snap_id)
|
|
|
4ae388 |
- ret = snprintf(pp->wwid, WWID_SIZE, "%s-%s", pool, image);
|
|
|
4ae388 |
- else
|
|
|
4ae388 |
- ret = snprintf(pp->wwid, WWID_SIZE, "%s-%s-%s", pool,
|
|
|
4ae388 |
- image, snap);
|
|
|
4ae388 |
- if (ret < WWID_SIZE) {
|
|
|
4ae388 |
- ret = 0;
|
|
|
4ae388 |
- } else {
|
|
|
4ae388 |
- condlog(0, "%s: wwid overflow", pp->dev);
|
|
|
4ae388 |
- ret = -EOVERFLOW;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
-
|
|
|
4ae388 |
-free_dev:
|
|
|
4ae388 |
- udev_device_unref(rbd_bus_dev);
|
|
|
4ae388 |
- return ret;
|
|
|
4ae388 |
-}
|
|
|
4ae388 |
-
|
|
|
4ae388 |
/*
|
|
|
4ae388 |
* Mangle string of length *len starting at start
|
|
|
4ae388 |
* by removing character sequence "00" (hex for a 0 byte),
|
|
|
4ae388 |
@@ -1405,7 +1336,6 @@ get_uid (struct path * pp, struct udev_d
|
|
|
4ae388 |
{
|
|
|
4ae388 |
char *c;
|
|
|
4ae388 |
const char *value;
|
|
|
4ae388 |
- int ret;
|
|
|
4ae388 |
|
|
|
4ae388 |
if (!pp->uid_attribute)
|
|
|
4ae388 |
select_getuid(pp);
|
|
|
4ae388 |
@@ -1416,34 +1346,22 @@ get_uid (struct path * pp, struct udev_d
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
memset(pp->wwid, 0, WWID_SIZE);
|
|
|
4ae388 |
- if (pp->bus == SYSFS_BUS_RBD) {
|
|
|
4ae388 |
- ret = get_rbd_uid(pp);
|
|
|
4ae388 |
- if (ret) {
|
|
|
4ae388 |
- condlog(1, "%s: failed to get sysfs uid: %s",
|
|
|
4ae388 |
- pp->dev, strerror(-ret));
|
|
|
4ae388 |
- pp->missing_udev_info = INFO_MISSING;
|
|
|
4ae388 |
- pp->tick = conf->retrigger_delay;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
+ value = udev_device_get_property_value(udev, pp->uid_attribute);
|
|
|
4ae388 |
+ if ((!value || strlen(value) == 0) && conf->cmd == CMD_VALID_PATH)
|
|
|
4ae388 |
+ value = getenv(pp->uid_attribute);
|
|
|
4ae388 |
+ if (value && strlen(value)) {
|
|
|
4ae388 |
+ size_t len = strlcpy(pp->wwid, value, WWID_SIZE);
|
|
|
4ae388 |
+ if (len > WWID_SIZE &&
|
|
|
4ae388 |
+ !fix_broken_nvme_wwid(pp, value, WWID_SIZE))
|
|
|
4ae388 |
+ condlog(0, "%s: wwid overflow", pp->dev);
|
|
|
4ae388 |
+ condlog(4, "%s: got wwid of '%s'", pp->dev, pp->wwid);
|
|
|
4ae388 |
+ pp->missing_udev_info = INFO_OK;
|
|
|
4ae388 |
+ pp->tick = 0;
|
|
|
4ae388 |
} else {
|
|
|
4ae388 |
- value = udev_device_get_property_value(udev,
|
|
|
4ae388 |
- pp->uid_attribute);
|
|
|
4ae388 |
- if ((!value || strlen(value) == 0) &&
|
|
|
4ae388 |
- conf->cmd == CMD_VALID_PATH)
|
|
|
4ae388 |
- value = getenv(pp->uid_attribute);
|
|
|
4ae388 |
- if (value && strlen(value)) {
|
|
|
4ae388 |
- size_t len = strlcpy(pp->wwid, value, WWID_SIZE);
|
|
|
4ae388 |
- if (len > WWID_SIZE &&
|
|
|
4ae388 |
- !fix_broken_nvme_wwid(pp, value, WWID_SIZE))
|
|
|
4ae388 |
- condlog(0, "%s: wwid overflow", pp->dev);
|
|
|
4ae388 |
- condlog(4, "%s: got wwid of '%s'", pp->dev, pp->wwid);
|
|
|
4ae388 |
- pp->missing_udev_info = INFO_OK;
|
|
|
4ae388 |
- pp->tick = 0;
|
|
|
4ae388 |
- } else {
|
|
|
4ae388 |
- condlog(3, "%s: no %s attribute", pp->dev,
|
|
|
4ae388 |
- pp->uid_attribute);
|
|
|
4ae388 |
- pp->missing_udev_info = INFO_MISSING;
|
|
|
4ae388 |
- pp->tick = conf->retrigger_delay;
|
|
|
4ae388 |
- }
|
|
|
4ae388 |
+ condlog(3, "%s: no %s attribute", pp->dev,
|
|
|
4ae388 |
+ pp->uid_attribute);
|
|
|
4ae388 |
+ pp->missing_udev_info = INFO_MISSING;
|
|
|
4ae388 |
+ pp->tick = conf->retrigger_delay;
|
|
|
4ae388 |
}
|
|
|
4ae388 |
|
|
|
4ae388 |
/* Strip any trailing blanks */
|
|
|
4ae388 |
Index: multipath-tools-130222/libmultipath/structs.h
|
|
|
4ae388 |
===================================================================
|
|
|
4ae388 |
--- multipath-tools-130222.orig/libmultipath/structs.h
|
|
|
4ae388 |
+++ multipath-tools-130222/libmultipath/structs.h
|
|
|
4ae388 |
@@ -60,7 +60,6 @@ enum sysfs_buses {
|
|
|
4ae388 |
SYSFS_BUS_IDE,
|
|
|
4ae388 |
SYSFS_BUS_CCW,
|
|
|
4ae388 |
SYSFS_BUS_CCISS,
|
|
|
4ae388 |
- SYSFS_BUS_RBD,
|
|
|
4ae388 |
SYSFS_BUS_NVME,
|
|
|
4ae388 |
};
|
|
|
4ae388 |
|