summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-rebalance.c
diff options
context:
space:
mode:
authorNithya Balachandran <nbalacha@redhat.com>2014-05-30 11:26:40 +0530
committerVijay Bellur <vbellur@redhat.com>2014-06-16 06:25:51 -0700
commit7382b66de76101d625ed888ec7b7f82fd7da56d3 (patch)
treee28bc5b65c6557907c4e011ca1ca7776cabd0656 /xlators/cluster/dht/src/dht-rebalance.c
parent0031bd1d18c874f3b68b59df7f84fce354b9b86c (diff)
Cluster/DHT: New logging framework
Moved all relevant DHT gf_log calls to the new logging framework. Change-Id: I3af3cfe0416e332774a6c4ff6a091d006c400af2 BUG: 1075611 Signed-off-by: Nithya Balachandran <nbalacha@redhat.com> Reviewed-on: http://review.gluster.org/7929 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-rebalance.c')
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c321
1 files changed, 216 insertions, 105 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 49241d17657..603502c780c 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -154,14 +154,18 @@ gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, dict_t *xattrs,
conf = this->private;
if (uuid_is_null (loc->pargfid)) {
- gf_log ("", GF_LOG_ERROR, "loc->pargfid is NULL for "
- "%s", loc->path);
+ gf_msg ("", GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed :"
+ "loc->pargfid is NULL for %s", loc->path);
goto out;
}
if (uuid_is_null (loc->gfid)) {
- gf_log ("", GF_LOG_ERROR, "loc->gfid is NULL for "
- "%s", loc->path);
+ gf_msg ("", GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed :"
+ "loc->gfid is NULL for %s", loc->path);
goto out;
}
@@ -174,14 +178,20 @@ gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, dict_t *xattrs,
cached_subvol = dht_subvol_get_cached (this, loc->inode);
if (!cached_subvol) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get cached subvol"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed :"
+ "Failed to get cached subvol"
" for %s on %s", loc->name, this->name);
goto out;
}
hashed_subvol = dht_subvol_get_hashed (this, loc);
if (!hashed_subvol) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get hashed subvol"
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed :"
+ "Failed to get hashed subvol"
" for %s on %s", loc->name, this->name);
goto out;
}
@@ -195,15 +205,22 @@ gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, dict_t *xattrs,
ret = dict_set_str (link_xattr, conf->link_xattr_name,
hashed_subvol->name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set "
- "linkto xattr in dict for %s", loc->name);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed :"
+ "Failed to set dictionary value:"
+ " key = %s for %s",
+ conf->link_xattr_name, loc->name);
goto out;
}
ret = syncop_setxattr (cached_subvol, loc, link_xattr, 0);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Linkto setxattr "
- "failed %s -> %s (%s)", cached_subvol->name,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed :"
+ "Linkto setxattr failed %s -> %s (%s)",
+ cached_subvol->name,
loc->name, strerror (-ret));
ret = -1;
goto out;
@@ -236,8 +253,11 @@ gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, dict_t *xattrs,
}
ret = syncop_lookup (hashed_subvol, loc, NULL, &iatt, NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed lookup %s on %s (%s)"
- , loc->name, hashed_subvol->name, strerror (-ret));
+ gf_msg (this->name, GF_LOG_ERROR, -ret,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed :Failed lookup %s on %s ",
+ loc->name, hashed_subvol->name);
+
ret = -1;
goto out;
}
@@ -270,7 +290,9 @@ __is_file_migratable (xlator_t *this, loc_t *loc,
int ret = -1;
if (IA_ISDIR (stbuf->ia_type)) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
"%s: migrate-file called on directory", loc->path);
ret = -1;
goto out;
@@ -291,12 +313,16 @@ __is_file_migratable (xlator_t *this, loc_t *loc,
Checkout gf_defrag_handle_hardlink for more information.
*/
if (ret && ret != -2) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
"%s: failed to migrate file with link",
loc->path);
}
} else {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
"%s: file has hardlinks", loc->path);
ret = -ENOTSUP;
}
@@ -324,21 +350,26 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
ret = dict_set_static_bin (dict, "gfid-req", stbuf->ia_gfid, 16);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s: failed to set gfid in dict for create", loc->path);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_DICT_SET_FAILED,
+ "%s: failed to set dictionary value: key = gfid-req",
+ loc->path);
goto out;
}
ret = dict_set_str (dict, conf->link_xattr_name, from->name);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s: failed to set gfid in dict for create", loc->path);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_DICT_SET_FAILED,
+ "%s: failed to set dictionary value: key = %s ",
+ loc->path, conf->link_xattr_name);
goto out;
}
fd = fd_create (loc->inode, DHT_REBALANCE_PID);
if (!fd) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: fd create failed (destination) (%s)",
loc->path, strerror (errno));
ret = -1;
@@ -349,8 +380,9 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
if (!ret) {
/* File exits in the destination, check if gfid matches */
if (uuid_compare (stbuf->ia_gfid, new_stbuf.ia_gfid) != 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "file %s exits in %s with different gfid",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_GFID_MISMATCH,
+ "file %s exists in %s with different gfid",
loc->path, to->name);
fd_unref (fd);
goto out;
@@ -358,7 +390,8 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
}
if ((ret < 0) && (-ret != ENOENT)) {
/* File exists in destination, but not accessible */
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: failed to lookup file (%s)",
loc->path, strerror (-ret));
ret = -1;
@@ -370,7 +403,8 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
ret = syncop_create (to, loc, O_RDWR, DHT_LINKFILE_MODE, fd,
dict, &new_stbuf);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"failed to create %s on %s (%s)",
loc->path, to->name, strerror (-ret));
ret = -1;
@@ -379,13 +413,15 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
ret = syncop_fsetxattr (to, fd, xattr, 0);
if (ret < 0)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: failed to set xattr on %s (%s)",
loc->path, to->name, strerror (-ret));
ret = syncop_ftruncate (to, fd, stbuf->ia_size);
if (ret < 0)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"ftruncate failed for %s on %s (%s)",
loc->path, to->name, strerror (-ret));
@@ -393,7 +429,8 @@ __dht_rebalance_create_dst_file (xlator_t *to, xlator_t *from, loc_t *loc, struc
(GF_SET_ATTR_UID | GF_SET_ATTR_GID),
NULL, NULL);
if (ret < 0)
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"chown failed for %s on %s (%s)",
loc->path, to->name, strerror (-ret));
@@ -423,7 +460,8 @@ __dht_check_free_space (xlator_t *to, xlator_t *from, loc_t *loc,
ret = syncop_statfs (from, loc, &src_statfs);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"failed to get statfs of %s on %s (%s)",
loc->path, from->name, strerror (-ret));
ret = -1;
@@ -432,7 +470,8 @@ __dht_check_free_space (xlator_t *to, xlator_t *from, loc_t *loc,
ret = syncop_statfs (to, loc, &dst_statfs);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"failed to get statfs of %s on %s (%s)",
loc->path, to->name, strerror (-ret));
ret = -1;
@@ -460,7 +499,9 @@ __dht_check_free_space (xlator_t *to, xlator_t *from, loc_t *loc,
GF_DISK_SECTOR_SIZE);
if ((dst_statfs_blocks - stbuf->ia_blocks) <
(src_statfs_blocks + stbuf->ia_blocks)) {
- gf_log (this->name, GF_LOG_WARNING,
+
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"data movement attempted from node (%s) with"
" higher disk space to a node (%s) with "
"lesser disk space (%s)", from->name,
@@ -475,7 +516,8 @@ __dht_check_free_space (xlator_t *to, xlator_t *from, loc_t *loc,
check_avail_space:
if (((dst_statfs.f_bavail * dst_statfs.f_bsize) /
GF_DISK_SECTOR_SIZE) < stbuf->ia_blocks) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"data movement attempted from node (%s) with "
"to node (%s) which does not have required free space"
" for %s", from->name, to->name, loc->path);
@@ -557,7 +599,8 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc,
fd = fd_create (loc->inode, DHT_REBALANCE_PID);
if (!fd) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: fd create failed (source)", loc->path);
ret = -1;
goto out;
@@ -565,7 +608,8 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc,
ret = syncop_open (from, loc, O_RDWR, fd);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"failed to open file %s on %s (%s)",
loc->path, from->name, strerror (-ret));
ret = -1;
@@ -589,7 +633,8 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc,
to show which is the target, so other clients can work around it */
ret = syncop_setxattr (from, loc, dict, 0);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"failed to set xattr on %s in %s (%s)",
loc->path, from->name, strerror (-ret));
ret = -1;
@@ -604,7 +649,8 @@ __dht_rebalance_open_src_file (xlator_t *from, xlator_t *to, loc_t *loc,
ret = syncop_setattr (from, loc, &iatt, GF_SET_ATTR_MODE, NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"failed to set mode on %s in %s (%s)",
loc->path, from->name, strerror (-ret));
ret = -1;
@@ -648,7 +694,9 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
/* check in the destination if the file is link file */
ret = syncop_lookup (to, loc, dict, &stbuf, &rsp_dict, NULL);
if ((ret < 0) && (-ret != ENOENT)) {
- gf_log (this->name, GF_LOG_WARNING, "%s: lookup failed (%s)",
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "%s: lookup failed (%s)",
loc->path, strerror (-ret));
ret = -1;
goto out;
@@ -662,7 +710,8 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
if (!ret) {
if (!check_is_linkfile (loc->inode, &stbuf, rsp_dict,
conf->link_xattr_name)) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: file exists in destination", loc->path);
ret = -1;
goto out;
@@ -671,7 +720,8 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
/* as file is linkfile, delete it */
ret = syncop_unlink (to, loc);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: failed to delete the linkfile (%s)",
loc->path, strerror (-ret));
ret = -1;
@@ -692,7 +742,8 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
/* Handle symlinks separately */
ret = syncop_readlink (from, loc, &link, buf->ia_size);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: readlink on symlink failed (%s)",
loc->path, strerror (-ret));
ret = -1;
@@ -701,7 +752,8 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
ret = syncop_symlink (to, loc, link, dict, 0);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: creating symlink failed (%s)",
loc->path, strerror (-ret));
ret = -1;
@@ -716,7 +768,9 @@ migrate_special_files (xlator_t *this, xlator_t *from, xlator_t *to, loc_t *loc,
makedev (ia_major (buf->ia_rdev),
ia_minor (buf->ia_rdev)), dict, 0);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "%s: mknod failed (%s)",
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "%s: mknod failed (%s)",
loc->path, strerror (-ret));
ret = -1;
goto out;
@@ -727,7 +781,8 @@ done:
(GF_SET_ATTR_UID | GF_SET_ATTR_GID |
GF_SET_ATTR_MODE), NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: failed to perform setattr on %s (%s)",
loc->path, to->name, strerror (-ret));
ret = -1;
@@ -735,7 +790,9 @@ done:
ret = syncop_unlink (from, loc);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, "%s: unlink failed (%s)",
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "%s: unlink failed (%s)",
loc->path, strerror (-ret));
ret = -1;
}
@@ -783,7 +840,9 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
ret = dict_set_int32 (dict, conf->link_xattr_name, 256);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
"%s: failed to set 'linkto' key in dict", loc->path);
goto out;
}
@@ -791,7 +850,10 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
/* Phase 1 - Data migration is in progress from now on */
ret = syncop_lookup (from, loc, dict, &stbuf, &xattr_rsp, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s: lookup failed on %s (%s)",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
+ "%s: lookup failed on %s (%s)",
loc->path, from->name, strerror (-ret));
ret = -1;
goto out;
@@ -820,7 +882,9 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
/* TODO: move all xattr related operations to fd based operations */
ret = syncop_listxattr (from, loc, &xattr);
if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
"%s: failed to get xattr from %s (%s)",
loc->path, from->name, strerror (-ret));
ret = -1;
@@ -840,7 +904,9 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
/* Open the source, and also update mode/xattr */
ret = __dht_rebalance_open_src_file (from, to, loc, &stbuf, &src_fd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to open %s on %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed: failed to open %s on %s",
loc->path, from->name);
goto out;
}
@@ -848,8 +914,10 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
ret = syncop_fstat (from, src_fd, &stbuf);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to lookup %s on %s (%s)",
- loc->path, from->name, strerror (-ret));
+ gf_msg (this->name, GF_LOG_ERROR, -ret,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:failed to lookup %s on %s ",
+ loc->path, from->name);
ret = -1;
goto out;
}
@@ -862,12 +930,16 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
ret = __dht_rebalance_migrate_data (from, to, src_fd, dst_fd,
stbuf.ia_size, file_has_holes);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s: failed to migrate data",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed: %s: failed to migrate data",
loc->path);
/* reset the destination back to 0 */
ret = syncop_ftruncate (to, dst_fd, 0);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed: "
"%s: failed to reset target size back to 0 (%s)",
loc->path, strerror (-ret));
}
@@ -892,9 +964,10 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
ret = syncop_fstat (from, src_fd, &new_stbuf);
if (ret < 0) {
/* Failed to get the stat info */
- gf_log (this->name, GF_LOG_ERROR,
- "failed to fstat file %s on %s (%s)",
- loc->path, from->name, strerror (-ret));
+ gf_msg ( this->name, GF_LOG_ERROR, -ret,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed: failed to fstat file %s on %s ",
+ loc->path, from->name);
ret = -1;
goto out;
}
@@ -915,9 +988,11 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
(GF_SET_ATTR_UID | GF_SET_ATTR_GID |
GF_SET_ATTR_MODE), NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
- "%s: failed to perform setattr on %s (%s)",
- loc->path, to->name, strerror (-ret));
+ gf_msg (this->name, GF_LOG_WARNING, -ret,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
+ "%s: failed to perform setattr on %s ",
+ loc->path, to->name);
ret = -1;
goto out;
}
@@ -927,9 +1002,9 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
(GF_SET_ATTR_MTIME | GF_SET_ATTR_ATIME),
NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
- "%s: failed to perform setattr on %s (%s)",
- loc->path, to->name, strerror (-ret));
+ gf_log (this->name, GF_LOG_WARNING,
+ "%s: failed to perform setattr on %s ",
+ loc->path, to->name);
ret = -1;
}
@@ -938,9 +1013,11 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
ret = syncop_fsetattr (from, src_fd, &empty_iatt,
GF_SET_ATTR_MODE, NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING, \
- "%s: failed to perform setattr on %s (%s)",
- loc->path, from->name, strerror (-ret));
+ gf_msg (this->name, GF_LOG_WARNING, -ret,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
+ "%s: failed to perform setattr on %s ",
+ loc->path, from->name);
ret = -1;
goto out;
}
@@ -967,7 +1044,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
/* Do a stat and check the gfid before unlink */
ret = syncop_stat (from, loc, &empty_iatt);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: failed to do a stat on %s (%s)",
loc->path, from->name, strerror (-ret));
ret = -1;
@@ -978,7 +1056,8 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
/* take out the source from namespace */
ret = syncop_unlink (from, loc);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"%s: failed to perform unlink on %s (%s)",
loc->path, from->name, strerror (-ret));
ret = -1;
@@ -988,13 +1067,14 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
ret = syncop_lookup (this, loc, NULL, NULL, NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG,
- "%s: failed to lookup the file on subvolumes (%s)",
- loc->path, strerror (-ret));
+ gf_msg_debug (this->name, 0,
+ "%s: failed to lookup the file on subvolumes (%s)",
+ loc->path, strerror (-ret));
ret = -1;
}
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ DHT_MSG_MIGRATE_FILE_COMPLETE,
"completed migration of %s from subvolume %s to %s",
loc->path, from->name, to->name);
@@ -1241,7 +1321,9 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
ret = syncop_opendir (this, loc, fd);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to open dir %s",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_DATA_FAILED,
+ "Migrate data failed: Failed to open dir %s",
loc->path);
ret = -1;
goto out;
@@ -1254,8 +1336,10 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR, "Readdir returned %s."
- " Aborting migrate-data",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_DATA_FAILED,
+ "%s: Migrate data failed: Readdir returned"
+ " %s. Aborting migrate-data", loc->path,
strerror(-ret));
ret = -1;
goto out;
@@ -1301,8 +1385,9 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
}
if (uuid_is_null (entry->d_stat.ia_gfid)) {
- gf_log (this->name, GF_LOG_ERROR, "%s/%s"
- " gfid not present", loc->path,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_GFID_NULL,
+ "%s/%s gfid not present", loc->path,
entry->d_name);
continue;
}
@@ -1310,8 +1395,9 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
uuid_copy (entry_loc.gfid, entry->d_stat.ia_gfid);
if (uuid_is_null (loc->gfid)) {
- gf_log (this->name, GF_LOG_ERROR, "%s/%s"
- " gfid not present", loc->path,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_GFID_NULL,
+ "%s/%s gfid not present", loc->path,
entry->d_name);
continue;
}
@@ -1323,8 +1409,10 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
ret = syncop_lookup (this, &entry_loc, NULL, &iatt,
NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s"
- " lookup failed", entry_loc.path);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:%s lookup failed",
+ entry_loc.path);
ret = -1;
continue;
}
@@ -1332,8 +1420,11 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
ret = syncop_getxattr (this, &entry_loc, &dict,
GF_XATTR_NODE_UUID_KEY);
if(ret < 0) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to "
- "get node-uuid for %s", entry_loc.path);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
+ "Failed to get node-uuid for %s",
+ entry_loc.path);
ret = -1;
continue;
}
@@ -1358,8 +1449,9 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
* the other node will take responsibility of migration
*/
if (uuid_compare (node_uuid, defrag->node_uuid)) {
- gf_log (this->name, GF_LOG_TRACE, "%s does not"
- "belong to this node", entry_loc.path);
+ gf_msg_trace (this->name, 0, "%s does not"
+ "belong to this node",
+ entry_loc.path);
continue;
}
@@ -1398,13 +1490,15 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
/* errno is overloaded. See
* rebalance_task_completion () */
if (op_errno == ENOSPC) {
- gf_log (this->name, GF_LOG_DEBUG,
- "migrate-data skipped for %s"
- " due to space constraints",
- entry_loc.path);
+ gf_msg_debug (this->name, 0,
+ "migrate-data skipped for"
+ " %s due to space "
+ "constraints",
+ entry_loc.path);
defrag->skipped +=1;
} else{
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"migrate-data failed for %s",
entry_loc.path);
defrag->total_failures +=1;
@@ -1414,16 +1508,18 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
defrag);
if (!ret)
- gf_log (this->name, GF_LOG_DEBUG,
- "migrate-data on %s failed: %s",
- entry_loc.path,
- strerror (op_errno));
+ gf_msg_debug (this->name, 0,
+ "migrate-data on %s "
+ "failed: %s",
+ entry_loc.path,
+ strerror (op_errno));
else if (ret == 1)
continue;
else if (ret == -1)
goto out;
} else if (ret > 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
"migrate-data failed for %s",
entry_loc.path);
defrag->total_failures +=1;
@@ -1502,7 +1598,7 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
goto out;
}
- gf_log (this->name, GF_LOG_TRACE, "fix layout called on %s", loc->path);
+ gf_msg_trace (this->name, 0, "fix layout called on %s", loc->path);
fd = fd_create (loc->inode, defrag->pid);
if (!fd) {
@@ -1618,8 +1714,10 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
fix_layout, migrate_data);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Fix layout "
- "failed for %s", entry_loc.path);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_LAYOUT_FIX_FAILED,
+ "Fix layout failed for %s",
+ entry_loc.path);
defrag->total_failures++;
goto out;
}
@@ -1691,7 +1789,9 @@ gf_defrag_start_crawl (void *data)
ret = syncop_lookup (this, &loc, NULL, &iatt, NULL, &parent);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "look up on / failed");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_REBALANCE_START_FAILED,
+ "Failed to start rebalance: look up on / failed");
ret = -1;
goto out;
}
@@ -1704,13 +1804,20 @@ gf_defrag_start_crawl (void *data)
ret = dict_set_str (fix_layout, GF_XATTR_FIX_LAYOUT_KEY, "yes");
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to set dict str");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_REBALANCE_START_FAILED,
+ "Failed to start rebalance:"
+ "Failed to set dictionary value: key = %s",
+ GF_XATTR_FIX_LAYOUT_KEY);
+
goto out;
}
ret = syncop_setxattr (this, &loc, fix_layout, 0);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "fix layout on %s failed",
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_REBALANCE_FAILED,
+ "fix layout on %s failed",
loc.path);
defrag->total_failures++;
ret = -1;
@@ -1806,8 +1913,9 @@ gf_defrag_start (void *data)
gf_defrag_done, frame, this);
if (ret)
- gf_log (this->name, GF_LOG_ERROR, "Could not create"
- " task for rebalance");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_REBALANCE_START_FAILED,
+ "Could not create task for rebalance");
out:
return NULL;
}
@@ -1903,9 +2011,11 @@ log:
break;
}
- gf_log (THIS->name, GF_LOG_INFO, "Rebalance is %s. Time taken is %.2f "
- "secs", status, elapsed);
- gf_log (THIS->name, GF_LOG_INFO, "Files migrated: %"PRIu64", size: %"
+ gf_msg (THIS->name, GF_LOG_INFO, 0, DHT_MSG_REBALANCE_STATUS,
+ "Rebalance is %s. Time taken is %.2f secs",
+ status, elapsed);
+ gf_msg (THIS->name, GF_LOG_INFO, 0, DHT_MSG_REBALANCE_STATUS,
+ "Files migrated: %"PRIu64", size: %"
PRIu64", lookups: %"PRIu64", failures: %"PRIu64", skipped: "
"%"PRIu64, files, size, lookup, failures, skipped);
@@ -1927,13 +2037,14 @@ gf_defrag_stop (gf_defrag_info_t *defrag, gf_defrag_status_t status,
goto out;
}
- gf_log ("", GF_LOG_INFO, "Received stop command on rebalance");
+ gf_msg ("", GF_LOG_INFO, 0, DHT_MSG_REBALANCE_STOPPED,
+ "Received stop command on rebalance");
defrag->defrag_status = status;
if (output)
gf_defrag_status_get (defrag, output);
ret = 0;
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("", 0, "Returning %d", ret);
return ret;
}