Skip to content

Commit

Permalink
Merge branch 'cjd3000-dog-force-alter-copy'
Browse files Browse the repository at this point in the history
  • Loading branch information
mitake committed Sep 19, 2015
2 parents b856eb0 + 95b2300 commit 50793c7
Show file tree
Hide file tree
Showing 24 changed files with 231 additions and 63 deletions.
8 changes: 4 additions & 4 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Run-time dependencies
Compile-time dependencies
-------------------------
* GNU Autotools
* corosync devel package
* liburcu devel package
* git
* corosync devel package (needed for building cluster using corosync)
* liburcu (userspace rcu) devel package
* optional:fuse-devel (for sheepfs)
* optional:libzookeeper-mt-dev (for zookeeper support)
* optional:libzookeeper-mt-dev (needed for building cluster using zookeeper)
* optional:curl, fcgi (for http request service)

Installing from source
------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ Debian related stuff
M: Alexander Guy <alexander@andern.org>
F: debian/*
L: sheepdog@lists.wpkg.org

Intel Intelligent Storage Acceleration Library
------------------------------
M: hongzhou zhang <hongzhou.h.zhang@intel.com>
F: lib/isa-l/*
L: sheepdog@lists.wpkg.org
31 changes: 25 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@ AC_CHECK_PROGS([GROFF], [groff])

AM_MISSING_PROG(AUTOM4TE, autom4te, $missing_dir)

# Check for programs
if [[[ $host = *x86_64* ]]]; then
AC_CHECK_PROG(HAVE_YASM, yasm, yes, no)
if test "$HAVE_YASM" = "no"; then
AC_MSG_ERROR([yasm not found as required.])
fi
AC_MSG_CHECKING([checking yasm version])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[vextracti128 xmm0, ymm0, 0;]])])
if yasm -f elf64 -i lib/isa-l/include lib/isa-l/erasure_code/gf_vect_dot_prod_avx2.asm -o /dev/null 2> /dev/null ; then
yasm_avx2_support=yes
AC_DEFINE_UNQUOTED([ENABLE_ISAL], 1, [enable isal])
AC_MSG_RESULT([yes])
else
yasm_avx2_support=no
AC_MSG_NOTICE([avx2 requires yasm 1.2.0 or higher])
fi
fi
AM_CONDITIONAL(YASM_AVX2_SUPPORT, test "$yasm_avx2_support" = "yes")

# Checks for libraries.
AC_CHECK_LIB([socket], [socket])
AC_CHECK_LIB([rt], [clock_gettime], , AC_MSG_ERROR(librt not found))
Expand Down Expand Up @@ -250,27 +269,27 @@ AC_ARG_ENABLE([sheepfs],
AM_CONDITIONAL(BUILD_SHEEPFS, test x$enable_sheepfs = xyes)

AC_ARG_ENABLE([http],
[ --enable-http : enable http request service (default no) ],,
[ --enable-http : enable http request service (default no) ],,
[ enable_http="no" ],)
AM_CONDITIONAL(BUILD_HTTP, test x$enable_http = xyes)

AC_ARG_ENABLE([nfs],
[ --enable-nfs : enable nfs server service (default no) ],,
[ --enable-nfs : enable nfs server service (default no) ],,
[ enable_nfs="no" ],)
AM_CONDITIONAL(BUILD_NFS, test x$enable_nfs = xyes)

AC_ARG_ENABLE([diskvnodes],
[ --enable-diskvnodes : enable disk as vnodes (default no) ],,
[ --enable-diskvnodes : enable disk as vnodes (default no) ],,
[ enable_diskvnodes="no" ],)
AM_CONDITIONAL(BUILD_DISKVNODES, test x$enable_diskvnodes = xyes)

AC_ARG_ENABLE([earthquake],
[ --enable-earthquake : enable earthquake debugger (default no) ],,
[ --enable-earthquake : enable earthquake debugger (default no) ],,
[ enable_earthquake="no" ],)
AM_CONDITIONAL(BUILD_EARTHQUAKE, test x$enable_earthquake = xyes)

AC_ARG_ENABLE([lttng-ust],
[ --enable-lttng-ust : enable tracing feature based on LTTng UST (default no) ],,
[ --enable-lttng-ust : enable tracing feature based on LTTng UST (default no) ],,
[ enable_lttng_ust="no" ],)
AM_CONDITIONAL(BUILD_LTTNG_UST, test x$enable_lttng_ust = xyes)

Expand Down Expand Up @@ -509,7 +528,7 @@ fi
if test "x${enable_trace}" = xyes && \
cc_supports_flag -pg ; then
AC_MSG_NOTICE([Enabling trace (-pg)])
TRACE_CFLAGS="-pg"
TRACE_CFLAGS="-pg -nopie"
else
TRACE_CFLAGS=""
fi
Expand Down
7 changes: 4 additions & 3 deletions dog/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ static int cluster_alter_copy(int argc, char **argv)
"use %d as default.\n", SD_DEFAULT_COPIES);
}

if (cluster_cmd_data.copies > sd_nodes_nr) {
if (!cluster_cmd_data.force && (cluster_cmd_data.copies > sd_nodes_nr)) {
char info[1024];
snprintf(info, sizeof(info), "Number of copies (%d) is larger "
"than number of nodes (%d).\n"
Expand Down Expand Up @@ -865,7 +865,8 @@ static int cluster_alter_copy(int argc, char **argv)
goto failure;
}

confirm(ALTER_CLUSTER_COPY_PRINT);
if (!cluster_cmd_data.force)
confirm(ALTER_CLUSTER_COPY_PRINT);

sd_init_req(&hdr, SD_OP_ALTER_CLUSTER_COPY);
hdr.cluster.copies = cluster_cmd_data.copies;
Expand Down Expand Up @@ -908,7 +909,7 @@ static struct subcommand cluster_cmd[] = {
cluster_reweight, cluster_options},
{"check", NULL, "aphT", "check and repair cluster", NULL,
CMD_NEED_ROOT|CMD_NEED_NODELIST, cluster_check, cluster_options},
{"alter-copy", NULL, "aphTc", "set the cluster's redundancy level",
{"alter-copy", NULL, "aphTcf", "set the cluster's redundancy level",
NULL, CMD_NEED_ROOT|CMD_NEED_NODELIST, cluster_alter_copy, cluster_options},
{NULL,},
};
Expand Down
2 changes: 2 additions & 0 deletions dog/dog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include "sheepdog_proto.h"
#include "sheep.h"
Expand Down
64 changes: 64 additions & 0 deletions dog/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,67 @@ static int node_vnodes(int argc, char **argv)
return do_generic_subcommand(node_vnodes_cmd, argc, argv);
}

static int node_format(int argc, char **argv)
{
char *dir = argv[optind++], *store_name;
char config_path[PATH_MAX];
struct stat st;
int ret, fd;
struct node_info info;

/*
* TODO: for more safe operation, this command should acquire lock which
* is shared with sheep process
*/

