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