From c4d312023ff5bc927327fc10d826c12bdbf2afeb Mon Sep 17 00:00:00 2001 From: Hari Gowtham Date: Wed, 17 Jun 2015 13:28:51 +0530 Subject: [PATCH 129/129] nfs.c nfs3.c: port log messages to a new framework Change-Id: I9ddb90d66d3ad3adb2916c0c949834794ee7bdf3 BUG: 1231778 Signed-off-by: Hari Gowtham Reviewed-on: http://review.gluster.org/11146 Tested-by: Gluster Build System Reviewed-by: jiffin tony Thottan Reviewed-by: Niels de Vos Reviewed-on: https://code.engineering.redhat.com/gerrit/50899 Reviewed-by: Jiffin Thottan Tested-by: Niels de Vos --- xlators/nfs/server/src/nfs-messages.h | 11 +- xlators/nfs/server/src/nfs.c | 356 ++++++++++++-------- xlators/nfs/server/src/nfs3.c | 593 ++++++++++++++++++++------------- 3 files changed, 585 insertions(+), 375 deletions(-) diff --git a/xlators/nfs/server/src/nfs-messages.h b/xlators/nfs/server/src/nfs-messages.h index 9c634b2..77b8564 100644 --- a/xlators/nfs/server/src/nfs-messages.h +++ b/xlators/nfs/server/src/nfs-messages.h @@ -45,7 +45,7 @@ */ #define GLFS_NFS_BASE GLFS_MSGID_COMP_NFS -#define GLFS_NFS_NUM_MESSAGES 201 +#define GLFS_NFS_NUM_MESSAGES 202 #define GLFS_MSGID_END (GLFS_NFS_BASE + GLFS_NFS_NUM_MESSAGES + 1) /* Messages with message IDs */ @@ -1654,6 +1654,15 @@ * */ +#define NFS_MSG_ENABLE_THROTTLE_FAIL (GLFS_NFS_BASE + 202) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ + + /*------------*/ #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c index 85af465..8b4bc75 100644 --- a/xlators/nfs/server/src/nfs.c +++ b/xlators/nfs/server/src/nfs.c @@ -37,6 +37,7 @@ #include "rpc-drc.h" #include "syscall.h" #include "rpcsvc.h" +#include "nfs-messages.h" #define OPT_SERVER_AUX_GIDS "nfs.server-aux-gids" #define OPT_SERVER_GID_CACHE_TIMEOUT "nfs.server.aux-gid-timeout" @@ -69,8 +70,8 @@ nfs_init_version (xlator_t *this, nfs_version_initer_t init, ret = nfs_add_initer (&nfs->versions, init, required); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, - "Failed to add protocol initializer"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PROT_INIT_ADD_FAIL, + "Failed to add protocol initializer"); goto err; } @@ -91,8 +92,8 @@ nfs_init_version (xlator_t *this, nfs_version_initer_t init, /* program not added */ if (!found) { - gf_log (GF_NFS, GF_LOG_ERROR, - "Program: %s NOT found", prog->progname); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PGM_NOT_FOUND, + "Program: %s NOT found", prog->progname); goto err; } @@ -100,12 +101,12 @@ nfs_init_version (xlator_t *this, nfs_version_initer_t init, if (nfs->override_portnum) prog->progport = nfs->override_portnum; - gf_log (GF_NFS, GF_LOG_DEBUG, "Starting program: %s", prog->progname); + gf_msg_debug (GF_NFS, 0, "Starting program: %s", prog->progname); ret = rpcsvc_program_register (nfs->rpcsvc, prog); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Program: %s init failed", - prog->progname); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PGM_INIT_FAIL, + "Program: %s init failed", prog->progname); goto err; } @@ -115,9 +116,8 @@ nfs_init_version (xlator_t *this, nfs_version_initer_t init, ret = rpcsvc_program_register_portmap (prog, prog->progport); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, - "Program %s registration failed", - prog->progname); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PGM_REG_FAIL, + "Program %s registration failed", prog->progname); goto err; } ret = 0; /* All well */ @@ -249,7 +249,8 @@ nfs_add_initer (struct list_head *list, nfs_version_initer_t init, new = GF_CALLOC (1, sizeof (*new), gf_nfs_mt_nfs_initer_list); if (!new) { - gf_log (GF_NFS, GF_LOG_ERROR, "Memory allocation failed"); + gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "Memory allocation failed"); return -1; } @@ -301,7 +302,7 @@ nfs_init_versions (struct nfs_state *nfs, xlator_t *this) if ((!nfs) || (!this)) return -1; - gf_log (GF_NFS, GF_LOG_DEBUG, "Initing protocol versions"); + gf_msg_debug (GF_NFS, 0, "Initing protocol versions"); versions = &nfs->versions; list_for_each_entry_safe (version, tmp, versions, list) { if (!version->init) { @@ -318,23 +319,25 @@ nfs_init_versions (struct nfs_state *nfs, xlator_t *this) version->program = prog; if (nfs->override_portnum) prog->progport = nfs->override_portnum; - gf_log (GF_NFS, GF_LOG_DEBUG, "Starting program: %s", + gf_msg_debug (GF_NFS, 0, "Starting program: %s", prog->progname); ret = rpcsvc_program_register (nfs->rpcsvc, prog); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Program: %s init failed", - prog->progname); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, + NFS_MSG_PGM_INIT_FAIL, + "Program: %s init failed", prog->progname); goto err; } if (nfs->register_portmap) { ret = rpcsvc_program_register_portmap (prog, prog->progport); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, - "%s program %s registration failed", + gf_msg (GF_NFS, GF_LOG_ERROR, 0, + NFS_MSG_PGM_REG_FAIL, + "%s program %s registration failed", version->required ? - "Required" : "Optional", + "Required" : "Optional", prog->progname); /* fatal error if the program is required */ @@ -359,30 +362,31 @@ nfs_add_all_initiators (struct nfs_state *nfs) /* Add the initializers for all versions. */ ret = nfs_add_initer (&nfs->versions, mnt3svc_init, _gf_true); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add " - "MOUNT3 protocol initializer"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PROT_INIT_ADD_FAIL, + "Failed to add MOUNT3 protocol initializer"); goto ret; } ret = nfs_add_initer (&nfs->versions, mnt1svc_init, _gf_true); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add " - "MOUNT1 protocol initializer"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PROT_INIT_ADD_FAIL, + "Failed to add MOUNT1 protocol initializer"); goto ret; } ret = nfs_add_initer (&nfs->versions, nfs3svc_init, _gf_true); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add " - "NFS3 protocol initializer"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PROT_INIT_ADD_FAIL, + "Failed to add NFS3 protocol initializer"); goto ret; } if (nfs->enable_nlm == _gf_true) { ret = nfs_add_initer (&nfs->versions, nlm4svc_init, _gf_false); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add protocol" - " initializer"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, + NFS_MSG_PROT_INIT_ADD_FAIL, + "Failed to add protocol initializer"); goto ret; } } @@ -390,8 +394,9 @@ nfs_add_all_initiators (struct nfs_state *nfs) if (nfs->enable_acl == _gf_true) { ret = nfs_add_initer (&nfs->versions, acl3svc_init, _gf_false); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add " - "ACL protocol initializer"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, + NFS_MSG_PROT_INIT_ADD_FAIL, + "Failed to add ACL protocol initializer"); goto ret; } } @@ -439,7 +444,7 @@ nfs_subvolume_set_started (struct nfs_state *nfs, xlator_t *xl) { for (;x < nfs->allsubvols; ++x) { if (nfs->initedxl[x] == xl) { - gf_log (GF_NFS, GF_LOG_DEBUG, + gf_msg_debug (GF_NFS, 0, "Volume already started %s", xl->name); break; @@ -448,7 +453,7 @@ nfs_subvolume_set_started (struct nfs_state *nfs, xlator_t *xl) if (nfs->initedxl[x] == NULL) { nfs->initedxl[x] = xl; ++nfs->upsubvols; - gf_log (GF_NFS, GF_LOG_DEBUG, "Starting up: %s " + gf_msg_debug (GF_NFS, 0, "Starting up: %s " ", vols started till now: %d", xl->name, nfs->upsubvols); goto unlock; @@ -469,13 +474,15 @@ nfs_start_subvol_lookup_cbk (call_frame_t *frame, void *cookie, struct iatt *postparent) { if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to lookup root: %s", + gf_msg (GF_NFS, GF_LOG_CRITICAL, op_errno, + NFS_MSG_LOOKUP_ROOT_FAIL, + "Failed to lookup root: %s", strerror (op_errno)); goto err; } nfs_subvolume_set_started (this->private, ((xlator_t *)cookie)); - gf_log (GF_NFS, GF_LOG_TRACE, "Started %s", ((xlator_t *)cookie)->name); + gf_msg_trace (GF_NFS, 0, "Started %s", ((xlator_t *)cookie)->name); err: return 0; } @@ -492,7 +499,7 @@ nfs_startup_subvolume (xlator_t *nfsx, xlator_t *xl) return -1; if (nfs_subvolume_started (nfsx->private, xl)) { - gf_log (GF_NFS,GF_LOG_TRACE, "Subvolume already started: %s", + gf_msg_trace (GF_NFS, 0, "Subvolume already started: %s", xl->name); ret = 0; goto err; @@ -500,7 +507,9 @@ nfs_startup_subvolume (xlator_t *nfsx, xlator_t *xl) ret = nfs_root_loc_fill (xl->itable, &rootloc); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init root loc"); + gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, + NFS_MSG_ROOT_LOC_INIT_FAIL, + "Failed to init root loc"); goto err; } @@ -509,8 +518,9 @@ nfs_startup_subvolume (xlator_t *nfsx, xlator_t *xl) nfs_start_subvol_lookup_cbk, (void *)nfsx->private); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to lookup root: %s", - strerror (-ret)); + gf_msg (GF_NFS, GF_LOG_CRITICAL, -ret, + NFS_MSG_LOOKUP_ROOT_FAIL, + "Failed to lookup root: %s", strerror (-ret)); goto err; } @@ -533,12 +543,14 @@ nfs_startup_subvolumes (xlator_t *nfsx) nfs = nfsx->private; cl = nfs->subvols; while (cl) { - gf_log (GF_NFS, GF_LOG_DEBUG, "Starting subvolume: %s", + gf_msg_debug (GF_NFS, 0, "Starting subvolume: %s", cl->xlator->name); ret = nfs_startup_subvolume (nfsx, cl->xlator); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to start-up " - "xlator: %s", cl->xlator->name); + gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, + NFS_MSG_STARTUP_FAIL, + "Failed to start-up xlator: %s", + cl->xlator->name); goto err; } cl = cl->next; @@ -562,8 +574,8 @@ nfs_init_subvolume (struct nfs_state *nfs, xlator_t *xl) lrusize = nfs->memfactor * GF_NFS_INODE_LRU_MULT; xl->itable = inode_table_new (lrusize, xl); if (!xl->itable) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to allocate " - "inode table"); + gf_msg (GF_NFS, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY, + "Failed to allocate inode table"); goto err; } ret = 0; @@ -583,14 +595,15 @@ nfs_init_subvolumes (struct nfs_state *nfs, xlator_list_t *cl) lrusize = nfs->memfactor * GF_NFS_INODE_LRU_MULT; nfs->subvols = cl; - gf_log (GF_NFS, GF_LOG_TRACE, "inode table lru: %d", lrusize); + gf_msg_trace (GF_NFS, 0, "inode table lru: %d", lrusize); while (cl) { - gf_log (GF_NFS, GF_LOG_DEBUG, "Initing subvolume: %s", + gf_msg_debug (GF_NFS, 0, "Initing subvolume: %s", cl->xlator->name); ret = nfs_init_subvolume (nfs, cl->xlator); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init " + gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, + NFS_MSG_XLATOR_INIT_FAIL, "Failed to init " "xlator: %s", cl->xlator->name); goto err; } @@ -602,12 +615,13 @@ nfs_init_subvolumes (struct nfs_state *nfs, xlator_list_t *cl) nfs->initedxl = GF_CALLOC (svcount, sizeof (xlator_t *), gf_nfs_mt_xlator_t ); if (!nfs->initedxl) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to allocated inited xls"); + gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "Failed to allocated inited xls"); ret = -1; goto err; } - gf_log (GF_NFS, GF_LOG_TRACE, "Inited volumes: %d", svcount); + gf_msg_trace (GF_NFS, 0, "Inited volumes: %d", svcount); nfs->allsubvols = svcount; ret = 0; err: @@ -647,7 +661,7 @@ nfs_user_create (nfs_user_t *newnfu, uid_t uid, gid_t gid, gid_t *auxgids, newnfu->gids[0] = gid; newnfu->ngrps = 1; - gf_log (GF_NFS, GF_LOG_TRACE, "uid: %d, gid %d, gids: %d", uid, gid, + gf_msg_trace (GF_NFS, 0, "uid: %d, gid %d, gids: %d", uid, gid, auxcount); if (!auxgids) @@ -656,7 +670,7 @@ nfs_user_create (nfs_user_t *newnfu, uid_t uid, gid_t gid, gid_t *auxgids, for (; y < auxcount; ++x,++y) { newnfu->gids[x] = auxgids[y]; ++newnfu->ngrps; - gf_log (GF_NFS, GF_LOG_TRACE, "gid: %d", auxgids[y]); + gf_msg_trace (GF_NFS, 0, "gid: %d", auxgids[y]); } return 0; @@ -707,8 +721,8 @@ mem_acct_init (xlator_t *this) ret = xlator_mem_acct_init (this, gf_nfs_mt_end + 1); if (ret != 0) { - gf_log(this->name, GF_LOG_ERROR, "Memory accounting init" - "failed"); + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "Memory accounting init failed"); return ret; } @@ -730,7 +744,7 @@ nfs_init_state (xlator_t *this) return NULL; if (!this->children) { - gf_log (GF_NFS, GF_LOG_INFO, + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_NFS_MAN_DISABLE, "NFS is manually disabled: Exiting"); /* Nothing for nfs process to do, exit cleanly */ kill (getpid (), SIGTERM); @@ -738,7 +752,8 @@ nfs_init_state (xlator_t *this) nfs = GF_CALLOC (1, sizeof (*nfs), gf_nfs_mt_nfs_state); if (!nfs) { - gf_log (GF_NFS, GF_LOG_ERROR, "memory allocation failed"); + gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "memory allocation failed"); return NULL; } @@ -747,14 +762,16 @@ nfs_init_state (xlator_t *this) ret = dict_get_str (this->options, "nfs.mem-factor", &optstr); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, + NFS_MSG_DICT_GET_FAILED, + "Failed to parse dict"); goto free_rpcsvc; } ret = gf_string2uint (optstr, &nfs->memfactor); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse uint " - "string"); + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse uint string"); goto free_rpcsvc; } } @@ -763,8 +780,8 @@ nfs_init_state (xlator_t *this) /* FIXME: Really saddens me to see this as xlator wide. */ nfs->foppool = mem_pool_new (struct nfs_fop_local, fopspoolsize); if (!nfs->foppool) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to allocate fops " - "local pool"); + gf_msg (GF_NFS, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY, + "Failed to allocate fops local pool"); goto free_rpcsvc; } @@ -773,14 +790,16 @@ nfs_init_state (xlator_t *this) ret = dict_get_str (this->options, "nfs.dynamic-volumes", &optstr); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, + NFS_MSG_DICT_GET_FAILED, + "Failed to parse dict"); goto free_foppool; } ret = gf_string2boolean (optstr, &boolt); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " - "string"); + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse bool string"); goto free_foppool; } @@ -791,14 +810,16 @@ nfs_init_state (xlator_t *this) nfs->enable_nlm = _gf_true; ret = dict_get_str_boolean (this->options, "nfs.nlm", _gf_true); if (ret == _gf_false) { - gf_log (GF_NFS, GF_LOG_INFO, "NLM is manually disabled"); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_NLM_MAN_DISABLE, + "NLM is manually disabled"); nfs->enable_nlm = _gf_false; } nfs->enable_acl = _gf_true; ret = dict_get_str_boolean (this->options, "nfs.acl", _gf_true); if (ret == _gf_false) { - gf_log (GF_NFS, GF_LOG_INFO, "ACL is manually disabled"); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_ACL_MAN_DISABLE, + "ACL is manually disabled"); nfs->enable_acl = _gf_false; } @@ -807,14 +828,15 @@ nfs_init_state (xlator_t *this) ret = dict_get_str (this->options, "nfs.enable-ino32", &optstr); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, + "Failed to parse dict"); goto free_foppool; } ret = gf_string2boolean (optstr, &boolt); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " - "string"); + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse bool string"); goto free_foppool; } @@ -826,14 +848,15 @@ nfs_init_state (xlator_t *this) ret = dict_get_str (this->options, "nfs.port", &optstr); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, + "Failed to parse dict"); goto free_foppool; } ret = gf_string2uint (optstr, &nfs->override_portnum); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse uint " - "string"); + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse uint string"); goto free_foppool; } } @@ -845,13 +868,16 @@ nfs_init_state (xlator_t *this) else ret = gf_asprintf (&optstr, "%d", GF_NFS3_PORT); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "failed mem-allocation"); + gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "failed mem-allocation"); goto free_foppool; } ret = dict_set_dynstr (this->options, "transport.socket.listen-port", optstr); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "dict_set_dynstr error"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, + NFS_MSG_DICT_SET_FAILED, + "dict_set_dynstr error"); goto free_foppool; } } @@ -861,7 +887,8 @@ nfs_init_state (xlator_t *this) */ ret = dict_set_str (this->options, "transport-type", "socket"); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "dict_set_str error"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_DICT_SET_FAILED, + "dict_set_str error"); goto free_foppool; } @@ -869,13 +896,15 @@ nfs_init_state (xlator_t *this) if (dict_get(this->options, "nfs.mount-udp")) { ret = dict_get_str (this->options, "nfs.mount-udp", &optstr); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, + "Failed to parse dict"); goto free_foppool; } ret = gf_string2boolean (optstr, &boolt); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse bool " "string"); goto free_foppool; } @@ -889,14 +918,15 @@ nfs_init_state (xlator_t *this) ret = dict_get_str (this->options, "nfs.exports-auth-enable", &optstr); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, + "Failed to parse dict"); goto free_foppool; } ret = gf_string2boolean (optstr, &boolt); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " - "string"); + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse bool string"); goto free_foppool; } @@ -909,14 +939,15 @@ nfs_init_state (xlator_t *this) ret = dict_get_str (this->options, "nfs.auth-refresh-interval-sec", &optstr); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, + "Failed to parse dict"); goto free_foppool; } ret = gf_string2uint (optstr, &nfs->auth_refresh_time_secs); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse uint " - "string"); + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse uint string"); goto free_foppool; } } @@ -926,14 +957,15 @@ nfs_init_state (xlator_t *this) ret = dict_get_str (this->options, "nfs.auth-cache-ttl-sec", &optstr); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, + "Failed to parse dict"); goto free_foppool; } ret = gf_string2uint (optstr, &nfs->auth_cache_ttl_sec); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse uint " - "string"); + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse uint string"); goto free_foppool; } } @@ -946,7 +978,8 @@ nfs_init_state (xlator_t *this) if (dict_get(this->options, "nfs.mount-rmtab")) { ret = dict_get_str (this->options, "nfs.mount-rmtab", &nfs->rmtab); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, + "Failed to parse dict"); goto free_foppool; } @@ -965,13 +998,15 @@ nfs_init_state (xlator_t *this) ret = dict_get_str (this->options, "rpc-auth.ports.insecure", &optstr); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, + "Failed to parse dict"); goto free_foppool; } ret = gf_string2boolean (optstr, &boolt); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse bool " "string"); goto free_foppool; } @@ -984,14 +1019,15 @@ nfs_init_state (xlator_t *this) ret = dict_get_str (this->options, "rpc-auth-allow-insecure", &optstr); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL, + "Failed to parse dict"); goto free_foppool; } ret = gf_string2boolean (optstr, &boolt); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse bool " - "string"); + gf_msg (GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_PARSE_FAIL, + "Failed to parse bool string"); goto free_foppool; } @@ -1005,14 +1041,16 @@ nfs_init_state (xlator_t *this) ret = dict_set_str (this->options, "rpc-auth-allow-insecure", "on"); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "dict_set_str error"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, + NFS_MSG_DICT_SET_FAILED, "dict_set_str error"); goto free_foppool; } dict_del (this->options, "rpc-auth.ports.insecure"); ret = dict_set_str (this->options, "rpc-auth.ports.insecure", "on"); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "dict_set_str error"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, + NFS_MSG_DICT_SET_FAILED, "dict_set_str error"); goto free_foppool; } } @@ -1027,21 +1065,24 @@ nfs_init_state (xlator_t *this) uint32, free_foppool); if (gid_cache_init(&nfs->gid_cache, nfs->server_aux_gids_max_age) < 0) { - gf_log(GF_NFS, GF_LOG_ERROR, "Failed to initialize group cache."); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, + NFS_MSG_INIT_GRP_CACHE_FAIL, + "Failed to initialize group cache."); goto free_foppool; } ret = sys_access (nfs->rpc_statd, X_OK); if (ret) { - gf_log (GF_NFS, GF_LOG_WARNING, "%s not enough permissions to" - " access. Disabling NLM", nfs->rpc_statd); + gf_msg (GF_NFS, GF_LOG_WARNING, EPERM, NFS_MSG_NO_PERM, + "%s not enough permissions to access. Disabling NLM", + nfs->rpc_statd); nfs->enable_nlm = _gf_false; } ret = sys_stat (nfs->rpc_statd, &stbuf); if (ret || !S_ISREG (stbuf.st_mode)) { - gf_log (GF_NFS, GF_LOG_WARNING, "%s not a regular file." - " Disabling NLM", nfs->rpc_statd); + gf_msg (GF_NFS, GF_LOG_WARNING, 0, NFS_MSG_REG_FILE_ERROR, + "%s not a regular file. Disabling NLM", nfs->rpc_statd); nfs->enable_nlm = _gf_false; } @@ -1049,13 +1090,15 @@ nfs_init_state (xlator_t *this) this->options, fopspoolsize); if (!nfs->rpcsvc) { ret = -1; - gf_log (GF_NFS, GF_LOG_ERROR, "RPC service init failed"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RPC_INIT_FAIL, + "RPC service init failed"); goto free_foppool; } ret = rpcsvc_set_throttle_on (nfs->rpcsvc); if (ret) { - gf_log (GF_NFS, GF_LOG_ERROR, "Enabling throttle failed"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_ENABLE_THROTTLE_FAIL, + "Enabling throttle failed"); goto free_foppool; } @@ -1063,7 +1106,7 @@ nfs_init_state (xlator_t *this) this->options, RPCSVC_DEF_NFS_OUTSTANDING_RPC_LIMIT); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RPC_CONFIG_FAIL, "Failed to configure outstanding-rpc-limit"); goto free_foppool; } @@ -1137,7 +1180,8 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) * 1. SET */ while (blacklist_keys[keyindx]) { if (dict_get (options, blacklist_keys[keyindx])) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, + NFS_MSG_RECONFIG_FAIL, "Reconfiguring %s needs NFS restart", blacklist_keys[keyindx]); goto out; @@ -1148,7 +1192,7 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) /* UNSET for nfs.mem-factor */ if ((!dict_get (options, "nfs.mem-factor")) && (nfs->memfactor != GF_NFS_DEFAULT_MEMFACTOR)) { - gf_log (GF_NFS, GF_LOG_INFO, + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_FAIL, "Reconfiguring nfs.mem-factor needs NFS restart"); goto out; } @@ -1156,7 +1200,7 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) /* UNSET for nfs.port */ if ((!dict_get (options, "nfs.port")) && (nfs->override_portnum)) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, "Reconfiguring nfs.port needs NFS restart"); goto out; } @@ -1166,14 +1210,15 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) if (dict_get (options, OPT_SERVER_RPC_STATD_PIDFILE)) { ret = dict_get_str (options, "nfs.rpc-statd", &rpc_statd); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to read " - "reconfigured option: nfs.rpc-statd"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read reconfigured option: " + "nfs.rpc-statd"); goto out; } } if (strcmp(nfs->rpc_statd, rpc_statd) != 0) { - gf_log (GF_NFS, GF_LOG_INFO, + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_FAIL, "Reconfiguring nfs.rpc-statd needs NFS restart"); goto out; } @@ -1183,8 +1228,9 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) if (dict_get (options, "nfs.mount-rmtab")) { ret = dict_get_str (options, "nfs.mount-rmtab", &rmtab); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to read " - "reconfigured option: nfs.mount-rmtab"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read reconfigured option:" + " nfs.mount-rmtab"); goto out; } gf_path_strip_trailing_slashes (rmtab); @@ -1193,21 +1239,21 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) if (strcmp ("/-", rmtab) == 0) { GF_FREE (nfs->rmtab); nfs->rmtab = NULL; - gf_log (GF_NFS, GF_LOG_INFO, - "Disabled writing of nfs.mount-rmtab"); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_WRITE_FAIL, + "Disabled writing of nfs.mount-rmtab"); } else if (!nfs->rmtab || strcmp (nfs->rmtab, rmtab) != 0) { mount_rewrite_rmtab (nfs->mstate, rmtab); - gf_log (GF_NFS, GF_LOG_INFO, - "Reconfigured nfs.mount-rmtab path: %s", - nfs->rmtab); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_PATH, + "Reconfigured nfs.mount-rmtab path: %s", nfs->rmtab); } GF_OPTION_RECONF (OPT_SERVER_AUX_GIDS, optbool, options, bool, out); if (nfs->server_aux_gids != optbool) { nfs->server_aux_gids = optbool; - gf_log(GF_NFS, GF_LOG_INFO, "Reconfigured %s with value %d", - OPT_SERVER_AUX_GIDS, optbool); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_VALUE, + "Reconfigured %s with value %d", OPT_SERVER_AUX_GIDS, + optbool); } GF_OPTION_RECONF (OPT_SERVER_GID_CACHE_TIMEOUT, optuint32, @@ -1215,8 +1261,9 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) if (nfs->server_aux_gids_max_age != optuint32) { nfs->server_aux_gids_max_age = optuint32; gid_cache_reconf (&nfs->gid_cache, optuint32); - gf_log(GF_NFS, GF_LOG_INFO, "Reconfigured %s with value %d", - OPT_SERVER_GID_CACHE_TIMEOUT, optuint32); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_VALUE, + "Reconfigured %s with value %d", + OPT_SERVER_GID_CACHE_TIMEOUT, optuint32); } /* reconfig nfs.dynamic-volumes */ @@ -1233,8 +1280,9 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) } if (nfs->dynamicvolumes != optbool) { nfs->dynamicvolumes = optbool; - gf_log(GF_NFS, GF_LOG_INFO, "Reconfigured nfs.dynamic-volumes" - " with value %d", optbool); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_VOL, + "Reconfigured nfs.dynamic-volumes with value %d", + optbool); } optbool = _gf_false; @@ -1242,7 +1290,7 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) ret = dict_get_str_boolean (options, "nfs.enable-ino32", _gf_false); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, "Failed to read reconfigured option: " "nfs.enable-ino32"); goto out; @@ -1251,8 +1299,8 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) } if (nfs->enable_ino32 != optbool) { nfs->enable_ino32 = optbool; - gf_log(GF_NFS, GF_LOG_INFO, "Reconfigured nfs.enable-ino32" - " with value %d", optbool); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_RECONFIG_ENABLE, + "Reconfigured nfs.enable-ino32 with value %d", optbool); } /* nfs.nlm is enabled by default */ @@ -1263,8 +1311,8 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) optbool = ret; } if (nfs->enable_nlm != optbool) { - gf_log (GF_NFS, GF_LOG_INFO, "NLM is manually %s", - (optbool ? "enabled":"disabled")); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_NLM_INFO, "NLM is" + " manually %s", (optbool ? "enabled":"disabled")); nfs->enable_nlm = optbool; nfs_reconfigure_nlm4 (this); } @@ -1277,8 +1325,8 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options) optbool = ret; } if (nfs->enable_acl != optbool) { - gf_log (GF_NFS, GF_LOG_INFO, "ACL is manually %s", - (optbool ? "enabled":"disabled")); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_ACL_INFO, "ACL is " + "manually %s", (optbool ? "enabled":"disabled")); nfs->enable_acl = optbool; nfs_reconfigure_acl3 (this); } @@ -1307,7 +1355,7 @@ reconfigure (xlator_t *this, dict_t *options) /* Reconfigure nfs options */ ret = nfs_reconfigure_state(this, options); if (ret) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, "nfs reconfigure state failed"); return (-1); } @@ -1315,7 +1363,7 @@ reconfigure (xlator_t *this, dict_t *options) /* Reconfigure nfs3 options */ ret = nfs3_reconfigure_state(this, options); if (ret) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, "nfs3 reconfigure state failed"); return (-1); } @@ -1323,7 +1371,7 @@ reconfigure (xlator_t *this, dict_t *options) /* Reconfigure mount options */ ret = mount_reconfigure_state(this, options); if (ret) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, "mount reconfigure state failed"); return (-1); } @@ -1331,7 +1379,7 @@ reconfigure (xlator_t *this, dict_t *options) /* Reconfigure rpc layer */ ret = rpcsvc_reconfigure_options (nfs->rpcsvc, options); if (ret) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, "rpcsvc reconfigure options failed"); return (-1); } @@ -1341,7 +1389,7 @@ reconfigure (xlator_t *this, dict_t *options) options, RPCSVC_DEF_NFS_OUTSTANDING_RPC_LIMIT); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, "Failed to reconfigure outstanding-rpc-limit"); return (-1); } @@ -1359,7 +1407,7 @@ reconfigure (xlator_t *this, dict_t *options) /* Reconfigure drc */ ret = rpcsvc_drc_reconfigure (nfs->rpcsvc, options); if (ret) { - gf_log (GF_NFS, GF_LOG_ERROR, + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_RECONFIG_FAIL, "rpcsvc DRC reconfigure failed"); return (-1); } @@ -1395,47 +1443,55 @@ init (xlator_t *this) { nfs = nfs_init_state (this); if (!nfs) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to init nfs option"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_OPT_INIT_FAIL, + "Failed to init nfs option"); return (-1); } ret = nfs_add_all_initiators (nfs); if (ret) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to add initiators"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_INIT_FAIL, + "Failed to add initiators"); return (-1); } ret = nfs_init_subvolumes (nfs, this->children); if (ret) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init NFS exports"); + gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, NFS_MSG_INIT_FAIL, + "Failed to init NFS exports"); return (-1); } ret = mount_init_state (this); if (ret) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init Mount state"); + gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, NFS_MSG_INIT_FAIL, + "Failed to init Mount state"); return (-1); } ret = nlm4_init_state (this); if (ret) { - gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to init NLM state"); + gf_msg (GF_NFS, GF_LOG_CRITICAL, 0, NFS_MSG_INIT_FAIL, + "Failed to init NLM state"); return (-1); } ret = nfs_init_versions (nfs, this); if (ret) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to initialize protocols"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_INIT_FAIL, + "Failed to initialize protocols"); return (-1); } ret = nfs_drc_init (this); if (ret) { - gf_log (GF_NFS, GF_LOG_ERROR, "Failed to initialize DRC"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_INIT_FAIL, + "Failed to initialize DRC"); return (-1); } - gf_log (GF_NFS, GF_LOG_INFO, "NFS service started"); + gf_msg (GF_NFS, GF_LOG_INFO, 0, NFS_MSG_STARTED, + "NFS service started"); return (0); /* SUCCESS */ } @@ -1448,7 +1504,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) subvol = (xlator_t *)data; - gf_log (GF_NFS, GF_LOG_TRACE, "Notification received: %d", + gf_msg_trace (GF_NFS, 0, "Notification received: %d", event); switch (event) { @@ -1478,7 +1534,7 @@ fini (xlator_t *this) mnt3svc_deinit (this); nfs = (struct nfs_state *)this->private; - gf_log (GF_NFS, GF_LOG_DEBUG, "NFS service going down"); + gf_msg_debug (GF_NFS, 0, "NFS service going down"); nfs_deinit_versions (&nfs->versions, this); return 0; } @@ -1532,7 +1588,8 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Could not get volname"); + gf_msg (this->name, GF_LOG_ERROR, -ret, NFS_MSG_VOL_NOT_FOUND, + "Could not get volname"); goto out; } @@ -1544,7 +1601,8 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) snprintf (key, sizeof (key), "client%d.hostname", count); ret = dict_set_str (dict, key, mentry->hostname); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + NFS_MSG_WRITE_FAIL, "Error writing hostname to dict"); goto out; } @@ -1556,7 +1614,8 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) snprintf (key, sizeof (key), "client%d.bytesread", count); ret = dict_set_uint64 (dict, key, 0); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + NFS_MSG_WRITE_FAIL, "Error writing bytes read to dict"); goto out; } @@ -1565,7 +1624,8 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) snprintf (key, sizeof (key), "client%d.byteswrite", count); ret = dict_set_uint64 (dict, key, 0); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + NFS_MSG_WRITE_FAIL, "Error writing bytes write to dict"); goto out; } @@ -1575,11 +1635,11 @@ nfs_priv_to_dict (xlator_t *this, dict_t *dict) ret = dict_set_int32 (dict, "clientcount", count); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, NFS_MSG_WRITE_FAIL, "Error writing client count to dict"); out: - gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret); + gf_msg_debug (THIS->name, 0, "Returning %d", ret); return ret; } @@ -1594,13 +1654,13 @@ nfs_priv (xlator_t *this) /* DRC needs the global drc structure, xl is of no use to it. */ ret = rpcsvc_drc_priv (((struct nfs_state *)(this->private))->rpcsvc->drc); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "Statedump of DRC failed"); + gf_msg_debug (this->name, 0, "Statedump of DRC failed"); goto out; } ret = nlm_priv (this); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "Statedump of NLM failed"); + gf_msg_debug (this->name, 0, "Statedump of NLM failed"); goto out; } out: diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c index 4e03277..d66ac5d 100644 --- a/xlators/nfs/server/src/nfs3.c +++ b/xlators/nfs/server/src/nfs3.c @@ -32,6 +32,7 @@ #include "nfs.h" #include "xdr-rpc.h" #include "xdr-generic.h" +#include "nfs-messages.h" #include #include @@ -42,8 +43,10 @@ do { \ if ((str)) { \ if (strlen ((str)) > (len)) { \ - gf_log (GF_NFS3, GF_LOG_ERROR, "strlen "\ - "too long"); \ + gf_msg (GF_NFS3, GF_LOG_ERROR, \ + ENAMETOOLONG, \ + NFS_MSG_STR_TOO_LONG, \ + "strlen too long"); \ status = NFS3ERR_NAMETOOLONG; \ retval = -ENAMETOOLONG; \ goto label; \ @@ -54,8 +57,9 @@ #define nfs3_validate_nfs3_state(request, state, status, label, retval) \ do { \ state = rpcsvc_request_program_private (request); \ - if (!state) { \ - gf_log (GF_NFS3, GF_LOG_ERROR, "NFSv3 state " \ + if (!state) { \ + gf_msg (GF_NFS3, GF_LOG_ERROR, EFAULT, \ + NFS_MSG_STATE_MISSING, "NFSv3 state " \ "missing from RPC request"); \ status = NFS3ERR_SERVERFAULT; \ ret = -EFAULT; \ @@ -80,7 +84,8 @@ __nfs3_get_export_by_index (struct nfs3_state *nfs3, uuid_t exportid) } exp = NULL; - gf_log (GF_NFS, GF_LOG_ERROR, "searchindex=%d not found", searchindex); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_INDEX_NOT_FOUND, + "searchindex=%d not found", searchindex); found: return exp; } @@ -130,7 +135,8 @@ nfs3_export_access (struct nfs3_state *nfs3, uuid_t exportid) exp = __nfs3_get_export_by_exportid (nfs3, exportid); if (!exp) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to get export by ID"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_EXPORT_ID_FAIL, + "Failed to get export by ID"); goto err; } @@ -143,7 +149,9 @@ err: #define nfs3_check_rw_volaccess(nfs3state, exid, status, label) \ do { \ if (nfs3_export_access (nfs3state,exid)!=GF_NFS3_VOLACCESS_RW){\ - gf_log (GF_NFS3, GF_LOG_ERROR, "No read-write access");\ + gf_msg (GF_NFS3, GF_LOG_ERROR, EACCES, \ + NFS_MSG_NO_RW_ACCESS, \ + "No read-write access"); \ status = NFS3ERR_ROFS; \ goto label; \ } \ @@ -214,8 +222,8 @@ out: rpc_transport_t *trans = NULL; \ volume = nfs3_fh_to_xlator ((nfs3state), handle); \ if (!volume) { \ - gf_uuid_unparse (handle->exportid, exportid); \ - gf_uuid_unparse (handle->gfid, gfid); \ + gf_uuid_unparse (handle->exportid, exportid); \ + gf_uuid_unparse (handle->gfid, gfid); \ trans = rpcsvc_request_transport (req); \ GF_LOG_OCCASIONALLY (nfs3state->occ_logger, \ GF_NFS3, GF_LOG_ERROR, "Failed to map " \ @@ -230,7 +238,7 @@ out: status = NFS3ERR_STALE; \ goto label; \ } else { \ - gf_log (GF_NFS3, GF_LOG_TRACE, "FH to Volume:" \ + gf_msg_trace (GF_NFS3, 0, "FH to Volume:" \ "%s", volume->name); \ rpcsvc_request_set_private (req, volume); \ } \ @@ -240,7 +248,9 @@ out: #define nfs3_validate_gluster_fh(handle, status, errlabel) \ do { \ if (!nfs3_fh_validate (handle)) { \ - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad Handle"); \ + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ + NFS_MSG_BAD_HANDLE, \ + "Bad Handle"); \ status = NFS3ERR_BADHANDLE; \ goto errlabel; \ } \ @@ -261,13 +271,14 @@ out: trans = rpcsvc_request_transport (cst->req); \ xlatorp = nfs3_fh_to_xlator (cst->nfs3state, \ &cst->resolvefh); \ - gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ + gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ sprintf (buf, "(%s) %s : %s", \ trans->peerinfo.identifier, \ xlatorp ? xlatorp->name : "ERR", gfid); \ - gf_log (GF_NFS3, GF_LOG_ERROR, "Unable to resolve FH"\ - ": %s", buf); \ - nfstat = nfs3_errno_to_nfsstat3 (-auth_errno);\ + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ + NFS_MSG_RESOLVE_FH_FAIL, "Unable to " \ + "resolve FH: %s", buf); \ + nfstat = nfs3_errno_to_nfsstat3 (-auth_errno); \ goto erlabl; \ } \ } while (0) \ @@ -281,13 +292,15 @@ out: trans = rpcsvc_request_transport (cst->req); \ xlatorp = nfs3_fh_to_xlator (cst->nfs3state, \ &cst->resolvefh); \ - gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ - snprintf (buf, sizeof (buf), "(%s) %s : %s", \ + gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ + snprintf (buf, sizeof (buf), "(%s) %s : %s", \ trans->peerinfo.identifier, \ xlatorp ? xlatorp->name : "ERR", \ - gfid ); \ - gf_log (GF_NFS3, GF_LOG_ERROR, "%s: %s", \ - strerror(cst->resolve_errno), buf); \ + gfid); \ + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ + NFS_MSG_RESOLVE_STAT, \ + "%s: %s", strerror(cst->resolve_errno), \ + buf); \ nfstat = nfs3_errno_to_nfsstat3 (cst->resolve_errno);\ goto erlabl; \ } \ @@ -303,12 +316,13 @@ out: trans = rpcsvc_request_transport (cst->req); \ xlatorp = nfs3_fh_to_xlator (cst->nfs3state, \ &cst->resolvefh); \ - gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ - snprintf (buf, sizeof (buf), "(%s) %s : %s", \ - trans->peerinfo.identifier, \ + gf_uuid_unparse (cst->resolvefh.gfid, gfid); \ + snprintf (buf, sizeof (buf), "(%s) %s : %s", \ + trans->peerinfo.identifier, \ xlatorp ? xlatorp->name : "ERR", \ - gfid); \ - gf_log (GF_NFS3, GF_LOG_ERROR, "%s: %s", \ + gfid); \ + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ + NFS_MSG_RESOLVE_STAT, "%s: %s", \ strerror(cst->resolve_errno), buf); \ nfstat = nfs3_errno_to_nfsstat3 (cs->resolve_errno);\ goto erlabl; \ @@ -349,7 +363,7 @@ out: goto erl; \ } \ \ - gf_uuid_copy ((fhd)->gfid, zero); \ + gf_uuid_copy ((fhd)->gfid, zero); \ (fhd)->gfid[15] = 1; \ (enam) = NULL; \ if ((gf_nfs_dvm_off (nfs_state (nfs3st->nfsx)))) \ @@ -366,8 +380,10 @@ out: #define nfs3_volume_started_check(nf3stt, vlm, rtval, erlbl) \ do { \ if ((!nfs_subvolume_started (nfs_state (nf3stt->nfsx), vlm))){\ - gf_log (GF_NFS3, GF_LOG_ERROR, "Volume is disabled: %s",\ - vlm->name); \ + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ + NFS_MSG_VOL_DISABLE, \ + "Volume is disabled: %s", \ + vlm->name); \ rtval = RPCSVC_ACTOR_IGNORE; \ goto erlbl; \ } \ @@ -442,7 +458,8 @@ nfs3_call_state_init (struct nfs3_state *s, rpcsvc_request_t *req, xlator_t *v) cs = (nfs3_call_state_t *) mem_get (s->localpool); if (!cs) { - gf_log (GF_NFS3, GF_LOG_ERROR, "out of memory"); + gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "out of memory"); return NULL; } @@ -465,7 +482,7 @@ nfs3_call_state_wipe (nfs3_call_state_t *cs) return; if (cs->fd) { - gf_log (GF_NFS3, GF_LOG_TRACE, "fd 0x%lx ref: %d", + gf_msg_trace (GF_NFS3, 0, "fd 0x%lx ref: %d", (long)cs->fd, cs->fd->refcount); fd_unref (cs->fd); } @@ -495,8 +512,9 @@ nfs3_call_state_wipe (nfs3_call_state_t *cs) do { \ calls = nfs3_call_state_init ((nfs3state), (rq), (vl)); \ if (!calls) { \ - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to " \ - "init call state"); \ + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, \ + NFS_MSG_INIT_CALL_STAT_FAIL, "Failed to"\ + " init call state"); \ opstat = NFS3ERR_SERVERFAULT; \ goto errlabel; \ } \ @@ -514,8 +532,8 @@ nfs3_serialize_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc, nfs3 = (struct nfs3_state *)rpcsvc_request_program_private (req); if (!nfs3) { - gf_log (GF_NFS3, GF_LOG_ERROR, "NFSv3 state not found in RPC" - " request"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_STATE_MISSING, + "NFSv3 state not found in RPC request"); goto ret; } @@ -526,7 +544,8 @@ nfs3_serialize_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc, can have 'xdr_sizeof' */ iob = iobuf_get (nfs3->iobpool); if (!iob) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to get iobuf"); + gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "Failed to get iobuf"); goto ret; } @@ -539,7 +558,8 @@ nfs3_serialize_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc, */ retlen = sfunc (*outmsg, arg); if (retlen == -1) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to encode message"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ENCODE_FAIL, + "Failed to encode message"); goto ret; } @@ -569,26 +589,30 @@ nfs3svc_submit_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc) iob = nfs3_serialize_reply (req, arg, sfunc, &outmsg); if (!iob) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to serialize reply"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SERIALIZE_REPLY_FAIL, + "Failed to serialize reply"); goto ret; } iobref = iobref_new (); if (!iobref) { - gf_log (GF_NFS3, GF_LOG_ERROR, "failed on iobref_new()"); + gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "failed on iobref_new()"); goto ret; } ret = iobref_add (iobref, iob); if (ret) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to add iob to iobref"); + gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "Failed to add iob to iobref"); goto ret; } /* Then, submit the message for transmission. */ ret = rpcsvc_submit_message (req, &outmsg, 1, NULL, 0, iobref); if (ret == -1) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Reply submission failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SUBMIT_REPLY_FAIL, + "Reply submission failed"); goto ret; } @@ -621,13 +645,15 @@ nfs3svc_submit_vector_reply (rpcsvc_request_t *req, void *arg, iob = nfs3_serialize_reply (req, arg, sfunc, &outmsg); if (!iob) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to serialize reply"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SERIALIZE_REPLY_FAIL, + "Failed to serialize reply"); goto ret; } if (iobref == NULL) { iobref = iobref_new (); if (!iobref) { - gf_log (GF_NFS3, GF_LOG_ERROR, "failed on iobref_new"); + gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, + NFS_MSG_NO_MEMORY, "failed on iobref_new"); goto ret; } new_iobref = 1; @@ -635,14 +661,16 @@ nfs3svc_submit_vector_reply (rpcsvc_request_t *req, void *arg, ret = iobref_add (iobref, iob); if (ret) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to add iob to iobref"); + gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "Failed to add iob to iobref"); goto ret; } /* Then, submit the message for transmission. */ ret = rpcsvc_submit_message (req, &outmsg, 1, payload, vcount, iobref); if (ret == -1) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Reply submission failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SUBMIT_REPLY_FAIL, + "Reply submission failed"); goto ret; } @@ -727,9 +755,10 @@ nfs3svc_getattr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, */ if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_GETATTR_LOOKUP_CBK, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->resolvedloc.path, + strerror (op_errno)); status = nfs3_cbk_errno_status (op_ret, op_errno); } else { @@ -757,9 +786,10 @@ nfs3svc_getattr_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_GETATTR_STAT_CBK, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->resolvedloc.path, + strerror (op_errno)); status = nfs3_cbk_errno_status (op_ret, op_errno); } @@ -833,8 +863,9 @@ nfs3_getattr_resume (void *carg) check_err: if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Stat fop failed: %s: %s", - cs->oploc.path, strerror (-ret)); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_STAT_FOP_FAIL, + "Stat fop failed: %s: %s", cs->oploc.path, + strerror (-ret)); stat = nfs3_errno_to_nfsstat3 (-ret); } @@ -899,14 +930,16 @@ nfs3svc_getattr (rpcsvc_request_t *req) nfs3_prep_getattr3args (&args, &fh); if (xdr_to_getattr3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_getattr (req, &fh); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "GETATTR procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_GETATTR_FAIL, + "GETATTR procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -942,7 +975,7 @@ nfs3svc_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_TRUNCATE_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -982,7 +1015,7 @@ nfs3svc_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_SETATTR_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -1038,15 +1071,17 @@ nfs3svc_setattr_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_SETATTR_STAT_CBK, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->resolvedloc.path, + strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); goto nfs3err; } if (buf->ia_ctime != cs->timestamp.seconds) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Timestamps not in sync"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_TIMESTAMP_NO_SYNC, + "Timestamps not in sync"); stat = NFS3ERR_NOT_SYNC; goto nfs3err; } @@ -1130,18 +1165,19 @@ nfs3_setattr (rpcsvc_request_t *req, struct nfs3_fh *fh, sattr3 *sattr, cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, &cs->stbuf, NULL); if (guard->check) { - gf_log (GF_NFS3, GF_LOG_TRACE, "Guard check required"); + gf_msg_trace (GF_NFS3, 0, "Guard check required"); cs->timestamp = guard->sattrguard3_u.obj_ctime; cs->sattrguardcheck = 1; } else { - gf_log (GF_NFS3, GF_LOG_TRACE, "Guard check not required"); + gf_msg_trace (GF_NFS3, 0, "Guard check not required"); cs->sattrguardcheck = 0; } if (!cs->setattr_valid) { ret = -EINVAL; /* Force a reply */ stat = NFS3_OK; - gf_log (GF_NFS3, GF_LOG_ERROR, "cs->setattr_valid is invalid"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_SETATTR_INVALID, + "cs->setattr_valid is invalid"); goto nfs3err; } @@ -1177,14 +1213,17 @@ nfs3svc_setattr (rpcsvc_request_t *req) nfs3_prep_setattr3args (&args, &fh); if (xdr_to_setattr3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, + NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_setattr (req, &fh, &args.new_attributes, &args.guard); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "SETATTR procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_SETATTR_FAIL, + "SETATTR procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -1219,7 +1258,7 @@ nfs3_fresh_lookup (nfs3_call_state_t *cs) char *oldresolventry = NULL; GF_VALIDATE_OR_GOTO (GF_NFS3, cs, err); - gf_log (GF_NFS3, GF_LOG_DEBUG, "inode needs fresh lookup"); + gf_msg_debug (GF_NFS3, 0, "inode needs fresh lookup"); inode_unlink (cs->resolvedloc.inode, cs->resolvedloc.parent, cs->resolventry); nfs_loc_wipe (&cs->resolvedloc); @@ -1251,10 +1290,16 @@ nfs3svc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, - (op_errno == ENOENT ? GF_LOG_TRACE : GF_LOG_WARNING), - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + if (op_errno == ENOENT) { + gf_msg_trace (GF_NFS, 0, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + } else { + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_SVC_LOOKUP, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), + cs->resolvedloc.path, strerror (op_errno)); + } status = nfs3_cbk_errno_status (op_ret, op_errno); goto xmit_res; } @@ -1297,9 +1342,10 @@ nfs3svc_lookup_parentdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_SVC_PAR_LOOKUP, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->resolvedloc.path, + strerror (op_errno)); status = nfs3_cbk_errno_status (op_ret, op_errno); goto xmit_res; } @@ -1343,8 +1389,8 @@ nfs3_lookup_parentdir_resume (void *carg) inode_t *parent = NULL; if (!carg) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Invalid argument," - " carg value NULL"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Invalid argument, carg value NULL"); return EINVAL; } @@ -1382,7 +1428,9 @@ nfs3_lookup_parentdir_resume (void *carg) NFS_RESOLVE_CREATE); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "nfs_inode_loc_fill" + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_INODE_LOC_FILL_ERROR, + "nfs_inode_loc_fill" " error"); goto errtostat; } @@ -1419,8 +1467,8 @@ nfs3_lookup_resume (void *carg) struct nfs3_fh newfh = {{0},}; if (!carg) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Invalid argument," - " carg value NULL"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Invalid argument, carg value NULL"); return EINVAL; } @@ -1484,7 +1532,9 @@ nfs3_lookup (rpcsvc_request_t *req, struct nfs3_fh *fh, int fhlen, char *name) nfs3_lookup_resume); if (ret < 0) { - gf_log (GF_NFS, GF_LOG_ERROR, "failed to start hard reslove"); + gf_msg (GF_NFS, GF_LOG_ERROR, -ret, + NFS_MSG_HARD_RESOLVE_FAIL, + "failed to start hard reslove"); stat = nfs3_errno_to_nfsstat3 (-ret); } @@ -1517,14 +1567,17 @@ nfs3svc_lookup (rpcsvc_request_t *req) nfs3_prep_lookup3args (&args, &fh, name); if (xdr_to_lookup3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_lookup (req, &fh, args.what.dir.data.data_len, name); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "LOOKUP procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_LOOKUP_PROC_FAIL, + "LOOKUP procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -1557,7 +1610,7 @@ nfs3svc_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_ACCESS_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); status = nfs3_cbk_errno_status (op_ret, op_errno); @@ -1580,8 +1633,8 @@ nfs3_access_resume (void *carg) nfs3_call_state_t *cs = NULL; if (!carg) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Invalid argument," - " carg value NULL"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Invalid argument, carg value NULL"); return EINVAL; } @@ -1667,14 +1720,17 @@ nfs3svc_access (rpcsvc_request_t *req) nfs3_prep_access3args (&args, &fh); if (xdr_to_access3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_access (req, &fh, args.access); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "ACCESS procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_ACCESS_PROC_FAIL, + "ACCESS procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -1710,7 +1766,7 @@ nfs3svc_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_READLINK_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -1771,7 +1827,8 @@ nfs3_readlink (rpcsvc_request_t *req, struct nfs3_fh *fh) nfs3_call_state_t *cs = NULL; if ((!req) || (!fh)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -1814,14 +1871,17 @@ nfs3svc_readlink (rpcsvc_request_t *req) nfs3_prep_readlink3args (&args, &fh); if (xdr_to_readlink3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_readlink (req, &fh); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "READLINK procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_READLINK_PROC_FAIL, + "READLINK procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -1878,7 +1938,7 @@ nfs3svc_read_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_READ_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -1946,7 +2006,8 @@ nfs3_read_resume (void *carg) nfs3_check_fh_resolve_status (cs, stat, nfs3err); fd = fd_anonymous (cs->resolvedloc.inode); if (!fd) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to create anonymous fd"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ANONYMOUS_FD_FAIL, + "Failed to create anonymous fd"); goto nfs3err; } @@ -1975,7 +2036,8 @@ nfs3_read (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, nfs3_call_state_t *cs = NULL; if ((!req) || (!fh)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -2018,14 +2080,17 @@ nfs3svc_read (rpcsvc_request_t *req) nfs3_prep_read3args (&args, &fh); if (xdr_to_read3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_read (req, &fh, args.offset, args.count); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "READ procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_READ_FAIL, + "READ procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -2065,7 +2130,7 @@ nfs3svc_write_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, nfs3 = rpcsvc_request_program_private (cs->req); if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_FSYNC_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -2125,7 +2190,7 @@ nfs3svc_write_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; nfs3 = rpcsvc_request_program_private (cs->req); if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_WRITE_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -2194,7 +2259,8 @@ nfs3_write_resume (void *carg) nfs3_check_fh_resolve_status (cs, stat, nfs3err); fd = fd_anonymous (cs->resolvedloc.inode); if (!fd) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to create anonymous fd"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ANONYMOUS_FD_FAIL, + "Failed to create anonymous fd"); goto nfs3err; } @@ -2245,7 +2311,8 @@ nfs3_write (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, nfs3_call_state_t *cs = NULL; if ((!req) || (!fh) || (!payload.iov_base)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -2309,7 +2376,8 @@ nfs3svc_write_vecsizer (int state, ssize_t *readsize, char *base_addr, ret = 0; *readsize = 0; } else - gf_log ("nfs", GF_LOG_ERROR, "state wrong"); + gf_msg ("nfs", GF_LOG_ERROR, 0, NFS_MSG_STATE_WRONG, + "state wrong"); return ret; } @@ -2326,7 +2394,8 @@ nfs3svc_write (rpcsvc_request_t *req) return ret; nfs3_prep_write3args (&args, &fh); if (xdr_to_write3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -2340,7 +2409,9 @@ nfs3svc_write (rpcsvc_request_t *req) ret = nfs3_write (req, &fh, args.offset, args.count, args.stable, req->msg[1], rpcsvc_request_iobref_ref (req)); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "WRITE procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_WRITE_FAIL, + "WRITE procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -2377,9 +2448,10 @@ nfs3svc_create_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_CREATE_SETATTR_CBK, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->resolvedloc.path, + strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); goto nfs3err; } @@ -2410,7 +2482,7 @@ nfs3svc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_CREATE_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -2514,9 +2586,10 @@ nfs3svc_create_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; nfs_request_user_init (&nfu, cs->req); if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_CREATE_STAT_CBK, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->resolvedloc.path, + strerror (op_errno)); ret = -op_errno; stat = nfs3_cbk_errno_status (op_ret, op_errno); goto nfs3err; @@ -2524,13 +2597,13 @@ nfs3svc_create_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if ((cs->stbuf.ia_mtime == buf->ia_mtime) && (cs->stbuf.ia_atime == buf->ia_atime)) { - gf_log (GF_NFS3, GF_LOG_DEBUG, + gf_msg_debug (GF_NFS3, 0, "Create req retransmitted verf %x %x", cs->stbuf.ia_mtime, cs->stbuf.ia_atime); stat = NFS3_OK; nfs3_fh_build_child_fh (&cs->parent, buf, &cs->fh); } else { - gf_log (GF_NFS3, GF_LOG_DEBUG, + gf_msg_debug (GF_NFS3, 0, "File already exist new_verf %x %x" "old_verf %x %x", cs->stbuf.ia_mtime, cs->stbuf.ia_atime, @@ -2684,7 +2757,8 @@ nfs3svc_create (rpcsvc_request_t *req) nfs3_prep_create3args (&args, &dirfh, name); if (xdr_to_create3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -2695,7 +2769,8 @@ nfs3svc_create (rpcsvc_request_t *req) ret = nfs3_create (req, &dirfh, name, args.how.mode, &args.how.createhow3_u.obj_attributes, cverf); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "CREATE procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_CREATE_FAIL, + "CREATE procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -2731,9 +2806,10 @@ nfs3svc_mkdir_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_MKDIR_SETATTR_CBK, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->resolvedloc.path, + strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); goto nfs3err; } @@ -2763,7 +2839,7 @@ nfs3svc_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_MKDIR_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -2849,7 +2925,8 @@ nfs3_mkdir (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, nfs3_call_state_t *cs = NULL; if ((!req) || (!dirfh) || (!name) || (!sattr)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -2895,14 +2972,16 @@ nfs3svc_mkdir (rpcsvc_request_t *req) return ret; nfs3_prep_mkdir3args (&args, &dirfh, name); if (xdr_to_mkdir3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_mkdir (req, &dirfh, name, &args.attributes); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "MKDIR procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_DIR_OP_FAIL, + "MKDIR procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -2941,7 +3020,7 @@ nfs3svc_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_SYMLINK_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -3003,7 +3082,8 @@ nfs3_symlink (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, nfs3_call_state_t *cs = NULL; if ((!req) || (!dirfh) || (!name) || (!target) || (!sattr)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -3058,7 +3138,8 @@ nfs3svc_symlink (rpcsvc_request_t *req) return ret; nfs3_prep_symlink3args (&args, &dirfh, name, target); if (xdr_to_symlink3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -3066,7 +3147,8 @@ nfs3svc_symlink (rpcsvc_request_t *req) ret = nfs3_symlink (req, &dirfh, name, target, &args.symlink.symlink_attributes); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "SYMLINK procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EXDEV, NFS_MSG_SYMLINK_FAIL, + "SYMLINK procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -3103,7 +3185,7 @@ nfs3svc_mknod_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_MKNOD_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -3135,7 +3217,7 @@ nfs3svc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_MKNOD_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -3282,7 +3364,8 @@ nfs3_mknod (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name, sattr3 *sattr = NULL; if ((!req) || (!fh) || (!name) || (!nodedata)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -3351,14 +3434,16 @@ nfs3svc_mknod (rpcsvc_request_t *req) return ret; nfs3_prep_mknod3args (&args, &fh, name); if (xdr_to_mknod3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_mknod (req, &fh, name, &args.what); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "MKNOD procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_MKNOD_FAIL, + "MKNOD procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -3393,7 +3478,7 @@ nfs3svc_remove_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_REMOVE_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -3471,7 +3556,8 @@ nfs3_remove (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name) nfs3_call_state_t *cs = NULL; if ((!req) || (!fh) || (!name)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -3517,14 +3603,16 @@ nfs3svc_remove (rpcsvc_request_t *req) return ret; nfs3_prep_remove3args (&args, &fh, name); if (xdr_to_remove3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_remove (req, &fh, name); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "REMOVE procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_REMOVE_FAIL, + "REMOVE procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -3559,7 +3647,7 @@ nfs3svc_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_RMDIR_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -3617,7 +3705,8 @@ nfs3_rmdir (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name) nfs3_call_state_t *cs = NULL; if ((!req) || (!fh) || (!name)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -3663,14 +3752,16 @@ nfs3svc_rmdir (rpcsvc_request_t *req) return ret; nfs3_prep_rmdir3args (&args, &fh, name); if (xdr_to_rmdir3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_rmdir (req, &fh, name); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "RMDIR procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, NFS_MSG_DIR_OP_FAIL, + "RMDIR procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -3713,7 +3804,7 @@ nfs3svc_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_RENAME_CBK, "%x: rename %s -> %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->oploc.path, cs->resolvedloc.path, strerror (op_errno)); @@ -3812,7 +3903,8 @@ nfs3_rename (rpcsvc_request_t *req, struct nfs3_fh *olddirfh, char *oldname, nfs3_call_state_t *cs = NULL; if ((!req) || (!olddirfh) || (!oldname) || (!newdirfh) || (!newname)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -3874,14 +3966,16 @@ nfs3svc_rename (rpcsvc_request_t *req) return ret; nfs3_prep_rename3args (&args, &olddirfh, oldname, &newdirfh, newname); if (xdr_to_rename3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_rename (req, &olddirfh, oldname, &newdirfh, newname); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "RENAME procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_RENAME_FAIL, + "RENAME procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -3918,7 +4012,7 @@ nfs3svc_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_LINK_CBK, "%x: link %s <- %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->oploc.path, cs->resolvedloc.path, strerror (op_errno)); @@ -4009,7 +4103,8 @@ nfs3_link (rpcsvc_request_t *req, struct nfs3_fh *targetfh, nfs3_call_state_t *cs = NULL; if ((!req) || (!targetfh) || (!dirfh) || (!newname)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -4063,14 +4158,16 @@ nfs3svc_link (rpcsvc_request_t *req) return ret; nfs3_prep_link3args (&args, &targetfh, &dirfh, newpath); if (xdr_to_link3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_link (req, &targetfh, &dirfh, newpath); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "LINK procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EXDEV, NFS_MSG_LINK_FAIL, + "LINK procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4129,7 +4226,8 @@ nfs3svc_readdir_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_READDIR_FSTAT_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -4140,7 +4238,7 @@ nfs3svc_readdir_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, * readdir'ing. */ if (cs->operrno == ENOENT) { - gf_log (GF_NFS3, GF_LOG_TRACE, "Reached end-of-directory"); + gf_msg_trace (GF_NFS3, 0, "Reached end-of-directory"); is_eof = 1; } @@ -4188,7 +4286,7 @@ nfs3svc_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_READDIR_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -4320,7 +4418,8 @@ nfs3_readdir_open_resume (void *carg) nfs3_check_fh_resolve_status (cs, stat, nfs3err); cs->fd = fd_anonymous (cs->resolvedloc.inode); if (!cs->fd) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Faile to create anonymous fd"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ANONYMOUS_FD_FAIL, + "Fail to create anonymous fd"); goto nfs3err; } @@ -4336,7 +4435,9 @@ nfs3_readdir_open_resume (void *carg) ret = nfs_opendir (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, nfs3svc_readdir_opendir_cbk, cs); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "auto-opendir failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_DIR_OP_FAIL, + "auto-opendir failed"); } } @@ -4376,7 +4477,8 @@ nfs3_readdir (rpcsvc_request_t *req, struct nfs3_fh *fh, cookie3 cookie, nfs3_call_state_t *cs = NULL; if ((!req) || (!fh)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -4435,7 +4537,8 @@ nfs3svc_readdir (rpcsvc_request_t *req) return ret; nfs3_prep_readdir3args (&ra, &fh); if (xdr_to_readdir3args (req->msg[0], &ra) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -4444,7 +4547,9 @@ nfs3svc_readdir (rpcsvc_request_t *req) ret = nfs3_readdir (req, &fh, ra.cookie, verf, ra.count, 0); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "READDIR procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_READDIR_FAIL, + "READDIR procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4467,7 +4572,8 @@ nfs3svc_readdirp (rpcsvc_request_t *req) return ret; nfs3_prep_readdirp3args (&ra, &fh); if (xdr_to_readdirp3args (req->msg[0], &ra) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -4477,7 +4583,9 @@ nfs3svc_readdirp (rpcsvc_request_t *req) ret = nfs3_readdir (req, &fh, ra.cookie, cverf, ra.dircount, ra.maxcount); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "READDIRP procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_READDIRP_FAIL, + "READDIRP procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4512,9 +4620,10 @@ nfs3_fsstat_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_FSSTAT_STAT_CBK, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->resolvedloc.path, + strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); } else stat = NFS3_OK; @@ -4539,9 +4648,10 @@ nfs3_fsstat_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, - "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), - cs->resolvedloc.path, strerror (op_errno)); + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, + NFS_MSG_FSSTAT_STATFS_CBK, "%x: %s => -1 (%s)", + rpcsvc_request_xid (cs->req), cs->resolvedloc.path, + strerror (op_errno)); ret = -op_errno; stat = nfs3_cbk_errno_status (op_ret, op_errno); goto err; @@ -4612,7 +4722,8 @@ nfs3_fsstat (rpcsvc_request_t *req, struct nfs3_fh *fh) nfs3_call_state_t *cs = NULL; if ((!req) || (!fh)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -4654,14 +4765,16 @@ nfs3svc_fsstat (rpcsvc_request_t *req) return ret; nfs3_prep_fsstat3args (&args, &fh); if (xdr_to_fsstat3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_fsstat (req, &fh); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "FSTAT procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FSTAT_FAIL, + "FSTAT procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4699,7 +4812,7 @@ nfs3svc_fsinfo_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_FSINFO_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); status = nfs3_cbk_errno_status (op_ret, op_errno); @@ -4759,7 +4872,8 @@ nfs3_fsinfo (rpcsvc_request_t *req, struct nfs3_fh *fh) nfs3_call_state_t *cs = NULL; if ((!req) || (!fh)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -4799,14 +4913,16 @@ nfs3svc_fsinfo (rpcsvc_request_t *req) nfs3_prep_fsinfo3args (&args, &root); if (xdr_to_fsinfo3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding arguments"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_fsinfo (req, &root); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "FSINFO procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FSINFO_FAIL, + "FSINFO procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4841,7 +4957,7 @@ nfs3svc_pathconf_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_PATHCONF_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -4901,7 +5017,8 @@ nfs3_pathconf (rpcsvc_request_t *req, struct nfs3_fh *fh) nfs3_call_state_t *cs = NULL; if ((!req) || (!fh)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -4943,14 +5060,17 @@ nfs3svc_pathconf (rpcsvc_request_t *req) return ret; nfs3_prep_pathconf3args (&args, &fh); if (xdr_to_pathconf3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_pathconf (req, &fh); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "PATHCONF procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, -ret, + NFS_MSG_PATHCONF_FAIL, + "PATHCONF procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4985,7 +5105,7 @@ nfs3svc_commit_cbk (call_frame_t *frame, void *cookie, xlator_t *this, cs = frame->local; if (op_ret == -1) { - gf_log (GF_NFS, GF_LOG_WARNING, + gf_msg (GF_NFS, GF_LOG_WARNING, op_errno, NFS_MSG_COMMIT_CBK, "%x: %s => -1 (%s)", rpcsvc_request_xid (cs->req), cs->resolvedloc.path, strerror (op_errno)); stat = nfs3_cbk_errno_status (op_ret, op_errno); @@ -5055,7 +5175,8 @@ nfs3_commit_open_resume (void *carg) nfs3_check_fh_resolve_status (cs, stat, nfs3err); cs->fd = fd_anonymous (cs->resolvedloc.inode); if (!cs->fd) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to create anonymous fd."); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ANONYMOUS_FD_FAIL, + "Failed to create anonymous fd."); goto nfs3err; } @@ -5086,7 +5207,8 @@ nfs3_commit (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, nfs3_call_state_t *cs = NULL; if ((!req) || (!fh)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Bad arguments"); + gf_msg (GF_NFS3, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY, + "Bad arguments"); return -1; } @@ -5131,14 +5253,16 @@ nfs3svc_commit (rpcsvc_request_t *req) return ret; nfs3_prep_commit3args (&args, &fh); if (xdr_to_commit3args (req->msg[0], &args) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_ARGS_DECODE_ERROR, + "Error decoding args"); rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } ret = nfs3_commit (req, &fh, args.offset, args.count); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "COMMIT procedure failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_COMMIT_FAIL, + "COMMIT procedure failed"); rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -5230,16 +5354,16 @@ nfs3_init_options (struct nfs3_state *nfs3, dict_t *options) if (dict_get (options, "nfs3.read-size")) { ret = dict_get_str (options, "nfs3.read-size", &optstr); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " - " option: nfs3.read-size"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read option: nfs3.read-size"); ret = -1; goto err; } ret = gf_string2uint64 (optstr, &size64); if (ret == -1) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to format" - " option: nfs3.read-size"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FORMAT_FAIL, + "Failed to format option: nfs3.read-size"); ret = -1; goto err; } @@ -5253,16 +5377,16 @@ nfs3_init_options (struct nfs3_state *nfs3, dict_t *options) if (dict_get (options, "nfs3.write-size")) { ret = dict_get_str (options, "nfs3.write-size", &optstr); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " - " option: nfs3.write-size"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read option: nfs3.write-size"); ret = -1; goto err; } ret = gf_string2uint64 (optstr, &size64); if (ret == -1) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to format" - " option: nfs3.write-size"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FORMAT_FAIL, + "Failed to format option: nfs3.write-size"); ret = -1; goto err; } @@ -5276,16 +5400,16 @@ nfs3_init_options (struct nfs3_state *nfs3, dict_t *options) if (dict_get (options, "nfs3.readdir-size")) { ret = dict_get_str (options,"nfs3.readdir-size", &optstr); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read" - " option: nfs3.readdir-size"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read option: nfs3.readdir-size"); ret = -1; goto err; } ret = gf_string2uint64 (optstr, &size64); if (ret == -1) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to format" - " option: nfs3.readdir-size"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_FORMAT_FAIL, + "Failed to format option: nfs3.readdir-size"); ret = -1; goto err; } @@ -5340,7 +5464,8 @@ nfs3_init_subvolume_options (xlator_t *nfsx, ret = snprintf (searchkey, 1024, "nfs3.%s.volume-id",exp->subvol->name); if (ret < 0) { - gf_log (GF_MNT, GF_LOG_ERROR, "snprintf failed"); + gf_msg (GF_MNT, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, + "snprintf failed"); ret = -1; goto err; } @@ -5348,14 +5473,15 @@ nfs3_init_subvolume_options (xlator_t *nfsx, if (dict_get (options, searchkey)) { ret = dict_get_str (options, searchkey, &optstr); if (ret < 0) { - gf_log (GF_MNT, GF_LOG_ERROR, "Failed to read option" - ": %s", searchkey); + gf_msg (GF_MNT, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read option: %s", searchkey); ret = -1; goto err; } } else { - gf_log (GF_MNT, GF_LOG_ERROR, "DVM is on but volume-id not " - "given for volume: %s", exp->subvol->name); + gf_msg (GF_MNT, GF_LOG_ERROR, 0, NFS_MSG_VOLID_MISSING, "DVM is" + " on but volume-id not given for volume: %s", + exp->subvol->name); ret = -1; goto err; } @@ -5363,8 +5489,9 @@ nfs3_init_subvolume_options (xlator_t *nfsx, if (optstr) { ret = gf_uuid_parse (optstr, volumeid); if (ret < 0) { - gf_log (GF_MNT, GF_LOG_ERROR, "Failed to parse volume " - "UUID"); + gf_msg (GF_MNT, GF_LOG_ERROR, 0, + NFS_MSG_PARSE_VOL_UUID_FAIL, + "Failed to parse volume UUID"); ret = -1; goto err; } @@ -5376,7 +5503,8 @@ no_dvm: name = exp->subvol->name; ret = snprintf (searchkey, 1024, "nfs3.%s.volume-access", name); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "snprintf failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, + "snprintf failed"); ret = -1; goto err; } @@ -5385,8 +5513,8 @@ no_dvm: if (dict_get (options, searchkey)) { ret = dict_get_str (options, searchkey, &optstr); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " - " option: %s", searchkey); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read option: %s", searchkey); ret = -1; goto err; } @@ -5397,7 +5525,8 @@ no_dvm: ret = snprintf (searchkey, 1024, "rpc-auth.%s.unix", name); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "snprintf failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, + "snprintf failed"); ret = -1; goto err; } @@ -5405,8 +5534,8 @@ no_dvm: if (dict_get (options, searchkey)) { ret = dict_get_str (options, searchkey, &optstr); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " - " option: %s", searchkey); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read option: %s", searchkey); ret = -1; goto err; } @@ -5415,7 +5544,8 @@ no_dvm: exp->trusted_sync = 0; ret = snprintf (searchkey, 1024, "nfs3.%s.trusted-sync", name); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "snprintf failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, + "snprintf failed"); ret = -1; goto err; } @@ -5423,15 +5553,16 @@ no_dvm: if (dict_get (options, searchkey)) { ret = dict_get_str (options, searchkey, &optstr); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " - " option: %s", searchkey); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read option: %s", searchkey); ret = -1; goto err; } ret = gf_string2boolean (optstr, &boolt); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to convert str " + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, + NFS_MSG_STR2BOOL_FAIL, "Failed to convert str " "to gf_boolean_t"); ret = -1; goto err; @@ -5444,7 +5575,8 @@ no_dvm: exp->trusted_write = 0; ret = snprintf (searchkey, 1024, "nfs3.%s.trusted-write", name); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "snprintf failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SNPRINTF_FAIL, + "snprintf failed"); ret = -1; goto err; } @@ -5452,16 +5584,17 @@ no_dvm: if (dict_get (options, searchkey)) { ret = dict_get_str (options, searchkey, &optstr); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to read " - " option: %s", searchkey); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_READ_FAIL, + "Failed to read option: %s", searchkey); ret = -1; goto err; } ret = gf_string2boolean (optstr, &boolt); if (ret < 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to convert str " - "to gf_boolean_t"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, + NFS_MSG_STR2BOOL_FAIL, "Failed to convert str" + " to gf_boolean_t"); ret = -1; goto err; } @@ -5477,7 +5610,7 @@ no_dvm: if (exp->trusted_sync) exp->trusted_write = 1; - gf_log (GF_NFS3, GF_LOG_TRACE, "%s: %s, %s, %s", exp->subvol->name, + gf_msg_trace (GF_NFS3, 0, "%s: %s, %s, %s", exp->subvol->name, (exp->access == GF_NFS3_VOLACCESS_RO)?"read-only":"read-write", (exp->trusted_sync == 0)?"no trusted_sync":"trusted_sync", (exp->trusted_write == 0)?"no trusted_write":"trusted_write"); @@ -5499,11 +5632,12 @@ nfs3_init_subvolume (struct nfs3_state *nfs3, xlator_t *subvol) exp = GF_CALLOC (1, sizeof (*exp), gf_nfs_mt_nfs3_export); exp->subvol = subvol; INIT_LIST_HEAD (&exp->explist); - gf_log (GF_NFS3, GF_LOG_TRACE, "Initing state: %s", exp->subvol->name); + gf_msg_trace (GF_NFS3, 0, "Initing state: %s", exp->subvol->name); ret = nfs3_init_subvolume_options (nfs3->nfsx, exp, NULL); if (ret == -1) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to init subvol"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SUBVOL_INIT_FAIL, + "Failed to init subvol"); goto exp_free; } @@ -5533,8 +5667,9 @@ nfs3_init_subvolumes (struct nfs3_state *nfs3) while (xl_list) { exp = nfs3_init_subvolume (nfs3, xl_list->xlator); if (!exp) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to init subvol: " - "%s", xl_list->xlator->name); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, + NFS_MSG_SUBVOL_INIT_FAIL, "Failed to init " + "subvol: %s", xl_list->xlator->name); goto err; } list_add_tail (&exp->explist, &nfs3->exports); @@ -5561,24 +5696,27 @@ nfs3_init_state (xlator_t *nfsx) nfs3 = (struct nfs3_state *)GF_CALLOC (1, sizeof (*nfs3), gf_nfs_mt_nfs3_state); if (!nfs3) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Memory allocation failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "Memory allocation failed"); return NULL; } nfs = nfsx->private; ret = nfs3_init_options (nfs3, nfsx->options); if (ret == -1) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to init options"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_OPT_INIT_FAIL, + "Failed to init options"); goto ret; } nfs3->iobpool = nfsx->ctx->iobuf_pool; localpool = nfs->memfactor * GF_NFS_CONCURRENT_OPS_MULT; - gf_log (GF_NFS3, GF_LOG_TRACE, "local pool: %d", localpool); + gf_msg_trace (GF_NFS3, 0, "local pool: %d", localpool); nfs3->localpool = mem_pool_new (nfs3_call_state_t, localpool); if (!nfs3->localpool) { - gf_log (GF_NFS3, GF_LOG_ERROR, "local mempool creation failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY, + "local mempool creation failed"); ret = -1; goto ret; } @@ -5588,8 +5726,8 @@ nfs3_init_state (xlator_t *nfsx) INIT_LIST_HEAD (&nfs3->exports); ret = nfs3_init_subvolumes (nfs3); if (ret == -1) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to init per-subvolume " - "state"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_SUBVOL_INIT_FAIL, + "Failed to init per-subvolume state"); goto free_localpool; } @@ -5600,7 +5738,8 @@ nfs3_init_state (xlator_t *nfsx) ret = rpcsvc_create_listeners (nfs->rpcsvc, nfsx->options, nfsx->name); if (ret == -1) { - gf_log (GF_NFS, GF_LOG_ERROR, "Unable to create listeners"); + gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_LISTENERS_CREATE_FAIL, + "Unable to create listeners"); goto free_localpool; } @@ -5631,7 +5770,8 @@ nfs3svc_init (xlator_t *nfsx) nfs3 = nfs3_init_state (nfsx); if (!nfs3) { - gf_log (GF_NFS3, GF_LOG_ERROR, "NFSv3 state init failed"); + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_STATE_INIT_FAIL, + "NFSv3 state init failed"); return NULL; } @@ -5658,7 +5798,7 @@ nfs3_reconfigure_state (xlator_t *nfsx, dict_t *options) ret = nfs3_init_options (nfs3, options); if (ret) { - gf_log (GF_NFS3, GF_LOG_ERROR, + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, NFS_MSG_RECONF_FAIL, "Failed to reconfigure options"); goto out; } @@ -5666,7 +5806,8 @@ nfs3_reconfigure_state (xlator_t *nfsx, dict_t *options) list_for_each_entry (exp, &nfs3->exports, explist) { ret = nfs3_init_subvolume_options (nfsx, exp, options); if (ret) { - gf_log (GF_NFS3, GF_LOG_ERROR, + gf_msg (GF_NFS3, GF_LOG_ERROR, 0, + NFS_MSG_RECONF_SUBVOL_FAIL, "Failed to reconfigure subvol options"); goto out; } -- 1.7.1