if (optind == argc) {
sd_err("specify store format");
return EXIT_USAGE;
}
store_name = argv[optind];

if (strcmp(store_name, "plain") && strcmp(store_name, "tree")) {
/*
* FIXME: store names should be macro defined in somewhere
* suitable
*/
sd_err("expected store format: plain, tree");
return EXIT_SYSFAIL;
}

memset(config_path, 0, sizeof(config_path));
snprintf(config_path, PATH_MAX, "%s/" NODE_CONFIG_PATH, dir);

ret = stat(config_path, &st);
if (ret < 0) {
if (errno != ENOENT) {
sd_err("failed to check existence of config (%s): %m",
config_path);
return EXIT_SYSFAIL;
}
} else {
/* TODO: dialogue and force option? */
sd_err("config file already exists: %s", config_path);
return EXIT_SYSFAIL;
}

fd = open(config_path, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
if (fd < 0) {
sd_err("failed to create a config file (%s): %m", config_path);
return EXIT_SYSFAIL;
}

memset(&info, 0, sizeof(info));
memcpy(info.store, store_name, STORE_LEN);
ret = xwrite(fd, &info, sizeof(info));
if (ret != sizeof(info)) {
sd_err("failed to write a config file (%s): %m", config_path);
return EXIT_SYSFAIL;
}

return 0;
}

static struct subcommand node_cmd[] = {
{"kill", "<node id>", "aprhlT", "kill node", NULL,
CMD_NEED_ROOT|CMD_NEED_NODELIST, node_kill, node_options},
Expand All @@ -847,6 +908,9 @@ static struct subcommand node_cmd[] = {
CMD_NEED_ROOT|CMD_NEED_ARG, node_log},
{"vnodes", "<num of vnodes>", "aph", "set new vnodes", node_vnodes_cmd,
CMD_NEED_ROOT|CMD_NEED_ARG, node_vnodes},
{"format", "<directory of sheep> <a name of store format>",
"aphT", "initialize store format of the node", NULL, CMD_NEED_ARG,
node_format},
{NULL,},
};

