diff options
author | Venkatesh Somyajulu <vsomyaju@redhat.com> | 2014-07-03 19:46:59 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-07-03 09:22:37 -0700 |
commit | dc46d5e84f88c5cc869b78ba9db32ed4035b9121 (patch) | |
tree | 17a7ebaaaa4a8255dcc9f1cc88de3a117e6c1b0e /xlators/cluster/dht | |
parent | dedef037d64fef59d74b9861562aa7f93857a53e (diff) |
cluster/dht: Added logging of new layout for dir-selfheal
Added a log which logs the new layout which will be used
for the directory self healing
It prints:
a) Subvolume name
b) Error --> Is needed because layout healing depends on
the error and having it in log will help in
debugging
c) Start Starting of the layout range
d) Stop Ending of the layout range
Change-Id: I48c9c697716a899165ed29b737362a75c62e09b3
BUG: 1113066
Signed-off-by: Venkatesh Somyajulu <vsomyaju@redhat.com>
Reviewed-on: http://review.gluster.org/8173
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster/dht')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 104 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 3 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-messages.h | 11 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-selfheal.c | 8 |
4 files changed, 125 insertions, 1 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 45450d5f383..d50b818cb16 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -5592,3 +5592,107 @@ dht_inode_ctx_layout_get (inode_t *inode, xlator_t *this, dht_layout_t **layout) return ret; } + +void +dht_log_new_layout_for_dir_selfheal (xlator_t *this, loc_t *loc, + dht_layout_t *layout) +{ + + char string[2048] = {0}; + char *output_string = NULL; + int len = 0; + int off = 0; + int i = 0; + gf_loglevel_t log_level = gf_log_get_loglevel(); + int ret = 0; + int max_string_len = 0; + + if (log_level < GF_LOG_INFO) + return; + + if (!layout) + return; + + if (!layout->cnt) + return; + + if (!loc) + return; + + if (!loc->path) + return; + + max_string_len = sizeof (string); + + ret = snprintf (string, max_string_len, "Setting layout of %s with ", + loc->path); + + if (ret < 0) + return; + + len += ret; + + /* Calculation of total length of the string required to calloc + * output_string. Log includes subvolume-name, start-range, end-range and + * err value. + * + * This log will help to debug cases where: + * a) Different processes set different layout of a directory. + * b) Error captured in lookup, which will be filled in layout->err + * (like ENOENT, ESTALE etc) + */ + + for (i = 0; i < layout->cnt; i++) { + + ret = snprintf (string, max_string_len, + "[Subvol_name: %s, Err: %d , Start: " + "%"PRIu32 " , Stop: %"PRIu32 " ], ", + layout->list[i].xlator->name, + layout->list[i].err, layout->list[i].start, + layout->list[i].stop); + + if (ret < 0) + return; + + len += ret; + + } + + len++; + + output_string = GF_CALLOC (len, sizeof (char), gf_common_mt_char); + + if (!output_string) + return; + + ret = snprintf (output_string, len, "Setting layout of %s with ", + loc->path); + + if (ret < 0) + goto err; + + off += ret; + + + for (i = 0; i < layout->cnt; i++) { + + ret = snprintf (output_string + off, len - off, + "[Subvol_name: %s, Err: %d , Start: " + "%"PRIu32 " , Stop: %"PRIu32 " ], ", + layout->list[i].xlator->name, + layout->list[i].err, layout->list[i].start, + layout->list[i].stop); + + if (ret < 0) + goto err; + + off += ret; + + } + + gf_msg (this->name, GF_LOG_INFO, 0, DHT_MSG_LOG_FIXED_LAYOUT, + "%s", output_string); + +err: + GF_FREE (output_string); +} diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index e45418a73f6..5dee622a2a1 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -807,4 +807,7 @@ dht_inode_ctx_get1 (xlator_t *this, inode_t *inode, xlator_t **subvol); int dht_subvol_status (dht_conf_t *conf, xlator_t *subvol); +void +dht_log_new_layout_for_dir_selfheal (xlator_t *this, loc_t *loc, + dht_layout_t *layout); #endif/* _DHT_H */ diff --git a/xlators/cluster/dht/src/dht-messages.h b/xlators/cluster/dht/src/dht-messages.h index 7668e91ac99..80b20a61efd 100644 --- a/xlators/cluster/dht/src/dht-messages.h +++ b/xlators/cluster/dht/src/dht-messages.h @@ -45,7 +45,7 @@ */ #define GLFS_DHT_BASE GLFS_MSGID_COMP_DHT -#define GLFS_DHT_NUM_MESSAGES 35 +#define GLFS_DHT_NUM_MESSAGES 36 #define GLFS_MSGID_END (GLFS_DHT_BASE + GLFS_DHT_NUM_MESSAGES + 1) /* Messages with message IDs */ @@ -429,8 +429,17 @@ * @recommendedaction None * */ + #define DHT_MSG_LAYOUT_SET_FAILED (GLFS_DHT_BASE + 35) +/*! + * @messageid 109036 + * @diagnosis Informational message regarding layout range distribution + * for a directory across subvolumes + * @recommendedaction None + */ + +#define DHT_MSG_LOG_FIXED_LAYOUT (GLFS_DHT_BASE + 36) /*------------*/ #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c index 1e2d7438350..4b64acc8793 100644 --- a/xlators/cluster/dht/src/dht-selfheal.c +++ b/xlators/cluster/dht/src/dht-selfheal.c @@ -236,6 +236,8 @@ dht_fix_dir_xattr (call_frame_t *frame, loc_t *loc, dht_layout_t *layout) local->call_cnt = count = conf->subvolume_cnt; + dht_log_new_layout_for_dir_selfheal (this, loc, layout); + for (i = 0; i < layout->cnt; i++) { dht_selfheal_dir_xattr_persubvol (frame, loc, layout, i, NULL); @@ -306,6 +308,9 @@ dht_selfheal_dir_xattr (call_frame_t *frame, loc_t *loc, dht_layout_t *layout) } local->call_cnt = missing_xattr; + + dht_log_new_layout_for_dir_selfheal (this, loc, layout); + for (i = 0; i < layout->cnt; i++) { if (layout->list[i].err != -1 || !layout->list[i].stop) continue; @@ -430,6 +435,9 @@ dht_selfheal_dir_xattr_for_nameless_lookup (call_frame_t *frame, loc_t *loc, } local->call_cnt = missing_xattr; + + dht_log_new_layout_for_dir_selfheal (this, loc, layout); + for (i = 0; i < layout->cnt; i++) { if (layout->list[i].err != -1 || !layout->list[i].stop) continue; |