summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorManikandan Selvaganesh <mselvaga@redhat.com>2015-04-13 15:50:12 +0530
committerNiels de Vos <ndevos@redhat.com>2015-04-28 11:57:54 -0700
commitf3ff9abbe5f80911a88222cbdbcfa8616b4743da (patch)
treea7e534c08da195e0a9ce87cbc47d2d8d1d8e80ec /xlators
parentee6cd10ce947787bf6ea589bca1cb259c4bb214d (diff)
nfs / nfs files : porting log messages to new framework
Porting log messages to a new framework for nfs-common.c, nfs-fops.c, nfs-fops.h, nfs-inodes.c, nfs3-fh.c, nfs3-helpers.c. Change-Id: I55cd94de62eafe6ad3754cd065d7459a81a9f285 BUG: 1194640 Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com> Reviewed-on: http://review.gluster.org/10214 Tested-by: NetBSD Build System Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/nfs/server/src/nfs-common.c52
-rw-r--r--xlators/nfs/server/src/nfs-fops.c69
-rw-r--r--xlators/nfs/server/src/nfs-fops.h8
-rw-r--r--xlators/nfs/server/src/nfs-inodes.c10
-rw-r--r--xlators/nfs/server/src/nfs3-fh.c8
-rw-r--r--xlators/nfs/server/src/nfs3-helpers.c261
6 files changed, 245 insertions, 163 deletions
diff --git a/xlators/nfs/server/src/nfs-common.c b/xlators/nfs/server/src/nfs-common.c
index 547e5b3a833..b6791566c2c 100644
--- a/xlators/nfs/server/src/nfs-common.c
+++ b/xlators/nfs/server/src/nfs-common.c
@@ -24,6 +24,7 @@
#include "nfs-mem-types.h"
#include "rpcsvc.h"
#include "iatt.h"
+#include "nfs-messages.h"
#include <libgen.h>
@@ -87,7 +88,7 @@ nfs_mntpath_to_xlator (xlator_list_t *cl, char *path)
volname = strdupa (path);
pathlen = strlen (volname);
- gf_log (GF_NFS, GF_LOG_TRACE, "Subvolume search: %s", path);
+ gf_msg_trace (GF_NFS, 0, "Subvolume search: %s", path);
if (volname[0] == '/')
volptr = &volname[1];
else
@@ -167,7 +168,8 @@ nfs_loc_fill (loc_t *loc, inode_t *inode, inode_t *parent, char *path)
if (path) {
loc->path = gf_strdup (path);
if (!loc->path) {
- gf_log (GF_NFS, GF_LOG_ERROR, "strdup failed");
+ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM,
+ NFS_MSG_NO_MEMORY, "strdup failed");
goto loc_wipe;
}
loc->name = strrchr (loc->path, '/');
@@ -201,8 +203,9 @@ nfs_inode_loc_fill (inode_t *inode, loc_t *loc, int how)
if (!gf_uuid_is_null (inode->gfid)) {
ret = inode_path (inode, NULL, &resolvedpath);
if (ret < 0) {
- gf_log (GF_NFS, GF_LOG_ERROR, "path resolution failed "
- "%s", resolvedpath);
+ gf_msg (GF_NFS, GF_LOG_ERROR, 0,
+ NFS_MSG_PATH_RESOLVE_FAIL, "path resolution "
+ "failed %s", resolvedpath);
goto err;
}
}
@@ -218,8 +221,9 @@ nfs_inode_loc_fill (inode_t *inode, loc_t *loc, int how)
ret = nfs_loc_fill (loc, inode, parent, resolvedpath);
if (ret < 0) {
- gf_log (GF_NFS, GF_LOG_ERROR, "loc fill resolution failed %s",
- resolvedpath);
+ gf_msg (GF_NFS, GF_LOG_ERROR, -ret,
+ NFS_MSG_LOC_FILL_RESOLVE_FAIL,
+ "loc fill resolution failed %s", resolvedpath);
goto err;
}
@@ -244,31 +248,37 @@ nfs_gfid_loc_fill (inode_table_t *itable, uuid_t gfid, loc_t *loc, int how)
inode = inode_find (itable, gfid);
if (!inode) {
- gf_log (GF_NFS, GF_LOG_TRACE, "Inode not found in itable, will try to create one.");
+ gf_msg_trace (GF_NFS, 0, "Inode not found in itable, will "
+ "try to create one.");
if (how == NFS_RESOLVE_CREATE) {
- gf_log (GF_NFS, GF_LOG_TRACE, "Inode needs to be created.");
+ gf_msg_trace (GF_NFS, 0, "Inode needs to be created.");
inode = inode_new (itable);
if (!inode) {
- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to "
+ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM,
+ NFS_MSG_NO_MEMORY, "Failed to "
"allocate memory");
ret = -ENOMEM;
goto err;
}
} else {
- gf_log (GF_NFS, GF_LOG_ERROR, "Inode not found in itable and no creation was requested.");
+ gf_msg (GF_NFS, GF_LOG_ERROR, ENOENT,
+ NFS_MSG_INODE_NOT_FOUND, "Inode not found in "
+ "itable and no creation was requested.");
ret = -ENOENT;
goto err;
}
} else {
- gf_log (GF_NFS, GF_LOG_TRACE, "Inode was found in the itable.");
+ gf_msg_trace (GF_NFS, 0, "Inode was found in the itable.");
}
gf_uuid_copy (loc->gfid, gfid);
ret = nfs_inode_loc_fill (inode, loc, how);
if (ret < 0) {
- gf_log (GF_NFS, GF_LOG_ERROR, "Inode loc filling failed.: %s", strerror (-ret));
+ gf_msg (GF_NFS, GF_LOG_ERROR, -ret,
+ NFS_MSG_INODE_LOC_FILL_ERROR,
+ "Inode loc filling failed.: %s", strerror (-ret));
goto err;
}
@@ -302,8 +312,8 @@ nfs_parent_inode_loc_fill (inode_t *parent, inode_t *entryinode, char *entry,
ret = inode_path (parent, entry, &path);
if (ret < 0) {
- gf_log (GF_NFS, GF_LOG_ERROR, "path resolution failed %s",
- path);
+ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PATH_RESOLVE_FAIL,
+ "path resolution failed %s", path);
goto err;
}
@@ -369,16 +379,16 @@ nfs_entry_loc_fill (inode_table_t *itable, uuid_t pargfid, char *entry,
ret = inode_path (parent, entry, &resolvedpath);
if (ret < 0) {
- gf_log (GF_NFS, GF_LOG_ERROR, "path resolution failed %s",
- resolvedpath);
+ gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PATH_RESOLVE_FAIL,
+ "path resolution failed %s", resolvedpath);
ret = -3;
goto err;
}
ret = nfs_loc_fill (loc, entryinode, parent, resolvedpath);
if (ret < 0) {
- gf_log (GF_NFS, GF_LOG_ERROR, "loc_fill failed %s",
- resolvedpath);
+ gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_INODE_LOC_FILL_ERROR,
+ "loc_fill failed %s", resolvedpath);
ret = -3;
}
@@ -449,7 +459,8 @@ nfs_fix_generation (xlator_t *this, inode_t *inode)
ictx = GF_CALLOC (1, sizeof (struct nfs_inode_ctx),
gf_nfs_mt_inode_ctx);
if (!ictx) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ NFS_MSG_NO_MEMORY,
"could not allocate nfs inode ctx");
return;
}
@@ -457,7 +468,8 @@ nfs_fix_generation (xlator_t *this, inode_t *inode)
ictx->generation = priv->generation;
ret = inode_ctx_put (inode, this, (uint64_t)ictx);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ NFS_MSG_INODE_CTX_STORE_FAIL,
"could not store nfs inode ctx");
return;
}
diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c
index c3f1b5e2fa6..e5990a1e834 100644
--- a/xlators/nfs/server/src/nfs-fops.c
+++ b/xlators/nfs/server/src/nfs-fops.c
@@ -27,6 +27,7 @@
#include "nfs-common.h"
#include "nfs3-helpers.h"
#include "nfs-mem-types.h"
+#include "nfs-messages.h"
#include <libgen.h>
#include <semaphore.h>
@@ -78,23 +79,23 @@ nfs_fix_groups (xlator_t *this, call_stack_t *root)
/* No cached list found. */
if (getpwuid_r(root->uid,&mypw,mystrs,sizeof(mystrs),&result) != 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, NFS_MSG_GETPWUID_FAIL,
"getpwuid_r(%u) failed", root->uid);
return;
}
if (!result) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, NFS_MSG_GETPWUID_FAIL,
"getpwuid_r(%u) found nothing", root->uid);
return;
}
- gf_log (this->name, GF_LOG_TRACE, "mapped %u => %s",
- root->uid, result->pw_name);
+ gf_msg_trace (this->name, 0, "mapped %u => %s",
+ root->uid, result->pw_name);
ngroups = GF_MAX_AUX_GROUPS;
if (getgrouplist(result->pw_name,root->gid,mygroups,&ngroups) == -1) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, NFS_MSG_MAP_GRP_LIST_FAIL,
"could not map %s to group list", result->pw_name);
return;
}
@@ -124,8 +125,8 @@ nfs_fix_groups (xlator_t *this, call_stack_t *root)
/* Copy data to the frame. */
for (i = 0; i < ngroups; ++i) {
- gf_log (this->name, GF_LOG_TRACE,
- "%s is in group %u", result->pw_name, mygroups[i]);
+ gf_msg_trace (this->name, 0, "%s is in group %u",
+ result->pw_name, mygroups[i]);
root->groups[i] = mygroups[i];
}
root->ngrps = ngroups;
@@ -228,10 +229,11 @@ nfs_create_frame (xlator_t *xl, nfs_user_t *nfu)
if (nfu->ngrps != 1) {
frame->root->ngrps = nfu->ngrps - 1;
- gf_log (GF_NFS, GF_LOG_TRACE,"uid: %d, gid %d, gids: %d",
- frame->root->uid, frame->root->gid, frame->root->ngrps);
+ gf_msg_trace (GF_NFS, 0, "uid: %d, gid %d, gids: %d",
+ frame->root->uid, frame->root->gid,
+ frame->root->ngrps);
for(y = 0, x = 1; y < frame->root->ngrps; x++,y++) {
- gf_log (GF_NFS, GF_LOG_TRACE, "gid: %d", nfu->gids[x]);
+ gf_msg_trace (GF_NFS, 0, "gid: %d", nfu->gids[x]);
frame->root->groups[y] = nfu->gids[x];
}
}
@@ -251,7 +253,8 @@ err:
fram = nfs_create_frame (xla, (nfuser)); \
if (!fram) { \
retval = (-ENOMEM); \
- gf_log (GF_NFS, GF_LOG_ERROR,"Frame creation failed");\
+ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, \
+ NFS_MSG_NO_MEMORY, "Frame creation failed");\
goto errlabel; \
} \
} while (0) \
@@ -359,7 +362,9 @@ nfs_gfid_dict (inode_t *inode)
dictgfid = dict_new ();
if (!dictgfid) {
- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to create gfid dict");
+ gf_msg (GF_NFS, GF_LOG_ERROR, errno,
+ NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "Failed to create gfid dict");
GF_FREE (dyngfid);
return (NULL);
}
@@ -445,7 +450,7 @@ nfs_fop_lookup (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *loc,
if ((!xl) || (!loc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Lookup: %s", loc->path);
+ gf_msg_trace (GF_NFS, 0, "Lookup: %s", loc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, loc);
@@ -491,7 +496,7 @@ nfs_fop_access (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *loc,
if ((!xl) || (!loc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Access: %s", loc->path);
+ gf_msg_trace (GF_NFS, 0, "Access: %s", loc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, loc);
@@ -538,7 +543,7 @@ nfs_fop_stat (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *loc,
if ((!xl) || (!loc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Stat: %s", loc->path);
+ gf_msg_trace (GF_NFS, 0, "Stat: %s", loc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, loc);
@@ -585,7 +590,7 @@ nfs_fop_fstat (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd,
if ((!nfsx) || (!xl) || (!fd) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "FStat");
+ gf_msg_trace (GF_NFS, 0, "FStat");
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_fd_ino (nfl, fd);
@@ -630,7 +635,7 @@ nfs_fop_opendir (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
if ((!nfsx) || (!xl) || (!pathloc) || (!dirfd) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Opendir: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Opendir: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
@@ -720,7 +725,7 @@ nfs_fop_readdirp (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *dirfd,
if ((!nfsx) || (!xl) || (!dirfd) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "readdir");
+ gf_msg_trace (GF_NFS, 0, "readdir");
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
@@ -767,7 +772,7 @@ nfs_fop_statfs (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Statfs: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Statfs: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
@@ -821,7 +826,7 @@ nfs_fop_create (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Create: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Create: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, pathloc);
@@ -872,7 +877,7 @@ nfs_fop_setattr (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Setattr: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Setattr: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, pathloc);
@@ -924,7 +929,7 @@ nfs_fop_mkdir (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Mkdir: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Mkdir: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, pathloc);
@@ -976,7 +981,7 @@ nfs_fop_symlink (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, char *target,
if ((!nfsx) || (!xl) || (!pathloc) || (!target) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Symlink: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Symlink: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, pathloc);
@@ -1025,7 +1030,7 @@ nfs_fop_readlink (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Readlink: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Readlink: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, pathloc);
@@ -1077,7 +1082,7 @@ nfs_fop_mknod (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Mknod: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Mknod: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, pathloc);
@@ -1126,7 +1131,7 @@ nfs_fop_rmdir (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Rmdir: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Rmdir: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, pathloc);
@@ -1175,7 +1180,7 @@ nfs_fop_unlink (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Unlink: %s", pathloc->path);
+ gf_msg_trace (GF_NFS, 0, "Unlink: %s", pathloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, pathloc);
@@ -1230,8 +1235,8 @@ nfs_fop_link (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *oldloc,
if ((!nfsx) || (!xl) || (!oldloc) || (!newloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Link: %s -> %s", newloc->path,
- oldloc->path);
+ gf_msg_trace (GF_NFS, 0, "Link: %s -> %s", newloc->path,
+ oldloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, newloc);
@@ -1289,8 +1294,8 @@ nfs_fop_rename (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *oldloc,
if ((!nfsx) || (!xl) || (!oldloc) || (!newloc) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Rename: %s -> %s", oldloc->path,
- newloc->path);
+ gf_msg_trace (GF_NFS, 0, "Rename: %s -> %s", oldloc->path,
+ newloc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
nfs_fop_save_root_ino (nfl, oldloc);
@@ -1336,7 +1341,7 @@ nfs_fop_open (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *loc,
if ((!nfsx) || (!xl) || (!loc) || (!fd) || (!nfu))
return ret;
- gf_log (GF_NFS, GF_LOG_TRACE, "Open: %s", loc->path);
+ gf_msg_trace (GF_NFS, 0, "Open: %s", loc->path);
nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err);
nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err);
diff --git a/xlators/nfs/server/src/nfs-fops.h b/xlators/nfs/server/src/nfs-fops.h
index 44e99c66b06..bd8cda18481 100644
--- a/xlators/nfs/server/src/nfs-fops.h
+++ b/xlators/nfs/server/src/nfs-fops.h
@@ -23,6 +23,7 @@
#include "stack.h"
#include "nfs.h"
#include "nfs-common.h"
+#include "nfs-messages.h"
#include <semaphore.h>
/* This structure used to communicate state between a fop and its callback.
@@ -111,7 +112,7 @@ nfs_fop_local_wipe (xlator_t *xl, struct nfs_fop_local *l);
nflocal = nfs_fop_local_init (nf); \
if (nflocal) { \
nflocal->proglocal = plocal; \
- nflocal->progcbk = *VOID(&pcbk); \
+ nflocal->progcbk = *VOID(&pcbk); \
nflocal->nfsx = nf; \
if (fram) \
((call_frame_t *)fram)->local = nflocal;\
@@ -129,9 +130,10 @@ nfs_fop_local_wipe (xlator_t *xl, struct nfs_fop_local *l);
#define nfs_fop_handle_local_init(fram,nfx, nfloc, cbck,prgloc,retval,lab) \
do { \
- prog_data_to_nfl (nfx, nfloc, fram, cbck, prgloc); \
+ prog_data_to_nfl (nfx, nfloc, fram, cbck, prgloc); \
if (!nfloc) { \
- gf_log (GF_NFS,GF_LOG_ERROR,"Failed to init local");\
+ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, \
+ NFS_MSG_NO_MEMORY, "Failed to init local"); \
retval = -ENOMEM; \
goto lab; \
} \
diff --git a/xlators/nfs/server/src/nfs-inodes.c b/xlators/nfs/server/src/nfs-inodes.c
index 63d5e8a198b..32c2f426ff4 100644
--- a/xlators/nfs/server/src/nfs-inodes.c
+++ b/xlators/nfs/server/src/nfs-inodes.c
@@ -20,6 +20,7 @@
#include "nfs-inodes.h"
#include "nfs-fops.h"
#include "xlator.h"
+#include "nfs-messages.h"
#include <libgen.h>
@@ -108,7 +109,8 @@ nfs_inode_create (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu,
newfd = fd_create (pathloc->inode, 0);
if (!newfd) {
- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to create new fd");
+ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY,
+ "Failed to create new fd");
ret = -ENOMEM;
goto wipe_nfl;
}
@@ -218,7 +220,8 @@ nfs_inode_open (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *loc,
newfd = fd_create (loc->inode, 0);
if (!newfd) {
- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to create fd");
+ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY,
+ "Failed to create fd");
ret = -ENOMEM;
goto err;
}
@@ -588,7 +591,8 @@ nfs_inode_opendir (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *loc,
newfd = fd_create (loc->inode, 0);
if (!newfd) {
- gf_log (GF_NFS, GF_LOG_ERROR, "Failed to create fd");
+ gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY,
+ "Failed to create fd");
ret = -ENOMEM;
goto err;
}
diff --git a/xlators/nfs/server/src/nfs3-fh.c b/xlators/nfs/server/src/nfs3-fh.c
index 8d492c8c72d..7c9b92e4587 100644
--- a/xlators/nfs/server/src/nfs3-fh.c
+++ b/xlators/nfs/server/src/nfs3-fh.c
@@ -23,6 +23,7 @@
#include "nfs-common.h"
#include "iatt.h"
#include "common-utils.h"
+#include "nfs-messages.h"
int
@@ -136,10 +137,9 @@ nfs3_log_fh (struct nfs3_fh *fh)
if (!fh)
return;
- gf_log ("nfs3-fh", GF_LOG_TRACE, "filehandle: exportid "
- "0x%s, gfid 0x%s",
- uuid_utoa_r (fh->exportid, exportidstr),
- uuid_utoa_r (fh->gfid, gfidstr));
+ gf_msg_trace ("nfs3-fh", 0, "filehandle: exportid 0x%s, gfid 0x%s",
+ uuid_utoa_r (fh->exportid, exportidstr),
+ uuid_utoa_r (fh->gfid, gfidstr));
}
int
diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c
index fb630a643cf..5bb34c138cf 100644
--- a/xlators/nfs/server/src/nfs3-helpers.c
+++ b/xlators/nfs/server/src/nfs3-helpers.c
@@ -27,6 +27,7 @@
#include "nfs-mem-types.h"
#include "iatt.h"
#include "common-utils.h"
+#include "nfs-messages.h"
#include "mount3.h"
#include <string.h>
@@ -683,7 +684,7 @@ nfs3_fill_entry3 (gf_dirent_t *entry, struct nfs3_fh *dfh)
if (!ent)
return NULL;
- gf_log (GF_NFS3, GF_LOG_TRACE, "Entry: %s", entry->d_name);
+ gf_msg_trace (GF_NFS3, 0, "Entry: %s", entry->d_name);
/* If the entry is . or .., we need to replace the physical ino and gen
* with 1 and 0 respectively if the directory is root. This funging is
@@ -762,8 +763,8 @@ nfs3_fill_entryp3 (gf_dirent_t *entry, struct nfs3_fh *dirfh, uint64_t devid)
*/
entry->d_ino = nfs3_iatt_gfid_to_ino (&entry->d_stat);
nfs3_funge_root_dotdot_dirent (entry, dirfh);
- gf_log (GF_NFS3, GF_LOG_TRACE, "Entry: %s, ino: %"PRIu64,
- entry->d_name, entry->d_ino);
+ gf_msg_trace (GF_NFS3, 0, "Entry: %s, ino: %"PRIu64,
+ entry->d_name, entry->d_ino);
ent = GF_CALLOC (1, sizeof (*ent), gf_nfs_mt_entryp3);
if (!ent)
return NULL;
@@ -1576,11 +1577,11 @@ nfs3_verify_dircookie (struct nfs3_state *nfs3, fd_t *dirfd, cookie3 cookie,
if (cookie == 0)
return 0;
- gf_log (GF_NFS3, GF_LOG_TRACE, "Verifying cookie: cverf: %"PRIu64
- ", cookie: %"PRIu64, cverf, cookie);
+ gf_msg_trace (GF_NFS3, 0, "Verifying cookie: cverf: %"PRIu64
+ ", cookie: %"PRIu64, cverf, cookie);
/* The cookie bad, no way cverf will be zero with a non-zero cookie. */
if ((cverf == 0) && (cookie != 0)) {
- gf_log (GF_NFS3, GF_LOG_TRACE, "Bad cookie requested");
+ gf_msg_trace (GF_NFS3, 0, "Bad cookie requested");
if (stat)
*stat = NFS3ERR_BAD_COOKIE;
goto err;
@@ -1602,7 +1603,7 @@ nfs3_verify_dircookie (struct nfs3_state *nfs3, fd_t *dirfd, cookie3 cookie,
goto err;
}
*/
- gf_log (GF_NFS3, GF_LOG_TRACE, "Cookie verified");
+ gf_msg_trace (GF_NFS3, 0, "Cookie verified");
if (stat)
*stat = NFS3_OK;
ret = 0;
@@ -1632,8 +1633,7 @@ nfs3_log_common_call (uint32_t xid, char *op, struct nfs3_fh *fh)
return;
nfs3_fh_to_str (fh, fhstr, sizeof (fhstr));
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, %s: args: %s", xid, op,
- fhstr);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, %s: args: %s", xid, op, fhstr);
}
@@ -1646,8 +1646,8 @@ nfs3_log_fh_entry_call (uint32_t xid, char *op, struct nfs3_fh *fh,
if (THIS->ctx->log.loglevel < GF_LOG_DEBUG)
return;
nfs3_fh_to_str (fh, fhstr, sizeof (fhstr));
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, %s: args: %s, name: %s", xid,
- op, fhstr, name);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, %s: args: %s, name: %s", xid,
+ op, fhstr, name);
}
@@ -1662,9 +1662,9 @@ nfs3_log_rename_call (uint32_t xid, struct nfs3_fh *src, char *sname,
return;
nfs3_fh_to_str (src, sfhstr, sizeof (sfhstr));
nfs3_fh_to_str (dst, dfhstr, sizeof (dfhstr));
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, RENAME: args: Src: %s, "
- "name: %s, Dst: %s, name: %s", xid, sfhstr, sname, dfhstr,
- dname);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, RENAME: args: Src: %s, "
+ "name: %s, Dst: %s, name: %s", xid, sfhstr, sname,
+ dfhstr, dname);
}
@@ -1689,8 +1689,8 @@ nfs3_log_create_call (uint32_t xid, struct nfs3_fh *fh, char *name,
else
modestr = unchkd;
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, CREATE: args: %s, name: %s,"
- " mode: %s", xid, fhstr, name, modestr);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, CREATE: args: %s, name: %s,"
+ " mode: %s", xid, fhstr, name, modestr);
}
@@ -1716,8 +1716,8 @@ nfs3_log_mknod_call (uint32_t xid, struct nfs3_fh *fh, char *name, int type)
else
modestr = fifo;
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, MKNOD: args: %s, name: %s,"
- " type: %s", xid, fhstr, name, modestr);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, MKNOD: args: %s, name: %s,"
+ " type: %s", xid, fhstr, name, modestr);
}
@@ -1730,8 +1730,8 @@ nfs3_log_symlink_call (uint32_t xid, struct nfs3_fh *fh, char *name, char *tgt)
if (THIS->ctx->log.loglevel < GF_LOG_DEBUG)
return;
nfs3_fh_to_str (fh, fhstr, sizeof (fhstr));
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, SYMLINK: args: %s, name: %s,"
- " target: %s", xid, fhstr, name, tgt);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, SYMLINK: args: %s, name: %s,"
+ " target: %s", xid, fhstr, name, tgt);
}
@@ -1746,8 +1746,8 @@ nfs3_log_link_call (uint32_t xid, struct nfs3_fh *fh, char *name,
return;
nfs3_fh_to_str (fh, dfhstr, sizeof (dfhstr));
nfs3_fh_to_str (tgt, tfhstr, sizeof (tfhstr));
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, LINK: args: %s, name: %s,"
- " target: %s", xid, dfhstr, name, tfhstr);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, LINK: args: %s, name: %s,"
+ " target: %s", xid, dfhstr, name, tfhstr);
}
@@ -1761,14 +1761,14 @@ nfs3_log_rw_call (uint32_t xid, char *op, struct nfs3_fh *fh, offset3 offt,
return;
nfs3_fh_to_str (fh, fhstr, sizeof (fhstr));
if (stablewrite == -1)
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, %s: args: %s, offset:"
- " %"PRIu64", count: %"PRIu32, xid, op, fhstr, offt,
- count);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, %s: args: %s, offset:"
+ " %"PRIu64", count: %"PRIu32, xid, op, fhstr,
+ offt, count);
else
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, %s: args: %s, offset:"
- " %"PRIu64", count: %"PRIu32", %s", xid, op, fhstr,
- offt, count,
- (stablewrite == UNSTABLE)?"UNSTABLE":"STABLE");
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, %s: args: %s, offset:"
+ " %"PRIu64", count: %"PRIu32", %s", xid, op,
+ fhstr, offt, count,
+ (stablewrite == UNSTABLE)?"UNSTABLE":"STABLE");
}
@@ -3395,7 +3395,11 @@ nfs3_log_common_res (uint32_t xid, int op, nfsstat3 stat, int pstat)
if (THIS->ctx->log.loglevel < ll)
return;
nfs3_stat_to_errstr (xid, nfs3op_strings[op].str, stat, pstat, errstr, sizeof (errstr));
- gf_log (GF_NFS3, ll, "%s", errstr);
+ if (ll == GF_LOG_DEBUG)
+ gf_msg_debug (GF_NFS3, 0, "%s", errstr);
+ else
+ gf_msg (GF_NFS3, ll, errno, NFS_MSG_STAT_ERROR, "%s", errstr);
+
}
void
@@ -3408,9 +3412,11 @@ nfs3_log_readlink_res (uint32_t xid, nfsstat3 stat, int pstat, char *linkpath)
return;
nfs3_stat_to_errstr (xid, "READLINK", stat, pstat, errstr, sizeof (errstr));
- gf_log (GF_NFS3, ll, "%s, target: %s",
- errstr, linkpath);
-
+ if (ll == GF_LOG_DEBUG)
+ gf_msg_debug (GF_NFS3, 0, "%s, target: %s", errstr, linkpath);
+ else
+ gf_msg (GF_NFS3, ll, errno, NFS_MSG_STAT_ERROR, "%s, target: %s",
+ errstr, linkpath);
}
void
@@ -3420,19 +3426,32 @@ nfs3_log_read_res (uint32_t xid, nfsstat3 stat, int pstat, count3 count,
char errstr[1024];
int ll = GF_LOG_DEBUG;
- ll = nfs3_loglevel (NFS3_READ, stat);
+ ll = nfs3_loglevel (NFS3_READ, stat);
if (THIS->ctx->log.loglevel < ll)
return;
nfs3_stat_to_errstr (xid, "READ", stat, pstat, errstr, sizeof (errstr));
if (vec)
- gf_log (GF_NFS3, ll, "%s, count: %"PRIu32", is_eof:"
- " %d, vector: count: %d, len: %zd", errstr, count,
- is_eof, veccount, vec->iov_len);
+ if (ll == GF_LOG_DEBUG)
+ gf_msg (GF_NFS3, ll, errno, NFS_MSG_STAT_ERROR,
+ "%s, count: %"PRIu32", is_eof:"
+ " %d, vector: count: %d, len: %zd", errstr,
+ count, is_eof, veccount, vec->iov_len);
+ else
+ gf_msg_debug (GF_NFS3, 0,
+ "%s, count: %"PRIu32", is_eof:"
+ " %d, vector: count: %d, len: %zd", errstr,
+ count, is_eof, veccount, vec->iov_len);
else
- gf_log (GF_NFS3, ll, "%s, count: %"PRIu32", is_eof:"
- " %d", errstr, count, is_eof);
-}
+ if (ll == GF_LOG_DEBUG)
+ gf_msg_debug (GF_NFS3, 0,
+ "%s, count: %"PRIu32", is_eof:"
+ " %d", errstr, count, is_eof);
+ else
+ gf_msg (GF_NFS3, ll, errno, NFS_MSG_STAT_ERROR,
+ "%s, count: %"PRIu32", is_eof:"
+ " %d", errstr, count, is_eof);
+}
void
nfs3_log_write_res (uint32_t xid, nfsstat3 stat, int pstat, count3 count,
@@ -3442,15 +3461,21 @@ nfs3_log_write_res (uint32_t xid, nfsstat3 stat, int pstat, count3 count,
int ll = nfs3_loglevel (NFS3_WRITE, stat);
if (THIS->ctx->log.loglevel < ll)
- return;
+ return;
nfs3_stat_to_errstr (xid, "WRITE", stat, pstat, errstr, sizeof (errstr));
- gf_log (GF_NFS3, ll, "%s, count: %"PRIu32", %s,wverf: %"PRIu64
- , errstr, count, (stable == UNSTABLE)?"UNSTABLE":"STABLE",
- wverf);
+ if (ll == GF_LOG_DEBUG)
+ gf_msg_debug (GF_NFS3, 0,
+ "%s, count: %"PRIu32", %s,wverf: %"PRIu64
+ , errstr, count, (stable == UNSTABLE)?"UNSTABLE":"STABLE",
+ wverf);
+ else
+ gf_msg (GF_NFS3, ll, errno, NFS_MSG_STAT_ERROR,
+ "%s, count: %"PRIu32", %s,wverf: %"PRIu64
+ , errstr, count, (stable == UNSTABLE)?"UNSTABLE":"STABLE",
+ wverf);
}
-
void
nfs3_log_newfh_res (uint32_t xid, int op, nfsstat3 stat, int pstat,
struct nfs3_fh *newfh)
@@ -3464,10 +3489,13 @@ nfs3_log_newfh_res (uint32_t xid, int op, nfsstat3 stat, int pstat,
nfs3_stat_to_errstr (xid, nfs3op_strings[op].str, stat, pstat, errstr, sizeof (errstr));
nfs3_fh_to_str (newfh, fhstr, sizeof (fhstr));
- gf_log (GF_NFS3, nfs3_loglevel (op, stat), "%s, %s", errstr, fhstr);
+ if (ll == GF_LOG_DEBUG)
+ gf_msg_debug (GF_NFS3, 0, "%s, %s", errstr, fhstr);
+ else
+ gf_msg (GF_NFS3, nfs3_loglevel (op, stat), errno, NFS_MSG_STAT_ERROR,
+ "%s, %s", errstr, fhstr);
}
-
void
nfs3_log_readdir_res (uint32_t xid, nfsstat3 stat, int pstat, uint64_t cverf,
count3 count, int is_eof)
@@ -3478,39 +3506,56 @@ nfs3_log_readdir_res (uint32_t xid, nfsstat3 stat, int pstat, uint64_t cverf,
if (THIS->ctx->log.loglevel < ll)
return;
nfs3_stat_to_errstr (xid, "READDIR", stat, pstat, errstr, sizeof (errstr));
- gf_log (GF_NFS3, ll, "%s, count: %"PRIu32", cverf: %"PRIu64
- ", is_eof: %d", errstr, count, cverf, is_eof);
+ if (ll == GF_LOG_DEBUG)
+ gf_msg_debug (GF_NFS3, 0,
+ "%s, count: %"PRIu32", cverf: %"PRIu64
+ ", is_eof: %d", errstr, count, cverf, is_eof);
+ else
+ gf_msg (GF_NFS3, ll, errno, NFS_MSG_STAT_ERROR,
+ "%s, count: %"PRIu32", cverf: %"PRIu64
+ ", is_eof: %d", errstr, count, cverf, is_eof);
}
-
void
nfs3_log_readdirp_res (uint32_t xid, nfsstat3 stat, int pstat, uint64_t cverf,
count3 dircount, count3 maxcount, int is_eof)
{
char errstr[1024];
- int ll = nfs3_loglevel (NFS3_READDIRP, stat);
+ int ll = nfs3_loglevel (NFS3_READDIRP, stat);
if (THIS->ctx->log.loglevel < ll)
return;
nfs3_stat_to_errstr (xid, "READDIRPLUS", stat, pstat, errstr, sizeof (errstr));
- gf_log (GF_NFS3, ll, "%s, dircount: %"PRIu32", maxcount: %"
- PRIu32", cverf: %"PRIu64", is_eof: %d", errstr, dircount,
- maxcount, cverf, is_eof);
-}
+ if (ll == GF_LOG_DEBUG)
+ gf_msg_debug (GF_NFS3, 0,
+ "%s, dircount: %"PRIu32", maxcount: %"
+ PRIu32", cverf: %"PRIu64", is_eof: %d", errstr, dircount,
+ maxcount, cverf, is_eof);
+ else
+ gf_msg (GF_NFS3, ll, errno, NFS_MSG_STAT_ERROR,
+ "%s, dircount: %"PRIu32", maxcount: %"
+ PRIu32", cverf: %"PRIu64", is_eof: %d", errstr, dircount,
+ maxcount, cverf, is_eof);
+}
void
nfs3_log_commit_res (uint32_t xid, nfsstat3 stat, int pstat, uint64_t wverf)
{
char errstr[1024];
- int ll = nfs3_loglevel (NFS3_COMMIT, stat);
+ int ll = nfs3_loglevel (NFS3_COMMIT, stat);
if (THIS->ctx->log.loglevel < ll)
return;
nfs3_stat_to_errstr (xid, "COMMIT", stat, pstat, errstr, sizeof (errstr));
- gf_log (GF_NFS3, ll, "%s, wverf: %"PRIu64, errstr, wverf);
-}
+ if (ll == GF_LOG_DEBUG)
+ gf_msg_debug (GF_NFS3, 0, "%s, wverf: %"PRIu64,
+ errstr, wverf);
+ else
+ gf_msg (GF_NFS3, ll, errno, NFS_MSG_STAT_ERROR,
+ "%s, wverf: %"PRIu64, errstr, wverf);
+}
void
nfs3_log_readdir_call (uint32_t xid, struct nfs3_fh *fh, count3 dircount,
@@ -3524,15 +3569,14 @@ nfs3_log_readdir_call (uint32_t xid, struct nfs3_fh *fh, count3 dircount,
nfs3_fh_to_str (fh, fhstr, sizeof (fhstr));
if (maxcount == 0)
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, READDIR: args: %s,"
- " count: %d", xid, fhstr, (uint32_t)dircount);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, READDIR: args: %s,"
+ " count: %d", xid, fhstr, (uint32_t)dircount);
else
- gf_log (GF_NFS3, GF_LOG_DEBUG, "XID: %x, READDIRPLUS: args: %s,"
- " dircount: %d, maxcount: %d", xid, fhstr,
- (uint32_t)dircount, (uint32_t)maxcount);
+ gf_msg_debug (GF_NFS3, 0, "XID: %x, READDIRPLUS: args: %s,"
+ " dircount: %d, maxcount: %d", xid, fhstr,
+ (uint32_t)dircount, (uint32_t)maxcount);
}
-
int
nfs3_fh_resolve_inode_done (nfs3_call_state_t *cs, inode_t *inode)
{
@@ -3541,10 +3585,12 @@ nfs3_fh_resolve_inode_done (nfs3_call_state_t *cs, inode_t *inode)
if ((!cs) || (!inode))
return ret;
- gf_log (GF_NFS3, GF_LOG_TRACE, "FH inode resolved");
+ gf_msg_trace (GF_NFS3, 0, "FH inode resolved");
ret = nfs_inode_loc_fill (inode, &cs->resolvedloc, NFS_RESOLVE_EXIST);
if (ret < 0) {
- gf_log (GF_NFS3, GF_LOG_ERROR, "inode loc fill failed");
+ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret,
+ NFS_MSG_INODE_LOC_FILL_ERROR,
+ "inode loc fill failed");
goto err;
}
@@ -3554,7 +3600,6 @@ err:
return ret;
}
-
int32_t
nfs3_fh_resolve_entry_lookup_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret,
@@ -3570,18 +3615,24 @@ nfs3_fh_resolve_entry_lookup_cbk (call_frame_t *frame, void *cookie,
cs->resolve_errno = op_errno;
if (op_ret == -1) {
- gf_log (GF_NFS3, (op_errno == ENOENT ? GF_LOG_TRACE : GF_LOG_ERROR),
- "Lookup failed: %s: %s",
- cs->resolvedloc.path, strerror (op_errno));
+ if (op_errno == ENOENT) {
+ gf_msg_trace (GF_NFS3, 0, "Lookup failed: %s: %s",
+ cs->resolvedloc.path,
+ strerror (op_errno));
+ } else {
+ gf_msg (GF_NFS3, GF_LOG_ERROR, op_errno,
+ NFS_MSG_LOOKUP_FAIL, "Lookup failed: %s: %s",
+ cs->resolvedloc.path, strerror (op_errno));
+ }
goto err;
} else
- gf_log (GF_NFS3, GF_LOG_TRACE, "Entry looked up: %s",
- cs->resolvedloc.path);
+ gf_msg_trace (GF_NFS3, 0, "Entry looked up: %s",
+ cs->resolvedloc.path);
- memcpy (&cs->stbuf, buf, sizeof (*buf));
- memcpy (&cs->postparent, postparent, sizeof (*postparent));
+ memcpy (&cs->stbuf, buf, sizeof (*buf));
+ memcpy (&cs->postparent, postparent, sizeof (*postparent));
linked_inode = inode_link (inode, cs->resolvedloc.parent,
- cs->resolvedloc.name, buf);
+ cs->resolvedloc.name, buf);
if (linked_inode) {
inode_lookup (linked_inode);
inode_unref (cs->resolvedloc.inode);
@@ -3592,7 +3643,6 @@ err:
return 0;
}
-
int32_t
nfs3_fh_resolve_inode_lookup_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret,
@@ -3608,15 +3658,21 @@ nfs3_fh_resolve_inode_lookup_cbk (call_frame_t *frame, void *cookie,
cs->resolve_errno = op_errno;
if (op_ret == -1) {
- gf_log (GF_NFS3, (op_errno == ENOENT ? GF_LOG_TRACE : GF_LOG_ERROR),
- "Lookup failed: %s: %s",
- cs->resolvedloc.path, strerror (op_errno));
+ if (op_errno == ENOENT) {
+ gf_msg_trace (GF_NFS3, 0, "Lookup failed: %s: %s",
+ cs->resolvedloc.path,
+ strerror (op_errno));
+ } else {
+ gf_msg (GF_NFS3, GF_LOG_ERROR, op_errno,
+ NFS_MSG_LOOKUP_FAIL, "Lookup failed: %s: %s",
+ cs->resolvedloc.path, strerror (op_errno));
+ }
nfs3_call_resume (cs);
goto err;
}
- memcpy (&cs->stbuf, buf, sizeof(*buf));
- memcpy (&cs->postparent, buf, sizeof(*postparent));
+ memcpy (&cs->stbuf, buf, sizeof(*buf));
+ memcpy (&cs->postparent, buf, sizeof(*postparent));
linked_inode = inode_link (inode, cs->resolvedloc.parent,
cs->resolvedloc.name, buf);
if (linked_inode) {
@@ -3639,7 +3695,6 @@ err:
}
-
/* Needs no extra argument since it knows that the fh to be resolved is in
* resolvefh and that it needs to start looking from the root.
*/
@@ -3652,14 +3707,16 @@ nfs3_fh_resolve_inode_hard (nfs3_call_state_t *cs)
if (!cs)
return ret;
- gf_log (GF_NFS3, GF_LOG_TRACE, "FH hard resolution for: gfid 0x%s",
- uuid_utoa (cs->resolvefh.gfid));
+ gf_msg_trace (GF_NFS3, 0, "FH hard resolution for: gfid 0x%s",
+ uuid_utoa (cs->resolvefh.gfid));
cs->hardresolved = 1;
nfs_loc_wipe (&cs->resolvedloc);
ret = nfs_gfid_loc_fill (cs->vol->itable, cs->resolvefh.gfid,
&cs->resolvedloc, NFS_RESOLVE_CREATE);
if (ret < 0) {
- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to fill loc using gfid: "
+ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret,
+ NFS_MSG_INODE_LOC_FILL_ERROR,
+ "Failed to fill loc using gfid: "
"%s", strerror (-ret));
goto out;
}
@@ -3684,17 +3741,17 @@ nfs3_fh_resolve_entry_hard (nfs3_call_state_t *cs)
nfs_loc_wipe (&cs->resolvedloc);
nfs_user_root_create (&nfu);
- gf_log (GF_NFS3, GF_LOG_TRACE, "FH hard resolution: gfid: %s "
- ", entry: %s", uuid_utoa (cs->resolvefh.gfid),
- cs->resolventry);
+ gf_msg_trace (GF_NFS3, 0, "FH hard resolution: gfid: %s "
+ ", entry: %s", uuid_utoa (cs->resolvefh.gfid),
+ cs->resolventry);
ret = nfs_entry_loc_fill (cs->vol->itable, cs->resolvefh.gfid,
cs->resolventry, &cs->resolvedloc,
NFS_RESOLVE_CREATE);
if (ret == -2) {
- gf_log (GF_NFS3, GF_LOG_TRACE, "Entry needs lookup: %s",
- cs->resolvedloc.path);
+ gf_msg_trace (GF_NFS3, 0, "Entry needs lookup: %s",
+ cs->resolvedloc.path);
/* If the NFS op is lookup, let the resume callback
* handle the sending of the lookup fop. Similarly,
* if the NFS op is create, let the create call
@@ -3713,8 +3770,8 @@ nfs3_fh_resolve_entry_hard (nfs3_call_state_t *cs)
}
ret = 0;
} else if (ret == -1) {
- gf_log (GF_NFS3, GF_LOG_TRACE, "Entry needs parent lookup: %s",
- cs->resolvedloc.path);
+ gf_msg_trace (GF_NFS3, 0, "Entry needs parent lookup: %s",
+ cs->resolvedloc.path);
ret = nfs3_fh_resolve_inode_hard (cs);
} else if (ret == 0) {
cs->resolve_ret = 0;
@@ -3733,7 +3790,7 @@ nfs3_fh_resolve_inode (nfs3_call_state_t *cs)
if (!cs)
return ret;
- gf_log (GF_NFS3, GF_LOG_TRACE, "FH needs inode resolution");
+ gf_msg_trace (GF_NFS3, 0, "FH needs inode resolution");
gf_uuid_copy (cs->resolvedloc.gfid, cs->resolvefh.gfid);
inode = inode_find (cs->vol->itable, cs->resolvefh.gfid);
if (!inode)
@@ -3801,12 +3858,13 @@ nfs3_fh_resolve_root_lookup_cbk (call_frame_t *frame, void *cookie,
cs->resolve_errno = op_errno;
if (op_ret == -1) {
- gf_log (GF_NFS3, GF_LOG_ERROR, "Root lookup failed: %s",
+ gf_msg (GF_NFS3, GF_LOG_ERROR, op_errno,
+ NFS_MSG_LOOKUP_ROOT_FAIL, "Root lookup failed: %s",
strerror (op_errno));
goto err;
} else
- gf_log (GF_NFS3, GF_LOG_TRACE, "Root looked up: %s",
- cs->resolvedloc.path);
+ gf_msg_trace (GF_NFS3, 0, "Root looked up: %s",
+ cs->resolvedloc.path);
nfs3_set_root_looked_up (cs->nfs3state, &cs->resolvefh);
err:
@@ -3830,11 +3888,12 @@ nfs3_fh_resolve_root (nfs3_call_state_t *cs)
}
nfs_user_root_create (&nfu);
- gf_log (GF_NFS3, GF_LOG_TRACE, "Root needs lookup");
+ gf_msg_trace (GF_NFS3, 0, "Root needs lookup");
ret = nfs_root_loc_fill (cs->vol->itable, &cs->resolvedloc);
if (ret < 0) {
- gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to lookup root from itable: %s",
- strerror (-ret));
+ gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_LOOKUP_ROOT_FAIL,
+ "Failed to lookup root from itable: %s",
+ strerror (-ret));
goto out;
}
@@ -3867,8 +3926,8 @@ __nfs3_fh_auth_get_peer (const rpcsvc_request_t *req, char *peer)
ret = rpcsvc_transport_peeraddr (trans, peer, RPCSVC_PEER_STRLEN,
&sastorage, sizeof (sastorage));
if (ret != 0) {
- gf_log (GF_NFS3, GF_LOG_WARNING, "Failed to get peer addr: %s",
- gai_strerror (ret));
+ gf_msg (GF_NFS3, GF_LOG_WARNING, 0, NFS_MSG_GET_PEER_ADDR_FAIL,
+ "Failed to get peer addr: %s", gai_strerror (ret));
}
return ret;
}