Expand Down
7 changes: 4 additions & 3 deletions dog/vdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2930,7 +2930,7 @@ static int vdi_alter_copy(int argc, char **argv)
"use %d as default.\n", SD_DEFAULT_COPIES);
}

if (vdi_cmd_data.nr_copies > sd_nodes_nr) {
if (!vdi_cmd_data.force && (vdi_cmd_data.nr_copies > sd_nodes_nr)) {
char info[1024];
snprintf(info, sizeof(info), "Number of copies (%d) is larger "
"than number of nodes (%d).\n"
Expand Down Expand Up @@ -2966,7 +2966,8 @@ static int vdi_alter_copy(int argc, char **argv)
return EXIT_FAILURE;
}

confirm(ALTER_VDI_COPY_PRINT);
if (!vdi_cmd_data.force)
confirm(ALTER_VDI_COPY_PRINT);

inode->nr_copies = vdi_cmd_data.nr_copies;
ret = dog_write_object(vid_to_vdi_oid(vid), 0, inode,
Expand Down Expand Up @@ -3179,7 +3180,7 @@ static struct subcommand vdi_cmd[] = {
"Run 'dog vdi cache' for more information",
vdi_cache_cmd, CMD_NEED_ROOT|CMD_NEED_ARG,
vdi_cache, vdi_options},
{"alter-copy", "<vdiname>", "caphT", "set the vdi's redundancy level",
{"alter-copy", "<vdiname>", "caphTf", "set the vdi's redundancy level",
NULL, CMD_NEED_ROOT|CMD_NEED_ARG|CMD_NEED_NODELIST, vdi_alter_copy, vdi_options},
{"lock", NULL, "aphT", "See 'dog vdi lock' for more information",
vdi_lock_cmd, CMD_NEED_ROOT|CMD_NEED_ARG, vdi_lock, vdi_options},
Expand Down
9 changes: 7 additions & 2 deletions include/fec.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ void fec_decode_buffer(struct fec *ctx, uint8_t *input[], const int in_idx[],

/* for isa-l */

#if defined __x86_64__ && defined(ENABLE_ISAL)
void isa_decode_buffer(struct fec *ctx, uint8_t *input[], const int in_idx[],
char *buf, int idx, uint32_t object_size);
#endif

/*
* @param inpkts an array of packets (size k); If a primary block, i, is present
Expand Down Expand Up @@ -172,12 +174,15 @@ static inline void ec_encode(struct fec *ctx, const uint8_t *ds[],
uint8_t *ps[])
{
int p = ctx->dp - ctx->d;

#if !defined __x86_64__ || !defined(ENABLE_ISAL)
int pidx[p];

for (int i = 0; i < p; i++)
pidx[i] = ctx->d + i;
#endif

#ifdef __x86_64__
#if defined __x86_64__ && defined(ENABLE_ISAL)
ec_encode_data(SD_EC_DATA_STRIPE_SIZE / ctx->d, ctx->d, p,
ctx->ec_tbl, (unsigned char **)ds, ps);
#else
Expand Down Expand Up @@ -209,7 +214,7 @@ static inline void ec_decode_buffer(struct fec *ctx, uint8_t *input[],
const int in_idx[], char *buf,
int idx, uint32_t object_size)
{
#ifdef __x86_64__
#if defined __x86_64__ && defined(ENABLE_ISAL)
isa_decode_buffer(ctx, input, in_idx, buf, idx, object_size);
#else
fec_decode_buffer(ctx, input, in_idx, buf, idx, object_size);
Expand Down
14 changes: 13 additions & 1 deletion include/internal_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ struct oid_entry {
int last; /* idx to the last element of the oid array */
};

/*
* node_info: node specific configuration
* This is a config data initialized with "dog node format".
* Currently, it is very simple so doesn't have different expressions
* like cluster_info and sheepdog_config.
*/
struct node_info {
uint8_t store[STORE_LEN];
};

#define NODE_CONFIG_PATH "node_config"

/*
* A joining sheep multicasts the local cluster info. Then, the existing nodes
* reply the latest cluster info which is unique among all of the nodes.
Expand All @@ -255,7 +267,7 @@ struct cluster_info {
enum sd_status status : 8;
uint8_t block_size_shift;
uint8_t __pad[3];
uint8_t store[STORE_LEN];
uint8_t default_store[STORE_LEN];

/* Node list at cluster_info->epoch */
struct sd_node nodes[SD_MAX_NODES];
Expand Down
2 changes: 1 addition & 1 deletion include/sheep.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ struct sheepdog_config {
uint64_t ctime;
uint16_t flags;
uint8_t copies;
uint8_t store[STORE_LEN];
uint8_t default_store[STORE_LEN];
uint8_t shutdown;
uint8_t copy_policy;
uint8_t block_size_shift;
Expand Down
20 changes: 16 additions & 4 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,27 @@ libsheepdog_a_CPPFLAGS = $(AM_CPPFLAGS) -DNO_SHEEPDOG_LOGGER

libsd_a_DEPENDENCIES =

noinst_LIBRARIES = libisa.a libsd.a
noinst_LIBRARIES =

if YASM_AVX2_SUPPORT
noinst_LIBRARIES += libisa.a
endif

noinst_LIBRARIES += libsd.a

if YASM_AVX2_SUPPORT
libisa_a_SOURCES = $(shell find isa-l/ -type f -regex ".*\.\(c\|h\|asm\)") \
isa-l/erasure_code/Makefile \
isa-l/Makefile \
isa-l/Makefile.nmake \
isa-l/make.inc
endif

libsd_a_SOURCES = event.c logger.c net.c util.c rbtree.c strbuf.c \
sha1.c option.c work.c sockfd_cache.c fec.c \
sd_inode.c common.c

if YASM_AVX2_SUPPORT
libsd_a_LIBADD_ = isa-l/bin/ec_base.o \
isa-l/bin/ec_highlevel_func.o \
isa-l/bin/ec_multibinary.o \
Expand All @@ -53,18 +62,21 @@ libsd_a_LIBADD_ = isa-l/bin/ec_base.o \
isa-l/bin/gf_5vect_dot_prod_avx.o \
isa-l/bin/gf_6vect_dot_prod_avx.o \
isa-l/bin/gf_vect_dot_prod_avx.o \
isa-l/bin/gf_vect_mul_avx.o \
isa-l/bin/gf_vect_mul_sse.o \
isa-l/bin/gf_2vect_dot_prod_avx2.o \
isa-l/bin/gf_3vect_dot_prod_avx2.o \
isa-l/bin/gf_4vect_dot_prod_avx2.o \
isa-l/bin/gf_5vect_dot_prod_avx2.o \
isa-l/bin/gf_6vect_dot_prod_avx2.o \
isa-l/bin/gf_vect_dot_prod_avx2.o \
isa-l/bin/gf_vect_mul_avx.o \
isa-l/bin/gf_vect_mul_sse.o
isa-l/bin/gf_vect_dot_prod_avx2.o
endif

if YASM_AVX2_SUPPORT
libsd_a_LIBADD_32 = isa-l/bin/ec_base.o \
isa-l/bin/ec_highlevel_func.o \
isa-l/bin/ec_multibinary.o
endif

if !X86_64
arch = 32
Expand Down
6 changes: 4 additions & 2 deletions lib/fec.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ void fec_free(struct fec *p)
sd_assert(p != NULL && p->magic == (((FEC_MAGIC ^ p->d) ^ p->dp) ^
(unsigned long) (p->enc_matrix)));
free(p->enc_matrix);
#ifdef __x86_64__
#if defined __x86_64__ && defined(ENABLE_ISAL)
free(p->ec_tbl);
#endif
free(p);
Expand Down Expand Up @@ -498,7 +498,7 @@ struct fec *fec_new(unsigned short d, unsigned short dp)
*p = 1;
free(tmp_m);

#ifdef __x86_64__
#if defined __x86_64__ && defined(ENABLE_ISAL)
retval->ec_tbl = xmalloc(dp * d * 32);
ec_init_tables(d, dp - d, retval->enc_matrix + (d * d),
retval->ec_tbl);
Expand Down Expand Up @@ -716,6 +716,7 @@ void fec_decode_buffer(struct fec *ctx, uint8_t *input[], const int in_idx[],
}
}

#if defined __x86_64__ && defined(ENABLE_ISAL)
void isa_decode_buffer(struct fec *ctx, uint8_t *input[], const int in_idx[],
char *buf, int idx, uint32_t object_size)
{
Expand Down Expand Up @@ -743,3 +744,4 @@ void isa_decode_buffer(struct fec *ctx, uint8_t *input[], const int in_idx[],
ec_init_tables(ed, 1, cm, ec_tbl);
ec_encode_data(len, ed, 1, ec_tbl, input, lost);
}
#endif
Loading

0 comments on commit 50793c7

Please sign in to comment.