diff options
Diffstat (limited to 'xlators/cluster/ec')
-rw-r--r-- | xlators/cluster/ec/src/Makefile.am | 1 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-combine.c | 76 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-common.c | 103 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-data.c | 22 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-dir-read.c | 56 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-dir-write.c | 117 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-generic.c | 130 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-heal.c | 112 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-heald.c | 18 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-helpers.c | 51 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-inode-read.c | 181 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-inode-write.c | 181 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-locks.c | 153 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-messages.h | 519 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec.c | 66 |
15 files changed, 1323 insertions, 463 deletions
diff --git a/xlators/cluster/ec/src/Makefile.am b/xlators/cluster/ec/src/Makefile.am index 12d87f99e4d..3ebd5ec3c53 100644 --- a/xlators/cluster/ec/src/Makefile.am +++ b/xlators/cluster/ec/src/Makefile.am @@ -27,6 +27,7 @@ ec_headers += ec-combine.h ec_headers += ec-gf.h ec_headers += ec-method.h ec_headers += ec-heald.h +ec_headers += ec-messages.h ec_ext_sources = $(top_builddir)/xlators/lib/src/libxlator.c diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c index d55e42a1752..f3905ce9216 100644 --- a/xlators/cluster/ec/src/ec-combine.c +++ b/xlators/cluster/ec/src/ec-combine.c @@ -17,6 +17,7 @@ #include "ec-helpers.h" #include "ec-common.h" #include "ec-combine.h" +#include "ec-messages.h" #include "quota-common-utils.h" #define EC_QUOTA_PREFIX "trusted.glusterfs.quota." @@ -78,16 +79,18 @@ ec_combine_write (ec_fop_data_t *fop, ec_cbk_data_t *dst, valid = 5; break; default: - gf_log_callingfn (fop->xl->name, GF_LOG_WARNING, "Invalid fop " - "%d", fop->id); + gf_msg_callingfn (fop->xl->name, GF_LOG_WARNING, EINVAL, + EC_MSG_INVALID_FOP, + "Invalid fop %d", fop->id); return 0; break; } if (!ec_iatt_combine(fop, dst->iatt, src->iatt, valid)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " - "answers of '%s'", gf_fop_list[fop->id]); - + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_IATT_MISMATCH, + "Mismatching iatt in " + "answers of '%s'", gf_fop_list[fop->id]); return 0; } return 1; @@ -184,22 +187,23 @@ int32_t ec_iatt_combine(ec_fop_data_t *fop, struct iatt *dst, struct iatt *src, * data is returned. */ failed = _gf_true; } else { - gf_log(fop->xl->name, GF_LOG_DEBUG, + gf_msg_debug (fop->xl->name, 0, "Ignoring iatt differences because inode is not " "locked"); } } if (failed) { - gf_log(fop->xl->name, GF_LOG_WARNING, - "Failed to combine iatt (inode: %lu-%lu, links: %u-%u, " - "uid: %u-%u, gid: %u-%u, rdev: %lu-%lu, size: %lu-%lu, " - "mode: %o-%o)", - dst[i].ia_ino, src[i].ia_ino, dst[i].ia_nlink, - src[i].ia_nlink, dst[i].ia_uid, src[i].ia_uid, - dst[i].ia_gid, src[i].ia_gid, dst[i].ia_rdev, - src[i].ia_rdev, dst[i].ia_size, src[i].ia_size, - st_mode_from_ia(dst[i].ia_prot, dst[i].ia_type), - st_mode_from_ia(src[i].ia_prot, dst[i].ia_type)); + gf_msg (fop->xl->name, GF_LOG_WARNING, 0, + EC_MSG_IATT_COMBINE_FAIL, + "Failed to combine iatt (inode: %lu-%lu, links: %u-%u, " + "uid: %u-%u, gid: %u-%u, rdev: %lu-%lu, size: %lu-%lu, " + "mode: %o-%o)", + dst[i].ia_ino, src[i].ia_ino, dst[i].ia_nlink, + src[i].ia_nlink, dst[i].ia_uid, src[i].ia_uid, + dst[i].ia_gid, src[i].ia_gid, dst[i].ia_rdev, + src[i].ia_rdev, dst[i].ia_size, src[i].ia_size, + st_mode_from_ia(dst[i].ia_prot, dst[i].ia_type), + st_mode_from_ia(src[i].ia_prot, dst[i].ia_type)); return 0; } @@ -291,8 +295,10 @@ int32_t ec_dict_list(data_t ** list, int32_t * count, ec_cbk_data_t * cbk, { if (i >= max) { - gf_log(cbk->fop->xl->name, GF_LOG_ERROR, "Unexpected number of " - "dictionaries"); + gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, EINVAL, + EC_MSG_INVALID_DICT_NUMS, + "Unexpected number of " + "dictionaries"); return 0; } @@ -339,7 +345,9 @@ char * ec_concat_prepare(xlator_t * xl, char ** sep, char ** post, return str; out: - gf_log(xl->name, GF_LOG_ERROR, "Invalid concat format"); + gf_msg (xl->name, GF_LOG_ERROR, EINVAL, + EC_MSG_INVALID_FORMAT, + "Invalid concat format"); GF_FREE(str); @@ -652,8 +660,10 @@ int32_t ec_dict_data_stime(ec_cbk_data_t * cbk, int32_t which, char * key) { if (gf_get_max_stime(cbk->fop->xl, dict, key, data[i]) != 0) { - gf_log(cbk->fop->xl->name, GF_LOG_ERROR, "STIME combination " - "failed"); + gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_STIME_COMBINE_FAIL, + "STIME combination " + "failed"); return -1; } @@ -731,8 +741,10 @@ int32_t ec_dict_combine(ec_cbk_data_t * cbk, int32_t which) if ((dict != NULL) && (dict_foreach(dict, ec_dict_data_combine, &data) != 0)) { - gf_log(cbk->fop->xl->name, GF_LOG_ERROR, "Dictionary combination " - "failed"); + gf_msg (cbk->fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_COMBINE_FAIL, + "Dictionary combination " + "failed"); return 0; } @@ -835,9 +847,10 @@ void ec_statvfs_combine(struct statvfs * dst, struct statvfs * src) if (dst->f_flag != src->f_flag) { - gf_log(THIS->name, GF_LOG_DEBUG, "Mismatching file system flags " - "(%lX, %lX)", - dst->f_flag, src->f_flag); + gf_msg_debug (THIS->name, 0, + "Mismatching file system flags " + "(%lX, %lX)", + dst->f_flag, src->f_flag); } dst->f_flag &= src->f_flag; } @@ -849,7 +862,7 @@ int32_t ec_combine_check(ec_cbk_data_t * dst, ec_cbk_data_t * src, if (dst->op_ret != src->op_ret) { - gf_log(fop->xl->name, GF_LOG_DEBUG, "Mismatching return code in " + gf_msg_debug (fop->xl->name, 0, "Mismatching return code in " "answers of '%s': %d <-> %d", ec_fop_name(fop->id), dst->op_ret, src->op_ret); @@ -859,7 +872,7 @@ int32_t ec_combine_check(ec_cbk_data_t * dst, ec_cbk_data_t * src, { if (dst->op_errno != src->op_errno) { - gf_log(fop->xl->name, GF_LOG_DEBUG, "Mismatching errno code in " + gf_msg_debug (fop->xl->name, 0, "Mismatching errno code in " "answers of '%s': %d <-> %d", ec_fop_name(fop->id), dst->op_errno, src->op_errno); @@ -869,9 +882,10 @@ int32_t ec_combine_check(ec_cbk_data_t * dst, ec_cbk_data_t * src, if (!ec_dict_compare(dst->xdata, src->xdata)) { - gf_log(fop->xl->name, GF_LOG_WARNING, "Mismatching xdata in answers " - "of '%s'", - ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_WARNING, 0, + EC_MSG_XDATA_MISMATCH, + "Mismatching xdata in answers " + "of '%s'", ec_fop_name(fop->id)); return 0; } diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c index 8230b093b58..414a872278d 100644 --- a/xlators/cluster/ec/src/ec-common.c +++ b/xlators/cluster/ec/src/ec-common.c @@ -18,6 +18,7 @@ #include "ec-fops.h" #include "ec-method.h" #include "ec.h" +#include "ec-messages.h" int32_t ec_child_valid(ec_t * ec, ec_fop_data_t * fop, int32_t idx) { @@ -117,14 +118,15 @@ int32_t ec_heal_report(call_frame_t * frame, void * cookie, xlator_t * this, uintptr_t good, uintptr_t bad, dict_t * xdata) { if (op_ret < 0) { - gf_log(this->name, GF_LOG_WARNING, "Heal failed (error %d)", - op_errno); + gf_msg (this->name, GF_LOG_WARNING, op_errno, + EC_MSG_HEAL_FAIL, "Heal failed"); } else { if ((mask & ~good) != 0) { - gf_log(this->name, GF_LOG_INFO, "Heal succeeded on %d/%d " - "subvolumes", - ec_bits_count(mask & ~(good | bad)), - ec_bits_count(mask & ~good)); + gf_msg (this->name, GF_LOG_INFO, 0, + EC_MSG_HEAL_SUCCESS, "Heal succeeded on %d/%d " + "subvolumes", + ec_bits_count(mask & ~(good | bad)), + ec_bits_count(mask & ~good)); } } @@ -156,10 +158,12 @@ void ec_check_status(ec_fop_data_t * fop) return; } - gf_log(fop->xl->name, GF_LOG_WARNING, "Operation failed on some " - "subvolumes (up=%lX, mask=%lX, " - "remaining=%lX, good=%lX, bad=%lX)", - ec->xl_up, fop->mask, fop->remaining, fop->good, fop->bad); + gf_msg (fop->xl->name, GF_LOG_WARNING, 0, + EC_MSG_OP_FAIL_ON_SUBVOLS, + "Operation failed on some " + "subvolumes (up=%lX, mask=%lX, " + "remaining=%lX, good=%lX, bad=%lX)", + ec->xl_up, fop->mask, fop->remaining, fop->good, fop->bad); if (fop->use_fd) { @@ -414,9 +418,11 @@ int32_t ec_child_select(ec_fop_data_t * fop) if ((fop->mask & ~mask) != 0) { - gf_log(fop->xl->name, GF_LOG_WARNING, "Executing operation with " - "some subvolumes unavailable " - "(%lX)", fop->mask & ~mask); + gf_msg (fop->xl->name, GF_LOG_WARNING, 0, + EC_MSG_OP_EXEC_UNAVAIL, + "Executing operation with " + "some subvolumes unavailable " + "(%lX)", fop->mask & ~mask); fop->mask &= mask; } @@ -453,9 +459,11 @@ int32_t ec_child_select(ec_fop_data_t * fop) num = ec_bits_count(fop->mask); if ((num < fop->minimum) && (num < ec->fragments)) { - gf_log(ec->xl->name, GF_LOG_ERROR, "Insufficient available childs " - "for this request (have %d, need " - "%d)", num, fop->minimum); + gf_msg (ec->xl->name, GF_LOG_ERROR, 0, + EC_MSG_CHILDS_INSUFFICIENT, + "Insufficient available childs " + "for this request (have %d, need " + "%d)", num, fop->minimum); return 0; } @@ -618,8 +626,10 @@ ec_lock_t *ec_lock_allocate(xlator_t *xl, loc_t *loc) if ((loc->inode == NULL) || (gf_uuid_is_null(loc->gfid) && gf_uuid_is_null(loc->inode->gfid))) { - gf_log(xl->name, GF_LOG_ERROR, "Trying to lock based on an invalid " - "inode"); + gf_msg (xl->name, GF_LOG_ERROR, EINVAL, + EC_MSG_INVALID_INODE, + "Trying to lock based on an invalid " + "inode"); return NULL; } @@ -845,11 +855,15 @@ ec_config_check (ec_fop_data_t *fop, ec_config_t *config) !ec_is_power_of_2(config->gf_word_size) || ((config->chunk_size * 8) % (config->gf_word_size * data_bricks) != 0)) { - gf_log(fop->xl->name, GF_LOG_ERROR, "Invalid or corrupted config"); + gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL, + EC_MSG_INVALID_CONFIG, + "Invalid or corrupted config"); } else { - gf_log(fop->xl->name, GF_LOG_ERROR, "Unsupported config " - "(V=%u, A=%u, W=%u, " - "N=%u, R=%u, S=%u)", + gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL, + EC_MSG_INVALID_CONFIG, + "Unsupported config " + "(V=%u, A=%u, W=%u, " + "N=%u, R=%u, S=%u)", config->version, config->algorithm, config->gf_word_size, config->bricks, config->redundancy, config->chunk_size); @@ -876,9 +890,9 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, ctx = lock->ctx; if (op_ret < 0) { - gf_log(this->name, GF_LOG_WARNING, - "Failed to get size and version (error %d: %s)", op_errno, - strerror (op_errno)); + gf_msg (this->name, GF_LOG_WARNING, op_errno, + EC_MSG_SIZE_VERS_GET_FAIL, + "Failed to get size and version"); goto out; } @@ -889,7 +903,9 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, if (ec_dict_del_array(dict, EC_XATTR_VERSION, ctx->pre_version, EC_VERSION_SIZE) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Unable to get version xattr"); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_VER_XATTR_GET_FAIL, + "Unable to get version xattr"); goto unlock; } @@ -900,7 +916,8 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, if (lock->loc.inode->ia_type == IA_IFREG) { if (ec_dict_del_number(dict, EC_XATTR_SIZE, &ctx->pre_size) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Unable to get size xattr"); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_SIZE_XATTR_GET_FAIL, "Unable to get size xattr"); goto unlock; } @@ -910,7 +927,9 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, if ((ec_dict_del_config(dict, EC_XATTR_CONFIG, &ctx->config) != 0) || !ec_config_check(parent, &ctx->config)) { - gf_log(this->name, GF_LOG_ERROR, "Unable to get config xattr"); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_CONFIG_XATTR_GET_FAIL, + "Unable to get config xattr"); goto unlock; } @@ -1235,7 +1254,9 @@ int32_t ec_locked(call_frame_t *frame, void *cookie, xlator_t *this, ec_lock_acquired(link); ec_lock(fop->parent); } else { - gf_log(this->name, GF_LOG_WARNING, "Failed to complete preop lock"); + gf_msg (this->name, GF_LOG_WARNING, 0, + EC_MSG_PREOP_LOCK_FAILED, + "Failed to complete preop lock"); } return 0; @@ -1400,8 +1421,10 @@ int32_t ec_unlocked(call_frame_t *frame, void *cookie, xlator_t *this, ec_lock_link_t *link = fop->data; if (op_ret < 0) { - gf_log(this->name, GF_LOG_WARNING, "entry/inode unlocking failed (%s)", - ec_fop_name(link->fop->id)); + gf_msg (this->name, GF_LOG_WARNING, 0, + EC_MSG_UNLOCK_FAILED, + "entry/inode unlocking failed (%s)", + ec_fop_name(link->fop->id)); } else { ec_trace("UNLOCKED", link->fop, "lock=%p", link->lock); } @@ -1447,9 +1470,9 @@ int32_t ec_update_size_version_done(call_frame_t * frame, void * cookie, ec_inode_t *ctx; if (op_ret < 0) { - gf_log(fop->xl->name, fop_log_level (fop->id, op_errno), - "Failed to update version and" - " size (error %d)", op_errno); + gf_msg(fop->xl->name, fop_log_level (fop->id, op_errno), op_errno, + EC_MSG_SIZE_VERS_UPDATE_FAIL, + "Failed to update version and size"); } else { fop->parent->mask &= fop->good; link = fop->data; @@ -1574,7 +1597,9 @@ out: ec_fop_set_error(fop, EIO); - gf_log(fop->xl->name, GF_LOG_ERROR, "Unable to update version and size"); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_SIZE_VERS_UPDATE_FAIL, + "Unable to update version and size"); } gf_boolean_t @@ -1706,8 +1731,10 @@ void ec_unlock_timer_add(ec_lock_link_t *link) lock->timer = gf_timer_call_after(fop->xl->ctx, delay, ec_unlock_timer_cbk, link); if (lock->timer == NULL) { - gf_log(fop->xl->name, GF_LOG_WARNING, "Unable to delay an " - "unlock"); + gf_msg(fop->xl->name, GF_LOG_WARNING, 0, + EC_MSG_UNLOCK_DELAY_FAILED, + "Unable to delay an " + "unlock"); lock->release = now = _gf_true; } @@ -1777,7 +1804,7 @@ void ec_lock_reuse(ec_fop_data_t *fop) release = _gf_true; } if (release) { - gf_log(fop->xl->name, GF_LOG_DEBUG, + gf_msg_debug (fop->xl->name, 0, "Lock contention detected"); } } diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c index 72f3b0b4107..0632371bb6d 100644 --- a/xlators/cluster/ec/src/ec-data.c +++ b/xlators/cluster/ec/src/ec-data.c @@ -12,6 +12,7 @@ #include "ec-helpers.h" #include "ec-common.h" #include "ec-data.h" +#include "ec-messages.h" ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, ec_fop_data_t * fop, int32_t id, @@ -23,15 +24,16 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, if (fop->xl != this) { - gf_log(this->name, GF_LOG_ERROR, "Mismatching xlators between request " - "and answer (req=%s, ans=%s).", - fop->xl->name, this->name); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_XLATOR_MISMATCH, "Mismatching xlators between request " + "and answer (req=%s, ans=%s).", fop->xl->name, this->name); return NULL; } if (fop->frame != frame) { - gf_log(this->name, GF_LOG_ERROR, "Mismatching frames between request " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FRAME_MISMATCH, "Mismatching frames between request " "and answer (req=%p, ans=%p).", fop->frame, frame); @@ -39,7 +41,8 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, } if (fop->id != id) { - gf_log(this->name, GF_LOG_ERROR, "Mismatching fops between request " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FOP_MISMATCH, "Mismatching fops between request " "and answer (req=%d, ans=%d).", fop->id, id); @@ -49,7 +52,8 @@ ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, cbk = mem_get0(ec->cbk_pool); if (cbk == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to allocate memory for an " + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Failed to allocate memory for an " "answer."); } @@ -123,7 +127,8 @@ ec_fop_data_t * ec_fop_data_allocate(call_frame_t * frame, xlator_t * this, fop = mem_get0(ec->fop_pool); if (fop == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to allocate memory for a " + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Failed to allocate memory for a " "request."); return NULL; @@ -155,7 +160,8 @@ ec_fop_data_t * ec_fop_data_allocate(call_frame_t * frame, xlator_t * this, } if (fop->frame == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to create a private frame " + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Failed to create a private frame " "for a request"); mem_put(fop); diff --git a/xlators/cluster/ec/src/ec-dir-read.c b/xlators/cluster/ec/src/ec-dir-read.c index 69df4d26901..dee20665a9c 100644 --- a/xlators/cluster/ec/src/ec-dir-read.c +++ b/xlators/cluster/ec/src/ec-dir-read.c @@ -16,6 +16,7 @@ #include "ec-combine.h" #include "ec-method.h" #include "ec-fops.h" +#include "ec-messages.h" /* FOP: opendir */ @@ -24,9 +25,10 @@ int32_t ec_combine_opendir(ec_fop_data_t * fop, ec_cbk_data_t * dst, { if (dst->fd != src->fd) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching fd in answers " - "of 'GF_FOP_OPENDIR': %p <-> %p", - dst->fd, src->fd); + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_FD_MISMATCH, "Mismatching fd in answers " + "of 'GF_FOP_OPENDIR': %p <-> %p", + dst->fd, src->fd); return 0; } @@ -63,8 +65,9 @@ int32_t ec_opendir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->fd = fd_ref(fd); if (cbk->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " + "file descriptor."); goto out; } @@ -75,7 +78,8 @@ int32_t ec_opendir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -216,8 +220,9 @@ int32_t ec_manager_opendir(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -231,7 +236,7 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(OPENDIR) %p", frame); + gf_msg_trace ("ec", 0, "EC(OPENDIR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -249,7 +254,8 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -259,7 +265,8 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -270,7 +277,8 @@ void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -308,7 +316,8 @@ ec_deitransform (xlator_t *this, off_t offset) out: if (idx < 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + EC_MSG_INVALID_REQUEST, "Invalid index %d in readdirp request", client_id); } return idx; @@ -521,8 +530,9 @@ int32_t ec_manager_readdir(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -536,7 +546,7 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(READDIR) %p", frame); + gf_msg_trace ("ec", 0, "EC(READDIR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -560,7 +570,8 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -571,7 +582,8 @@ void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -610,7 +622,7 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(READDIRP) %p", frame); + gf_msg_trace ("ec", 0, "EC(READDIRP) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -634,7 +646,8 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -645,7 +658,8 @@ void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; diff --git a/xlators/cluster/ec/src/ec-dir-write.c b/xlators/cluster/ec/src/ec-dir-write.c index ce09138fb7a..5fe97c8f728 100644 --- a/xlators/cluster/ec/src/ec-dir-write.c +++ b/xlators/cluster/ec/src/ec-dir-write.c @@ -16,6 +16,7 @@ #include "ec-combine.h" #include "ec-method.h" #include "ec-fops.h" +#include "ec-messages.h" int ec_dir_write_cbk (call_frame_t *frame, xlator_t *this, @@ -266,8 +267,9 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -282,7 +284,7 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(CREATE) %p", frame); + gf_msg_trace ("ec", 0, "EC(CREATE) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -306,7 +308,8 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -316,7 +319,8 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -327,7 +331,8 @@ void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -465,8 +470,9 @@ int32_t ec_manager_link(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -480,7 +486,7 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(LINK) %p", frame); + gf_msg_trace ("ec", 0, "EC(LINK) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -497,7 +503,8 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], oldloc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -506,7 +513,8 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[1], newloc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -516,7 +524,8 @@ void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -667,8 +676,9 @@ int32_t ec_manager_mkdir(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -682,7 +692,7 @@ void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(MKDIR) %p", frame); + gf_msg_trace ("ec", 0, "EC(MKDIR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -704,7 +714,8 @@ void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -714,7 +725,8 @@ void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -894,8 +906,9 @@ int32_t ec_manager_mknod(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -909,7 +922,7 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(MKNOD) %p", frame); + gf_msg_trace ("ec", 0, "EC(MKNOD) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -932,7 +945,8 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -942,7 +956,8 @@ void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1082,8 +1097,9 @@ int32_t ec_manager_rename(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1097,7 +1113,7 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(RENAME) %p", frame); + gf_msg_trace ("ec", 0, "EC(RENAME) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1116,7 +1132,8 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], oldloc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1125,7 +1142,8 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[1], newloc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1135,7 +1153,8 @@ void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1259,8 +1278,9 @@ int32_t ec_manager_rmdir(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1274,7 +1294,7 @@ void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(RMDIR) %p", frame); + gf_msg_trace ("ec", 0, "EC(RMDIR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1295,7 +1315,8 @@ void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1305,7 +1326,8 @@ void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1440,8 +1462,9 @@ int32_t ec_manager_symlink(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1456,7 +1479,7 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(SYMLINK) %p", frame); + gf_msg_trace ("ec", 0, "EC(SYMLINK) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1478,7 +1501,8 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->str[0] = gf_strdup(linkname); if (fop->str[0] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Failed to duplicate a string."); goto out; } @@ -1487,7 +1511,8 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1497,7 +1522,8 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1622,8 +1648,9 @@ int32_t ec_manager_unlink(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1637,7 +1664,7 @@ void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(UNLINK) %p", frame); + gf_msg_trace ("ec", 0, "EC(UNLINK) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1658,7 +1685,8 @@ void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1668,7 +1696,8 @@ void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; diff --git a/xlators/cluster/ec/src/ec-generic.c b/xlators/cluster/ec/src/ec-generic.c index 8973241a974..d8c6d91fa89 100644 --- a/xlators/cluster/ec/src/ec-generic.c +++ b/xlators/cluster/ec/src/ec-generic.c @@ -16,6 +16,7 @@ #include "ec-combine.h" #include "ec-method.h" #include "ec-fops.h" +#include "ec-messages.h" #include "byte-order.h" /* FOP: flush */ @@ -46,7 +47,8 @@ int32_t ec_flush_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -163,8 +165,9 @@ int32_t ec_manager_flush(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -178,7 +181,7 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FLUSH) %p", frame); + gf_msg_trace ("ec", 0, "EC(FLUSH) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -199,7 +202,8 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -210,7 +214,8 @@ void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -236,7 +241,8 @@ int32_t ec_combine_fsync(ec_fop_data_t * fop, ec_cbk_data_t * dst, ec_cbk_data_t * src) { if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 2)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_IATT_MISMATCH, "Mismatching iatt in " "answers of 'GF_FOP_FSYNC'"); return 0; @@ -283,7 +289,8 @@ int32_t ec_fsync_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -411,8 +418,9 @@ int32_t ec_manager_fsync(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -426,7 +434,7 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FSYNC) %p", frame); + gf_msg_trace ("ec", 0, "EC(FSYNC) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -449,7 +457,8 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -460,7 +469,8 @@ void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -508,7 +518,8 @@ int32_t ec_fsyncdir_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -625,8 +636,9 @@ int32_t ec_manager_fsyncdir(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -640,7 +652,7 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FSYNCDIR) %p", frame); + gf_msg_trace ("ec", 0, "EC(FSYNCDIR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -663,7 +675,8 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -674,7 +687,8 @@ void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -749,7 +763,8 @@ int32_t ec_combine_lookup(ec_fop_data_t * fop, ec_cbk_data_t * dst, ec_cbk_data_t * src) { if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 2)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_IATT_MISMATCH, "Mismatching iatt in " "answers of 'GF_FOP_LOOKUP'"); return 0; @@ -788,8 +803,9 @@ int32_t ec_lookup_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->inode = inode_ref(inode); if (cbk->inode == NULL) { - gf_log(this->name, GF_LOG_ERROR, - "Failed to reference an inode."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_INODE_REF_FAIL, + "Failed to reference an inode."); goto out; } @@ -808,7 +824,8 @@ int32_t ec_lookup_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -848,8 +865,9 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state) if (fop->xdata == NULL) { fop->xdata = dict_new(); if (fop->xdata == NULL) { - gf_log(fop->xl->name, GF_LOG_ERROR, "Unable to prepare " - "lookup request"); + gf_msg (fop->xl->name, GF_LOG_ERROR, EIO, + EC_MSG_LOOKUP_REQ_PREP_FAIL, "Unable to prepare " + "lookup request"); fop->error = EIO; @@ -863,7 +881,8 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state) (dict_set_uint64(fop->xdata, EC_XATTR_VERSION, 0) != 0) || (dict_set_uint64(fop->xdata, EC_XATTR_DIRTY, 0) != 0)) { - gf_log(fop->xl->name, GF_LOG_ERROR, "Unable to prepare lookup " + gf_msg (fop->xl->name, GF_LOG_ERROR, EIO, + EC_MSG_LOOKUP_REQ_PREP_FAIL, "Unable to prepare lookup " "request"); fop->error = EIO; @@ -947,8 +966,9 @@ int32_t ec_manager_lookup(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -962,7 +982,7 @@ void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(LOOKUP) %p", frame); + gf_msg_trace ("ec", 0, "EC(LOOKUP) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -980,7 +1000,8 @@ void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -990,7 +1011,8 @@ void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1054,7 +1076,8 @@ int32_t ec_statfs_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1154,8 +1177,9 @@ int32_t ec_manager_statfs(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1169,7 +1193,7 @@ void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(STATFS) %p", frame); + gf_msg_trace ("ec", 0, "EC(STATFS) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1187,7 +1211,8 @@ void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1197,7 +1222,8 @@ void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1224,7 +1250,8 @@ int32_t ec_combine_xattrop(ec_fop_data_t *fop, ec_cbk_data_t *dst, { if (!ec_dict_compare(dst->dict, src->dict)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching dictionary in " + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_DICT_MISMATCH, "Mismatching dictionary in " "answers of 'GF_FOP_XATTROP'"); return 0; @@ -1413,8 +1440,9 @@ int32_t ec_manager_xattrop(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1429,7 +1457,7 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(XATTROP) %p", frame); + gf_msg_trace ("ec", 0, "EC(XATTROP) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1450,7 +1478,8 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1460,7 +1489,8 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->dict = dict_ref(xattr); if (fop->dict == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1471,7 +1501,8 @@ void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1509,7 +1540,7 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FXATTROP) %p", frame); + gf_msg_trace ("ec", 0, "EC(FXATTROP) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1533,7 +1564,8 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -1544,7 +1576,8 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->dict = dict_ref(xattr); if (fop->dict == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1555,7 +1588,8 @@ void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c index c2b8e117045..7067ed95306 100644 --- a/xlators/cluster/ec/src/ec-heal.c +++ b/xlators/cluster/ec/src/ec-heal.c @@ -21,6 +21,7 @@ #include "ec-mem-types.h" #include "ec-data.h" #include "byte-order.h" +#include "ec-messages.h" #include "syncop.h" #include "syncop-utils.h" #include "cluster-syncop.h" @@ -500,9 +501,9 @@ ec_heal_init (ec_fop_data_t * fop) inode = heal->loc.inode; if (inode == NULL) { - gf_log(fop->xl->name, GF_LOG_WARNING, "Unable to start inode healing " - "because there is not enough " - "information"); + gf_msg (fop->xl->name, GF_LOG_WARNING, ENODATA, + EC_MSG_DATA_UNAVAILABLE, "Unable to start inode healing " + "because there is not enough information"); error = ENODATA; goto out; @@ -528,8 +529,10 @@ ec_heal_init (ec_fop_data_t * fop) } if (list_empty(&ctx->heal)) { - gf_log("ec", GF_LOG_INFO, "Healing '%s', gfid %s", heal->loc.path, - uuid_utoa(heal->loc.gfid)); + gf_msg ("ec", GF_LOG_INFO, 0, + EC_MSG_HEALING_INFO, + "Healing '%s', gfid %s", heal->loc.path, + uuid_utoa(heal->loc.gfid)); } else { ec_sleep(fop); } @@ -679,10 +682,9 @@ void ec_heal_remove_others(ec_heal_t * heal) if ((cbk->op_errno != ENOENT) && (cbk->op_errno != ENOTDIR) && (cbk->op_errno != ESTALE)) { - gf_log(heal->xl->name, GF_LOG_WARNING, "Don't know how to " - "remove inode with " - "error %d", - cbk->op_errno); + gf_msg (heal->xl->name, GF_LOG_WARNING, cbk->op_errno, + EC_MSG_INODE_REMOVE_FAIL, "Don't know how to " + "remove inode"); } ec_heal_exclude(heal, cbk->mask); @@ -713,9 +715,9 @@ void ec_heal_prepare_others(ec_heal_t * heal) } else { - gf_log(heal->xl->name, GF_LOG_ERROR, "Don't know how to " - "heal error %d", - cbk->op_errno); + gf_msg (heal->xl->name, GF_LOG_ERROR, cbk->op_errno, + EC_MSG_HEAL_FAIL, "Don't know how to " + "heal"); ec_heal_exclude(heal, cbk->mask); } @@ -802,9 +804,8 @@ void ec_heal_prepare(ec_heal_t * heal) } else { - gf_log(heal->xl->name, GF_LOG_ERROR, "Don't know how to heal " - "error %d", - cbk->op_errno); + gf_msg (heal->xl->name, GF_LOG_ERROR, cbk->op_errno, + EC_MSG_HEAL_FAIL, "Don't know how to heal "); } } else @@ -814,7 +815,8 @@ void ec_heal_prepare(ec_heal_t * heal) heal->fd = fd_create(heal->loc.inode, heal->fop->frame->root->pid); if (heal->fd == NULL) { - gf_log(heal->xl->name, GF_LOG_ERROR, "Unable to create a new " + gf_msg (heal->xl->name, GF_LOG_ERROR, errno, + EC_MSG_FD_CREATE_FAIL, "Unable to create a new " "file descriptor"); goto out; @@ -1088,7 +1090,7 @@ ec_heal_writev_cbk (call_frame_t *frame, void *cookie, ec_trace("WRITE_CBK", cookie, "ret=%d, errno=%d", op_ret, op_errno); - gf_log (fop->xl->name, GF_LOG_DEBUG, "%s: write op_ret %d, op_errno %s" + gf_msg_debug (fop->xl->name, 0, "%s: write op_ret %d, op_errno %s" " at %"PRIu64, uuid_utoa (heal->fd->inode->gfid), op_ret, strerror (op_errno), heal->offset); @@ -1112,7 +1114,7 @@ int32_t ec_heal_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, if (op_ret > 0) { - gf_log (fop->xl->name, GF_LOG_DEBUG, "%s: read succeeded, proceeding " + gf_msg_debug (fop->xl->name, 0, "%s: read succeeded, proceeding " "to write at %"PRIu64, uuid_utoa (heal->fd->inode->gfid), heal->offset); ec_writev(heal->fop->frame, heal->xl, heal->bad, EC_MINIMUM_ONE, @@ -1121,7 +1123,7 @@ int32_t ec_heal_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, } else { - gf_log (fop->xl->name, GF_LOG_DEBUG, "%s: read failed %s, failing " + gf_msg_debug (fop->xl->name, 0, "%s: read failed %s, failing " "to heal block at %"PRIu64, uuid_utoa (heal->fd->inode->gfid), strerror (op_errno), heal->offset); @@ -1563,8 +1565,9 @@ ec_manager_heal (ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1578,7 +1581,7 @@ void ec_heal2(call_frame_t *frame, xlator_t *this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(HEAL) %p", frame); + gf_msg_trace ("ec", 0, "EC(HEAL) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, this->private, out); @@ -1597,7 +1600,8 @@ void ec_heal2(call_frame_t *frame, xlator_t *this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1607,7 +1611,8 @@ void ec_heal2(call_frame_t *frame, xlator_t *this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1658,7 +1663,7 @@ void ec_fheal(call_frame_t * frame, xlator_t * this, uintptr_t target, if (ctx != NULL) { - gf_log("ec", GF_LOG_DEBUG, "FHEAL ctx: flags=%X, open=%lX, bad=%lX", + gf_msg_trace ("ec", 0, "FHEAL ctx: flags=%X, open=%lX, bad=%lX", ctx->flags, ctx->open, ctx->bad); ec_heal(frame, this, target, minimum, func, data, &ctx->loc, partial, xdata); @@ -2107,7 +2112,7 @@ ec_heal_metadata (call_frame_t *frame, ec_t *ec, inode_t *inode, 0); { if (ret <= ec->fragments) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " + gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " "as only %d number of subvolumes could " "be locked", uuid_utoa (inode->gfid), ret); ret = -ENOTCONN; @@ -2274,7 +2279,7 @@ ec_delete_stale_name (dict_t *gfid_db, char *key, data_t *d, void *data) dict_del (gfid_db, key); out: if (ret < 0) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s/%s: heal failed %s", + gf_msg_debug (ec->xl->name, 0, "%s/%s: heal failed %s", uuid_utoa (name_data->parent->gfid), name_data->name, strerror (-ret)); } @@ -2456,7 +2461,7 @@ ec_create_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name, ret = 0; out: if (ret < 0) - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s/%s: heal failed %s", + gf_msg_debug (ec->xl->name, 0, "%s/%s: heal failed %s", uuid_utoa (parent->gfid), name, strerror (-ret)); cluster_replies_wipe (replies, ec->nodes); loc_wipe (&loc); @@ -2552,7 +2557,8 @@ __ec_heal_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name, } if (gfid_db->count > 1) { - gf_log (ec->xl->name, GF_LOG_INFO, "%s/%s: Not able to heal", + gf_msg (ec->xl->name, GF_LOG_INFO, 0, + EC_MSG_HEAL_FAIL, "%s/%s: Not able to heal", uuid_utoa (parent->gfid), name); memset (participants, 0, ec->nodes); goto out; @@ -2602,7 +2608,7 @@ ec_heal_name (call_frame_t *frame, ec_t *ec, inode_t *parent, char *name, 0, 0); { if (ret <= ec->fragments) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s/%s: Skipping " + gf_msg_debug (ec->xl->name, 0, "%s/%s: Skipping " "heal as only %d number of subvolumes could " "be locked", uuid_utoa (parent->gfid), name, ret); @@ -2703,7 +2709,7 @@ __ec_heal_entry (call_frame_t *frame, ec_t *ec, inode_t *inode, 0, 0); { if (ret <= ec->fragments) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " + gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " "as only %d number of subvolumes could " "be locked", uuid_utoa (inode->gfid), ret); ret = -ENOTCONN; @@ -2768,7 +2774,7 @@ ec_heal_entry (call_frame_t *frame, ec_t *ec, inode_t *inode, 0, 0); { if (ret <= ec->fragments) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " + gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " "as only %d number of subvolumes could " "be locked", uuid_utoa (inode->gfid), ret); ret = -ENOTCONN; @@ -2968,10 +2974,10 @@ out: dict_unref (xattrs); cluster_replies_wipe (replies, ec->nodes); if (ret < 0) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: heal failed %s", + gf_msg_debug (ec->xl->name, 0, "%s: heal failed %s", uuid_utoa (fd->inode->gfid), strerror (-ret)); } else { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: sources: %d, sinks: " + gf_msg_debug (ec->xl->name, 0, "%s: sources: %d, sinks: " "%d", uuid_utoa (fd->inode->gfid), EC_COUNT (sources, ec->nodes), EC_COUNT (healed_sinks, ec->nodes)); @@ -3041,7 +3047,7 @@ out: if (xattrs) dict_unref (xattrs); if (ret < 0) - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: heal failed %s", + gf_msg_debug (ec->xl->name, 0, "%s: heal failed %s", uuid_utoa (fd->inode->gfid), strerror (-ret)); return ret; } @@ -3061,7 +3067,7 @@ ec_manager_heal_block (ec_fop_data_t *fop, int32_t state) return EC_STATE_HEAL_DATA_COPY; case EC_STATE_HEAL_DATA_COPY: - gf_log (fop->xl->name, GF_LOG_DEBUG, "%s: read/write starting", + gf_msg_debug (fop->xl->name, 0, "%s: read/write starting", uuid_utoa (heal->fd->inode->gfid)); ec_heal_data_block (heal); @@ -3093,8 +3099,9 @@ ec_manager_heal_block (ec_fop_data_t *fop, int32_t state) return -EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -3109,7 +3116,7 @@ ec_heal_block (call_frame_t *frame, xlator_t *this, uintptr_t target, ec_fop_data_t *fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(HEAL) %p", frame); + gf_msg_trace("ec", 0, "EC(HEAL) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, this->private, out); @@ -3185,7 +3192,7 @@ ec_rebuild_data (call_frame_t *frame, ec_t *ec, fd_t *fd, uint64_t size, for (heal->offset = 0; (heal->offset < size) && !heal->done; heal->offset += heal->size) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: sources: %d, sinks: " + gf_msg_debug (ec->xl->name, 0, "%s: sources: %d, sinks: " "%d, offset: %"PRIu64" bsize: %"PRIu64, uuid_utoa (fd->inode->gfid), EC_COUNT (sources, ec->nodes), @@ -3200,7 +3207,7 @@ ec_rebuild_data (call_frame_t *frame, ec_t *ec, fd_t *fd, uint64_t size, LOCK_DESTROY (&heal->lock); syncbarrier_destroy (heal->data); if (ret < 0) - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: heal failed %s", + gf_msg_debug (ec->xl->name, 0, "%s: heal failed %s", uuid_utoa (fd->inode->gfid), strerror (-ret)); return ret; } @@ -3237,7 +3244,7 @@ __ec_heal_trim_sinks (call_frame_t *frame, ec_t *ec, fd_t *fd, out: cluster_replies_wipe (replies, ec->nodes); if (ret < 0) - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: heal failed %s", + gf_msg_debug (ec->xl->name, 0, "%s: heal failed %s", uuid_utoa (fd->inode->gfid), strerror (-ret)); return ret; } @@ -3392,7 +3399,7 @@ ec_restore_time_and_adjust_versions (call_frame_t *frame, ec_t *ec, fd_t *fd, fd->inode, 0, 0); { if (ret <= ec->fragments) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " + gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " "as only %d number of subvolumes could " "be locked", uuid_utoa (fd->inode->gfid), ret); ret = -ENOTCONN; @@ -3457,7 +3464,7 @@ __ec_heal_data (call_frame_t *frame, ec_t *ec, fd_t *fd, unsigned char *heal_on, fd->inode, 0, 0); { if (ret <= ec->fragments) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " + gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " "as only %d number of subvolumes could " "be locked", uuid_utoa (fd->inode->gfid), ret); ret = -ENOTCONN; @@ -3484,7 +3491,7 @@ unlock: if (ret < 0) goto out; - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: sources: %d, sinks: " + gf_msg_debug (ec->xl->name, 0, "%s: sources: %d, sinks: " "%d", uuid_utoa (fd->inode->gfid), EC_COUNT (sources, ec->nodes), EC_COUNT (healed_sinks, ec->nodes)); @@ -3552,7 +3559,7 @@ ec_heal_data (call_frame_t *frame, ec_t *ec, gf_boolean_t block, inode_t *inode, } { if (ret <= ec->fragments) { - gf_log (ec->xl->name, GF_LOG_DEBUG, "%s: Skipping heal " + gf_msg_debug (ec->xl->name, 0, "%s: Skipping heal " "as only %d number of subvolumes could " "be locked", uuid_utoa (inode->gfid), ret); ret = -ENOTCONN; @@ -3614,12 +3621,15 @@ ec_heal_do (xlator_t *this, void *data, loc_t *loc, int32_t partial) ret = ec_heal_name (frame, ec, loc->parent, (char *)loc->name, participants); if (ret == 0) { - gf_log (this->name, GF_LOG_INFO, "%s: name heal " + gf_msg (this->name, GF_LOG_INFO, 0, + EC_MSG_HEAL_SUCCESS, "%s: name heal " "successful on %lX", loc->path, - ec_char_array_to_mask (participants, ec->nodes)); + ec_char_array_to_mask (participants, + ec->nodes)); } else { - gf_log (this->name, GF_LOG_INFO, "%s: name heal " - "failed on %s", loc->path, strerror (-ret)); + gf_msg (this->name, GF_LOG_INFO, -ret, + EC_MSG_HEAL_FAIL, "%s: name heal " + "failed", loc->path); } } @@ -3691,7 +3701,7 @@ ec_heal (call_frame_t *frame, xlator_t *this, uintptr_t target, ec_fop_data_t *fop = NULL; int ret = 0; - gf_log("ec", GF_LOG_TRACE, "EC(HEAL) %p", frame); + gf_msg_trace ("ec", 0, "EC(HEAL) %p", frame); VALIDATE_OR_GOTO(this, fail); GF_VALIDATE_OR_GOTO(this->name, this->private, fail); diff --git a/xlators/cluster/ec/src/ec-heald.c b/xlators/cluster/ec/src/ec-heald.c index bfdf9597e0e..75f58487264 100644 --- a/xlators/cluster/ec/src/ec-heald.c +++ b/xlators/cluster/ec/src/ec-heald.c @@ -12,6 +12,7 @@ #include "defaults.h" #include "compat-errno.h" #include "ec.h" +#include "ec-messages.h" #include "ec-heald.h" #include "ec-mem-types.h" #include "syncop.h" @@ -182,7 +183,7 @@ ec_shd_index_inode (xlator_t *this, xlator_t *subvol) if (ret) goto out; - gf_log (this->name, GF_LOG_DEBUG, "index-dir gfid for %s: %s", + gf_msg_debug (this->name, 0, "index-dir gfid for %s: %s", subvol->name, uuid_utoa (index_gfid)); inode = ec_shd_inode_find (this, subvol, index_gfid); @@ -232,7 +233,7 @@ ec_shd_index_heal (xlator_t *subvol, gf_dirent_t *entry, loc_t *parent, if (!ec->shd.enabled) return -EBUSY; - gf_log (healer->this->name, GF_LOG_DEBUG, "got entry: %s", + gf_msg_debug (healer->this->name, 0, "got entry: %s", entry->d_name); ret = gf_uuid_parse (entry->d_name, loc.gfid); @@ -274,7 +275,8 @@ ec_shd_index_sweep (struct subvol_healer *healer) loc.inode = ec_shd_index_inode (healer->this, subvol); if (!loc.inode) { - gf_log (healer->this->name, GF_LOG_WARNING, + gf_msg (healer->this->name, GF_LOG_WARNING, errno, + EC_MSG_INDEX_DIR_GET_FAIL, "unable to get index-dir on %s", subvol->name); return -errno; } @@ -357,13 +359,13 @@ ec_shd_index_healer (void *data) ASSERT_LOCAL(this, healer); - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "starting index sweep on subvol %s", ec_subvol_name (this, healer->subvol)); ec_shd_index_sweep (healer); - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "finished index sweep on subvol %s", ec_subvol_name (this, healer->subvol)); } @@ -397,13 +399,15 @@ ec_shd_full_healer (void *data) ASSERT_LOCAL(this, healer); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + EC_MSG_FULL_SWEEP_START, "starting full sweep on subvol %s", ec_subvol_name (this, healer->subvol)); ec_shd_full_sweep (healer, this->itable->root); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + EC_MSG_FULL_SWEEP_STOP, "finished full sweep on subvol %s", ec_subvol_name (this, healer->subvol)); } diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c index 48251c84bac..372633df6be 100644 --- a/xlators/cluster/ec/src/ec-helpers.c +++ b/xlators/cluster/ec/src/ec-helpers.c @@ -15,6 +15,7 @@ #include "ec-mem-types.h" #include "ec-fops.h" #include "ec-helpers.h" +#include "ec-messages.h" #ifndef ffsll #define ffsll(x) __builtin_ffsll(x) @@ -79,7 +80,7 @@ void ec_trace(const char * event, ec_fop_data_t * fop, const char * fmt, ...) msg = "<memory allocation error>"; } - gf_log("ec", GF_LOG_TRACE, "%s(%s) %p(%p) [refs=%d, winds=%d, jobs=%d] " + gf_msg_trace ("ec", 0, "%s(%s) %p(%p) [refs=%d, winds=%d, jobs=%d] " "frame=%p/%p, min/exp=%d/%d, err=%d state=%d " "{%s:%s:%s} %s", event, ec_fop_name(fop->id), fop, fop->parent, fop->refs, @@ -250,8 +251,10 @@ int32_t ec_dict_set_config(dict_t * dict, char * key, ec_config_t * config) if (config->version > EC_CONFIG_VERSION) { - gf_log("ec", GF_LOG_ERROR, "Trying to store an unsupported config " - "version (%u)", config->version); + gf_msg ("ec", GF_LOG_ERROR, EINVAL, + EC_MSG_UNSUPPORTED_VERSION, + "Trying to store an unsupported config " + "version (%u)", config->version); return -1; } @@ -291,8 +294,10 @@ int32_t ec_dict_del_config(dict_t * dict, char * key, ec_config_t * config) config->version = (data >> 56) & 0xff; if (config->version > EC_CONFIG_VERSION) { - gf_log("ec", GF_LOG_ERROR, "Found an unsupported config version (%u)", - config->version); + gf_msg ("ec", GF_LOG_ERROR, EINVAL, + EC_MSG_UNSUPPORTED_VERSION, + "Found an unsupported config version (%u)", + config->version); return -1; } @@ -324,7 +329,9 @@ int32_t ec_loc_gfid_check(xlator_t * xl, uuid_t dst, uuid_t src) if (gf_uuid_compare(dst, src) != 0) { - gf_log(xl->name, GF_LOG_WARNING, "Mismatching GFID's in loc"); + gf_msg (xl->name, GF_LOG_WARNING, 0, + EC_MSG_GFID_MISMATCH, + "Mismatching GFID's in loc"); return 0; } @@ -369,8 +376,10 @@ int32_t ec_loc_setup_parent(xlator_t *xl, inode_table_t *table, loc_t *loc) } else if (loc->path && strchr (loc->path, '/')) { path = gf_strdup(loc->path); if (path == NULL) { - gf_log(xl->name, GF_LOG_ERROR, "Unable to duplicate path '%s'", - loc->path); + gf_msg (xl->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Unable to duplicate path '%s'", + loc->path); goto out; } @@ -422,8 +431,10 @@ int32_t ec_loc_setup_path(xlator_t *xl, loc_t *loc) if (loc->name != NULL) { if (strcmp(loc->name, name) != 0) { - gf_log(xl->name, GF_LOG_ERROR, "Invalid name '%s' in loc", - loc->name); + gf_msg (xl->name, GF_LOG_ERROR, EINVAL, + EC_MSG_INVALID_LOC_NAME, + "Invalid name '%s' in loc", + loc->name); goto out; } @@ -458,17 +469,21 @@ int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent) if (loc->path && strchr (loc->path, '/')) { str = gf_strdup(loc->path); if (str == NULL) { - gf_log(xl->name, GF_LOG_ERROR, "Unable to duplicate path '%s'", - loc->path); + gf_msg (xl->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Unable to duplicate path '%s'", + loc->path); - goto out; + goto out; } parent->path = gf_strdup(dirname(str)); if (parent->path == NULL) { - gf_log(xl->name, GF_LOG_ERROR, "Unable to duplicate path '%s'", - dirname(str)); + gf_msg (xl->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Unable to duplicate path '%s'", + dirname(str)); - goto out; + goto out; } } @@ -480,7 +495,9 @@ int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent) if ((parent->inode == NULL) && (parent->path == NULL) && gf_uuid_is_null(parent->gfid)) { - gf_log(xl->name, GF_LOG_ERROR, "Parent inode missing for loc_t"); + gf_msg (xl->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_PARENT_INODE_MISSING, + "Parent inode missing for loc_t"); goto out; } diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c index 1f91391a401..29e61bae8fd 100644 --- a/xlators/cluster/ec/src/ec-inode-read.c +++ b/xlators/cluster/ec/src/ec-inode-read.c @@ -16,6 +16,7 @@ #include "ec-combine.h" #include "ec-method.h" #include "ec-fops.h" +#include "ec-messages.h" /* FOP: access */ @@ -131,8 +132,10 @@ ec_manager_access(ec_fop_data_t *fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, + "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -146,7 +149,7 @@ void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(ACCESS) %p", frame); + gf_msg_trace ("ec", 0, "EC(ACCESS) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -166,7 +169,9 @@ void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, + "Failed to copy a location."); goto out; } @@ -176,8 +181,10 @@ void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -203,7 +210,8 @@ int32_t ec_combine_getxattr(ec_fop_data_t * fop, ec_cbk_data_t * dst, { if (!ec_dict_compare(dst->dict, src->dict)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching dictionary in " + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_DICT_MISMATCH, "Mismatching dictionary in " "answers of 'GF_FOP_GETXATTR'"); return 0; @@ -241,8 +249,10 @@ int32_t ec_getxattr_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->dict = dict_ref(dict); if (cbk->dict == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -253,8 +263,10 @@ int32_t ec_getxattr_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -404,8 +416,10 @@ int32_t ec_manager_getxattr(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, + "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -473,7 +487,7 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(GETXATTR) %p", frame); + gf_msg_trace ("ec", 0, "EC(GETXATTR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -500,7 +514,9 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, + "Failed to copy a location."); goto out; } @@ -510,7 +526,9 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->str[0] = gf_strdup(name); if (fop->str[0] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a string."); goto out; } @@ -520,8 +538,10 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -568,8 +588,10 @@ int32_t ec_fgetxattr_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->dict = dict_ref(dict); if (cbk->dict == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -580,8 +602,10 @@ int32_t ec_fgetxattr_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -618,7 +642,7 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FGETXATTR) %p", frame); + gf_msg_trace ("ec", 0, "EC(FGETXATTR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -640,8 +664,10 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, + "Failed to reference a " + "file descriptor."); goto out; } @@ -651,7 +677,8 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->str[0] = gf_strdup(name); if (fop->str[0] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Failed to duplicate a string."); goto out; } @@ -661,7 +688,8 @@ ec_fgetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -685,7 +713,8 @@ int32_t ec_combine_open(ec_fop_data_t * fop, ec_cbk_data_t * dst, { if (dst->fd != src->fd) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching fd in answers " + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_FD_MISMATCH, "Mismatching fd in answers " "of 'GF_FOP_OPEN': %p <-> %p", dst->fd, src->fd); @@ -724,7 +753,8 @@ int32_t ec_open_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->fd = fd_ref(fd); if (cbk->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -736,7 +766,8 @@ int32_t ec_open_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -902,8 +933,9 @@ int32_t ec_manager_open(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -917,7 +949,7 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(OPEN) %p", frame); + gf_msg_trace ("ec", 0, "EC(OPEN) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -937,7 +969,8 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -947,7 +980,8 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -958,7 +992,8 @@ void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -984,7 +1019,8 @@ int32_t ec_combine_readlink(ec_fop_data_t * fop, ec_cbk_data_t * dst, ec_cbk_data_t * src) { if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 1)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_IATT_MISMATCH, "Mismatching iatt in " "answers of 'GF_FOP_READLINK'"); return 0; @@ -1064,8 +1100,9 @@ int32_t ec_manager_readlink(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1079,7 +1116,7 @@ void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(READLINK) %p", frame); + gf_msg_trace ("ec", 0, "EC(READLINK) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1099,7 +1136,8 @@ void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1109,7 +1147,8 @@ void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1250,14 +1289,16 @@ int32_t ec_combine_readv(ec_fop_data_t * fop, ec_cbk_data_t * dst, { if (!ec_vector_compare(dst->vector, dst->int32, src->vector, src->int32)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching vector in " + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_VECTOR_MISMATCH, "Mismatching vector in " "answers of 'GF_FOP_READ'"); return 0; } if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 1)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_IATT_MISMATCH, "Mismatching iatt in " "answers of 'GF_FOP_READ'"); return 0; @@ -1299,7 +1340,8 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->vector = iov_dup(vector, count); if (cbk->vector == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a " + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Failed to duplicate a " "vector list."); goto out; @@ -1315,7 +1357,8 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->buffers = iobref_ref(iobref); if (cbk->buffers == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_BUF_REF_FAIL, "Failed to reference a " "buffer."); goto out; @@ -1327,7 +1370,8 @@ int32_t ec_readv_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1462,8 +1506,9 @@ int32_t ec_manager_readv(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1477,7 +1522,7 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(READ) %p", frame); + gf_msg_trace ("ec", 0, "EC(READ) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1502,7 +1547,8 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -1513,7 +1559,8 @@ void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1539,7 +1586,8 @@ int32_t ec_combine_stat(ec_fop_data_t * fop, ec_cbk_data_t * dst, ec_cbk_data_t * src) { if (!ec_iatt_combine(fop, dst->iatt, src->iatt, 1)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_IATT_MISMATCH, "Mismatching iatt in " "answers of 'GF_FOP_STAT'"); return 0; @@ -1582,7 +1630,8 @@ int32_t ec_stat_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1726,8 +1775,9 @@ int32_t ec_manager_stat(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1741,7 +1791,7 @@ void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(STAT) %p", frame); + gf_msg_trace ("ec", 0, "EC(STAT) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1759,7 +1809,8 @@ void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, "Failed to copy a location."); goto out; } @@ -1769,7 +1820,8 @@ void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1825,7 +1877,8 @@ int32_t ec_fstat_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; @@ -1861,7 +1914,7 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FSTAT) %p", frame); + gf_msg_trace ("ec", 0, "EC(FSTAT) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1882,7 +1935,8 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, "Failed to reference a " "file descriptor."); goto out; @@ -1893,7 +1947,8 @@ void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, "Failed to reference a " "dictionary."); goto out; diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c index 368b3ae5edf..ff8e89e6a72 100644 --- a/xlators/cluster/ec/src/ec-inode-write.c +++ b/xlators/cluster/ec/src/ec-inode-write.c @@ -16,6 +16,7 @@ #include "ec-combine.h" #include "ec-method.h" #include "ec-fops.h" +#include "ec-messages.h" int ec_inode_write_cbk (call_frame_t *frame, xlator_t *this, void *cookie, @@ -192,8 +193,10 @@ ec_manager_xattr (ec_fop_data_t *fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, + "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -208,7 +211,7 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(REMOVEXATTR) %p", frame); + gf_msg_trace ("ec", 0, "EC(REMOVEXATTR) %p", frame); VALIDATE_OR_GOTO (this, out); GF_VALIDATE_OR_GOTO (this->name, frame, out); @@ -227,7 +230,9 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, + "Failed to copy a location."); goto out; } @@ -237,7 +242,9 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->str[0] = gf_strdup(name); if (fop->str[0] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a string."); goto out; } @@ -247,8 +254,10 @@ ec_removexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -292,7 +301,7 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FREMOVEXATTR) %p", frame); + gf_msg_trace ("ec", 0, "EC(FREMOVEXATTR) %p", frame); VALIDATE_OR_GOTO (this, out); GF_VALIDATE_OR_GOTO (this->name, frame, out); @@ -314,8 +323,10 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, + "Failed to reference a " + "file descriptor."); goto out; } @@ -325,7 +336,9 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->str[0] = gf_strdup(name); if (fop->str[0] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a string."); goto out; } @@ -335,8 +348,10 @@ ec_fremovexattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -495,8 +510,10 @@ int32_t ec_manager_setattr(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, + "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -511,7 +528,7 @@ void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(SETATTR) %p", frame); + gf_msg_trace ("ec", 0, "EC(SETATTR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -532,7 +549,9 @@ void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, + "Failed to copy a location."); goto out; } @@ -546,8 +565,10 @@ void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -594,7 +615,7 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FSETATTR) %p", frame); + gf_msg_trace ("ec", 0, "EC(FSETATTR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -618,8 +639,10 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, + "Failed to reference a " + "file descriptor."); goto out; } @@ -633,8 +656,10 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -680,7 +705,7 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(SETXATTR) %p", frame); + gf_msg_trace ("ec", 0, "EC(SETXATTR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -701,7 +726,9 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, + "Failed to copy a location."); goto out; } @@ -711,8 +738,10 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->dict = dict_ref(dict); if (fop->dict == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -722,8 +751,10 @@ ec_setxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -768,8 +799,10 @@ ec_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -805,7 +838,7 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FSETXATTR) %p", frame); + gf_msg_trace ("ec", 0, "EC(FSETXATTR) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -829,8 +862,10 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, + "Failed to reference a " + "file descriptor."); goto out; } @@ -840,8 +875,10 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->dict = dict_ref(dict); if (fop->dict == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -851,8 +888,10 @@ ec_fsetxattr (call_frame_t *frame, xlator_t *this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -1117,8 +1156,10 @@ int32_t ec_manager_truncate(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, + "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1132,7 +1173,7 @@ void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(TRUNCATE) %p", frame); + gf_msg_trace ("ec", 0, "EC(TRUNCATE) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1153,7 +1194,9 @@ void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, + "Failed to copy a location."); goto out; } @@ -1163,8 +1206,10 @@ void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -1211,7 +1256,7 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FTRUNCATE) %p", frame); + gf_msg_trace ("ec", 0, "EC(FTRUNCATE) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1235,8 +1280,10 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, + "Failed to reference a " + "file descriptor."); goto out; } @@ -1246,8 +1293,10 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -1645,8 +1694,10 @@ int32_t ec_manager_writev(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, + "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1661,7 +1712,7 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(WRITE) %p", frame); + gf_msg_trace ("ec", 0, "EC(WRITE) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1687,8 +1738,10 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, + "Failed to reference a " + "file descriptor."); goto out; } @@ -1698,8 +1751,10 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->vector = iov_dup(vector, count); if (fop->vector == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a " - "vector list."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a " + "vector list."); goto out; } @@ -1710,8 +1765,10 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->buffers = iobref_ref(iobref); if (fop->buffers == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "buffer."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_BUF_REF_FAIL, + "Failed to reference a " + "buffer."); goto out; } @@ -1721,8 +1778,10 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } diff --git a/xlators/cluster/ec/src/ec-locks.c b/xlators/cluster/ec/src/ec-locks.c index 22b6fa4d6e5..dd79514359f 100644 --- a/xlators/cluster/ec/src/ec-locks.c +++ b/xlators/cluster/ec/src/ec-locks.c @@ -16,6 +16,7 @@ #include "ec-combine.h" #include "ec-method.h" #include "ec-fops.h" +#include "ec-messages.h" #define EC_LOCK_MODE_NONE 0 #define EC_LOCK_MODE_INC 1 @@ -91,7 +92,9 @@ int32_t ec_lock_unlocked(call_frame_t * frame, void * cookie, { if (op_ret < 0) { - gf_log(this->name, GF_LOG_WARNING, "Failed to unlock an entry/inode"); + gf_msg (this->name, GF_LOG_WARNING, 0, + EC_MSG_UNLOCK_FAILED, + "Failed to unlock an entry/inode"); } return 0; @@ -103,7 +106,9 @@ int32_t ec_lock_lk_unlocked(call_frame_t * frame, void * cookie, { if (op_ret < 0) { - gf_log(this->name, GF_LOG_WARNING, "Failed to unlock an lk"); + gf_msg(this->name, GF_LOG_WARNING, 0, + EC_MSG_LK_UNLOCK_FAILED, + "Failed to unlock an lk"); } return 0; @@ -137,8 +142,10 @@ int32_t ec_entrylk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg(this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -277,8 +284,10 @@ int32_t ec_manager_entrylk(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, + "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -293,7 +302,7 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(ENTRYLK) %p", frame); + gf_msg_trace ("ec", 0, "EC(ENTRYLK) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -316,7 +325,9 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->str[0] = gf_strdup(volume); if (fop->str[0] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a string."); goto out; } @@ -325,7 +336,9 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, + "Failed to copy a location."); goto out; } @@ -335,7 +348,9 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->str[1] = gf_strdup(basename); if (fop->str[1] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a string."); goto out; } @@ -345,8 +360,10 @@ void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -393,8 +410,10 @@ int32_t ec_fentrylk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -431,7 +450,7 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FENTRYLK) %p", frame); + gf_msg_trace ("ec", 0, "EC(FENTRYLK) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -456,7 +475,9 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->str[0] = gf_strdup(volume); if (fop->str[0] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a string."); goto out; } @@ -466,8 +487,10 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, + "Failed to reference a " + "file descriptor."); goto out; } @@ -477,7 +500,9 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->str[1] = gf_strdup(basename); if (fop->str[1] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a string."); goto out; } @@ -487,8 +512,10 @@ void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -535,8 +562,10 @@ int32_t ec_inodelk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -687,8 +716,10 @@ int32_t ec_manager_inodelk(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, + "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -703,7 +734,7 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(INODELK) %p", frame); + gf_msg_trace ("ec", 0, "EC(INODELK) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -725,7 +756,9 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->str[0] = gf_strdup(volume); if (fop->str[0] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a string."); goto out; } @@ -734,7 +767,9 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, { if (loc_copy(&fop->loc[0], loc) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to copy a location."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_LOC_COPY_FAIL, + "Failed to copy a location."); goto out; } @@ -758,8 +793,10 @@ void ec_inodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -806,8 +843,10 @@ int32_t ec_finodelk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -844,7 +883,7 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(FINODELK) %p", frame); + gf_msg_trace ("ec", 0, "EC(FINODELK) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -868,7 +907,9 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->str[0] = gf_strdup(volume); if (fop->str[0] == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to duplicate a string."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, + "Failed to duplicate a string."); goto out; } @@ -878,8 +919,10 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "file descriptor."); goto out; } @@ -903,8 +946,10 @@ void ec_finodelk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -930,8 +975,10 @@ int32_t ec_combine_lk(ec_fop_data_t * fop, ec_cbk_data_t * dst, { if (!ec_flock_compare(&dst->flock, &src->flock)) { - gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching lock in " - "answers of 'GF_FOP_LK'"); + gf_msg (fop->xl->name, GF_LOG_NOTICE, 0, + EC_MSG_LOCK_MISMATCH, + "Mismatching lock in " + "answers of 'GF_FOP_LK'"); return 0; } @@ -983,8 +1030,10 @@ int32_t ec_lk_cbk(call_frame_t * frame, void * cookie, xlator_t * this, cbk->xdata = dict_ref(xdata); if (cbk->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } @@ -1105,8 +1154,10 @@ int32_t ec_manager_lk(ec_fop_data_t * fop, int32_t state) return EC_STATE_END; default: - gf_log(fop->xl->name, GF_LOG_ERROR, "Unhandled state %d for %s", - state, ec_fop_name(fop->id)); + gf_msg (fop->xl->name, GF_LOG_ERROR, 0, + EC_MSG_UNHANDLED_STATE, + "Unhandled state %d for %s", + state, ec_fop_name(fop->id)); return EC_STATE_END; } @@ -1120,7 +1171,7 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target, ec_fop_data_t * fop = NULL; int32_t error = EIO; - gf_log("ec", GF_LOG_TRACE, "EC(LK) %p", frame); + gf_msg_trace ("ec", 0, "EC(LK) %p", frame); VALIDATE_OR_GOTO(this, out); GF_VALIDATE_OR_GOTO(this->name, frame, out); @@ -1143,8 +1194,10 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->fd = fd_ref(fd); if (fop->fd == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "file descriptor."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_FILE_DESC_REF_FAIL, + "Failed to reference a " + "file descriptor."); goto out; } @@ -1168,8 +1221,10 @@ void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target, fop->xdata = dict_ref(xdata); if (fop->xdata == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to reference a " - "dictionary."); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_DICT_REF_FAIL, + "Failed to reference a " + "dictionary."); goto out; } diff --git a/xlators/cluster/ec/src/ec-messages.h b/xlators/cluster/ec/src/ec-messages.h new file mode 100644 index 00000000000..81ae3bb8c1b --- /dev/null +++ b/xlators/cluster/ec/src/ec-messages.h @@ -0,0 +1,519 @@ +/* + 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 _EC_MESSAGES_H_ +#define _EC_MESSAGES_H_ + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "glfs-message-id.h" + +/*! \file ec-messages.h + * \brief Glusterd 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_EC_COMP_BASE GLFS_MSGID_COMP_EC +#define GLFS_NUM_MESSAGES 65 +#define GLFS_MSGID_END (GLFS_EC_COMP_BASE + GLFS_NUM_MESSAGES + 1) +/* Messaged with message IDs */ +#define glfs_msg_start_x GLFS_EC_COMP_BASE, "Invalid: Start of messages" +/*------------*/ + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INVALID_CONFIG (GLFS_EC_COMP_BASE + 1) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_HEAL_FAIL (GLFS_EC_COMP_BASE + 2) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_DICT_COMBINE_FAIL (GLFS_EC_COMP_BASE + 3) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_STIME_COMBINE_FAIL (GLFS_EC_COMP_BASE + 4) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INVALID_DICT_NUMS (GLFS_EC_COMP_BASE + 5) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_IATT_COMBINE_FAIL (GLFS_EC_COMP_BASE + 6) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INVALID_FORMAT (GLFS_EC_COMP_BASE + 7) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_DICT_GET_FAILED (GLFS_EC_COMP_BASE + 8) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_UNHANDLED_STATE (GLFS_EC_COMP_BASE + 9) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_FILE_DESC_REF_FAIL (GLFS_EC_COMP_BASE + 10) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_LOC_COPY_FAIL (GLFS_EC_COMP_BASE + 11) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_BUF_REF_FAIL (GLFS_EC_COMP_BASE + 12) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_DICT_REF_FAIL (GLFS_EC_COMP_BASE + 13) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_LK_UNLOCK_FAILED (GLFS_EC_COMP_BASE + 14) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_UNLOCK_FAILED (GLFS_EC_COMP_BASE + 15) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_LOC_PARENT_INODE_MISSING (GLFS_EC_COMP_BASE + 16) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INVALID_LOC_NAME (GLFS_EC_COMP_BASE + 17) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_NO_MEMORY (GLFS_EC_COMP_BASE + 18) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_GFID_MISMATCH (GLFS_EC_COMP_BASE + 19) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_UNSUPPORTED_VERSION (GLFS_EC_COMP_BASE + 20) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_FD_CREATE_FAIL (GLFS_EC_COMP_BASE + 21) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_READDIRP_REQ_PREP_FAIL (GLFS_EC_COMP_BASE + 22) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_LOOKUP_REQ_PREP_FAIL (GLFS_EC_COMP_BASE + 23) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INODE_REF_FAIL (GLFS_EC_COMP_BASE + 24) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_LOOKUP_READAHEAD_FAIL (GLFS_EC_COMP_BASE + 25) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_FRAME_MISMATCH (GLFS_EC_COMP_BASE + 26) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_XLATOR_MISMATCH (GLFS_EC_COMP_BASE + 27) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_VECTOR_MISMATCH (GLFS_EC_COMP_BASE + 28) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_IATT_MISMATCH (GLFS_EC_COMP_BASE + 29) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_FD_MISMATCH (GLFS_EC_COMP_BASE + 30) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_DICT_MISMATCH (GLFS_EC_COMP_BASE + 31) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INDEX_DIR_GET_FAIL (GLFS_EC_COMP_BASE + 32) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_PREOP_LOCK_FAILED (GLFS_EC_COMP_BASE + 33) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_CHILDS_INSUFFICIENT (GLFS_EC_COMP_BASE + 34) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_OP_EXEC_UNAVAIL (GLFS_EC_COMP_BASE + 35) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_UNLOCK_DELAY_FAILED (GLFS_EC_COMP_BASE + 36) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_SIZE_VERS_UPDATE_FAIL (GLFS_EC_COMP_BASE + 37) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INVALID_REQUEST (GLFS_EC_COMP_BASE + 38) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INVALID_LOCK_TYPE (GLFS_EC_COMP_BASE + 39) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_SIZE_VERS_GET_FAIL (GLFS_EC_COMP_BASE + 40) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_FILE_SIZE_GET_FAIL (GLFS_EC_COMP_BASE + 41) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_FOP_MISMATCH (GLFS_EC_COMP_BASE + 42) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_SUBVOL_ID_DICT_SET_FAIL (GLFS_EC_COMP_BASE + 43) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_SUBVOL_BUILD_FAIL (GLFS_EC_COMP_BASE + 44) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_XLATOR_INIT_FAIL (GLFS_EC_COMP_BASE + 45) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_NO_PARENTS (GLFS_EC_COMP_BASE + 46) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_TIMER_CREATE_FAIL (GLFS_EC_COMP_BASE + 47) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_TOO_MANY_SUBVOLS (GLFS_EC_COMP_BASE + 48) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_DATA_UNAVAILABLE (GLFS_EC_COMP_BASE + 49) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INODE_REMOVE_FAIL (GLFS_EC_COMP_BASE + 50) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INVALID_REDUNDANCY (GLFS_EC_COMP_BASE + 51) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_XLATOR_PARSE_OPT_FAIL (GLFS_EC_COMP_BASE + 52) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_OP_FAIL_ON_SUBVOLS (GLFS_EC_COMP_BASE + 53) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INVALID_INODE (GLFS_EC_COMP_BASE + 54) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_LOCK_MISMATCH (GLFS_EC_COMP_BASE + 55) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_XDATA_MISMATCH (GLFS_EC_COMP_BASE + 56) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_HEALING_INFO (GLFS_EC_COMP_BASE + 57) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_HEAL_SUCCESS (GLFS_EC_COMP_BASE + 58) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_FULL_SWEEP_START (GLFS_EC_COMP_BASE + 59) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_FULL_SWEEP_STOP (GLFS_EC_COMP_BASE + 59) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_INVALID_FOP (GLFS_EC_COMP_BASE + 60) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_EC_UP (GLFS_EC_COMP_BASE + 61) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_EC_DOWN (GLFS_EC_COMP_BASE + 62) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_SIZE_XATTR_GET_FAIL (GLFS_EC_COMP_BASE + 63) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_VER_XATTR_GET_FAIL (GLFS_EC_COMP_BASE + 64) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + */ +#define EC_MSG_CONFIG_XATTR_GET_FAIL (GLFS_EC_COMP_BASE + 65) + +/*------------*/ +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" + +#endif /* !_EC_MESSAGES_H_ */ diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c index 797c390e383..64ab91bf9bd 100644 --- a/xlators/cluster/ec/src/ec.c +++ b/xlators/cluster/ec/src/ec.c @@ -18,6 +18,7 @@ #include "ec-fops.h" #include "ec-method.h" #include "ec.h" +#include "ec-messages.h" #include "ec-heald.h" #define EC_MAX_FRAGMENTS EC_METHOD_MAX_FRAGMENTS @@ -51,8 +52,10 @@ int32_t ec_parse_options(xlator_t * this) if ((ec->redundancy < 1) || (ec->redundancy >= ec->fragments) || (ec->fragments > EC_MAX_FRAGMENTS)) { - gf_log(this->name, GF_LOG_ERROR, "Invalid redundancy (must be between " - "1 and %d)", (ec->nodes - 1) / 2); + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + EC_MSG_INVALID_REDUNDANCY, + "Invalid redundancy (must be between " + "1 and %d)", (ec->nodes - 1) / 2); goto out; } @@ -68,7 +71,7 @@ int32_t ec_parse_options(xlator_t * this) ec->fragment_size = EC_METHOD_CHUNK_SIZE; ec->stripe_size = ec->fragment_size * ec->fragments; - gf_log("ec", GF_LOG_DEBUG, "Initialized with: nodes=%u, fragments=%u, " + gf_msg_debug ("ec", 0, "Initialized with: nodes=%u, fragments=%u, " "stripe_size=%u, node_mask=%lX", ec->nodes, ec->fragments, ec->stripe_size, ec->node_mask); @@ -90,7 +93,8 @@ int32_t ec_prepare_childs(xlator_t * this) } if (count > EC_MAX_NODES) { - gf_log(this->name, GF_LOG_ERROR, "Too many subvolumes"); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_TOO_MANY_SUBVOLS, "Too many subvolumes"); return EINVAL; } @@ -99,7 +103,8 @@ int32_t ec_prepare_childs(xlator_t * this) ec->xl_list = GF_CALLOC(count, sizeof(ec->xl_list[0]), ec_mt_xlator_t); if (ec->xl_list == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Allocation of xlator list failed"); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Allocation of xlator list failed"); return ENOMEM; } @@ -204,7 +209,8 @@ int32_t mem_acct_init(xlator_t * this) { if (xlator_mem_acct_init(this, ec_mt_end + 1) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Memory accounting initialization " + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Memory accounting initialization " "failed."); return -1; @@ -258,7 +264,8 @@ ec_up (xlator_t *this, ec_t *ec) } ec->up = 1; - gf_log(this->name, GF_LOG_INFO, "Going UP"); + gf_msg (this->name, GF_LOG_INFO, 0, + EC_MSG_EC_UP, "Going UP"); } void @@ -270,7 +277,8 @@ ec_down (xlator_t *this, ec_t *ec) } ec->up = 0; - gf_log(this->name, GF_LOG_INFO, "Going DOWN"); + gf_msg (this->name, GF_LOG_INFO, 0, + EC_MSG_EC_DOWN, "Going DOWN"); } void @@ -325,13 +333,14 @@ ec_launch_notify_timer (xlator_t *this, ec_t *ec) { struct timespec delay = {0, }; - gf_log (this->name, GF_LOG_DEBUG, "Initiating child-down timer"); + gf_msg_debug (this->name, 0, "Initiating child-down timer"); delay.tv_sec = 10; delay.tv_nsec = 0; ec->timer = gf_timer_call_after (this->ctx, delay, ec_notify_cbk, ec); if (ec->timer == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Cannot create timer " - "for delayed initialization"); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_TIMER_CREATE_FAIL, "Cannot create timer " + "for delayed initialization"); } } @@ -358,7 +367,7 @@ ec_handle_down (xlator_t *this, ec_t *ec, int32_t idx) } if (((ec->xl_up >> idx) & 1) != 0) { /* Duplicate event */ - gf_log(this->name, GF_LOG_DEBUG, "Child %d is DOWN", idx); + gf_msg_debug (this->name, 0, "Child %d is DOWN", idx); ec->xl_up ^= 1ULL << idx; ec->xl_up_count--; @@ -419,7 +428,7 @@ ec_notify (xlator_t *this, int32_t event, void *data, void *data2) dict_t *output = NULL; gf_boolean_t propagate = _gf_true; - gf_log (this->name, GF_LOG_TRACE, "NOTIFY(%d): %p, %p", + gf_msg_trace (this->name, 0, "NOTIFY(%d): %p, %p", event, data, data2); if (event == GF_EVENT_TRANSLATOR_OP) { @@ -514,13 +523,15 @@ init (xlator_t *this) if (this->parents == NULL) { - gf_log(this->name, GF_LOG_WARNING, "Volume does not have parents."); + gf_msg (this->name, GF_LOG_WARNING, 0, + EC_MSG_NO_PARENTS, "Volume does not have parents."); } ec = GF_MALLOC(sizeof(*ec), ec_mt_ec_t); if (ec == NULL) { - gf_log(this->name, GF_LOG_ERROR, "Failed to allocate private memory."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Failed to allocate private memory."); return -1; } @@ -539,21 +550,24 @@ init (xlator_t *this) if ((ec->fop_pool == NULL) || (ec->cbk_pool == NULL) || (ec->lock_pool == NULL)) { - gf_log(this->name, GF_LOG_ERROR, "Failed to create memory pools."); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + EC_MSG_NO_MEMORY, "Failed to create memory pools."); goto failed; } if (ec_prepare_childs(this) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to initialize xlator"); + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_XLATOR_INIT_FAIL, "Failed to initialize xlator"); goto failed; } if (ec_parse_options(this) != 0) { - gf_log(this->name, GF_LOG_ERROR, "Failed to parse xlator options"); + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + EC_MSG_XLATOR_PARSE_OPT_FAIL, "Failed to parse xlator options"); goto failed; } @@ -564,21 +578,23 @@ init (xlator_t *this) if (ec->shd.iamshd) ec_selfheal_daemon_init (this); - gf_log(this->name, GF_LOG_DEBUG, "Disperse translator initialized."); + gf_msg_debug (this->name, 0, "Disperse translator initialized."); ec->leaf_to_subvolid = dict_new (); if (!ec->leaf_to_subvolid) goto failed; if (glusterfs_reachable_leaves (this, ec->leaf_to_subvolid)) { - gf_log (this->name, GF_LOG_ERROR, "Failed to build subvol " - "dictionary"); - goto failed; + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_SUBVOL_BUILD_FAIL, "Failed to build subvol " + "dictionary"); + goto failed; } if (ec_subvol_to_subvol_id_transform (ec, ec->leaf_to_subvolid) < 0) { - gf_log (this->name, GF_LOG_ERROR, "Failed to build subvol-id " - "dictionary"); - goto failed; + gf_msg (this->name, GF_LOG_ERROR, 0, + EC_MSG_SUBVOL_ID_DICT_SET_FAIL, "Failed to build subvol-id " + "dictionary"); + goto failed; } return 0; |