[sheepdog] [PATCH 1/2] dog: add a dog_err helper to decuple logger from dog
Liu Yuan
namei.unix at gmail.com
Tue Nov 12 09:14:21 CET 2013
Dog just use logger the way as fprintf. So there is no reason to couple dog with
logger which is mainly used by sheep. Let's decouple it from logger and use
fprintf directly.
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
dog/cluster.c | 28 ++++----
dog/common.c | 20 +++---
dog/dog.c | 28 ++++----
dog/dog.h | 7 ++
dog/farm/farm.c | 14 ++--
dog/farm/sha1_file.c | 9 +--
dog/farm/snap.c | 8 +--
dog/farm/trunk.c | 2 +-
dog/node.c | 34 +++++-----
dog/trace.c | 26 ++++----
dog/treeview.c | 11 +--
dog/vdi.c | 181 +++++++++++++++++++++++++-------------------------
12 files changed, 190 insertions(+), 178 deletions(-)
mode change 100644 => 100755 tests/functional/077
diff --git a/dog/cluster.c b/dog/cluster.c
index b455602..a70802a 100644
--- a/dog/cluster.c
+++ b/dog/cluster.c
@@ -49,7 +49,7 @@ static int list_store(void)
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Restore failed: %s", sd_strerror(rsp->result));
+ dog_err("Restore failed: %s", sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -87,7 +87,7 @@ static int cluster_format(int argc, char **argv)
if (ret < 0)
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("%s", sd_strerror(rsp->result));
+ dog_err("%s", sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -114,7 +114,7 @@ static int cluster_format(int argc, char **argv)
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Format failed: %s", sd_strerror(rsp->result));
+ dog_err("Format failed: %s", sd_strerror(rsp->result));
if (rsp->result == SD_RES_NO_STORE)
return list_store();
else
@@ -199,7 +199,7 @@ static int cluster_shutdown(int argc, char **argv)
ret = send_light_req(&sd_nid, &hdr);
if (ret) {
- sd_err("failed to execute request");
+ dog_err("failed to execute request");
return EXIT_FAILURE;
}
@@ -238,7 +238,7 @@ static int list_snapshot(int argc, char **argv)
ret = EXIT_SUCCESS;
out:
if (ret)
- sd_err("Fail to list snapshot.");
+ dog_err("Fail to list snapshot.");
free(buf);
return ret;
}
@@ -283,12 +283,12 @@ static int save_snapshot(int argc, char **argv)
unused = strtol(tag, &p, 10);
if (tag != p) {
- sd_err("Tag should not start with number.");
+ dog_err("Tag should not start with number.");
return EXIT_USAGE;
}
if (!argv[optind]) {
- sd_err("Please specify the path to save snapshot.");
+ dog_err("Please specify the path to save snapshot.");
return EXIT_USAGE;
}
path = argv[optind];
@@ -297,7 +297,7 @@ static int save_snapshot(int argc, char **argv)
goto out;
if (farm_contain_snapshot(0, tag)) {
- sd_err("Snapshot tag has already been used for another"
+ dog_err("Snapshot tag has already been used for another"
" snapshot, please, use another one.");
goto out;
}
@@ -311,7 +311,7 @@ static int save_snapshot(int argc, char **argv)
ret = EXIT_SUCCESS;
out:
if (ret)
- sd_err("Fail to save snapshot to path: %s.", path);
+ dog_err("Fail to save snapshot to path: %s.", path);
object_tree_free();
return ret;
}
@@ -328,7 +328,7 @@ static int load_snapshot(int argc, char **argv)
idx = 0;
if (!argv[optind]) {
- sd_err("Please specify the path to save snapshot.");
+ dog_err("Please specify the path to save snapshot.");
return EXIT_USAGE;
}
path = argv[optind];
@@ -337,7 +337,7 @@ static int load_snapshot(int argc, char **argv)
goto out;
if (!farm_contain_snapshot(idx, tag)) {
- sd_err("Snapshot index or tag does not exist.");
+ dog_err("Snapshot index or tag does not exist.");
goto out;
}
@@ -350,7 +350,7 @@ static int load_snapshot(int argc, char **argv)
ret = EXIT_SUCCESS;
out:
if (ret)
- sd_err("Fail to load snapshot");
+ dog_err("Fail to load snapshot");
return ret;
}
@@ -391,7 +391,7 @@ static int cluster_force_recover(int argc, char **argv)
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("failed to execute request, %s",
+ dog_err("failed to execute request, %s",
sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -528,7 +528,7 @@ static int cluster_parser(int ch, const char *opt)
cluster_cmd_data.copies =
parse_copy(opt, &cluster_cmd_data.copy_policy);
if (!cluster_cmd_data.copies) {
- sd_err("Invalid parameter %s\n"
+ dog_err("Invalid parameter %s\n"
"To create replicated vdi, set -c x\n"
" x(1 to %d) - number of replicated copies\n"
"To create erasure coded vdi, set -c x:y\n"
diff --git a/dog/common.c b/dog/common.c
index c243386..3aa61ec 100644
--- a/dog/common.c
+++ b/dog/common.c
@@ -72,12 +72,12 @@ int sd_read_object(uint64_t oid, void *data, unsigned int datalen,
ret = dog_exec_req(&sd_nid, &hdr, data);
if (ret < 0) {
- sd_err("Failed to read object %" PRIx64, oid);
+ dog_err("Failed to read object %" PRIx64, oid);
return SD_RES_EIO;
}
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Failed to read object %" PRIx64 " %s", oid,
+ dog_err("Failed to read object %" PRIx64 " %s", oid,
sd_strerror(rsp->result));
return rsp->result;
}
@@ -114,11 +114,11 @@ int sd_write_object(uint64_t oid, uint64_t cow_oid, void *data,
ret = dog_exec_req(&sd_nid, &hdr, data);
if (ret < 0) {
- sd_err("Failed to write object %" PRIx64, oid);
+ dog_err("Failed to write object %" PRIx64, oid);
return SD_RES_EIO;
}
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Failed to write object %" PRIx64 ": %s", oid,
+ dog_err("Failed to write object %" PRIx64 ": %s", oid,
sd_strerror(rsp->result));
return rsp->result;
}
@@ -145,7 +145,7 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
if (ret < 0)
goto out;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("%s", sd_strerror(rsp->result));
+ dog_err("%s", sd_strerror(rsp->result));
goto out;
}
@@ -157,7 +157,7 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
ret = sd_read_object(oid, &i, SD_INODE_HEADER_SIZE, 0, true);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read inode header");
+ dog_err("Failed to read inode header");
continue;
}
@@ -173,7 +173,7 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
rlen, SD_INODE_HEADER_SIZE, true);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read inode");
+ dog_err("Failed to read inode");
continue;
}
}
@@ -217,7 +217,7 @@ int send_light_req(const struct node_id *nid, struct sd_req *hdr)
return -1;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Response's result: %s", sd_strerror(rsp->result));
+ dog_err("Response's result: %s", sd_strerror(rsp->result));
return -1;
}
@@ -235,7 +235,7 @@ int do_generic_subcommand(struct subcommand *sub, int argc, char **argv)
if (flags & CMD_NEED_NODELIST) {
ret = update_node_list(SD_MAX_NODES);
if (ret < 0) {
- sd_err("Failed to get node list");
+ dog_err("Failed to get node list");
exit(EXIT_SYSFAIL);
}
}
@@ -430,7 +430,7 @@ void dump_loglevels(bool err)
{
for (int i = 0; i < ARRAY_SIZE(loglevel_table); i++) {
if (err)
- sd_err("%s\t(%d)", loglevel_table[i], i);
+ dog_err("%s\t(%d)", loglevel_table[i], i);
else
sd_info("%s\t(%d)", loglevel_table[i], i);
}
diff --git a/dog/dog.c b/dog/dog.c
index 16298ad..7884c28 100644
--- a/dog/dog.c
+++ b/dog/dog.c
@@ -72,7 +72,7 @@ int update_node_list(int max_nodes)
goto out;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Failed to update node list: %s",
+ dog_err("Failed to update node list: %s",
sd_strerror(rsp->result));
ret = -1;
goto out;
@@ -81,7 +81,7 @@ int update_node_list(int max_nodes)
size = rsp->data_length;
sd_nodes_nr = size / sizeof(*ent);
if (sd_nodes_nr == 0) {
- sd_err("There are no active sheep daemons");
+ dog_err("There are no active sheep daemons");
exit(EXIT_FAILURE);
}
@@ -132,7 +132,7 @@ static const struct sd_option *find_opt(int ch)
}
}
- sd_err("Internal error");
+ dog_err("Internal error");
exit(EXIT_SYSFAIL);
}
@@ -197,7 +197,7 @@ static unsigned long setup_commands(const struct command *commands,
if (!found) {
if (cmd && strcmp(cmd, "help") && strcmp(cmd, "--help") &&
strcmp(cmd, "-h")) {
- sd_err("Invalid command '%s'", cmd);
+ dog_err("Invalid command '%s'", cmd);
usage(commands, EXIT_USAGE);
}
usage(commands, 0);
@@ -218,10 +218,10 @@ static unsigned long setup_commands(const struct command *commands,
if (!command_fn) {
if (subcmd && strcmp(subcmd, "help") &&
strcmp(subcmd, "--help") && strcmp(subcmd, "-h"))
- sd_err("Invalid command '%s %s'", cmd, subcmd);
- sd_err("Available %s commands:", cmd);
+ dog_err("Invalid command '%s %s'", cmd, subcmd);
+ dog_err("Available %s commands:", cmd);
for (s = commands[i].sub; s->name; s++)
- sd_err(" %s %s", cmd, s->name);
+ dog_err(" %s %s", cmd, s->name);
exit(EXIT_USAGE);
}
@@ -235,7 +235,7 @@ static void usage(const struct command *commands, int status)
char name[64];
if (status)
- sd_err("Try '%s --help' for more information.", program_name);
+ dog_err("Try '%s --help' for more information.", program_name);
else {
printf("Sheepdog administrator utility\n");
printf("Usage: %s <command> <subcommand> [options]\n", program_name);
@@ -324,7 +324,7 @@ static const struct sd_option *build_sd_options(const char *opts)
static void crash_handler(int signo)
{
- sd_err("dog exits unexpectedly (%s).", strsignal(signo));
+ dog_err("dog exits unexpectedly (%s).", strsignal(signo));
sd_backtrace();
@@ -377,7 +377,7 @@ int main(int argc, char **argv)
switch (ch) {
case 'a':
if (!str_to_addr(optarg, sdhost)) {
- sd_err("Invalid ip address %s", optarg);
+ dog_err("Invalid ip address %s", optarg);
return EXIT_FAILURE;
}
memcpy(sd_nid.addr, sdhost, sizeof(sdhost));
@@ -385,7 +385,7 @@ int main(int argc, char **argv)
case 'p':
sdport = strtol(optarg, &p, 10);
if (optarg == p || sdport < 1 || sdport > UINT16_MAX) {
- sd_err("Invalid port number '%s'", optarg);
+ dog_err("Invalid port number '%s'", optarg);
exit(EXIT_USAGE);
}
sd_nid.port = sdport;
@@ -417,7 +417,7 @@ int main(int argc, char **argv)
if (flags & CMD_NEED_NODELIST) {
ret = update_node_list(SD_MAX_NODES);
if (ret < 0) {
- sd_err("Failed to get node list");
+ dog_err("Failed to get node list");
exit(EXIT_SYSFAIL);
}
}
@@ -429,12 +429,12 @@ int main(int argc, char **argv)
exit(EXIT_SYSFAIL);
if (init_work_queue(get_nr_nodes) != 0) {
- sd_err("Failed to init work queue");
+ dog_err("Failed to init work queue");
exit(EXIT_SYSFAIL);
}
if (sockfd_init()) {
- sd_err("sockfd_init() failed");
+ dog_err("sockfd_init() failed");
exit(EXIT_SYSFAIL);
}
diff --git a/dog/dog.h b/dog/dog.h
index ecf873a..c86e9a4 100644
--- a/dog/dog.h
+++ b/dog/dog.h
@@ -101,4 +101,11 @@ int do_loglevel_get(const struct node_id *nid, int32_t *ret_loglevel);
const char *loglevel_to_str(int loglevel);
void dump_loglevels(bool err);
+#define dog_err(fmt, args...) \
+({ \
+ fprintf(stderr, fmt, ##args); \
+ fprintf(stderr, "\n"); \
+ fflush(stderr); \
+})
+
#endif
diff --git a/dog/farm/farm.c b/dog/farm/farm.c
index 990d26b..c9a252b 100644
--- a/dog/farm/farm.c
+++ b/dog/farm/farm.c
@@ -128,7 +128,7 @@ static int create_directory(const char *p)
strbuf_addstr(&buf, p);
if (xmkdir(buf.buf, 0755) < 0) {
if (errno == EEXIST)
- sd_err("Path is not a directory: %s", p);
+ dog_err("Path is not a directory: %s", p);
goto out;
}
@@ -153,7 +153,7 @@ static int create_directory(const char *p)
ret = 0;
out:
if (ret)
- sd_err("Fail to create directory: %m");
+ dog_err("Fail to create directory: %m");
strbuf_release(&buf);
return ret;
}
@@ -201,10 +201,10 @@ static int notify_vdi_add(uint32_t vdi_id, uint8_t nr_copies,
ret = dog_exec_req(&sd_nid, &hdr, buf);
if (ret < 0)
- sd_err("Fail to notify vdi add event(%"PRIx32", %d)", vdi_id,
+ dog_err("Fail to notify vdi add event(%"PRIx32", %d)", vdi_id,
nr_copies);
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("%s", sd_strerror(rsp->result));
+ dog_err("%s", sd_strerror(rsp->result));
ret = -1;
}
@@ -223,7 +223,7 @@ int farm_init(const char *path)
return 0;
out:
if (ret)
- sd_err("Fail to init farm.");
+ dog_err("Fail to init farm.");
return ret;
}
@@ -257,7 +257,7 @@ static void do_save_object(struct work *work)
return;
error:
free(buf);
- sd_err("Fail to save object, oid %"PRIx64, sw->entry.oid);
+ dog_err("Fail to save object, oid %"PRIx64, sw->entry.oid);
uatomic_set_true(&work_error);
}
@@ -379,7 +379,7 @@ static void do_load_object(struct work *work)
return;
error:
free(buffer);
- sd_err("Fail to load object, oid %"PRIx64, sw->entry.oid);
+ dog_err("Fail to load object, oid %"PRIx64, sw->entry.oid);
uatomic_set_true(&work_error);
}
diff --git a/dog/farm/sha1_file.c b/dog/farm/sha1_file.c
index 3ba2519..0c7f001 100644
--- a/dog/farm/sha1_file.c
+++ b/dog/farm/sha1_file.c
@@ -66,7 +66,7 @@ static int sha1_buffer_write(const unsigned char *sha1,
fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
if (fd < 0) {
if (errno != EEXIST) {
- sd_err("failed to open file %s with error: %m",
+ dog_err("failed to open file %s with error: %m",
filename);
ret = -1;
}
@@ -74,7 +74,7 @@ static int sha1_buffer_write(const unsigned char *sha1,
}
len = xwrite(fd, buf, size);
if (len != size) {
- sd_err("%m");
+ dog_err("%m");
close(fd);
return -1;
}
@@ -103,7 +103,8 @@ static int verify_sha1_file(const unsigned char *sha1,
sha1_from_buffer(buf, len, tmp);
if (memcmp((char *)tmp, (char *)sha1, SHA1_DIGEST_SIZE) != 0) {
- sd_err("failed, %s != %s", sha1_to_hex(sha1), sha1_to_hex(tmp));
+ dog_err("failed, %s != %s", sha1_to_hex(sha1),
+ sha1_to_hex(tmp));
return -1;
}
return 0;
@@ -121,7 +122,7 @@ void *sha1_file_read(const unsigned char *sha1, size_t *size)
return NULL;
}
if (fstat(fd, &st) < 0) {
- sd_err("%m");
+ dog_err("%m");
goto out;
}
diff --git a/dog/farm/snap.c b/dog/farm/snap.c
index 8c46484..5ecacf3 100644
--- a/dog/farm/snap.c
+++ b/dog/farm/snap.c
@@ -37,7 +37,7 @@ int snap_init(const char *farm_dir)
fd = open(snap_log_path, O_CREAT | O_EXCL, 0666);
if (fd < 0) {
if (errno != EEXIST) {
- sd_err("%m");
+ dog_err("%m");
goto out;
}
}
@@ -60,7 +60,7 @@ int snap_log_write(uint32_t idx, const char *tag, unsigned char *sha1)
fd = open(snap_log_path, O_WRONLY | O_APPEND);
if (fd < 0) {
- sd_err("%m");
+ dog_err("%m");
goto out;
}
@@ -86,11 +86,11 @@ void *snap_log_read(int *out_nr)
fd = open(snap_log_path, O_RDONLY);
if (fd < 0) {
- sd_err("%m");
+ dog_err("%m");
goto out;
}
if (fstat(fd, &st) < 0) {
- sd_err("%m");
+ dog_err("%m");
goto out_close;
}
diff --git a/dog/farm/trunk.c b/dog/farm/trunk.c
index 0515560..dffa599 100644
--- a/dog/farm/trunk.c
+++ b/dog/farm/trunk.c
@@ -62,7 +62,7 @@ int for_each_entry_in_trunk(unsigned char *trunk_sha1,
trunk = trunk_file_read(trunk_sha1);
if (!trunk) {
- sd_err("failed to read trunk");
+ dog_err("failed to read trunk");
return ret;
}
diff --git a/dog/node.c b/dog/node.c
index f896078..3755e43 100644
--- a/dog/node.c
+++ b/dog/node.c
@@ -80,7 +80,7 @@ static int node_info(int argc, char **argv)
}
if (success == 0) {
- sd_err("Cannot get information from any nodes");
+ dog_err("Cannot get information from any nodes");
return EXIT_SYSFAIL;
}
@@ -111,11 +111,11 @@ static int get_recovery_state(struct recovery_state *state)
ret = dog_exec_req(&sd_nid, &req, state);
if (ret < 0) {
- sd_err("Failed to execute request");
+ dog_err("Failed to execute request");
return -1;
}
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("%s", sd_strerror(rsp->result));
+ dog_err("%s", sd_strerror(rsp->result));
return -1;
}
@@ -209,7 +209,7 @@ static int node_recovery(int argc, char **argv)
if (ret < 0)
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("%s", sd_strerror(rsp->result));
+ dog_err("%s", sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -250,21 +250,21 @@ static int node_kill(int argc, char **argv)
const char *p = argv[optind++];
if (!is_numeric(p)) {
- sd_err("Invalid node id '%s', please specify a numeric value",
+ dog_err("Invalid node id '%s', please specify a numeric value",
p);
exit(EXIT_USAGE);
}
node_id = strtol(p, NULL, 10);
if (node_id < 0 || node_id >= sd_nodes_nr) {
- sd_err("Invalid node id '%d'", node_id);
+ dog_err("Invalid node id '%d'", node_id);
exit(EXIT_USAGE);
}
sd_init_req(&req, SD_OP_KILL_NODE);
ret = send_light_req(&idx_to_node(&sd_nroot, node_id)->nid, &req);
if (ret) {
- sd_err("Failed to execute request");
+ dog_err("Failed to execute request");
exit(EXIT_FAILURE);
}
@@ -287,7 +287,7 @@ again:
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("failed to get stat information: %s",
+ dog_err("failed to get stat information: %s",
sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -327,7 +327,7 @@ static int node_md_info(struct node_id *nid)
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("failed to get multi-disk infomation: %s",
+ dog_err("failed to get multi-disk infomation: %s",
sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -371,7 +371,7 @@ static int do_plug_unplug(char *disks, bool plug)
int ret;
if (!strlen(disks)) {
- sd_err("Empty path isn't allowed");
+ dog_err("Empty path isn't allowed");
return EXIT_FAILURE;
}
@@ -387,7 +387,7 @@ static int do_plug_unplug(char *disks, bool plug)
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Failed to execute request, look for sheep.log"
+ dog_err("Failed to execute request, look for sheep.log"
" for more information");
return EXIT_FAILURE;
}
@@ -451,22 +451,22 @@ static int node_log_level_set(int argc, char **argv)
ret = do_loglevel_set(&sd_nid, loglevel_str);
switch (ret) {
case EXIT_USAGE:
- sd_err("invalid loglevel: %s", loglevel_str);
- sd_err("available loglevels:");
+ dog_err("invalid loglevel: %s", loglevel_str);
+ dog_err("available loglevels:");
dump_loglevels(true);
ret = -1;
break;
case EXIT_FAILURE:
case EXIT_SYSFAIL:
- sd_err("Failed to execute request");
+ dog_err("Failed to execute request");
ret = -1;
break;
case EXIT_SUCCESS:
/* do nothing */
break;
default:
- sd_err("unknown return code of do_loglevel_set(): %d", ret);
+ dog_err("unknown return code of do_loglevel_set(): %d", ret);
ret = -1;
break;
}
@@ -482,14 +482,14 @@ static int node_log_level_get(int argc, char **argv)
switch (ret) {
case EXIT_FAILURE:
case EXIT_SYSFAIL:
- sd_err("Failed to execute request");
+ dog_err("Failed to execute request");
ret = -1;
break;
case EXIT_SUCCESS:
sd_info("%s (%d)", loglevel_to_str(loglevel), loglevel);
break;
default:
- sd_err("unknown return code of do_loglevel_get(): %d", ret);
+ dog_err("unknown return code of do_loglevel_get(): %d", ret);
ret = -1;
break;
}
diff --git a/dog/trace.c b/dog/trace.c
index 806a3dd..67c17e2 100644
--- a/dog/trace.c
+++ b/dog/trace.c
@@ -84,7 +84,7 @@ static int trace_read_buffer(void)
tfd = open(tracefile, O_CREAT | O_RDWR | O_APPEND | O_TRUNC, 0644);
if (tfd < 0) {
- sd_err("can't create tracefile");
+ dog_err("can't create tracefile");
return EXIT_SYSFAIL;
}
@@ -100,7 +100,7 @@ read_buffer:
goto read_buffer;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Trace failed: %s", sd_strerror(rsp->result));
+ dog_err("Trace failed: %s", sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -131,13 +131,13 @@ static int trace_enable(int argc, char **argv)
case SD_RES_SUCCESS:
break;
case SD_RES_NO_SUPPORT:
- sd_err("no such tracer %s", tracer);
+ dog_err("no such tracer %s", tracer);
return EXIT_FAILURE;
case SD_RES_INVALID_PARMS:
- sd_err("tracer %s is already enabled", tracer);
+ dog_err("tracer %s is already enabled", tracer);
return EXIT_FAILURE;
default:
- sd_err("unknown error (%s)", sd_strerror(rsp->result));
+ dog_err("unknown error (%s)", sd_strerror(rsp->result));
return EXIT_SYSFAIL;
}
@@ -163,13 +163,13 @@ static int trace_disable(int argc, char **argv)
case SD_RES_SUCCESS:
break;
case SD_RES_NO_SUPPORT:
- sd_err("no such tracer %s", tracer);
+ dog_err("no such tracer %s", tracer);
return EXIT_FAILURE;
case SD_RES_INVALID_PARMS:
- sd_err("tracer %s is not enabled", tracer);
+ dog_err("tracer %s is not enabled", tracer);
return EXIT_FAILURE;
default:
- sd_err("unknown error (%s)", sd_strerror(rsp->result));
+ dog_err("unknown error (%s)", sd_strerror(rsp->result));
return EXIT_SYSFAIL;
}
@@ -190,7 +190,7 @@ static int trace_status(int argc, char **argv)
if (ret < 0)
return EXIT_SYSFAIL;
switch (rsp->result) {
- sd_err("%s", sd_strerror(rsp->result));
+ dog_err("%s", sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -205,25 +205,25 @@ static void *map_trace_file(struct stat *st)
void *map;
if (fd < 0) {
- sd_err("%m");
+ dog_err("%m");
return NULL;
}
if (fstat(fd, st) < 0) {
- sd_err("%m");
+ dog_err("%m");
close(fd);
return NULL;
}
if (st->st_size == 0) {
- sd_err("trace file is empty");
+ dog_err("trace file is empty");
return NULL;
}
map = mmap(NULL, st->st_size, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);
if (map == MAP_FAILED) {
- sd_err("%m");
+ dog_err("%m");
return NULL;
}
diff --git a/dog/treeview.c b/dog/treeview.c
index c5bad44..87e247c 100644
--- a/dog/treeview.c
+++ b/dog/treeview.c
@@ -15,6 +15,7 @@
#include "util.h"
#include "treeview.h"
+#include "dog.h"
#ifndef MAX_DEPTH
#define MAX_DEPTH 100
@@ -50,7 +51,7 @@ static struct vdi_tree *find_vdi(struct vdi_tree *parent, uint32_t vid,
}
static struct vdi_tree *new_vdi(const char *name, const char *label,
- uint64_t vid, uint64_t pvid, bool highlight)
+ uint64_t vid, uint64_t pvid, bool hl)
{
struct vdi_tree *vdi;
@@ -59,7 +60,7 @@ static struct vdi_tree *new_vdi(const char *name, const char *label,
pstrcpy(vdi->label, sizeof(vdi->label), label);
vdi->vid = vid;
vdi->pvid = pvid;
- vdi->highlight = highlight;
+ vdi->highlight = hl;
INIT_LIST_HEAD(&vdi->children);
return vdi;
}
@@ -70,11 +71,11 @@ void init_tree(void)
}
void add_vdi_tree(const char *name, const char *label, uint32_t vid,
- uint32_t pvid, bool highlight)
+ uint32_t pvid, bool hl)
{
struct vdi_tree *vdi, *parent;
- vdi = new_vdi(name, label, vid, pvid, highlight);
+ vdi = new_vdi(name, label, vid, pvid, hl);
if (!vdi)
return;
@@ -175,7 +176,7 @@ void dump_tree(void)
width = malloc(sizeof(int) * depth);
more = malloc(sizeof(int) * depth);
if (!width || !more) {
- sd_err("Failed to allocate memory");
+ dog_err("Failed to allocate memory");
return;
}
diff --git a/dog/vdi.c b/dog/vdi.c
index 7a4d64b..85ad3d7 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -271,10 +271,10 @@ static int do_print_obj(const char *sheep, uint64_t oid, struct sd_rsp *rsp,
break;
case SD_RES_OLD_NODE_VER:
case SD_RES_NEW_NODE_VER:
- sd_err("The node list has changed: please try again");
+ dog_err("The node list has changed: please try again");
break;
default:
- sd_err("%s: hit an unexpected error (%s)", sheep,
+ dog_err("%s: hit an unexpected error (%s)", sheep,
sd_strerror(rsp->result));
break;
}
@@ -308,10 +308,10 @@ static int obj_info_filler(const char *sheep, uint64_t oid, struct sd_rsp *rsp,
break;
case SD_RES_OLD_NODE_VER:
case SD_RES_NEW_NODE_VER:
- sd_err("The node list has changed: please try again");
+ dog_err("The node list has changed: please try again");
break;
default:
- sd_err("%s: hit an unexpected error (%s)", sheep,
+ dog_err("%s: hit an unexpected error (%s)", sheep,
sd_strerror(rsp->result));
break;
}
@@ -342,7 +342,7 @@ static void parse_objs(uint64_t oid, obj_parser_func_t func, void *data,
if (ret < 0)
continue;
switch (rsp->result) {
- sd_err("%s", sd_strerror(rsp->result));
+ dog_err("%s", sd_strerror(rsp->result));
continue;
}
@@ -429,7 +429,7 @@ static int find_vdi_name(const char *vdiname, uint32_t snapid, const char *tag,
return -1;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Cannot get VDI info for %s %d %s: %s", vdiname, snapid,
+ dog_err("Cannot get VDI info for %s %d %s: %s", vdiname, snapid,
tag, sd_strerror(rsp->result));
return -1;
}
@@ -447,19 +447,20 @@ static int read_vdi_obj(const char *vdiname, int snapid, const char *tag,
ret = find_vdi_name(vdiname, snapid, tag, &vid, 0);
if (ret < 0) {
- sd_err("Failed to open VDI %s", vdiname);
+ dog_err("Failed to open VDI %s", vdiname);
return EXIT_FAILURE;
}
ret = sd_read_object(vid_to_vdi_oid(vid), inode, size, 0, true);
if (ret != SD_RES_SUCCESS) {
if (snapid) {
- sd_err("Failed to read a snapshot %s:%d", vdiname,
+ dog_err("Failed to read a snapshot %s:%d", vdiname,
snapid);
} else if (tag && tag[0]) {
- sd_err("Failed to read a snapshot %s:%s", vdiname, tag);
+ dog_err("Failed to read a snapshot %s:%s", vdiname,
+ tag);
} else {
- sd_err("Failed to read a vdi %s", vdiname);
+ dog_err("Failed to read a vdi %s", vdiname);
}
return EXIT_FAILURE;
}
@@ -497,7 +498,7 @@ int do_vdi_create(const char *vdiname, int64_t vdi_size,
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Failed to create VDI %s: %s", vdiname,
+ dog_err("Failed to create VDI %s: %s", vdiname,
sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -518,19 +519,19 @@ static int vdi_create(int argc, char **argv)
struct sd_inode *inode = NULL;
if (!argv[optind]) {
- sd_err("Please specify the VDI size");
+ dog_err("Please specify the VDI size");
return EXIT_USAGE;
}
ret = option_parse_size(argv[optind], &size);
if (ret < 0)
return EXIT_USAGE;
if (size > SD_MAX_VDI_SIZE) {
- sd_err("VDI size is too large");
+ dog_err("VDI size is too large");
return EXIT_USAGE;
}
if (nr_copies > sd_nodes_nr) {
- sd_err("There are not enough nodes(%d) to hold the copies(%d)",
+ dog_err("There are not enough nodes(%d) to hold the copies(%d)",
sd_nodes_nr, nr_copies);
return EXIT_USAGE;
}
@@ -544,7 +545,7 @@ static int vdi_create(int argc, char **argv)
ret = sd_read_object(vid_to_vdi_oid(vid), inode, sizeof(*inode), 0, true);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read a newly created VDI object");
+ dog_err("Failed to read a newly created VDI object");
ret = EXIT_FAILURE;
goto out;
}
@@ -595,7 +596,7 @@ static int vdi_snapshot(int argc, char **argv)
struct sd_inode *inode = (struct sd_inode *)buf;
if (vdi_cmd_data.snapshot_id != 0) {
- sd_err("Please specify a non-integer value for "
+ dog_err("Please specify a non-integer value for "
"a snapshot tag name");
return EXIT_USAGE;
}
@@ -636,14 +637,14 @@ static int vdi_clone(int argc, char **argv)
dst_vdi = argv[optind];
if (!dst_vdi) {
- sd_err("Destination VDI name must be specified");
+ dog_err("Destination VDI name must be specified");
ret = EXIT_USAGE;
goto out;
}
if (!vdi_cmd_data.snapshot_id && !vdi_cmd_data.snapshot_tag[0]) {
- sd_err("Only snapshot VDIs can be cloned");
- sd_err("Please specify the '-s' option");
+ dog_err("Only snapshot VDIs can be cloned");
+ dog_err("Please specify the '-s' option");
ret = EXIT_USAGE;
goto out;
}
@@ -722,14 +723,14 @@ static int vdi_resize(int argc, char **argv)
struct sd_inode *inode = (struct sd_inode *)buf;
if (!argv[optind]) {
- sd_err("Please specify the new size for the VDI");
+ dog_err("Please specify the new size for the VDI");
return EXIT_USAGE;
}
ret = option_parse_size(argv[optind], &new_size);
if (ret < 0)
return EXIT_USAGE;
if (new_size > SD_MAX_VDI_SIZE) {
- sd_err("New VDI size is too large");
+ dog_err("New VDI size is too large");
return EXIT_USAGE;
}
@@ -738,7 +739,7 @@ static int vdi_resize(int argc, char **argv)
return ret;
if (new_size < inode->vdi_size) {
- sd_err("Shrinking VDIs is not implemented");
+ dog_err("Shrinking VDIs is not implemented");
return EXIT_USAGE;
}
inode->vdi_size = new_size;
@@ -748,7 +749,7 @@ static int vdi_resize(int argc, char **argv)
0, inode->nr_copies, inode->copy_policy,
false, true);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to update an inode header");
+ dog_err("Failed to update an inode header");
return EXIT_FAILURE;
}
@@ -765,7 +766,7 @@ static int do_vdi_delete(const char *vdiname, int snap_id, const char *snap_tag)
ret = find_vdi_name(vdiname, snap_id, snap_tag, &vid, 0);
if (ret < 0) {
- sd_err("Failed to open VDI %s", vdiname);
+ dog_err("Failed to open VDI %s", vdiname);
return EXIT_FAILURE;
}
@@ -774,7 +775,7 @@ static int do_vdi_delete(const char *vdiname, int snap_id, const char *snap_tag)
ret = send_light_req(&sd_nid, &hdr);
if (ret) {
- sd_err("failed to execute request");
+ dog_err("failed to execute request");
return EXIT_FAILURE;
}
@@ -792,7 +793,7 @@ static int do_vdi_delete(const char *vdiname, int snap_id, const char *snap_tag)
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("Failed to delete %s: %s", vdiname,
+ dog_err("Failed to delete %s: %s", vdiname,
sd_strerror(rsp->result));
if (rsp->result == SD_RES_NO_VDI)
return EXIT_MISSING;
@@ -820,7 +821,7 @@ static int vdi_rollback(int argc, char **argv)
struct sd_inode *inode = (struct sd_inode *)buf;
if (!vdi_cmd_data.snapshot_id && !vdi_cmd_data.snapshot_tag[0]) {
- sd_err("Please specify the '-s' option");
+ dog_err("Please specify the '-s' option");
return EXIT_USAGE;
}
@@ -836,7 +837,7 @@ static int vdi_rollback(int argc, char **argv)
ret = do_vdi_delete(vdiname, 0, NULL);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to delete the current state");
+ dog_err("Failed to delete the current state");
return EXIT_FAILURE;
}
@@ -872,7 +873,7 @@ static int vdi_object(int argc, char **argv)
vid = info.vid;
if (vid == 0) {
- sd_err("VDI not found");
+ dog_err("VDI not found");
return EXIT_MISSING;
}
@@ -909,7 +910,7 @@ static int vdi_object(int argc, char **argv)
printf("The inode object 0x%" PRIx32 " idx %u is not allocated\n",
vid, idx);
} else
- sd_err("Failed to read the inode object 0x%" PRIx32,
+ dog_err("Failed to read the inode object 0x%" PRIx32,
vid);
}
@@ -1001,7 +1002,7 @@ static int vdi_track(int argc, char **argv)
vid = info.vid;
nr_copies = info.nr_copies;
if (vid == 0) {
- sd_err("VDI not found");
+ dog_err("VDI not found");
return EXIT_MISSING;
}
@@ -1024,7 +1025,7 @@ static int vdi_track(int argc, char **argv)
vid_to_data_oid(vid, 0)));
if (!oid_info.success) {
- sd_err("Failed to read the inode object 0x%" PRIx32, vid);
+ dog_err("Failed to read the inode object 0x%" PRIx32, vid);
goto err;
}
if (!oid_info.data_oid) {
@@ -1098,7 +1099,7 @@ static int vdi_setattr(int argc, char **argv)
key = argv[optind++];
if (!key) {
- sd_err("Please specify the attribute key");
+ dog_err("Please specify the attribute key");
return EXIT_USAGE;
}
@@ -1111,7 +1112,7 @@ reread:
ret = read(STDIN_FILENO, value + offset,
SD_MAX_VDI_ATTR_VALUE_LEN - offset);
if (ret < 0) {
- sd_err("Failed to read attribute value from stdin: %m");
+ dog_err("Failed to read attribute value from stdin: %m");
return EXIT_SYSFAIL;
}
if (ret > 0) {
@@ -1130,16 +1131,17 @@ reread:
vdi_cmd_data.exclusive, vdi_cmd_data.delete);
if (ret) {
if (ret == SD_RES_VDI_EXIST) {
- sd_err("The attribute '%s' already exists", key);
+ dog_err("The attribute '%s' already exists", key);
return EXIT_EXISTS;
} else if (ret == SD_RES_NO_OBJ) {
- sd_err("Attribute '%s' not found", key);
+ dog_err("Attribute '%s' not found", key);
return EXIT_MISSING;
} else if (ret == SD_RES_NO_VDI) {
- sd_err("VDI not found");
+ dog_err("VDI not found");
return EXIT_MISSING;
} else
- sd_err("Failed to set attribute: %s", sd_strerror(ret));
+ dog_err("Failed to set attribute: %s",
+ sd_strerror(ret));
return EXIT_FAILURE;
}
@@ -1156,7 +1158,7 @@ static int vdi_getattr(int argc, char **argv)
key = argv[optind++];
if (!key) {
- sd_err("Please specify the attribute key");
+ dog_err("Please specify the attribute key");
return EXIT_USAGE;
}
@@ -1164,13 +1166,13 @@ static int vdi_getattr(int argc, char **argv)
vdi_cmd_data.snapshot_id, key, NULL, 0, &vid,
&attr_oid, &nr_copies, false, false, false);
if (ret == SD_RES_NO_OBJ) {
- sd_err("Attribute '%s' not found", key);
+ dog_err("Attribute '%s' not found", key);
return EXIT_MISSING;
} else if (ret == SD_RES_NO_VDI) {
- sd_err("VDI not found");
+ dog_err("VDI not found");
return EXIT_MISSING;
} else if (ret) {
- sd_err("Failed to find attribute oid: %s", sd_strerror(ret));
+ dog_err("Failed to find attribute oid: %s", sd_strerror(ret));
return EXIT_MISSING;
}
@@ -1178,7 +1180,7 @@ static int vdi_getattr(int argc, char **argv)
ret = sd_read_object(oid, &vattr, SD_ATTR_OBJ_SIZE, 0, true);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read attribute oid: %s", sd_strerror(ret));
+ dog_err("Failed to read attribute oid: %s", sd_strerror(ret));
return EXIT_SYSFAIL;
}
@@ -1216,7 +1218,7 @@ static int vdi_read(int argc, char **argv)
goto out;
if (inode->vdi_size < offset) {
- sd_err("Read offset is beyond the end of the VDI");
+ dog_err("Read offset is beyond the end of the VDI");
ret = EXIT_FAILURE;
goto out;
}
@@ -1231,7 +1233,7 @@ static int vdi_read(int argc, char **argv)
oid = vid_to_data_oid(inode->data_vdi_id[idx], idx);
ret = sd_read_object(oid, buf, len, offset, false);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read VDI");
+ dog_err("Failed to read VDI");
ret = EXIT_FAILURE;
goto out;
}
@@ -1240,7 +1242,7 @@ static int vdi_read(int argc, char **argv)
ret = xwrite(STDOUT_FILENO, buf, len);
if (ret < 0) {
- sd_err("Failed to write to stdout: %m");
+ dog_err("Failed to write to stdout: %m");
ret = EXIT_SYSFAIL;
goto out;
}
@@ -1288,7 +1290,7 @@ static int vdi_write(int argc, char **argv)
goto out;
if (inode->vdi_size < offset) {
- sd_err("Write offset is beyond the end of the VDI");
+ dog_err("Write offset is beyond the end of the VDI");
ret = EXIT_FAILURE;
goto out;
}
@@ -1314,7 +1316,7 @@ static int vdi_write(int argc, char **argv)
ret = xread(STDIN_FILENO, buf, len);
if (ret < 0) {
- sd_err("Failed to read from stdin: %m");
+ dog_err("Failed to read from stdin: %m");
ret = EXIT_SYSFAIL;
goto out;
} else if (ret < len) {
@@ -1329,7 +1331,7 @@ static int vdi_write(int argc, char **argv)
inode->nr_copies, inode->copy_policy,
create, false);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to write VDI");
+ dog_err("Failed to write VDI");
ret = EXIT_FAILURE;
goto out;
}
@@ -1389,7 +1391,7 @@ static void *read_object_from(const struct sd_vnode *vnode, uint64_t oid)
free(buf);
return NULL;
default:
- sd_err("FATAL: failed to read %"PRIx64", %s", oid,
+ dog_err("FATAL: failed to read %"PRIx64", %s", oid,
sd_strerror(rsp->result));
exit(EXIT_FAILURE);
}
@@ -1418,7 +1420,7 @@ static void write_object_to(const struct sd_vnode *vnode, uint64_t oid,
exit(EXIT_SYSFAIL);
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("FATAL: failed to write %"PRIx64", %s", oid,
+ dog_err("FATAL: failed to write %"PRIx64", %s", oid,
sd_strerror(rsp->result));
exit(EXIT_FAILURE);
}
@@ -1525,7 +1527,7 @@ static void vdi_check_object_work(struct work *work)
vcw->object_found = false;
break;
default:
- sd_err("failed to read %" PRIx64 " from %s, %s", info->oid,
+ dog_err("failed to read %" PRIx64 " from %s, %s", info->oid,
addr_to_str(vcw->vnode->node->nid.addr,
vcw->vnode->node->nid.port),
sd_strerror(rsp->result));
@@ -1538,13 +1540,14 @@ static void check_replicatoin_object(struct vdi_check_info *info)
if (info->majority == NULL) {
switch (info->result) {
case VDI_CHECK_NO_OBJ_FOUND:
- sd_err("no node has %" PRIx64, info->oid);
+ dog_err("no node has %" PRIx64, info->oid);
break;
case VDI_CHECK_NO_MAJORITY_FOUND:
- sd_err("no majority of %" PRIx64, info->oid);
+ dog_err("no majority of %" PRIx64, info->oid);
break;
default:
- sd_err("unknown result of vdi check: %d", info->result);
+ dog_err("unknown result of vdi check: %d",
+ info->result);
exit(EXIT_FAILURE);
break;
}
@@ -1604,12 +1607,13 @@ static void check_erasure_object(struct vdi_check_info *info)
ec_decode_buffer(ctx, ds, idx, obj, d + k);
if (memcmp(obj, info->vcw[d + k].buf, len) != 0) {
/* TODO repair the inconsistency */
- sd_err("object %"PRIx64" is inconsistent", oid);
+ dog_err("object %"PRIx64" is inconsistent",
+ oid);
goto out;
}
}
} else if (j > p) {
- sd_err("failed to rebuild object %"PRIx64". %d copies get "
+ dog_err("failed to rebuild object %"PRIx64". %d copies get "
"lost, more than %d", oid, j, p);
goto out;
} else {
@@ -1729,7 +1733,7 @@ int do_vdi_check(const struct sd_inode *inode)
struct work_queue *wq;
if (sd_nodes_nr < inode->nr_copies) {
- sd_err("ABORT: Not enough active nodes for consistency-check");
+ dog_err("ABORT: Not enough active nodes for consistency-check");
return EXIT_FAILURE;
}
@@ -1769,7 +1773,7 @@ static int vdi_check(int argc, char **argv)
vdi_cmd_data.snapshot_tag, NULL, inode,
SD_INODE_SIZE);
if (ret != EXIT_SUCCESS) {
- sd_err("FATAL: no inode objects");
+ dog_err("FATAL: no inode objects");
return ret;
}
@@ -1831,7 +1835,7 @@ static int get_obj_backup(int idx, uint32_t from_vid, uint32_t to_vid,
ret = sd_read_object(vid_to_data_oid(to_vid, idx), backup->data,
SD_DATA_OBJ_SIZE, 0, true);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read object %" PRIx32 ", %d", to_vid,
+ dog_err("Failed to read object %" PRIx32 ", %d", to_vid,
idx);
return EXIT_FAILURE;
}
@@ -1842,7 +1846,7 @@ static int get_obj_backup(int idx, uint32_t from_vid, uint32_t to_vid,
ret = sd_read_object(vid_to_data_oid(from_vid, idx), from_data,
SD_DATA_OBJ_SIZE, 0, true);
if (ret != SD_RES_SUCCESS) {
- sd_err("Failed to read object %" PRIx32 ", %d",
+ dog_err("Failed to read object %" PRIx32 ", %d",
from_vid, idx);
return EXIT_FAILURE;
}
@@ -1870,7 +1874,7 @@ static int vdi_backup(int argc, char **argv)
if ((!vdi_cmd_data.snapshot_id && !vdi_cmd_data.snapshot_tag[0]) ||
(!vdi_cmd_data.from_snapshot_id &&
!vdi_cmd_data.from_snapshot_tag[0])) {
- sd_err("Please specify snapshots with '-F' and '-s' options");
+ dog_err("Please specify snapshots with '-F' and '-s' options");
ret = EXIT_USAGE;
goto out;
}
@@ -1891,7 +1895,7 @@ static int vdi_backup(int argc, char **argv)
ret = xwrite(STDOUT_FILENO, &hdr, sizeof(hdr));
if (ret < 0) {
- sd_err("failed to write backup header, %m");
+ dog_err("failed to write backup header, %m");
ret = EXIT_SYSFAIL;
goto out;
}
@@ -1913,14 +1917,14 @@ static int vdi_backup(int argc, char **argv)
ret = xwrite(STDOUT_FILENO, backup,
sizeof(*backup) - sizeof(backup->data));
if (ret < 0) {
- sd_err("failed to write backup data, %m");
+ dog_err("failed to write backup data, %m");
ret = EXIT_SYSFAIL;
goto out;
}
ret = xwrite(STDOUT_FILENO, backup->data + backup->offset,
backup->length);
if (ret < 0) {
- sd_err("failed to write backup data, %m");
+ dog_err("failed to write backup data, %m");
ret = EXIT_SYSFAIL;
goto out;
}
@@ -1932,7 +1936,7 @@ static int vdi_backup(int argc, char **argv)
ret = xwrite(STDOUT_FILENO, backup,
sizeof(*backup) - sizeof(backup->data));
if (ret < 0) {
- sd_err("failed to write end marker, %m");
+ dog_err("failed to write end marker, %m");
ret = EXIT_SYSFAIL;
goto out;
}
@@ -1981,11 +1985,11 @@ static uint32_t do_restore(const char *vdiname, int snapid, const char *tag)
ret = xread(STDIN_FILENO, &hdr, sizeof(hdr));
if (ret != sizeof(hdr))
- sd_err("failed to read backup header, %m");
+ dog_err("failed to read backup header, %m");
if (hdr.version != VDI_BACKUP_FORMAT_VERSION ||
hdr.magic != VDI_BACKUP_MAGIC) {
- sd_err("The backup file is corrupted");
+ dog_err("The backup file is corrupted");
ret = EXIT_SYSFAIL;
goto out;
}
@@ -1997,7 +2001,7 @@ static uint32_t do_restore(const char *vdiname, int snapid, const char *tag)
ret = do_vdi_create(vdiname, inode->vdi_size, inode->vdi_id, &vid,
false, inode->nr_copies, inode->copy_policy);
if (ret != EXIT_SUCCESS) {
- sd_err("Failed to read VDI");
+ dog_err("Failed to read VDI");
goto out;
}
@@ -2005,7 +2009,7 @@ static uint32_t do_restore(const char *vdiname, int snapid, const char *tag)
ret = xread(STDIN_FILENO, backup,
sizeof(*backup) - sizeof(backup->data));
if (ret != sizeof(*backup) - sizeof(backup->data)) {
- sd_err("failed to read backup data");
+ dog_err("failed to read backup data");
ret = EXIT_SYSFAIL;
break;
}
@@ -2017,14 +2021,14 @@ static uint32_t do_restore(const char *vdiname, int snapid, const char *tag)
ret = xread(STDIN_FILENO, backup->data, backup->length);
if (ret != backup->length) {
- sd_err("failed to read backup data");
+ dog_err("failed to read backup data");
ret = EXIT_SYSFAIL;
break;
}
ret = restore_obj(backup, vid, inode);
if (ret != SD_RES_SUCCESS) {
- sd_err("failed to restore backup");
+ dog_err("failed to restore backup");
do_vdi_delete(vdiname, 0, NULL);
ret = EXIT_FAILURE;
break;
@@ -2048,8 +2052,8 @@ static int vdi_restore(int argc, char **argv)
bool need_current_recovery = false;
if (!vdi_cmd_data.snapshot_id && !vdi_cmd_data.snapshot_tag[0]) {
- sd_err("We can restore a backup file only to snapshots");
- sd_err("Please specify the '-s' option");
+ dog_err("We can restore a backup file only to snapshots");
+ dog_err("Please specify the '-s' option");
ret = EXIT_USAGE;
goto out;
}
@@ -2058,7 +2062,7 @@ static int vdi_restore(int argc, char **argv)
vdi_cmd_data.snapshot_tag, NULL, inode_for_check,
SD_INODE_SIZE);
if (ret != SD_RES_SUCCESS) {
- sd_err("Snapshot ID %d or tag %s doesn't exist",
+ dog_err("Snapshot ID %d or tag %s doesn't exist",
vdi_cmd_data.snapshot_id, vdi_cmd_data.snapshot_tag);
goto out;
@@ -2081,14 +2085,14 @@ static int vdi_restore(int argc, char **argv)
}
if (is_stdin_console()) {
- sd_err("stdin must be pipe");
+ dog_err("stdin must be pipe");
ret = EXIT_USAGE;
goto out;
}
ret = do_vdi_delete(vdiname, 0, NULL);
if (ret != EXIT_SUCCESS) {
- sd_err("Failed to delete the current state");
+ dog_err("Failed to delete the current state");
goto out;
}
need_current_recovery = true;
@@ -2105,7 +2109,7 @@ out:
true, current_inode->nr_copies,
current_inode->copy_policy);
if (recovery_ret != EXIT_SUCCESS) {
- sd_err("failed to resume the current vdi");
+ dog_err("failed to resume the current vdi");
ret = recovery_ret;
}
}
@@ -2124,7 +2128,7 @@ static int vdi_cache_flush(int argc, char **argv)
ret = find_vdi_name(vdiname, vdi_cmd_data.snapshot_id,
vdi_cmd_data.snapshot_tag, &vid, 0);
if (ret < 0) {
- sd_err("Failed to open VDI %s", vdiname);
+ dog_err("Failed to open VDI %s", vdiname);
ret = EXIT_FAILURE;
goto out;
}
@@ -2134,7 +2138,7 @@ static int vdi_cache_flush(int argc, char **argv)
ret = send_light_req(&sd_nid, &hdr);
if (ret) {
- sd_err("failed to execute request");
+ dog_err("failed to execute request");
return EXIT_FAILURE;
}
out:
@@ -2151,7 +2155,7 @@ static int vdi_cache_delete(int argc, char **argv)
ret = find_vdi_name(vdiname, vdi_cmd_data.snapshot_id,
vdi_cmd_data.snapshot_tag, &vid, 0);
if (ret < 0) {
- sd_err("Failed to open VDI %s", vdiname);
+ dog_err("Failed to open VDI %s", vdiname);
ret = EXIT_FAILURE;
goto out;
}
@@ -2161,7 +2165,7 @@ static int vdi_cache_delete(int argc, char **argv)
ret = send_light_req(&sd_nid, &hdr);
if (ret) {
- sd_err("failed to execute request");
+ dog_err("failed to execute request");
return EXIT_FAILURE;
}
out:
@@ -2198,7 +2202,7 @@ static int vdi_cache_info(int argc, char **argv)
return EXIT_SYSFAIL;
if (rsp->result != SD_RES_SUCCESS) {
- sd_err("failed to get cache infomation: %s",
+ dog_err("failed to get cache infomation: %s",
sd_strerror(rsp->result));
return EXIT_FAILURE;
}
@@ -2239,7 +2243,7 @@ static int vdi_cache_purge(int argc, char **argv)
ret = find_vdi_name(vdiname, vdi_cmd_data.snapshot_id,
vdi_cmd_data.snapshot_tag, &vid, 0);
if (ret < 0) {
- sd_err("Failed to open VDI %s", vdiname);
+ dog_err("Failed to open VDI %s", vdiname);
ret = EXIT_FAILURE;
goto out;
}
@@ -2253,7 +2257,7 @@ static int vdi_cache_purge(int argc, char **argv)
ret = send_light_req(&sd_nid, &hdr);
if (ret) {
- sd_err("failed to execute request");
+ dog_err("failed to execute request");
return EXIT_FAILURE;
}
out:
@@ -2346,7 +2350,7 @@ static int vdi_parser(int ch, const char *opt)
case 'i':
vdi_cmd_data.index = strtol(opt, &p, 10);
if (opt == p) {
- sd_err("The index must be an integer");
+ dog_err("The index must be an integer");
exit(EXIT_FAILURE);
}
break;
@@ -2357,8 +2361,7 @@ static int vdi_parser(int ch, const char *opt)
pstrcpy(vdi_cmd_data.snapshot_tag,
sizeof(vdi_cmd_data.snapshot_tag), opt);
} else if (vdi_cmd_data.snapshot_id == 0) {
- fprintf(stderr,
- "The snapshot id must be larger than zero\n");
+ dog_err("The snapshot id must be larger than zero");
exit(EXIT_FAILURE);
}
break;
@@ -2375,7 +2378,7 @@ static int vdi_parser(int ch, const char *opt)
vdi_cmd_data.nr_copies = parse_copy(opt,
&vdi_cmd_data.copy_policy);
if (!vdi_cmd_data.nr_copies) {
- sd_err("Invalid parameter %s\n"
+ dog_err("Invalid parameter %s\n"
"To create replicated vdi, set -c x\n"
" x(1 to %d) - number of replicated copies\n"
"To create erasure coded vdi, set -c x:y\n"
diff --git a/tests/functional/077 b/tests/functional/077
old mode 100644
new mode 100755
--
1.7.9.5
More information about the sheepdog
mailing list