diff options
Diffstat (limited to 'xlators/nfs/server/src/nfs.c')
-rw-r--r-- | xlators/nfs/server/src/nfs.c | 356 |
1 files changed, 208 insertions, 148 deletions
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c index 85af465ce7b..8b4bc75ea00 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: |