diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/bit-rot/src/bitd/Makefile.am | 2 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h | 391 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 101 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot.c | 239 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/stub/Makefile.am | 2 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h | 158 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub.c | 116 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub.h | 7 |
8 files changed, 815 insertions, 201 deletions
diff --git a/xlators/features/bit-rot/src/bitd/Makefile.am b/xlators/features/bit-rot/src/bitd/Makefile.am index f67fa1a3acd..fd42ebe5a72 100644 --- a/xlators/features/bit-rot/src/bitd/Makefile.am +++ b/xlators/features/bit-rot/src/bitd/Makefile.am @@ -13,7 +13,7 @@ bit_rot_la_SOURCES = bit-rot.c bit-rot-scrub.c bit-rot-tbf.c bit_rot_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(top_builddir)/xlators/features/changelog/lib/src/libgfchangelog.la -noinst_HEADERS = bit-rot.h bit-rot-scrub.h bit-rot-tbf.h +noinst_HEADERS = bit-rot.h bit-rot-scrub.h bit-rot-tbf.h bit-rot-bitd-messages.h AM_CFLAGS = -Wall $(GF_CFLAGS) diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h new file mode 100644 index 00000000000..af3a74fc752 --- /dev/null +++ b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h @@ -0,0 +1,391 @@ +/* + Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. + */ + +#ifndef _BITROT_BITD_MESSAGES_H_ +#define _BITROT_BITD_MESSAGES_H_ + +#include "glfs-message-id.h" + +/* file bit-rot-bitd-messages.h + * brief BIT-ROT log-message IDs and their descriptions + */ + +/* NOTE: Rules for message additions + * 1) Each instance of a message is _better_ left with a unique message ID, even + * if the message format is the same. Reasoning is that, if the message + * format needs to change in one instance, the other instances are not + * impacted or the new change does not change the ID of the instance being + * modified. + * 2) Addition of a message, + * - Should increment the GLFS_NUM_MESSAGES + * - Append to the list of messages defined, towards the end + * - Retain macro naming as glfs_msg_X (for redability across developers) + * NOTE: Rules for message format modifications + * 3) Check acorss the code if the message ID macro in question is reused + * anywhere. If reused then then the modifications should ensure correctness + * everywhere, or needs a new message ID as (1) above was not adhered to. If + * not used anywhere, proceed with the required modification. + * NOTE: Rules for message deletion + * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used + * anywhere, then can be deleted, but will leave a hole by design, as + * addition rules specify modification to the end of the list and not filling + * holes. + */ + +#define GLFS_BITROT_BITD_BASE GLFS_MSGID_COMP_BITROT_BITD +#define GLFS_BITROT_BITD_NUM_MESSAGES 48 +#define GLFS_MSGID_END (GLFS_BITROT_BITD_BASE + \ + GLFS_BITROT_BITD_NUM_MESSAGES + 1) +/* Messaged with message IDs */ +#define glfs_msg_start_x GLFS_BITROT_BITD_BASE, "Invalid: Start of messages" +/*------------*/ + + +#define BRB_MSG_FD_CREATE_FAILED (GLFS_BITROT_BITD_BASE + 1) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ + +#define BRB_MSG_READV_FAILED (GLFS_BITROT_BITD_BASE + 2) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ + +#define BRB_MSG_BLOCK_READ_FAILED (GLFS_BITROT_BITD_BASE + 3) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_CALC_CHECKSUM_FAILED (GLFS_BITROT_BITD_BASE + 4) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_NO_MEMORY (GLFS_BITROT_BITD_BASE + 5) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_GET_SIGN_FAILED (GLFS_BITROT_BITD_BASE + 6) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SET_SIGN_FAILED (GLFS_BITROT_BITD_BASE + 7) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_OP_FAILED (GLFS_BITROT_BITD_BASE + 8) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_READ_AND_SIGN_FAILED (GLFS_BITROT_BITD_BASE + 9) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SIGN_FAILED (GLFS_BITROT_BITD_BASE + 10) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_GET_SUBVOL_FAILED (GLFS_BITROT_BITD_BASE + 11) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SET_TIMER_FAILED (GLFS_BITROT_BITD_BASE + 12) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_GET_INFO_FAILED (GLFS_BITROT_BITD_BASE + 13) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_PATH_FAILED (GLFS_BITROT_BITD_BASE + 14) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_MARK_BAD_FILE (GLFS_BITROT_BITD_BASE + 15) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_TRIGGER_SIGN (GLFS_BITROT_BITD_BASE + 16) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_REGISTER_FAILED (GLFS_BITROT_BITD_BASE + 17) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_CRAWLING_START (GLFS_BITROT_BITD_BASE + 18) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SPAWN_FAILED (GLFS_BITROT_BITD_BASE + 19) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_INVALID_SUBVOL_CHILD (GLFS_BITROT_BITD_BASE + 20) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SKIP_OBJECT (GLFS_BITROT_BITD_BASE + 21) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_NO_CHILD (GLFS_BITROT_BITD_BASE + 22) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_CHECKSUM_MISMATCH (GLFS_BITROT_BITD_BASE + 23) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_MARK_CORRUPTED (GLFS_BITROT_BITD_BASE + 24) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_CRAWLING_FINISH (GLFS_BITROT_BITD_BASE + 25) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_CALC_ERROR (GLFS_BITROT_BITD_BASE + 26) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_LOOKUP_FAILED (GLFS_BITROT_BITD_BASE + 27) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_PARTIAL_VERSION_PRESENCE (GLFS_BITROT_BITD_BASE + 28) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_MEM_ACNT_FAILED (GLFS_BITROT_BITD_BASE + 29) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_TIMER_WHEEL_UNAVAILABLE (GLFS_BITROT_BITD_BASE + 30) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_BITROT_LOADED (GLFS_BITROT_BITD_BASE + 31) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SCALE_DOWN_FAILED (GLFS_BITROT_BITD_BASE + 32) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SCALE_UP_FAILED (GLFS_BITROT_BITD_BASE + 33) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SCALE_DOWN_SCRUBBER (GLFS_BITROT_BITD_BASE + 34) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SCALING_UP_SCRUBBER (GLFS_BITROT_BITD_BASE + 35) +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define BRB_MSG_UNKNOWN_THROTTLE (GLFS_BITROT_BITD_BASE + 36) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_RATE_LIMIT_INFO (GLFS_BITROT_BITD_BASE + 37) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SCRUB_INFO (GLFS_BITROT_BITD_BASE + 38) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_CONNECTED_TO_BRICK (GLFS_BITROT_BITD_BASE + 39) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_BRICK_INFO (GLFS_BITROT_BITD_BASE + 40) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SUBVOL_CONNECT_FAILED (GLFS_BITROT_BITD_BASE + 41) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_INVALID_SUBVOL (GLFS_BITROT_BITD_BASE + 42) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_RESCHEDULE_SCRUBBER_FAILED (GLFS_BITROT_BITD_BASE + 43) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ + +#define BRB_MSG_SCRUB_START (GLFS_BITROT_BITD_BASE + 44) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SCRUB_FINISH (GLFS_BITROT_BITD_BASE + 45) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SCRUB_RUNNING (GLFS_BITROT_BITD_BASE + 46) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SCRUB_RESCHEDULED (GLFS_BITROT_BITD_BASE + 47) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRB_MSG_SCRUB_TUNABLE (GLFS_BITROT_BITD_BASE + 48) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" +#endif /* !_BITROT_BITD_MESSAGES_H_ */ diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c index 76d9e268f56..bb3f1290026 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c @@ -18,6 +18,7 @@ #include "bit-rot-scrub.h" #include <pthread.h> +#include "bit-rot-bitd-messages.h" struct br_scrubbers { pthread_t scrubthread; @@ -58,7 +59,7 @@ bitd_fetch_signature (xlator_t *this, br_child_t *child, ret = dict_get_ptr (*xattr, GLUSTERFS_GET_OBJECT_SIGNATURE, (void **) sign); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_SIGN_FAILED, "failed to extract signature info [GFID: %s]", uuid_utoa (fd->inode->gfid)); goto unref_dict; @@ -106,12 +107,12 @@ bitd_scrub_post_compute_check (xlator_t *this, * The log entry looks pretty ugly, but helps in debugging.. */ if (signptr->stale || (signptr->version != version)) { - gf_log (this->name, GF_LOG_DEBUG, - "<STAGE: POST> Object [GFID: %s] either has a stale " - "signature OR underwent signing during checksumming " - "{Stale: %d | Version: %lu,%lu}", - uuid_utoa (fd->inode->gfid), (signptr->stale) ? 1 : 0, - version, signptr->version); + gf_msg_debug (this->name, 0, "<STAGE: POST> Object [GFID: %s] " + "either has a stale signature OR underwent " + "signing during checksumming {Stale: %d | " + "Version: %lu,%lu}", uuid_utoa (fd->inode->gfid), + (signptr->stale) ? 1 : 0, version, + signptr->version); ret = -1; goto unref_dict; } @@ -172,7 +173,7 @@ bitd_scrub_pre_compute_check (xlator_t *this, br_child_t *child, int32_t ret = -1; if (bitd_is_bad_file (this, child, NULL, fd)) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_SKIP_OBJECT, "Object [GFID: %s] is marked corrupted, skipping..", uuid_utoa (fd->inode->gfid)); goto out; @@ -180,9 +181,9 @@ bitd_scrub_pre_compute_check (xlator_t *this, br_child_t *child, ret = bitd_signature_staleness (this, child, fd, &stale, version); if (!ret && stale) { - gf_log (this->name, GF_LOG_DEBUG, - "<STAGE: PRE> Object [GFID: %s] has stale signature", - uuid_utoa (fd->inode->gfid)); + gf_msg_debug (this->name, 0, "<STAGE: PRE> Object [GFID: %s] " + "has stale signature", + uuid_utoa (fd->inode->gfid)); ret = -1; } @@ -210,13 +211,14 @@ bitd_compare_ckum (xlator_t *this, if (strncmp (sign->signature, (char *) md, strlen (sign->signature)) == 0) { - gf_log (this->name, GF_LOG_DEBUG, "%s [GFID: %s | Brick: %s] " - "matches calculated checksum", loc->path, - uuid_utoa (linked_inode->gfid), child->brick_path); + gf_msg_debug (this->name, 0, "%s [GFID: %s | Brick: %s] " + "matches calculated checksum", loc->path, + uuid_utoa (linked_inode->gfid), + child->brick_path); return 0; } - gf_log (this->name, GF_LOG_ALERT, + gf_msg (this->name, GF_LOG_ALERT, 0, BRB_MSG_CHECKSUM_MISMATCH, "Object checksum mismatch: %s [GFID: %s | Brick: %s]", loc->path, uuid_utoa (linked_inode->gfid), child->brick_path); @@ -229,19 +231,19 @@ bitd_compare_ckum (xlator_t *this, ret = dict_set_int32 (xattr, BITROT_OBJECT_BAD_KEY, _gf_true); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_MARK_BAD_FILE, "Error setting bad-file marker for %s [GFID: %s | " "Brick: %s]", loc->path, uuid_utoa (linked_inode->gfid), child->brick_path); goto dictfree; } - gf_log (this->name, GF_LOG_INFO, "Marking %s [GFID: %s | Brick: %s] " - "as corrupted..", loc->path, uuid_utoa (linked_inode->gfid), - child->brick_path); + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_MARK_CORRUPTED, "Marking %s" + " [GFID: %s | Brick: %s] as corrupted..", loc->path, + uuid_utoa (linked_inode->gfid), child->brick_path); ret = syncop_fsetxattr (child->xl, fd, xattr, 0, NULL, NULL); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_MARK_BAD_FILE, "Error marking object %s [GFID: %s] as corrupted", loc->path, uuid_utoa (linked_inode->gfid)); @@ -303,12 +305,12 @@ br_scrubber_scrub_begin (xlator_t *this, struct br_fsscan_entry *fsentry) if (linked_inode) inode_lookup (linked_inode); - gf_log (this->name, GF_LOG_DEBUG, "Scrubbing object %s [GFID: %s]", - entry->d_name, uuid_utoa (linked_inode->gfid)); + gf_msg_debug (this->name, 0, "Scrubbing object %s [GFID: %s]", + entry->d_name, uuid_utoa (linked_inode->gfid)); if (iatt.ia_type != IA_IFREG) { - gf_log (this->name, GF_LOG_DEBUG, "%s is not a regular " - "file", entry->d_name); + gf_msg_debug (this->name, 0, "%s is not a regular file", + entry->d_name); ret = 0; goto unref_inode; } @@ -318,8 +320,9 @@ br_scrubber_scrub_begin (xlator_t *this, struct br_fsscan_entry *fsentry) */ fd = fd_create (linked_inode, 0); if (!fd) { - gf_log (this->name, GF_LOG_ERROR, "failed to create fd for " - "inode %s", uuid_utoa (linked_inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_FD_CREATE_FAILED, + "failed to create fd for inode %s", + uuid_utoa (linked_inode->gfid)); goto unref_inode; } @@ -350,8 +353,9 @@ br_scrubber_scrub_begin (xlator_t *this, struct br_fsscan_entry *fsentry) ret = br_calculate_obj_checksum (md, child, fd, &iatt); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "error calculating hash " - "for object [GFID: %s]", uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_CALC_ERROR, + "error calculating hash for object [GFID: %s]", + uuid_utoa (fd->inode->gfid)); ret = -1; goto free_md; } @@ -512,8 +516,15 @@ br_fsscanner_log_time (xlator_t *this, br_child_t *child, const char *sfx) gettimeofday (&tv, NULL); gf_time_fmt (timestr, sizeof (timestr), tv.tv_sec, gf_timefmt_FT); - gf_log (this->name, GF_LOG_INFO, - "Scrubbing \"%s\" %s at %s", child->brick_path, sfx, timestr); + if (strcasecmp (sfx, "started") == 0) { + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_START, + "Scrubbing \"%s\" %s at %s", child->brick_path, sfx, + timestr); + } else { + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_FINISH, + "Scrubbing \"%s\" %s at %s", child->brick_path, sfx, + timestr); + } } static void @@ -670,8 +681,8 @@ br_fsscan_schedule (xlator_t *this, br_child_t *child, gf_time_fmt (timestr, sizeof (timestr), (fsscan->boot + timo), gf_timefmt_FT); - gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s scheduled to " - "run at %s", child->brick_path, timestr); + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_INFO, "Scrubbing for " + "%s scheduled to run at %s", child->brick_path, timestr); return 0; @@ -706,11 +717,12 @@ br_fsscan_reschedule (xlator_t *this, ret = gf_tw_mod_timer (priv->timer_wheel, fsscan->timer, timo); if (!ret && pendingcheck) - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_RUNNING, "Scrubber for %s is currently running and would be " "rescheduled after completion", child->brick_path); else - gf_log (this->name, GF_LOG_INFO, "Scrubbing for %s rescheduled " + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_RESCHEDULED, + "Scrubbing for %s rescheduled " "to run at %s", child->brick_path, timestr); return 0; @@ -753,7 +765,7 @@ br_scrubber_calc_scale (xlator_t *this, pow (M_E, BR_SCRUB_THREAD_SCALE_AGGRESSIVE); break; default: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_UNKNOWN_THROTTLE, "Unknown throttle %d", throttle); } @@ -928,7 +940,7 @@ br_scrubber_scale_up (xlator_t *this, diff = (int)(v2 - v1); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCALING_UP_SCRUBBER, "Scaling up scrubbers [%d => %d]", v1, v2); for (i = 0; i < diff; i++) { @@ -951,7 +963,7 @@ br_scrubber_scale_up (xlator_t *this, goto error_return; if (i != diff) /* degraded scaling.. */ - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_SCALE_UP_FAILED, "Could not fully scale up to %d scrubber(s). Spawned " "%d/%d [total scrubber(s): %d]", v2, i, diff, (v1 + i)); @@ -973,7 +985,7 @@ br_scrubber_scale_down (xlator_t *this, diff = (int)(v1 - v2); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCALE_DOWN_SCRUBBER, "Scaling down scrubbers [%d => %d]", v1, v2); for (i = 0 ; i < diff; i++) { @@ -990,10 +1002,10 @@ br_scrubber_scale_down (xlator_t *this, } if (ret) { - gf_log (this->name, GF_LOG_WARNING, - "Could not fully scale down to %d scrubber(s). " - "Terminated %d/%d [total scrubber(s): %d]", - v1, i, diff, (v2 - i)); + gf_msg (this->name, GF_LOG_WARNING, 0, + BRB_MSG_SCALE_DOWN_FAILED, "Could not fully scale down " + "to %d scrubber(s). Terminated %d/%d [total " + "scrubber(s): %d]", v1, i, diff, (v2 - i)); ret = 0; } @@ -1157,8 +1169,9 @@ static void br_scrubber_log_option (xlator_t *this, if (scrubstall) return; /* logged as pause */ - gf_log (this->name, GF_LOG_INFO, "SCRUB TUNABLES:: [Frequency: %s, " - "Throttle: %s]", scrub_freq_str[fsscrub->frequency], + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_TUNABLE, "SCRUB " + "TUNABLES:: [Frequency: %s, Throttle: %s]", + scrub_freq_str[fsscrub->frequency], scrub_throttle_str[fsscrub->throttle]); } diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c index 03fd1c2f1ab..4b698fc9fa4 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot.c @@ -19,6 +19,7 @@ #include "bit-rot.h" #include "bit-rot-scrub.h" #include <pthread.h> +#include "bit-rot-bitd-messages.h" #include "tw.h" @@ -174,8 +175,8 @@ bitd_is_bad_file (xlator_t *this, br_child_t *child, loc_t *loc, fd_t *fd) NULL); if (!ret) { - gf_log (this->name, GF_LOG_DEBUG, "[GFID: %s] is marked " - "corrupted", uuid_utoa (inode->gfid)); + gf_msg_debug (this->name, 0, "[GFID: %s] is marked corrupted", + uuid_utoa (inode->gfid)); bad_file = _gf_true; } @@ -252,8 +253,9 @@ br_object_open (xlator_t *this, ret = -EINVAL; fd = fd_create (inode, 0); if (!fd) { - gf_log (this->name, GF_LOG_ERROR, "failed to create fd for the " - "inode %s", uuid_utoa (inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_FD_CREATE_FAILED, + "failed to create fd for the inode %s", + uuid_utoa (inode->gfid)); goto out; } @@ -308,8 +310,8 @@ br_object_read_block_and_sign (xlator_t *this, fd_t *fd, br_child_t *child, NULL); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "readv on %s failed (%s)", - uuid_utoa (fd->inode->gfid), strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, BRB_MSG_READV_FAILED, + "readv on %s failed", uuid_utoa (fd->inode->gfid)); ret = -1; goto out; } @@ -359,7 +361,8 @@ br_calculate_obj_checksum (unsigned char *md, ret = br_object_read_block_and_sign (this, fd, child, offset, block, &sha256); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "reading block with " + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_BLOCK_READ_FAILED, "reading block with " "offset %lu of object %s failed", offset, uuid_utoa (fd->inode->gfid)); break; @@ -403,24 +406,27 @@ br_object_read_sign (inode_t *linked_inode, fd_t *fd, br_object_t *object, md = GF_CALLOC (SHA256_DIGEST_LENGTH, sizeof (*md), gf_common_mt_char); if (!md) { - gf_log (this->name, GF_LOG_ERROR, "failed to allocate memory " - "for saving hash of the object %s", - uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY, + "failed to allocate memory for saving hash of the " + "object %s", uuid_utoa (fd->inode->gfid)); goto out; } ret = br_object_checksum (md, object, fd, iatt); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "calculating checksum for " - "the object %s failed", uuid_utoa (linked_inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_CALC_CHECKSUM_FAILED, "calculating checksum " + "for the object %s failed", + uuid_utoa (linked_inode->gfid)); goto free_signature; } sign = br_prepare_signature (md, SHA256_DIGEST_LENGTH, BR_SIGNATURE_TYPE_SHA256, object); if (!sign) { - gf_log (this->name, GF_LOG_ERROR, "failed to get the signature " - "for the object %s", uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_SIGN_FAILED, + "failed to get the signature for the object %s", + uuid_utoa (fd->inode->gfid)); goto free_signature; } @@ -429,16 +435,17 @@ br_object_read_sign (inode_t *linked_inode, fd_t *fd, br_object_t *object, (void *)sign, signature_size (SHA256_DIGEST_LENGTH)); if (!xattr) { - gf_log (this->name, GF_LOG_ERROR, "dict allocation for signing" - " failed for the object %s", + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_SIGN_FAILED, + "dict allocation for signing failed for the object %s", uuid_utoa (fd->inode->gfid)); goto free_isign; } ret = syncop_fsetxattr (object->child->xl, fd, xattr, 0, NULL, NULL); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "fsetxattr of signature to " - "the object %s failed", uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_SIGN_FAILED, + "fsetxattr of signature to the object %s failed", + uuid_utoa (fd->inode->gfid)); goto unref_dict; } @@ -464,9 +471,14 @@ void br_log_object (xlator_t *this, char *op, uuid_t gfid, int32_t op_errno) { int softerror = br_object_sign_softerror (op_errno); - gf_log (this->name, (softerror) ? GF_LOG_DEBUG : GF_LOG_ERROR, - "%s() failed on object %s [reason: %s]", - op, uuid_utoa (gfid), strerror (op_errno)); + if (softerror) { + gf_msg_debug (this->name, 0, "%s() failed on object %s " + "[reason: %s]", op, uuid_utoa (gfid), + strerror (op_errno)); + } else { + gf_msg (this->name, GF_LOG_ERROR, op_errno, BRB_MSG_OP_FAILED, + "%s() failed on object %s", op, uuid_utoa (gfid)); + } } void @@ -474,9 +486,13 @@ br_log_object_path (xlator_t *this, char *op, const char *path, int32_t op_errno) { int softerror = br_object_sign_softerror (op_errno); - gf_log (this->name, (softerror) ? GF_LOG_DEBUG : GF_LOG_ERROR, - "%s() failed on object %s [reason: %s]", - op, path, strerror (op_errno)); + if (softerror) { + gf_msg_debug (this->name, 0, "%s() failed on object %s " + "[reason: %s]", op, path, strerror (op_errno)); + } else { + gf_msg (this->name, GF_LOG_ERROR, op_errno, BRB_MSG_OP_FAILED, + "%s() failed on object %s", op, path); + } } static void @@ -504,8 +520,9 @@ br_trigger_sign (xlator_t *this, br_child_t *child, ret = -1; fd = fd_create (linked_inode, 0); if (!fd) { - gf_log (this->name, GF_LOG_ERROR, "Failed to create fd " - "[GFID %s]", uuid_utoa (linked_inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_FD_CREATE_FAILED, + "Failed to create fd [GFID %s]", + uuid_utoa (linked_inode->gfid)); goto cleanup_dict; } @@ -529,7 +546,7 @@ br_trigger_sign (xlator_t *this, br_child_t *child, dict_unref (dict); out: if (ret) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_TRIGGER_SIGN, "Could not trigger signingd for %s (reopen hint: %d)", uuid_utoa (linked_inode->gfid), val); } @@ -605,13 +622,14 @@ static inline int32_t br_sign_object (br_object_t *object) * we have an open file descriptor on the object. from here on, * do not be generous to file operation errors. */ - gf_log (this->name, GF_LOG_DEBUG, - "Signing object [%s]", uuid_utoa (linked_inode->gfid)); + gf_msg_debug (this->name, 0, "Signing object [%s]", + uuid_utoa (linked_inode->gfid)); ret = br_object_read_sign (linked_inode, fd, object, &iatt); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "reading and signing of the " - "object %s failed", uuid_utoa (linked_inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_READ_AND_SIGN_FAILED, "reading and signing of " + "the object %s failed", uuid_utoa (linked_inode->gfid)); goto unref_fd; } @@ -665,8 +683,8 @@ br_process_object (void *arg) ret = br_sign_object (object); if (ret && !br_object_sign_softerror (-ret)) - gf_log (this->name, GF_LOG_ERROR, - "SIGNING FAILURE [%s]", + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_SIGN_FAILED, "SIGNING FAILURE [%s]", uuid_utoa (object->gfid)); GF_FREE (object); } @@ -790,32 +808,34 @@ br_brick_callback (void *xl, char *brick, gf_uuid_copy (gfid, ev->u.releasebr.gfid); - gf_log (this->name, GF_LOG_DEBUG, - "RELEASE EVENT [GFID %s]", uuid_utoa (gfid)); + gf_msg_debug (this->name, 0, "RELEASE EVENT [GFID %s]", + uuid_utoa (gfid)); child = br_get_child_from_brick_path (this, brick); if (!child) { - gf_log (this->name, GF_LOG_ERROR, "failed to get the subvolume " - "for the brick %s", brick); + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_SUBVOL_FAILED, + "failed to get the subvolume for the brick %s", brick); goto out; } object = br_initialize_object (this, child, ev); if (!object) { - gf_log (this->name, GF_LOG_ERROR, "failed to allocate " - "object memory [GFID: %s]", uuid_utoa (gfid)); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY, + "failed to allocate object memory [GFID: %s]", + uuid_utoa (gfid)); goto out; } timer = br_initialize_timer (this, object, child, ev); if (!timer) { - gf_log (this->name, GF_LOG_ERROR, "failed to allocate " - "object expiry timer [GFID: %s]", uuid_utoa (gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_SET_TIMER_FAILED, + "failed to allocate object expiry timer [GFID: %s]", + uuid_utoa (gfid)); goto free_object; } - gf_log (this->name, GF_LOG_DEBUG, "->callback: brick [%s], type [%d]\n", - brick, ev->ev_type); + gf_msg_debug (this->name, 0, "->callback: brick [%s], type [%d]\n", + brick, ev->ev_type); return; @@ -862,7 +882,7 @@ br_check_object_need_sign (xlator_t *this, dict_t *xattr, br_child_t *child) ret = dict_get_ptr (xattr, GLUSTERFS_GET_OBJECT_SIGNATURE, (void **)&sign); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_SIGN_FAILED, "failed to get object signature info"); goto out; } @@ -890,8 +910,8 @@ br_prepare_loc (xlator_t *this, br_child_t *child, loc_t *parent, else { loc->inode = inode; if (loc->inode->ia_type != IA_IFREG) { - gf_log (this->name, GF_LOG_DEBUG, "%s is not a regular " - "file", entry->d_name); + gf_msg_debug (this->name, 0, "%s is not a regular " + "file", entry->d_name); ret = 0; goto out; } @@ -902,8 +922,8 @@ br_prepare_loc (xlator_t *this, br_child_t *child, loc_t *parent, ret = inode_path (parent->inode, entry->d_name, (char **)&loc->path); if (ret < 0 || !loc->path) { - gf_log (this->name, GF_LOG_ERROR, "inode_path on %s " - "(parent: %s) failed", entry->d_name, + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_PATH_FAILED, + "inode_path on %s (parent: %s) failed", entry->d_name, uuid_utoa (parent->inode->gfid)); goto out; } @@ -964,8 +984,8 @@ bitd_oneshot_crawl (xlator_t *subvol, inode_lookup (linked_inode); if (iatt.ia_type != IA_IFREG) { - gf_log (this->name, GF_LOG_DEBUG, - "%s is not a regular file, skipping..", entry->d_name); + gf_msg_debug (this->name, 0, "%s is not a regular file, " + "skipping..", entry->d_name); ret = 0; goto unref_inode; } @@ -987,7 +1007,7 @@ bitd_oneshot_crawl (xlator_t *subvol, */ if (bitd_is_bad_file (this, child, &loc, NULL)) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_SKIP_OBJECT, "Entry [%s] is marked corrupted.. skipping.", loc.path); goto unref_inode; } @@ -1005,9 +1025,10 @@ bitd_oneshot_crawl (xlator_t *subvol, if (op_errno == ENODATA && (iatt.ia_size != 0)) need_signing = _gf_true; if (op_errno == EINVAL) - gf_log (this->name, GF_LOG_WARNING, "Partial version " - "xattr presence detected, ignoring [GFID: %s]", - uuid_utoa (linked_inode->gfid)); + gf_msg (this->name, GF_LOG_WARNING, 0, + BRB_MSG_PARTIAL_VERSION_PRESENCE, "Partial " + "version xattr presence detected, ignoring " + "[GFID: %s]", uuid_utoa (linked_inode->gfid)); } else { need_signing = br_check_object_need_sign (this, xattr, child); } @@ -1015,7 +1036,7 @@ bitd_oneshot_crawl (xlator_t *subvol, if (!need_signing) goto unref_dict; - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_TRIGGER_SIGN, "Triggering signing for %s [GFID: %s | Brick: %s]", loc.path, uuid_utoa (linked_inode->gfid), child->brick_path); br_trigger_sign (this, child, linked_inode, &loc, _gf_true); @@ -1048,8 +1069,9 @@ br_oneshot_signer (void *arg) THIS = this; - gf_log (this->name, GF_LOG_INFO, "Crawling brick [%s], scanning " - "for unsigned objects", child->brick_path); + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_CRAWLING_START, + "Crawling brick [%s], scanning for unsigned objects", + child->brick_path); loc.inode = child->table->root; (void) syncop_ftw_throttle @@ -1057,7 +1079,7 @@ br_oneshot_signer (void *arg) GF_CLIENT_PID_BITD, child, bitd_oneshot_crawl, BR_CRAWL_THROTTLE_COUNT, BR_CRAWL_THROTTLE_ZZZ); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_CRAWLING_FINISH, "Completed crawling brick [%s]", child->brick_path); return NULL; @@ -1092,15 +1114,16 @@ br_enact_signer (xlator_t *this, br_child_t *child, br_stub_init_t *stub) ret = gf_changelog_register_generic (brick, 1, 1, this->ctx->cmd_args.log_file, -1, this); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Register to changelog failed" - " [Reason: %s]", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + BRB_MSG_REGISTER_FAILED, "Register to changelog " + "failed"); goto dealloc; } child->threadrunning = 0; ret = gf_thread_create (&child->thread, NULL, br_oneshot_signer, child); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_SPAWN_FAILED, "failed to spawn FS crawler thread"); else child->threadrunning = 1; @@ -1143,8 +1166,9 @@ br_enact_scrubber (xlator_t *this, br_child_t *child) ret = gf_thread_create (&child->thread, NULL, br_fsscanner, child); if (ret != 0) { - gf_log (this->name, GF_LOG_ALERT, "failed to spawn bitrot " - "scrubber daemon [Brick: %s]", child->brick_path); + gf_msg (this->name, GF_LOG_ALERT, 0, BRB_MSG_SPAWN_FAILED, + "failed to spawn bitrot scrubber daemon [Brick: %s]", + child->brick_path); goto error_return; } @@ -1206,8 +1230,8 @@ br_brick_connect (xlator_t *this, br_child_t *child) if (ret) { op_errno = -ret; ret = -1; - gf_log (this->name, GF_LOG_ERROR, "lookup on root failed " - "[Reason: %s]", strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + BRB_MSG_LOOKUP_FAILED, "lookup on root failed"); goto wipeloc; } @@ -1216,15 +1240,15 @@ br_brick_connect (xlator_t *this, br_child_t *child) if (ret) { op_errno = -ret; ret = -1; - gf_log (this->name, GF_LOG_ERROR, "failed to get stub info " - "[Reason: %s]", strerror (op_errno)); + gf_msg (this->name, GF_LOG_ERROR, op_errno, + BRB_MSG_GET_INFO_FAILED, "failed to get stub info"); goto wipeloc; } ret = dict_get_ptr (xattr, GLUSTERFS_GET_BR_STUB_INIT_TIME, (void **)&stub); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_GET_INFO_FAILED, "failed to extract stub information"); goto free_dict; } @@ -1239,7 +1263,7 @@ br_brick_connect (xlator_t *this, br_child_t *child) ret = br_enact_signer (this, child, stub); if (!ret) - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_CONNECTED_TO_BRICK, "Connected to brick %s..", child->brick_path); free_dict: @@ -1288,8 +1312,9 @@ br_handle_events (void *arg) ret = br_brick_connect (this, child); if (ret) - gf_log (this->name, GF_LOG_ERROR, "failed to connect " - "to subvolume %s", child->xl->name); + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_SUBVOL_CONNECT_FAILED, "failed to " + "connect to subvolume %s", child->xl->name); } return NULL; @@ -1306,8 +1331,8 @@ mem_acct_init (xlator_t *this) ret = xlator_mem_acct_init (this, gf_br_stub_mt_end + 1); if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, "Memory accounting" - " init failed"); + gf_msg (this->name, GF_LOG_WARNING, 0, BRB_MSG_MEM_ACNT_FAILED, + "Memory accounting init failed"); return ret; } @@ -1325,15 +1350,16 @@ notify (xlator_t *this, int32_t event, void *data, ...) subvol = (xlator_t *)data; priv = this->private; - gf_log (this->name, GF_LOG_TRACE, "Notification received: %d", event); + gf_msg_trace (this->name, 0, "Notification received: %d", event); idx = br_find_child_index (this, subvol); switch (event) { case GF_EVENT_CHILD_UP: if (idx < 0) { - gf_log (this->name, GF_LOG_ERROR, - "Got event %d from invalid subvolume", event); + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_INVALID_SUBVOL, "Got event %d from " + "invalid subvolume", event); goto out; } @@ -1361,7 +1387,8 @@ notify (xlator_t *this, int32_t event, void *data, ...) case GF_EVENT_CHILD_DOWN: if (idx < 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_INVALID_SUBVOL_CHILD, "Got event %d from invalid subvolume", event); goto out; } @@ -1425,8 +1452,9 @@ br_init_signer (xlator_t *this, br_private_t *priv) ret = gf_thread_create (&priv->obj_queue->workers[i], NULL, br_process_object, this); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, - "thread creation failed (%s)", strerror (-ret)); + gf_msg (this->name, GF_LOG_ERROR, -ret, + BRB_MSG_SPAWN_FAILED, "thread creation" + " failed"); ret = -1; goto cleanup_threads; } @@ -1477,10 +1505,10 @@ br_rate_limit_signer (xlator_t *this, int child_count, int numbricks) #endif if (!spec.rate) - gf_log (this->name, - GF_LOG_INFO, "[Rate Limit Info] \"FULL THROTTLE\""); + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_RATE_LIMIT_INFO, + "[Rate Limit Info] \"FULL THROTTLE\""); else - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_RATE_LIMIT_INFO, "[Rate Limit Info] \"tokens/sec (rate): %lu, " "maxlimit: %lu\"", spec.rate, spec.maxlimit); @@ -1535,17 +1563,18 @@ init (xlator_t *this) { int i = 0; int32_t ret = -1; - br_private_t *priv = NULL; + br_private_t *priv = NULL; xlator_list_t *trav = NULL; - if (!this->children) { - gf_log (this->name, GF_LOG_ERROR, "FATAL: no children"); - goto out; - } + if (!this->children) { + gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_NO_CHILD, + "FATAL: no children"); + goto out; + } priv = GF_CALLOC (1, sizeof (*priv), gf_br_mt_br_private_t); if (!priv) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRB_MSG_NO_MEMORY, "failed to allocate memory (->priv)"); goto out; } @@ -1566,8 +1595,9 @@ init (xlator_t *this) priv->children[i].timer_pool = mem_pool_new (struct gf_tw_timer_list, 4096); if (!priv->children[i].timer_pool) { - gf_log (this->name, GF_LOG_ERROR, - "failed to allocate mem-pool for timer"); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + BRB_MSG_NO_MEMORY, "failed to allocate mem-pool" + " for timer"); errno = ENOMEM; goto free_children; } @@ -1586,7 +1616,8 @@ init (xlator_t *this) priv->timer_wheel = glusterfs_global_timer_wheel (this); if (!priv->timer_wheel) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_TIMER_WHEEL_UNAVAILABLE, "global timer wheel unavailable"); goto cleanup_mutex; } @@ -1608,13 +1639,13 @@ init (xlator_t *this) ret = gf_thread_create (&priv->thread, NULL, br_handle_events, this); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, - "thread creation failed (%s)", strerror (-ret)); + gf_msg (this->name, GF_LOG_ERROR, -ret, + BRB_MSG_SPAWN_FAILED, "thread creation failed"); ret = -1; } if (!ret) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_BITROT_LOADED, "bit-rot xlator loaded in \"%s\" mode", (priv->iamscrubber) ? "SCRUBBER" : "SIGNER"); return 0; @@ -1686,11 +1717,11 @@ reconfigure (xlator_t *this, dict_t *options) for (; i < priv->child_count; i++) { child = &priv->children[i]; if (!child->child_up) { - gf_log (this->name, GF_LOG_INFO, - "Brick %s is offline, skipping " - "rescheduling (scrub would auto- " - "schedule when brick is back online).", - child->brick_path); + gf_msg (this->name, GF_LOG_INFO, 0, + BRB_MSG_BRICK_INFO, "Brick %s is " + "offline, skipping rescheduling (scrub" + " would auto- schedule when brick is " + "back online).", child->brick_path); continue; } @@ -1698,10 +1729,12 @@ reconfigure (xlator_t *this, dict_t *options) ret = br_fsscan_reschedule (this, child, fsscan, fsscrub, _gf_true); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Could not " - "reschedule scrubber for brick: %s. " - "Scubbing will continue according to " - "old frequency.", child->brick_path); + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, + "Could not reschedule scrubber for " + "brick: %s. Scubbing will continue " + "according to old frequency.", + child->brick_path); } } } diff --git a/xlators/features/bit-rot/src/stub/Makefile.am b/xlators/features/bit-rot/src/stub/Makefile.am index 579dd1c02b6..30e7ca72cb6 100644 --- a/xlators/features/bit-rot/src/stub/Makefile.am +++ b/xlators/features/bit-rot/src/stub/Makefile.am @@ -7,7 +7,7 @@ bitrot_stub_la_SOURCES = bit-rot-stub.c bitrot_stub_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la noinst_HEADERS = bit-rot-stub.h bit-rot-common.h bit-rot-stub-mem-types.h \ - bit-rot-object-version.h + bit-rot-object-version.h bit-rot-stub-messages.h AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h new file mode 100644 index 00000000000..d940b653cc8 --- /dev/null +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h @@ -0,0 +1,158 @@ +/* + Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. + */ + +#ifndef _BITROT_STUB_MESSAGES_H_ +#define _BITROT_STUB_MESSAGES_H_ + +#include "glfs-message-id.h" + +/* file bit-rot-stub-messages.h + * brief BIT-ROT log-message IDs and their descriptions + */ + +/* NOTE: Rules for message additions + * 1) Each instance of a message is _better_ left with a unique message ID, even + * if the message format is the same. Reasoning is that, if the message + * format needs to change in one instance, the other instances are not + * impacted or the new change does not change the ID of the instance being + * modified. + * 2) Addition of a message, + * - Should increment the GLFS_NUM_MESSAGES + * - Append to the list of messages defined, towards the end + * - Retain macro naming as glfs_msg_X (for redability across developers) + * NOTE: Rules for message format modifications + * 3) Check acorss the code if the message ID macro in question is reused + * anywhere. If reused then then the modifications should ensure correctness + * everywhere, or needs a new message ID as (1) above was not adhered to. If + * not used anywhere, proceed with the required modification. + * NOTE: Rules for message deletion + * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used + * anywhere, then can be deleted, but will leave a hole by design, as + * addition rules specify modification to the end of the list and not filling + * holes. + */ + +#define GLFS_BITROT_STUB_BASE GLFS_MSGID_COMP_BITROT_STUB +#define GLFS_BITROT_STUB_NUM_MESSAGES 15 +#define GLFS_MSGID_END (GLFS_BITROT_STUB_BASE + \ + GLFS_BITROT_STUB_NUM_MESSAGES + 1) +/* Messaged with message IDs */ +#define glfs_msg_start_x GLFS_BITROT_STUB_BASE, "Invalid: Start of messages" +/*------------*/ + + +#define BRS_MSG_NO_MEMORY (GLFS_BITROT_STUB_BASE + 1) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_SET_EVENT_FAILED (GLFS_BITROT_STUB_BASE + 2) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_MEM_ACNT_FAILED (GLFS_BITROT_STUB_BASE + 3) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_CREATE_FRAME_FAILED (GLFS_BITROT_STUB_BASE + 4) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_SET_CONTEXT_FAILED (GLFS_BITROT_STUB_BASE + 5) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_CHANGE_VERSION_FAILED (GLFS_BITROT_STUB_BASE + 6) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_ADD_FD_TO_LIST_FAILED (GLFS_BITROT_STUB_BASE + 7) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_SET_FD_CONTEXT_FAILED (GLFS_BITROT_STUB_BASE + 8) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_CREATE_ANONYMOUS_FD_FAILED (GLFS_BITROT_STUB_BASE + 9) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_NO_CHILD (GLFS_BITROT_STUB_BASE + 10) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_STUB_ALLOC_FAILED (GLFS_BITROT_STUB_BASE + 11) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_GET_INODE_CONTEXT_FAILED (GLFS_BITROT_STUB_BASE + 12) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_CANCEL_SIGN_THREAD_FAILED (GLFS_BITROT_STUB_BASE + 13) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_ADD_FD_TO_INODE (GLFS_BITROT_STUB_BASE + 14) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define BRS_MSG_SIGN_VERSION_ERROR (GLFS_BITROT_STUB_BASE + 15) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" +#endif /* !_BITROT_STUB_MESSAGES_H_ */ diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c index 5238f4333bb..fe019f452c9 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c @@ -20,7 +20,7 @@ #include "bit-rot-stub.h" #include "bit-rot-stub-mem-types.h" - +#include "bit-rot-stub-messages.h" #include "bit-rot-common.h" #define BR_STUB_REQUEST_COOKIE 0x1 @@ -46,8 +46,8 @@ mem_acct_init (xlator_t *this) ret = xlator_mem_acct_init (this, gf_br_stub_mt_end + 1); if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, "Memory accounting" - " init failed"); + gf_msg (this->name, GF_LOG_WARNING, 0, BRS_MSG_MEM_ACNT_FAILED, + "Memory accounting init failed"); return ret; } @@ -60,12 +60,13 @@ init (xlator_t *this) int32_t ret = 0; char *tmp = NULL; struct timeval tv = {0,}; - br_stub_private_t *priv = NULL; + br_stub_private_t *priv = NULL; - if (!this->children) { - gf_log (this->name, GF_LOG_ERROR, "FATAL: no children"); - goto error_return; - } + if (!this->children) { + gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_NO_CHILD, + "FATAL: no children"); + goto error_return; + } priv = GF_CALLOC (1, sizeof (*priv), gf_br_stub_mt_private_t); if (!priv) @@ -94,7 +95,7 @@ init (xlator_t *this) if (ret != 0) goto cleanup_lock; - gf_log (this->name, GF_LOG_DEBUG, "bit-rot stub loaded"); + gf_msg_debug (this->name, 0, "bit-rot stub loaded"); this->private = priv; return 0; @@ -122,7 +123,8 @@ fini (xlator_t *this) ret = gf_thread_cleanup_xint (priv->signth); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_CANCEL_SIGN_THREAD_FAILED, "Could not cancel sign serializer thread"); goto out; } @@ -335,8 +337,9 @@ br_stub_need_versioning (xlator_t *this, ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " - "context for the inode %s", + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " + "inode context for the inode %s", uuid_utoa (fd->inode->gfid)); goto error_return; } @@ -370,8 +373,9 @@ br_stub_anon_fd_ctx (xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx) if (!br_stub_fd) { ret = br_stub_add_fd_to_inode (this, fd, ctx); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "failed to " - "add fd to the inode (gfid: %s)", + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_ADD_FD_TO_INODE, "failed to add fd to " + "the inode (gfid: %s)", uuid_utoa (fd->inode->gfid)); goto out; } @@ -392,8 +396,9 @@ br_stub_versioning_prep (call_frame_t *frame, local = br_stub_alloc_local (this); if (!local) { - gf_log (this->name, GF_LOG_ERROR, "local allocation failed " - "(gfid: %s)", uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, BRS_MSG_NO_MEMORY, + "local allocation failed (gfid: %s)", + uuid_utoa (fd->inode->gfid)); goto error_return; } @@ -688,9 +693,10 @@ br_stub_compare_sign_version (xlator_t *this, if (ctx->currentversion < sbuf->signedversion) { invalid = _gf_true; } else if (ctx->currentversion > sbuf->signedversion) { - gf_log (this->name, GF_LOG_DEBUG, "\"Signing version\" " - "(%lu) lower than \"Current version \" (%lu)", - ctx->currentversion, sbuf->signedversion); + gf_msg_debug (this->name, 0, "\"Signing version\" " + "(%lu) lower than \"Current version \" " + "(%lu)", ctx->currentversion, + sbuf->signedversion); *fakesuccess = 1; } } @@ -698,9 +704,10 @@ br_stub_compare_sign_version (xlator_t *this, if (invalid) { ret = -1; - gf_log (this->name, GF_LOG_WARNING, - "Signing version exceeds current version [%lu > %lu]", - sbuf->signedversion, ctx->currentversion); + gf_msg (this->name, GF_LOG_WARNING, 0, + BRS_MSG_SIGN_VERSION_ERROR, "Signing version exceeds " + "current version [%lu > %lu]", sbuf->signedversion, + ctx->currentversion); } out: @@ -870,9 +877,9 @@ br_stub_handle_object_reopen (call_frame_t *frame, stub = fop_fsetxattr_cbk_stub (frame, br_stub_fsetxattr_resume, 0, 0, NULL); if (!stub) { - gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " - "fsetxattr fop (gfid: %s), unwinding", - uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, + "failed to allocate stub for fsetxattr fop (gfid: %s)," + " unwinding", uuid_utoa (fd->inode->gfid)); goto cleanup_local; } @@ -998,8 +1005,9 @@ br_stub_is_object_stale (xlator_t *this, call_frame_t *frame, inode_t *inode, ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " - "context for %s", uuid_utoa (inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " + "inode context for %s", uuid_utoa (inode->gfid)); goto out; } @@ -1384,9 +1392,9 @@ br_stub_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, offset, flags, iobref, xdata); if (!stub) { - gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " - "write fop (gfid: %s), unwinding", - uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, + "failed to allocate stub for write fop (gfid: %s), " + "unwinding", uuid_utoa (fd->inode->gfid)); goto cleanup_local; } @@ -1491,9 +1499,9 @@ br_stub_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, stub = fop_ftruncate_stub (frame, br_stub_ftruncate_resume, fd, offset, xdata); if (!stub) { - gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " - "ftruncate fop (gfid: %s), unwinding", - uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, + "failed to allocate stub for ftruncate fop (gfid: %s)," + " unwinding", uuid_utoa (fd->inode->gfid)); goto cleanup_local; } @@ -1592,8 +1600,10 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, fd = fd_anonymous (loc->inode); if (!fd) { - gf_log (this->name, GF_LOG_ERROR, "failed to create anonymous " - "fd for the inode %s", uuid_utoa (loc->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_CREATE_ANONYMOUS_FD_FAILED, "failed to create " + "anonymous fd for the inode %s", + uuid_utoa (loc->inode->gfid)); goto unwind; } @@ -1619,9 +1629,9 @@ br_stub_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, stub = fop_truncate_stub (frame, br_stub_truncate_resume, loc, offset, xdata); if (!stub) { - gf_log (this->name, GF_LOG_ERROR, "failed to allocate stub for " - "truncate fop (gfid: %s), unwinding", - uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, BRS_MSG_STUB_ALLOC_FAILED, + "failed to allocate stub for truncate fop (gfid: %s), " + "unwinding", uuid_utoa (fd->inode->gfid)); goto cleanup_local; } @@ -1685,8 +1695,9 @@ br_stub_open (call_frame_t *frame, xlator_t *this, ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "failed to get the inode " - "context for the file %s (gfid: %s)", loc->path, + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " + "inode context for the file %s (gfid: %s)", loc->path, uuid_utoa (fd->inode->gfid)); goto unwind; } @@ -1697,8 +1708,10 @@ br_stub_open (call_frame_t *frame, xlator_t *this, ret = br_stub_add_fd_to_inode (this, fd, ctx); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "failed add fd to the list " - "(gfid: %s)", uuid_utoa (fd->inode->gfid)); + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_ADD_FD_TO_LIST_FAILED, + "failed add fd to the list (gfid: %s)", + uuid_utoa (fd->inode->gfid)); goto unwind; } @@ -1730,7 +1743,8 @@ br_stub_add_fd_to_inode (xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx) ret = br_stub_require_release_call (this, fd, &br_stub_fd); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "failed to set the fd " + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_SET_FD_CONTEXT_FAILED, "failed to set the fd " "context for the file (gfid: %s)", uuid_utoa (fd->inode->gfid)); goto out; @@ -2118,7 +2132,7 @@ br_stub_send_ipc_fop (xlator_t *this, fd_t *fd, unsigned long releaseversion, xdata = dict_new (); if (!xdata) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, ENOMEM, BRS_MSG_NO_MEMORY, "dict allocation failed: cannot send IPC FOP " "to changelog"); goto out; @@ -2127,14 +2141,16 @@ br_stub_send_ipc_fop (xlator_t *this, fd_t *fd, unsigned long releaseversion, ret = dict_set_static_bin (xdata, "RELEASE-EVENT", &ev, CHANGELOG_EV_SIZE); if (ret) { - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, BRS_MSG_SET_EVENT_FAILED, "cannot set release event in dict"); goto dealloc_dict; } frame = create_frame (this, this->ctx->pool); if (!frame) { - gf_log (this->name, GF_LOG_WARNING, "create_frame() failure"); + gf_msg (this->name, GF_LOG_WARNING, 0, + BRS_MSG_CREATE_FRAME_FAILED, + "create_frame() failure"); goto dealloc_dict; } @@ -2240,10 +2256,10 @@ br_stub_release (xlator_t *this, fd_t *fd) UNLOCK (&inode->lock); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "releaseversion: %lu | flags: %d | signinfo: %d", - (unsigned long) ntohl (releaseversion), - flags, ntohl(signinfo)); + gf_msg_debug (this->name, 0, "releaseversion: %lu | flags: %d " + "| signinfo: %d", + (unsigned long) ntohl (releaseversion), flags, + ntohl(signinfo)); br_stub_send_ipc_fop (this, fd, releaseversion, signinfo); } diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h index 43be68b26a0..4747cc816a7 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h @@ -19,6 +19,7 @@ #include "bit-rot-stub-mem-types.h" #include "bit-rot-common.h" +#include "bit-rot-stub-messages.h" typedef int (br_stub_version_cbk) (call_frame_t *, void *, xlator_t *, int32_t, int32_t, dict_t *); @@ -218,7 +219,8 @@ br_stub_require_release_call (xlator_t *this, fd_t *fd, br_stub_fd_t **fd_ctx) ret = br_stub_fd_ctx_set (this, fd, br_stub_fd); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + BRS_MSG_SET_CONTEXT_FAILED, "could not set fd context (for release callback"); else *fd_ctx = br_stub_fd; @@ -272,7 +274,8 @@ __br_stub_set_ongoing_version (br_stub_inode_ctx_t *ctx, unsigned long version) if (ctx->currentversion < version) ctx->currentversion = version; else - gf_log ("bit-rot-stub", GF_LOG_WARNING, "current version: %lu" + gf_msg ("bit-rot-stub", GF_LOG_WARNING, 0, + BRS_MSG_CHANGE_VERSION_FAILED, "current version: %lu" "new version: %lu", ctx->currentversion, version); } |