summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server/src/acl3.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/nfs/server/src/acl3.c')
-rw-r--r--xlators/nfs/server/src/acl3.c129
1 files changed, 84 insertions, 45 deletions
diff --git a/xlators/nfs/server/src/acl3.c b/xlators/nfs/server/src/acl3.c
index 230fb229579..21a92325b72 100644
--- a/xlators/nfs/server/src/acl3.c
+++ b/xlators/nfs/server/src/acl3.c
@@ -30,6 +30,7 @@
#include "acl3.h"
#include "byte-order.h"
#include "compat-errno.h"
+#include "nfs-messages.h"
static int
acl3_nfs_acl_to_xattr (aclentry *ace, void *xattrbuf,
@@ -56,7 +57,9 @@ nfs3_stat_to_fattr3 (struct iatt *buf, fattr3 *fa);
do { \
state = rpcsvc_request_program_private (request); \
if (!state) { \
- gf_log (GF_ACL, GF_LOG_ERROR, "NFSv3 state " \
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno, \
+ NFS_MSG_STATE_MISSING, \
+ "NFSv3 state " \
"missing from RPC request"); \
rpcsvc_request_seterr (req, SYSTEM_ERR); \
status = NFS3ERR_SERVERFAULT; \
@@ -67,7 +70,9 @@ nfs3_stat_to_fattr3 (struct iatt *buf, fattr3 *fa);
#define acl3_validate_gluster_fh(handle, status, errlabel) \
do { \
if (!nfs3_fh_validate (handle)) { \
- gf_log (GF_ACL, GF_LOG_ERROR, "Bad Handle"); \
+ gf_msg (GF_ACL, GF_LOG_ERROR, EINVAL, \
+ NFS_MSG_BAD_HANDLE, \
+ "Bad Handle"); \
status = NFS3ERR_BADHANDLE; \
goto errlabel; \
} \
@@ -83,22 +88,24 @@ nfs3_fh_to_xlator (struct nfs3_state *nfs3, struct nfs3_fh *fh);
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 (GF_ACL, GF_LOG_ERROR, "Failed to map " \
+ gf_msg (GF_ACL, GF_LOG_ERROR, 0, \
+ NFS_MSG_FH_TO_VOL_FAIL, "Failed to map " \
"FH to vol: client=%s, exportid=%s, gfid=%s",\
trans->peerinfo.identifier, exportid, \
gfid); \
- gf_log (GF_ACL, GF_LOG_ERROR, \
+ gf_msg (GF_ACL, GF_LOG_ERROR, ESTALE, \
+ NFS_MSG_VOLUME_ERROR, \
"Stale nfs client %s must be trying to "\
"connect to a deleted volume, please " \
"unmount it.", trans->peerinfo.identifier);\
status = NFS3ERR_STALE; \
goto label; \
} else { \
- gf_log (GF_ACL, GF_LOG_TRACE, "FH to Volume: %s"\
- ,volume->name); \
+ gf_msg_trace (GF_ACL, 0, "FH to Volume: %s", \
+ volume->name); \
rpcsvc_request_set_private (req, volume); \
} \
} while (0); \
@@ -106,8 +113,9 @@ nfs3_fh_to_xlator (struct nfs3_state *nfs3, struct nfs3_fh *fh);
#define acl3_volume_started_check(nfs3state, vlm, rtval, erlbl) \
do { \
if ((!nfs_subvolume_started (nfs_state (nfs3state->nfsx), vlm))){\
- gf_log (GF_ACL, GF_LOG_ERROR, "Volume is disabled: %s",\
- vlm->name); \
+ gf_msg (GF_ACL, GF_LOG_ERROR, 0, NFS_MSG_VOL_DISABLE, \
+ "Volume is disabled: %s", \
+ vlm->name); \
rtval = RPCSVC_ACTOR_IGNORE; \
goto erlbl; \
} \
@@ -122,13 +130,14 @@ nfs3_fh_to_xlator (struct nfs3_state *nfs3, struct nfs3_fh *fh);
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_ACL, GF_LOG_ERROR, "Unable to resolve FH"\
- ": %s", buf); \
+ gf_msg (GF_ACL, GF_LOG_ERROR, cst->resolve_errno, \
+ NFS_MSG_RESOLVE_FH_FAIL, "Unable to resolve "\
+ "FH: %s", buf); \
nfstat = nfs3_errno_to_nfsstat3 (cst->resolve_errno);\
goto erlabl; \
} \
@@ -136,9 +145,10 @@ nfs3_fh_to_xlator (struct nfs3_state *nfs3, struct nfs3_fh *fh);
#define acl3_handle_call_state_init(nfs3state, calls, rq, v, opstat, errlabel)\
do { \
- calls = nfs3_call_state_init ((nfs3state), (rq), v); \
+ calls = nfs3_call_state_init ((nfs3state), (rq), v); \
if (!calls) { \
- gf_log (GF_ACL, GF_LOG_ERROR, "Failed to " \
+ gf_msg (GF_ACL, GF_LOG_ERROR, 0, \
+ NFS_MSG_INIT_CALL_STAT_FAIL, "Failed to " \
"init call state"); \
opstat = NFS3ERR_SERVERFAULT; \
rpcsvc_request_seterr (req, SYSTEM_ERR); \
@@ -162,7 +172,8 @@ acl3svc_submit_reply (rpcsvc_request_t *req, void *arg, acl3_serializer sfunc)
nfs3 = (struct nfs3_state *)rpcsvc_request_program_private (req);
if (!nfs3) {
- gf_log (GF_ACL, GF_LOG_ERROR, "mount state not found");
+ gf_msg (GF_ACL, GF_LOG_ERROR, EINVAL,
+ NFS_MSG_MNT_STATE_NOT_FOUND, "mount state not found");
goto ret;
}
@@ -171,7 +182,8 @@ acl3svc_submit_reply (rpcsvc_request_t *req, void *arg, acl3_serializer sfunc)
*/
iob = iobuf_get (nfs3->iobpool);
if (!iob) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Failed to get iobuf");
+ gf_msg (GF_ACL, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY,
+ "Failed to get iobuf");
goto ret;
}
@@ -181,27 +193,31 @@ acl3svc_submit_reply (rpcsvc_request_t *req, void *arg, acl3_serializer sfunc)
*/
msglen = sfunc (outmsg, arg);
if (msglen < 0) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Failed to encode message");
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno, NFS_MSG_ENCODE_MSG_FAIL,
+ "Failed to encode message");
goto ret;
}
outmsg.iov_len = msglen;
iobref = iobref_new ();
if (iobref == NULL) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Failed to get iobref");
+ gf_msg (GF_ACL, GF_LOG_ERROR, ENOMEM, NFS_MSG_NO_MEMORY,
+ "Failed to get iobref");
goto ret;
}
ret = iobref_add (iobref, iob);
if (ret) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Failed to add iob to iobref");
+ gf_msg (GF_ACL, 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_ACL, GF_LOG_ERROR, "Reply submission failed");
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno, NFS_MSG_REP_SUBMIT_FAIL,
+ "Reply submission failed");
goto ret;
}
@@ -222,7 +238,8 @@ acl3svc_null (rpcsvc_request_t *req)
struct iovec dummyvec = {0, };
if (!req) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Got NULL request!");
+ gf_msg (GF_ACL, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY,
+ "Got NULL request!");
return 0;
}
rpcsvc_submit_generic (req, &dummyvec, 1, NULL, 0, NULL);
@@ -262,8 +279,8 @@ acl3_getacl_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int defacl = 1; /* DEFAULT ACL */
if (!frame->local) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Invalid argument,"
- " frame->local NULL");
+ gf_msg (GF_ACL, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY,
+ "Invalid argument, frame->local NULL");
return -EINVAL;
}
cs = frame->local;
@@ -287,7 +304,8 @@ acl3_getacl_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
data->len,
!defacl);
if (aclcount < 0) {
- gf_log (GF_ACL, GF_LOG_ERROR,
+ gf_msg (GF_ACL, GF_LOG_ERROR, aclcount,
+ NFS_MSG_GET_USER_ACL_FAIL,
"Failed to get USER ACL");
stat = nfs3_errno_to_nfsstat3 (-aclcount);
goto err;
@@ -331,8 +349,8 @@ acl3_default_getacl_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int ret = -1;
if (!frame->local) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Invalid argument,"
- " frame->local NULL");
+ gf_msg (GF_ACL, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY,
+ "Invalid argument, frame->local NULL");
return -EINVAL;
}
cs = frame->local;
@@ -356,7 +374,8 @@ acl3_default_getacl_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
data->len,
defacl);
if (aclcount < 0) {
- gf_log (GF_ACL, GF_LOG_ERROR,
+ gf_msg (GF_ACL, GF_LOG_ERROR, aclcount,
+ NFS_MSG_GET_DEF_ACL_FAIL,
"Failed to get DEFAULT ACL");
stat = nfs3_errno_to_nfsstat3 (-aclcount);
goto err;
@@ -399,8 +418,8 @@ acl3_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
uint64_t deviceid = 0;
if (!frame->local) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Invalid argument,"
- " frame->local NULL");
+ gf_msg (GF_ACL, GF_LOG_ERROR, EINVAL, NFS_MSG_INVALID_ENTRY,
+ "Invalid argument, frame->local NULL");
return EINVAL;
}
@@ -463,7 +482,8 @@ acl3_getacl_resume (void *carg)
stat = -ret;
acl3err:
if (ret < 0) {
- gf_log (GF_ACL, GF_LOG_ERROR, "unable to open_and_resume");
+ gf_msg (GF_ACL, GF_LOG_ERROR, stat, NFS_MSG_OPEN_FAIL,
+ "unable to open_and_resume");
cs->args.getaclreply.status = nfs3_errno_to_nfsstat3 (stat);
acl3_getacl_reply (cs->req, &cs->args.getaclreply);
nfs3_call_state_wipe (cs);
@@ -495,7 +515,8 @@ acl3svc_getacl (rpcsvc_request_t *req)
memset (&getaclreply, 0, sizeof (getaclreply));
getaclargs.fh.n_bytes = (char *)&fh;
if (xdr_to_getaclargs(req->msg[0], &getaclargs) <= 0) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Error decoding args");
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno, NFS_MSG_ARGS_DECODE_ERROR,
+ "Error decoding args");
rpcsvc_request_seterr (req, GARBAGE_ARGS);
goto rpcerr;
}
@@ -521,7 +542,8 @@ acl3svc_getacl (rpcsvc_request_t *req)
acl3err:
if (ret < 0) {
- gf_log (GF_ACL, GF_LOG_ERROR, "unable to resolve and resume");
+ gf_msg (GF_ACL, GF_LOG_ERROR, -ret, NFS_MSG_RESOLVE_ERROR,
+ "unable to resolve and resume");
getaclreply.status = stat;
acl3_getacl_reply (req, &getaclreply);
nfs3_call_state_wipe (cs);
@@ -582,7 +604,8 @@ acl3_setacl_resume (void *carg)
acl3err:
if (ret < 0) {
stat = -ret;
- gf_log (GF_ACL, GF_LOG_ERROR, "unable to open_and_resume");
+ gf_msg (GF_ACL, GF_LOG_ERROR, stat, NFS_MSG_OPEN_FAIL,
+ "unable to open_and_resume");
cs->args.setaclreply.status = nfs3_errno_to_nfsstat3 (stat);
acl3_setacl_reply (cs->req, &cs->args.setaclreply);
nfs3_call_state_wipe (cs);
@@ -632,7 +655,8 @@ acl3svc_setacl (rpcsvc_request_t *req)
setaclargs.aclentry.aclentry_val = aclentry;
setaclargs.daclentry.daclentry_val = daclentry;
if (xdr_to_setaclargs(req->msg[0], &setaclargs) <= 0) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Error decoding args");
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno, NFS_MSG_ARGS_DECODE_ERROR,
+ "Error decoding args");
rpcsvc_request_seterr (req, GARBAGE_ARGS);
goto rpcerr;
}
@@ -660,7 +684,9 @@ acl3svc_setacl (rpcsvc_request_t *req)
cs->aclcount,
!defacl);
if (aclerrno < 0) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Failed to set USER ACL");
+ gf_msg (GF_ACL, GF_LOG_ERROR, -aclerrno,
+ NFS_MSG_SET_USER_ACL_FAIL,
+ "Failed to set USER ACL");
stat = nfs3_errno_to_nfsstat3 (-aclerrno);
goto acl3err;
}
@@ -671,7 +697,9 @@ acl3svc_setacl (rpcsvc_request_t *req)
cs->daclcount,
defacl);
if (aclerrno < 0) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Failed to set DEFAULT ACL");
+ gf_msg (GF_ACL, GF_LOG_ERROR, -aclerrno,
+ NFS_MSG_SET_DEF_ACL_FAIL,
+ "Failed to set DEFAULT ACL");
stat = nfs3_errno_to_nfsstat3 (-aclerrno);
goto acl3err;
}
@@ -681,7 +709,8 @@ acl3svc_setacl (rpcsvc_request_t *req)
acl3err:
if (ret < 0) {
- gf_log (GF_ACL, GF_LOG_ERROR, "unable to resolve and resume");
+ gf_msg (GF_ACL, GF_LOG_ERROR, -ret, NFS_MSG_RESOLVE_ERROR,
+ "unable to resolve and resume");
setaclreply.status = stat;
acl3_setacl_reply (req, &setaclreply);
nfs3_call_state_wipe (cs);
@@ -736,7 +765,8 @@ acl3svc_init(xlator_t *nfsx)
ns = nfs->nfs3state;
if (!ns) {
- gf_log (GF_ACL, GF_LOG_ERROR, "ACL3 init failed");
+ gf_msg (GF_ACL, GF_LOG_ERROR, EINVAL, NFS_MSG_ACL_INIT_FAIL,
+ "ACL3 init failed");
goto err;
}
acl3prog.private = ns;
@@ -753,32 +783,41 @@ acl3svc_init(xlator_t *nfsx)
goto err;
ret = dict_set_str (options, "transport-type", "socket");
if (ret == -1) {
- gf_log (GF_ACL, GF_LOG_ERROR, "dict_set_str error");
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno, NFS_MSG_DICT_SET_FAILED,
+ "dict_set_str error");
goto err;
}
if (nfs->allow_insecure) {
ret = dict_set_str (options, "rpc-auth-allow-insecure", "on");
if (ret == -1) {
- gf_log (GF_ACL, GF_LOG_ERROR, "dict_set_str error");
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno,
+ NFS_MSG_DICT_SET_FAILED,
+ "dict_set_str error");
goto err;
}
ret = dict_set_str (options, "rpc-auth.ports.insecure", "on");
if (ret == -1) {
- gf_log (GF_ACL, GF_LOG_ERROR, "dict_set_str error");
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno,
+ NFS_MSG_DICT_SET_FAILED,
+ "dict_set_str error");
goto err;
}
}
ret = dict_set_str (options, "transport.address-family", "inet");
if (ret == -1) {
- gf_log (GF_ACL, GF_LOG_ERROR, "dict_set_str error");
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno,
+ NFS_MSG_DICT_SET_FAILED,
+ "dict_set_str error");
goto err;
}
ret = rpcsvc_create_listeners (nfs->rpcsvc, options, "ACL");
if (ret == -1) {
- gf_log (GF_ACL, GF_LOG_ERROR, "Unable to create listeners");
+ gf_msg (GF_ACL, GF_LOG_ERROR, errno,
+ NFS_MSG_LISTENERS_CREATE_FAIL,
+ "Unable to create listeners");
dict_unref (options);
goto err;
}