diff options
author | krishna <krishna@gluster.com> | 2011-07-27 18:16:59 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-29 03:37:07 -0700 |
commit | 6c7a89321af50925fb53da378d996881a1907f31 (patch) | |
tree | bfa27e593f6418879a13873c9db6f01676904c7c /xlators/nfs/server/src | |
parent | 8b9cb1701f6365f7b4f5ed166f37020781f59467 (diff) |
RPC unify code change
Change-Id: Ibe18a2a63fd023ac57652c4dfc8ac8a69d983b83
BUG: 3112
Signed-off-by: krishna <krishna@gluster.com>
Reviewed-on: http://review.gluster.com/116
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amar@gluster.com>
Diffstat (limited to 'xlators/nfs/server/src')
-rw-r--r-- | xlators/nfs/server/src/Makefile.am | 12 | ||||
-rw-r--r-- | xlators/nfs/server/src/mount3.c | 140 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs-fops.c | 9 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs-fops.h | 2 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs-generics.c | 6 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs-generics.h | 2 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs.c | 60 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs3-helpers.c | 5 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs3.c | 562 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs3.h | 3 |
10 files changed, 447 insertions, 354 deletions
diff --git a/xlators/nfs/server/src/Makefile.am b/xlators/nfs/server/src/Makefile.am index f8968916c39..8fd28638506 100644 --- a/xlators/nfs/server/src/Makefile.am +++ b/xlators/nfs/server/src/Makefile.am @@ -1,13 +1,17 @@ xlator_LTLIBRARIES = server.la xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/nfs -nfsrpclibdir = $(top_srcdir)/xlators/nfs/lib/src +nfsrpclibdir = $(top_srcdir)/rpc/rpc-lib/src server_la_LDFLAGS = -module -avoidversion -server_la_SOURCES = nfs.c nfs-common.c nfs-fops.c nfs-inodes.c nfs-generics.c mount3.c nfs3-fh.c nfs3.c nfs3-helpers.c $(nfsrpclibdir)/auth-null.c $(nfsrpclibdir)/auth-unix.c $(nfsrpclibdir)/msg-nfs3.c $(nfsrpclibdir)/rpc-socket.c $(nfsrpclibdir)/rpcsvc-auth.c $(nfsrpclibdir)/rpcsvc.c $(nfsrpclibdir)/xdr-nfs3.c $(nfsrpclibdir)/xdr-rpc.c +server_la_SOURCES = nfs.c nfs-common.c nfs-fops.c nfs-inodes.c nfs-generics.c mount3.c nfs3-fh.c nfs3.c nfs3-helpers.c server_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la -noinst_HEADERS = nfs.h nfs-common.h nfs-fops.h nfs-inodes.h nfs-generics.h mount3.h nfs3-fh.h nfs3.h nfs3-helpers.h nfs-mem-types.h $(nfsrpclibdir)/xdr-rpc.h $(nfsrpclibdir)/msg-nfs3.h $(nfsrpclibdir)/xdr-common.h $(nfsrpclibdir)/xdr-nfs3.h $(nfsrpclibdir)/rpc-socket.h $(nfsrpclibdir)/rpcsvc.h +noinst_HEADERS = nfs.h nfs-common.h nfs-fops.h nfs-inodes.h nfs-generics.h mount3.h nfs3-fh.h nfs3.h nfs3-helpers.h nfs-mem-types.h + AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS)\ + -DLIBDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/auth\" \ -I$(top_srcdir)/libglusterfs/src -shared -nostartfiles $(GF_CFLAGS)\ - -I$(nfsrpclibdir) -L$(xlatordir)/ -I$(CONTRIBDIR)/rbtree + -I$(nfsrpclibdir) -L$(xlatordir)/ -I$(CONTRIBDIR)/rbtree\ + -I$(top_srcdir)/rpc/xdr/src/ \ + -I$(top_srcdir)/contrib/md5/ CLEANFILES = diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c index 643c5ebfaf5..5b765271996 100644 --- a/xlators/nfs/server/src/mount3.c +++ b/xlators/nfs/server/src/mount3.c @@ -56,11 +56,12 @@ mnt3svc_submit_reply (rpcsvc_request_t *req, void *arg, mnt3_serializer sfunc) struct iobuf *iob = NULL; struct mount3_state *ms = NULL; int ret = -1; + struct iobref *iobref = NULL; if (!req) return -1; - ms = (struct mount3_state *)nfs_rpcsvc_request_program_private (req); + ms = (struct mount3_state *)rpcsvc_request_program_private (req); if (!ms) { gf_log (GF_MNT, GF_LOG_ERROR, "mount state not found"); goto ret; @@ -81,9 +82,18 @@ mnt3svc_submit_reply (rpcsvc_request_t *req, void *arg, mnt3_serializer sfunc) */ outmsg.iov_len = sfunc (outmsg, arg); + iobref = iobref_new (); + if (iobref == NULL) { + gf_log (GF_MNT, GF_LOG_ERROR, "Failed to get iobref"); + goto ret; + } + + iobref_add (iobref, iob); + /* Then, submit the message for transmission. */ - ret = nfs_rpcsvc_submit_message (req, outmsg, iob); + ret = rpcsvc_submit_message (req, &outmsg, 1, NULL, 0, iobref); iobuf_unref (iob); + iobref_unref (iobref); if (ret == -1) { gf_log (GF_MNT, GF_LOG_ERROR, "Reply submission failed"); goto ret; @@ -195,7 +205,7 @@ mnt3svc_update_mountlist (struct mount3_state *ms, rpcsvc_request_t *req, /* Must get the IP or hostname of the client so we * can map it into the mount entry. */ - ret = nfs_rpcsvc_conn_peername (req->conn, me->hostname, MNTPATHLEN); + ret = rpcsvc_transport_peername (req->trans, me->hostname, MNTPATHLEN); if (ret == -1) goto free_err; @@ -260,7 +270,7 @@ mnt3svc_lookup_mount_cbk (call_frame_t *frame, void *cookie, return -1; mntxl = (xlator_t *)cookie; - ms = (struct mount3_state *)nfs_rpcsvc_request_program_private (req); + ms = (struct mount3_state *)rpcsvc_request_program_private (req); if (!ms) { gf_log (GF_MNT, GF_LOG_ERROR, "mount state not found"); op_ret = -1; @@ -287,9 +297,9 @@ xmit_res: gf_log (GF_MNT, GF_LOG_DEBUG, "MNT reply: fh %s, status: %d", fhstr, status); if (op_ret == 0) { - svc = nfs_rpcsvc_request_service (req); - autharrlen = nfs_rpcsvc_auth_array (svc, mntxl->name, autharr, - 10); + svc = rpcsvc_request_service (req); + autharrlen = rpcsvc_auth_array (svc, mntxl->name, autharr, + 10); } res = mnt3svc_set_mountres3 (status, &fh, autharr, autharrlen); @@ -502,7 +512,8 @@ __mnt3_resolve_export_subdir_comp (mnt3_resolve_t *mres) &mres->resolveloc, NFS_RESOLVE_CREATE); if ((ret < 0) && (ret != -2)) { gf_log (GF_MNT, GF_LOG_ERROR, "Failed to resolve and create " - "inode: parent gfid %s, entry %s", uuid_utoa (mres->resolveloc.inode->gfid), nextcomp); + "inode: parent gfid %s, entry %s", + uuid_utoa (mres->resolveloc.inode->gfid), nextcomp); ret = -EFAULT; goto err; } @@ -558,9 +569,9 @@ err: if (op_ret == -1) { gf_log (GF_MNT, GF_LOG_DEBUG, "Mount reply status: %d", mntstat); - svc = nfs_rpcsvc_request_service (mres->req); - autharrlen = nfs_rpcsvc_auth_array (svc, mntxl->name, autharr, - 10); + svc = rpcsvc_request_service (mres->req); + autharrlen = rpcsvc_auth_array (svc, mntxl->name, autharr, + 10); res = mnt3svc_set_mountres3 (mntstat, &fh, autharr, autharrlen); mnt3svc_submit_reply (mres->req, (void *)&res, @@ -735,22 +746,23 @@ int mnt3_check_client_net (struct mount3_state *ms, rpcsvc_request_t *req, xlator_t *targetxl) { + rpcsvc_t *svc = NULL; int ret = -1; if ((!ms) || (!req) || (!targetxl)) return -1; - svc = nfs_rpcsvc_request_service (req); - ret = nfs_rpcsvc_conn_peer_check (svc->options, targetxl->name, - nfs_rpcsvc_request_conn (req)); + svc = rpcsvc_request_service (req); + ret = rpcsvc_transport_peer_check (svc->options, targetxl->name, + rpcsvc_request_transport (req)); if (ret == RPCSVC_AUTH_REJECT) { gf_log (GF_MNT, GF_LOG_TRACE, "Peer not allowed"); goto err; } - ret = nfs_rpcsvc_conn_privport_check (svc, targetxl->name, - nfs_rpcsvc_request_conn (req)); + ret = rpcsvc_transport_privport_check (svc, targetxl->name, + rpcsvc_request_transport (req)); if (ret == RPCSVC_AUTH_REJECT) { gf_log (GF_MNT, GF_LOG_TRACE, "Unprivileged port not allowed"); goto err; @@ -806,10 +818,10 @@ mnt3_find_export (rpcsvc_request_t *req, char *path, struct mnt3_export **e) if ((!req) || (!path) || (!e)) return -1; - ms = (struct mount3_state *)nfs_rpcsvc_request_program_private (req); + ms = (struct mount3_state *) rpcsvc_request_program_private (req); if (!ms) { gf_log (GF_MNT, GF_LOG_ERROR, "Mount state not present"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); goto err; } @@ -854,17 +866,17 @@ mnt3svc_mnt (rpcsvc_request_t *req) pvec.iov_base = path; pvec.iov_len = MNTPATHLEN; - ret = xdr_to_mountpath (pvec, req->msg); + ret = xdr_to_mountpath (pvec, req->msg[0]); if (ret == -1) { gf_log (GF_MNT, GF_LOG_ERROR, "Failed to decode args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_ARGS); + rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } - ms = (struct mount3_state *)nfs_rpcsvc_request_program_private (req); + ms = (struct mount3_state *)rpcsvc_request_program_private (req); if (!ms) { gf_log (GF_MNT, GF_LOG_ERROR, "Mount state not present"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = -1; goto rpcerr; } @@ -921,8 +933,7 @@ mnt3svc_null (rpcsvc_request_t *req) gf_log (GF_MNT, GF_LOG_ERROR, "Got NULL request!"); return 0; } - - nfs_rpcsvc_submit_generic (req, dummyvec, NULL); + rpcsvc_submit_generic (req, &dummyvec, 1, NULL, 0, NULL); return 0; } @@ -1028,9 +1039,9 @@ mnt3svc_dump (rpcsvc_request_t *req) if (!req) return -1; - ms = (struct mount3_state *)nfs_rpcsvc_request_program_private (req); + ms = (struct mount3_state *)rpcsvc_request_program_private (req); if (!ms) { - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); goto rpcerr; } @@ -1040,7 +1051,7 @@ mnt3svc_dump (rpcsvc_request_t *req) if (!mlist) { if (ret != 0) { - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = -1; goto rpcerr; } else { @@ -1141,22 +1152,22 @@ mnt3svc_umnt (rpcsvc_request_t *req) /* Remove the mount point from the exports list. */ pvec.iov_base = dirpath; pvec.iov_len = MNTPATHLEN; - ret = xdr_to_mountpath (pvec, req->msg);; + ret = xdr_to_mountpath (pvec, req->msg[0]); if (ret == -1) { gf_log (GF_MNT, GF_LOG_ERROR, "Failed decode args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_ARGS); + rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } - ms = (struct mount3_state *)nfs_rpcsvc_request_program_private (req); + ms = (struct mount3_state *)rpcsvc_request_program_private (req); if (!ms) { gf_log (GF_MNT, GF_LOG_ERROR, "Mount state not present"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = -1; goto rpcerr; } - ret = nfs_rpcsvc_conn_peername (req->conn, hostname, MNTPATHLEN); + ret = rpcsvc_transport_peername (req->trans, hostname, MNTPATHLEN); if (ret != 0) { gf_log (GF_MNT, GF_LOG_ERROR, "Failed to get remote name: %s", gai_strerror (ret)); @@ -1173,13 +1184,13 @@ mnt3svc_umnt (rpcsvc_request_t *req) try_umount_with_addr: if (ret != 0) - ret = nfs_rpcsvc_conn_peeraddr (req->conn, hostname, MNTPATHLEN, - NULL, 0); + ret = rpcsvc_transport_peeraddr (req->trans, hostname, + MNTPATHLEN, NULL, 0); if (ret != 0) { gf_log (GF_MNT, GF_LOG_ERROR, "Failed to get remote addr: %s", gai_strerror (ret)); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); goto rpcerr; } @@ -1247,10 +1258,10 @@ mnt3svc_umntall (rpcsvc_request_t *req) if (!req) return ret; - ms = (struct mount3_state *)nfs_rpcsvc_request_program_private (req); + ms = (struct mount3_state *)rpcsvc_request_program_private (req); if (!ms) { gf_log (GF_MNT, GF_LOG_ERROR, "Mount state not present"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); goto rpcerr; } @@ -1306,8 +1317,8 @@ mnt3_xlchildren_to_exports (rpcsvc_t *svc, struct mount3_state *ms) strcpy (elist->ex_dir, ent->expname); - addrstr = nfs_rpcsvc_volume_allowed (svc->options, - ent->vol->name); + addrstr = rpcsvc_volume_allowed (svc->options, + ent->vol->name); if (addrstr) addrstr = gf_strdup (addrstr); else @@ -1354,15 +1365,15 @@ mnt3svc_export (rpcsvc_request_t *req) if (!req) return -1; - ms = (struct mount3_state *)nfs_rpcsvc_request_program_private (req); + ms = (struct mount3_state *)rpcsvc_request_program_private (req); if (!ms) { gf_log (GF_MNT, GF_LOG_ERROR, "mount state not found"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); goto err; } /* Using the children translator names, build the export list */ - elist = mnt3_xlchildren_to_exports (nfs_rpcsvc_request_service (req), + elist = mnt3_xlchildren_to_exports (rpcsvc_request_service (req), ms); /* Do not return error when exports list is empty. An exports list can * be empty when no subvolumes have come up. No point returning error @@ -1754,10 +1765,9 @@ rpcsvc_program_t mnt3prog = { .prognum = MOUNT_PROGRAM, .progver = MOUNT_V3, .progport = GF_MOUNTV3_PORT, - .progaddrfamily = AF_INET, - .proghost = NULL, .actors = mnt3svc_actors, .numactors = MOUNT3_PROC_COUNT, + .min_auth = AUTH_NULL, }; @@ -1766,6 +1776,9 @@ mnt3svc_init (xlator_t *nfsx) { struct mount3_state *mstate = NULL; struct nfs_state *nfs = NULL; + dict_t *options = NULL; + char *portstr = NULL; + int ret = -1; if (!nfsx || !nfsx->private) return NULL; @@ -1780,6 +1793,22 @@ mnt3svc_init (xlator_t *nfsx) } mnt3prog.private = mstate; + options = dict_new (); + + ret = gf_asprintf (&portstr, "%d", GF_MOUNTV3_PORT); + if (ret == -1) + goto err; + + ret = dict_set_dynstr (options, "transport.socket.listen-port", portstr); + if (ret == -1) + goto err; + ret = dict_set_str (options, "transport-type", "socket"); + rpcsvc_create_listeners (nfs->rpcsvc, options, nfsx->name); + if (ret == -1) { + gf_log (GF_NFS, GF_LOG_ERROR, "Unable to create listeners"); + dict_unref (options); + goto err; + } return &mnt3prog; err: @@ -1801,10 +1830,9 @@ rpcsvc_program_t mnt1prog = { .prognum = MOUNT_PROGRAM, .progver = MOUNT_V1, .progport = GF_MOUNTV1_PORT, - .progaddrfamily = AF_INET, - .proghost = NULL, .actors = mnt1svc_actors, .numactors = MOUNT1_PROC_COUNT, + .min_auth = AUTH_NULL, }; @@ -1813,6 +1841,9 @@ mnt1svc_init (xlator_t *nfsx) { struct mount3_state *mstate = NULL; struct nfs_state *nfs = NULL; + dict_t *options = NULL; + char *portstr = NULL; + int ret = -1; if (!nfsx || !nfsx->private) return NULL; @@ -1828,6 +1859,23 @@ mnt1svc_init (xlator_t *nfsx) mnt1prog.private = mstate; + options = dict_new (); + + ret = gf_asprintf (&portstr, "%d", GF_MOUNTV1_PORT); + if (ret == -1) + goto err; + + ret = dict_set_dynstr (options, "transport.socket.listen-port", portstr); + if (ret == -1) + goto err; + ret = dict_set_str (options, "transport-type", "socket"); + rpcsvc_create_listeners (nfs->rpcsvc, options, nfsx->name); + if (ret == -1) { + gf_log (GF_NFS, GF_LOG_ERROR, "Unable to create listeners"); + dict_unref (options); + goto err; + } + return &mnt1prog; err: return NULL; diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c index 7150cc46887..b4cbc18756d 100644 --- a/xlators/nfs/server/src/nfs-fops.c +++ b/xlators/nfs/server/src/nfs-fops.c @@ -1235,20 +1235,20 @@ nfs_fop_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int nfs_fop_write (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, - struct iobuf *srciob, struct iovec *vector, int32_t count, + struct iobref *srciobref, struct iovec *vector, int32_t count, off_t offset, fop_writev_cbk_t cbk, void *local) { call_frame_t *frame = NULL; int ret = -EFAULT; struct nfs_fop_local *nfl = NULL; - if ((!nfsx) || (!xl) || (!fd) || (!vector) || (!nfu) || (!srciob)) + if ((!nfsx) || (!xl) || (!fd) || (!vector) || (!nfu) || (!srciobref)) return ret; nfs_fop_handle_frame_create (frame, nfsx, nfu, ret, err); nfs_fop_handle_local_init (frame, nfsx, nfl, cbk, local, ret, err); nfs_fop_save_root_fd_ino (nfl, fd); - +/* nfl->iobref = iobref_new (); if (!nfl->iobref) { gf_log (GF_NFS, GF_LOG_ERROR, "iobref creation failed"); @@ -1257,8 +1257,9 @@ nfs_fop_write (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, } iobref_add (nfl->iobref, srciob); +*/ STACK_WIND_COOKIE (frame, nfs_fop_writev_cbk, xl, xl,xl->fops->writev - , fd, vector, count, offset, nfl->iobref); + , fd, vector, count, offset, srciobref); ret = 0; err: if (ret < 0) { diff --git a/xlators/nfs/server/src/nfs-fops.h b/xlators/nfs/server/src/nfs-fops.h index 4d09e3e242e..a220baa4670 100644 --- a/xlators/nfs/server/src/nfs-fops.h +++ b/xlators/nfs/server/src/nfs-fops.h @@ -180,7 +180,7 @@ nfs_fop_fsync (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, extern int nfs_fop_write (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, - struct iobuf *srciob, struct iovec *vector, int32_t count, + struct iobref *srciobref, struct iovec *vector, int32_t count, off_t offset, fop_writev_cbk_t cbk, void *local); extern int diff --git a/xlators/nfs/server/src/nfs-generics.c b/xlators/nfs/server/src/nfs-generics.c index 010fb17564c..5bc09b7d418 100644 --- a/xlators/nfs/server/src/nfs-generics.c +++ b/xlators/nfs/server/src/nfs-generics.c @@ -170,11 +170,11 @@ nfs_fsync (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, int nfs_write (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, - struct iobuf *srciob, struct iovec *vector, int32_t count, + struct iobref *srciobref, struct iovec *vector, int32_t count, off_t offset, fop_writev_cbk_t cbk, void *local) { - return nfs_fop_write (nfsx, xl, nfu, fd, srciob, vector, count, offset, - cbk, local); + return nfs_fop_write (nfsx, xl, nfu, fd, srciobref, vector, count, + offset, cbk, local); } diff --git a/xlators/nfs/server/src/nfs-generics.h b/xlators/nfs/server/src/nfs-generics.h index fa907b7c555..66156a3b81d 100644 --- a/xlators/nfs/server/src/nfs-generics.h +++ b/xlators/nfs/server/src/nfs-generics.h @@ -92,7 +92,7 @@ nfs_fsync (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, extern int nfs_write (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, - struct iobuf *srciob, struct iovec *vector, int32_t count, + struct iobref *srciobref, struct iovec *vector, int32_t count, off_t offset, fop_writev_cbk_t cbk, void *local); extern int diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c index b4568f519cf..7bf5383292b 100644 --- a/xlators/nfs/server/src/nfs.c +++ b/xlators/nfs/server/src/nfs.c @@ -82,8 +82,8 @@ nfs_deinit_versions (struct list_head *versions, xlator_t *this) version->deinit (this); */ if (version->program) - nfs_rpcsvc_program_unregister (nfs->rpcsvc, - *(version->program)); + rpcsvc_program_unregister (nfs->rpcsvc, + (version->program)); list_del (&version->list); GF_FREE (version); @@ -92,7 +92,6 @@ nfs_deinit_versions (struct list_head *versions, xlator_t *this) return 0; } - int nfs_init_versions (struct nfs_state *nfs, xlator_t *this) { @@ -118,17 +117,24 @@ nfs_init_versions (struct nfs_state *nfs, xlator_t *this) ret = -1; goto err; } - prog->actorxl = this; +// prog->actorxl = this; version->program = prog; if (nfs->override_portnum) prog->progport = nfs->override_portnum; gf_log (GF_NFS, GF_LOG_DEBUG, "Starting program: %s", prog->progname); - ret = nfs_rpcsvc_program_register (nfs->rpcsvc, *prog); + + ret = rpcsvc_program_register (nfs->rpcsvc, prog); if (ret == -1) { gf_log (GF_NFS, GF_LOG_ERROR, "Program init failed"); goto err; } + if (rpcsvc_register_portmap_enabled(nfs->rpcsvc)) { + ret = rpcsvc_program_register_portmap (prog, + prog->progport); + if (ret == -1) + goto err; + } } ret = 0; @@ -367,7 +373,7 @@ nfs_init_subvolumes (struct nfs_state *nfs, xlator_list_t *cl) } LOCK_INIT (&nfs->svinitlock); - nfs->initedxl = GF_CALLOC (svcount, sizeof (xlator_t *), + 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"); @@ -440,9 +446,9 @@ nfs_request_user_init (nfs_user_t *nfu, rpcsvc_request_t *req) if ((!req) || (!nfu)) return; - gidarr = nfs_rpcsvc_auth_unix_auxgids (req, &gids); - nfs_user_create (nfu, nfs_rpcsvc_request_uid (req), - nfs_rpcsvc_request_gid (req), gidarr, gids); + gidarr = rpcsvc_auth_unix_auxgids (req, &gids); + nfs_user_create (nfu, rpcsvc_request_uid (req), + rpcsvc_request_gid (req), gidarr, gids); return; } @@ -456,7 +462,7 @@ mem_acct_init (xlator_t *this) return ret; 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"); @@ -493,7 +499,7 @@ nfs_init_state (xlator_t *this) /* RPC service needs to be started before NFS versions can be * inited. */ - nfs->rpcsvc = nfs_rpcsvc_init (this->ctx, this->options); + nfs->rpcsvc = rpcsvc_init (this->ctx, this->options); if (!nfs->rpcsvc) { gf_log (GF_NFS, GF_LOG_ERROR, "RPC service init failed"); goto free_nfs; @@ -565,7 +571,7 @@ nfs_init_state (xlator_t *this) nfs->enable_ino32 = 1; } - nfs->override_portnum = 0; + nfs->override_portnum = GF_NFS3_PORT; if (dict_get (this->options, "nfs.port")) { ret = dict_get_str (this->options, "nfs.port", &optstr); @@ -582,6 +588,27 @@ nfs_init_state (xlator_t *this) } } + if (dict_get(this->options, "transport.socket.listen-port") == NULL) { + ret = gf_asprintf (&optstr, "%d", nfs->override_portnum); + if (ret == -1) { + gf_log (GF_NFS, GF_LOG_ERROR, "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"); + goto free_foppool; + } + } + + if (dict_get(this->options, "transport-type") == NULL) { + ret = dict_set_str (this->options, "transport-type", "socket"); + if (ret == -1) { + gf_log (GF_NFS, GF_LOG_ERROR, "dict_set_str error"); + goto free_foppool; + } + } this->private = (void *)nfs; INIT_LIST_HEAD (&nfs->versions); @@ -857,6 +884,15 @@ struct volume_options options[] = { "However, can be disabled if needed. Enabled by" "default." }, + { .key = {"rpc-auth.auth-unix.*.allow"}, + .type = GF_OPTION_TYPE_STR, + .description = "Disable or enable the AUTH_UNIX authentication type " + "for a particular exported volume over-riding defaults" + " and general setting for AUTH_UNIX scheme. Must " + "always be enabled for better interoperability." + "However, can be disabled if needed. Enabled by" + "default." + }, { .key = {"rpc-auth.auth-null.*"}, .type = GF_OPTION_TYPE_BOOL, .description = "Disable or enable the AUTH_NULL authentication type " diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c index 0b39e3d162e..9f0939d9c2d 100644 --- a/xlators/nfs/server/src/nfs3-helpers.c +++ b/xlators/nfs/server/src/nfs3-helpers.c @@ -1710,7 +1710,8 @@ nfs3_dir_open_and_resume (nfs3_call_state_t *cs, nfs3_resume_fn_t resume) gf_log (GF_NFS3, GF_LOG_TRACE, "Opening: %s", cs->resolvedloc.path); fd = fd_lookup (cs->resolvedloc.inode, 0); if (fd) { - gf_log (GF_NFS3, GF_LOG_TRACE, "fd found in state: ref: %d", fd->refcount); + gf_log (GF_NFS3, GF_LOG_TRACE, "fd found in state: ref: %d", + fd->refcount); cs->fd = fd; /* Gets unrefd when the call state is wiped. */ cs->resolve_ret = 0; nfs3_call_resume (cs); @@ -1955,7 +1956,7 @@ nfs3_file_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, fd->refcount); } - nfs3 = nfs_rpcsvc_request_program_private (cs->req); + nfs3 = rpcsvc_request_program_private (cs->req); /* Call states are flushed even when the opening of the file failed. * This allows returning an error for each one of the file io requests * that are currently queued waiting for the open to succeed. diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c index 70ce23a3990..a162c498300 100644 --- a/xlators/nfs/server/src/nfs3.c +++ b/xlators/nfs/server/src/nfs3.c @@ -38,7 +38,8 @@ #include "nfs3-helpers.h" #include "nfs-mem-types.h" #include "nfs.h" - +#include "xdr-rpc.h" +#include "xdr-generic.h" #include <sys/socket.h> #include <sys/uio.h> @@ -58,7 +59,7 @@ #define nfs3_validate_nfs3_state(request, state, status, label, retval) \ do { \ - state = nfs_rpcsvc_request_program_private (request); \ + state = rpcsvc_request_program_private (request); \ if (!nfs3) { \ gf_log (GF_NFS3, GF_LOG_ERROR, "NFSv3 state " \ "missing from RPC request"); \ @@ -224,7 +225,7 @@ out: } else { \ gf_log (GF_NFS3, GF_LOG_TRACE, "FH to Volume: %s"\ ,volume->name); \ - nfs_rpcsvc_request_set_private (req, volume); \ + rpcsvc_request_set_private (req, volume); \ } \ } while (0); \ @@ -425,6 +426,8 @@ nfs3_call_state_wipe (nfs3_call_state_t *cs) nfs_loc_wipe (&cs->resolvedloc); if (cs->iob) iobuf_unref (cs->iob); + if (cs->iobref) + iobref_unref (cs->iobref); memset (cs, 0, sizeof (*cs)); mem_put (nfs3->localpool, cs); /* Already refd by fd_lookup, so no need to ref again. */ @@ -452,7 +455,7 @@ nfs3_serialize_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc, struct iobuf *iob = NULL; ssize_t retlen = -1; - nfs3 = (struct nfs3_state *)nfs_rpcsvc_request_program_private (req); + 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"); @@ -500,6 +503,7 @@ nfs3svc_submit_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc) struct iovec outmsg = {0, }; struct iobuf *iob = NULL; int ret = -1; + struct iobref *iobref = NULL; if (!req) return -1; @@ -510,14 +514,24 @@ nfs3svc_submit_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc) goto ret; } + iobref = iobref_new (); + if (!iobref) { + gf_log (GF_NFS3, GF_LOG_ERROR, "failed on iobref_new()"); + goto ret; + } + + iobref_add (iobref, iob); + /* Then, submit the message for transmission. */ - ret = nfs_rpcsvc_submit_message (req, outmsg, iob); + ret = rpcsvc_submit_message (req, &outmsg, 1, NULL, 0, iobref); /* Now that we've done our job of handing the message to the RPC layer * we can safely unref the iob in the hope that RPC layer must have * ref'ed the iob on receiving into the txlist. */ iobuf_unref (iob); + iobref_unref (iobref); + if (ret == -1) { gf_log (GF_NFS3, GF_LOG_ERROR, "Reply submission failed"); goto ret; @@ -532,11 +546,12 @@ ret: int nfs3svc_submit_vector_reply (rpcsvc_request_t *req, void *arg, nfs3_serializer sfunc, struct iovec *payload, - int vcount, struct iobref *piobref) + int vcount, struct iobref *iobref) { struct iovec outmsg = {0, }; struct iobuf *iob = NULL; int ret = -1; + int new_iobref = 0; if (!req) return -1; @@ -544,25 +559,40 @@ 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"); - goto err; + goto ret; + } + if (iobref == NULL) { + iobref = iobref_new (); + if (!iobref) { + gf_log (GF_NFS3, GF_LOG_ERROR, "failed on iobref_new"); + goto ret; + } + new_iobref = 1; } - ret = nfs_rpcsvc_request_attach_vector (req, outmsg, iob, NULL, 0); - iobuf_unref (iob); + iobref_add (iobref, iob); - if (piobref) - ret = nfs_rpcsvc_request_attach_vectors (req, payload, vcount, - piobref); + /* Then, submit the message for transmission. */ + ret = rpcsvc_submit_message (req, &outmsg, 1, payload, vcount, iobref); - if (ret == -1) - goto err; - ret = nfs_rpcsvc_submit_vectors (req); -err: + /* Now that we've done our job of handing the message to the RPC layer + * we can safely unref the iob in the hope that RPC layer must have + * ref'ed the iob on receiving into the txlist. + */ + iobuf_unref (iob); + if (new_iobref) + iobref_unref (iobref); + if (ret == -1) { + gf_log (GF_NFS3, GF_LOG_ERROR, "Reply submission failed"); + goto ret; + } + + ret = 0; +ret: return ret; } - uint64_t nfs3_request_xlator_deviceid (rpcsvc_request_t *rq) { @@ -574,8 +604,8 @@ nfs3_request_xlator_deviceid (rpcsvc_request_t *rq) if (!rq) return 0; - xl = nfs_rpcsvc_request_private (rq); - nfs3 = nfs_rpcsvc_request_program_private (rq); + xl = rpcsvc_request_private (rq); + nfs3 = rpcsvc_request_program_private (rq); if (gf_nfs_dvm_off (nfs_state (nfs3->nfsx))) devid = (uint64_t)nfs_xlator_to_xlid (nfs3->exportslist, xl); else { @@ -593,8 +623,7 @@ nfs3svc_null (rpcsvc_request_t *req) struct iovec dummyvec = {0, }; if (!req) return RPCSVC_ACTOR_ERROR; - - nfs_rpcsvc_submit_generic (req, dummyvec, NULL); + rpcsvc_submit_generic (req, &dummyvec, 1, NULL, 0, NULL); return RPCSVC_ACTOR_SUCCESS; } @@ -628,7 +657,7 @@ nfs3svc_getattr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) status = nfs3_errno_to_nfsstat3 (op_errno); - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "GETATTR", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "GETATTR", status, op_errno); nfs3_getattr_reply (cs->req, status, buf); @@ -650,7 +679,7 @@ nfs3svc_getattr_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) status = nfs3_errno_to_nfsstat3 (op_errno); - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "GETATTR", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "GETATTR", status, op_errno); nfs3_getattr_reply (cs->req, status, buf); @@ -695,7 +724,7 @@ nfs3_getattr_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "GETATTR", stat, -ret); nfs3_getattr_reply (cs->req, stat, NULL); nfs3_call_state_wipe (cs); @@ -718,7 +747,7 @@ nfs3_getattr (rpcsvc_request_t *req, struct nfs3_fh *fh) if ((!req) || (!fh)) return -1; - nfs3_log_common_call (nfs_rpcsvc_request_xid (req), "GETATTR", fh); + nfs3_log_common_call (rpcsvc_request_xid (req), "GETATTR", fh); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); nfs3_map_fh_to_volume (nfs3, fh, req, vol, stat, nfs3err); @@ -731,7 +760,7 @@ nfs3_getattr (rpcsvc_request_t *req, struct nfs3_fh *fh) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "GETATTR", + nfs3_log_common_res (rpcsvc_request_xid (req), "GETATTR", stat, -ret); nfs3_getattr_reply (req, stat, NULL); ret = 0; @@ -753,16 +782,16 @@ nfs3svc_getattr (rpcsvc_request_t *req) return ret; nfs3_prep_getattr3args (&args, &fh); - if (xdr_to_getattr3args (req->msg, &args) <= 0) { + if (xdr_to_getattr3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -812,7 +841,7 @@ nfs3svc_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = NFS3_OK; nfs3err: - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "SETATTR", stat, + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "SETATTR", stat, op_errno); nfs3_setattr_reply (cs->req, stat, prestat, postbuf); nfs3_call_state_wipe (cs); @@ -869,7 +898,7 @@ nfs3svc_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "SETATTR", stat, op_errno); nfs3_setattr_reply (cs->req, stat, prebuf, postop); nfs3_call_state_wipe (cs); @@ -912,7 +941,7 @@ nfs3svc_setattr_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "SETATTR", stat, op_errno); nfs3_setattr_reply (cs->req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -950,7 +979,7 @@ nfs3_setattr_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "SETATTR", stat, -ret); nfs3_setattr_reply (cs->req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -975,7 +1004,7 @@ nfs3_setattr (rpcsvc_request_t *req, struct nfs3_fh *fh, sattr3 *sattr, return -1; } - nfs3_log_common_call (nfs_rpcsvc_request_xid (req), "SETATTR", fh); + nfs3_log_common_call (rpcsvc_request_xid (req), "SETATTR", fh); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); nfs3_map_fh_to_volume (nfs3, fh, req, vol, stat, nfs3err); @@ -1006,7 +1035,7 @@ nfs3_setattr (rpcsvc_request_t *req, struct nfs3_fh *fh, sattr3 *sattr, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "SETATTR", + nfs3_log_common_res (rpcsvc_request_xid (req), "SETATTR", stat, -ret); nfs3_setattr_reply (req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -1032,16 +1061,16 @@ nfs3svc_setattr (rpcsvc_request_t *req) return ret; nfs3_prep_setattr3args (&args, &fh); - if (xdr_to_setattr3args (req->msg, &args) <= 0) { + if (xdr_to_setattr3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -1114,7 +1143,8 @@ nfs3svc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } nfs3_fh_build_child_fh (&cs->parent, buf, &newfh); - oldinode = inode_link (inode, cs->resolvedloc.parent, cs->resolvedloc.name, buf); + oldinode = inode_link (inode, cs->resolvedloc.parent, + cs->resolvedloc.name, buf); xmit_res: /* Only send fresh lookup if it was a revalidate that failed. */ if ((op_ret == -1) && (nfs3_is_revalidate_lookup (cs))) { @@ -1122,7 +1152,7 @@ xmit_res: goto out; } - nfs3_log_newfh_res (nfs_rpcsvc_request_xid (cs->req), "LOOKUP", status, + nfs3_log_newfh_res (rpcsvc_request_xid (cs->req), "LOOKUP", status, op_errno, &newfh); nfs3_lookup_reply (cs->req, status, &newfh, buf, postparent); nfs3_call_state_wipe (cs); @@ -1172,7 +1202,7 @@ nfs3svc_lookup_parentdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } xmit_res: - nfs3_log_newfh_res (nfs_rpcsvc_request_xid (cs->req), "LOOKUP", status, + nfs3_log_newfh_res (rpcsvc_request_xid (cs->req), "LOOKUP", status, op_errno, &newfh); nfs3_lookup_reply (cs->req, status, &newfh, buf, postparent); nfs3_call_state_wipe (cs); @@ -1237,7 +1267,7 @@ errtostat: nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "LOOKUP", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "LOOKUP", stat, -ret); nfs3_lookup_reply (cs->req, stat, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -1272,7 +1302,7 @@ nfs3_lookup_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "LOOKUP", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "LOOKUP", stat, -ret); nfs3_lookup_reply (cs->req, stat, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -1296,7 +1326,7 @@ nfs3_lookup (rpcsvc_request_t *req, struct nfs3_fh *fh, int fhlen, char *name) return -1; } - nfs3_log_fh_entry_call (nfs_rpcsvc_request_xid (req), "LOOKUP", fh, + nfs3_log_fh_entry_call (rpcsvc_request_xid (req), "LOOKUP", fh, name); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); if (nfs3_solaris_zerolen_fh (fh, fhlen)) @@ -1321,7 +1351,7 @@ nfs3_lookup (rpcsvc_request_t *req, struct nfs3_fh *fh, int fhlen, char *name) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "LOOKUP", + nfs3_log_common_res (rpcsvc_request_xid (req), "LOOKUP", stat, -ret); nfs3_lookup_reply (req, stat, NULL, NULL, NULL); @@ -1348,16 +1378,16 @@ nfs3svc_lookup (rpcsvc_request_t *req) return ret; nfs3_prep_lookup3args (&args, &fh, name); - if (xdr_to_lookup3args (req->msg, &args) <= 0) { + if (xdr_to_lookup3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -1392,7 +1422,7 @@ nfs3svc_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) status = nfs3_errno_to_nfsstat3 (op_errno); - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "ACCESS", status, + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "ACCESS", status, op_errno); nfs3_access_reply (cs->req, status, op_errno); nfs3_call_state_wipe (cs); @@ -1422,7 +1452,7 @@ nfs3_access_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "ACCESS", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "ACCESS", stat, -ret); nfs3_access_reply (cs->req, stat, 0); nfs3_call_state_wipe (cs); @@ -1445,7 +1475,7 @@ nfs3_access (rpcsvc_request_t *req, struct nfs3_fh *fh, uint32_t accbits) if ((!req) || (!fh)) return -1; - nfs3_log_common_call (nfs_rpcsvc_request_xid (req), "ACCESS", fh); + nfs3_log_common_call (rpcsvc_request_xid (req), "ACCESS", fh); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); nfs3_map_fh_to_volume (nfs3, fh, req, vol, stat, nfs3err); @@ -1459,7 +1489,7 @@ nfs3_access (rpcsvc_request_t *req, struct nfs3_fh *fh, uint32_t accbits) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "ACCESS", + nfs3_log_common_res (rpcsvc_request_xid (req), "ACCESS", stat, -ret); nfs3_access_reply (req, stat, 0); nfs3_call_state_wipe (cs); @@ -1481,16 +1511,16 @@ nfs3svc_access (rpcsvc_request_t *req) return ret; nfs3_prep_access3args (&args, &fh); - if (xdr_to_access3args (req->msg, &args) <= 0) { + if (xdr_to_access3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -1532,7 +1562,7 @@ nfs3svc_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = NFS3_OK; nfs3err: - nfs3_log_readlink_res (nfs_rpcsvc_request_xid (cs->req), stat, op_errno, + nfs3_log_readlink_res (rpcsvc_request_xid (cs->req), stat, op_errno, (char *)path); nfs3_readlink_reply (cs->req, stat, (char *)path, buf); nfs3_call_state_wipe (cs); @@ -1562,7 +1592,7 @@ nfs3_readlink_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "READLINK", stat, -ret); nfs3_readlink_reply (cs->req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -1586,7 +1616,7 @@ nfs3_readlink (rpcsvc_request_t *req, struct nfs3_fh *fh) return -1; } - nfs3_log_common_call (nfs_rpcsvc_request_xid (req), "READLINK", fh); + nfs3_log_common_call (rpcsvc_request_xid (req), "READLINK", fh); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); nfs3_map_fh_to_volume (nfs3, fh, req, vol, stat, nfs3err); @@ -1599,7 +1629,7 @@ nfs3_readlink (rpcsvc_request_t *req, struct nfs3_fh *fh) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "READLINK", + nfs3_log_common_res (rpcsvc_request_xid (req), "READLINK", stat, -ret); nfs3_readlink_reply (req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -1624,16 +1654,16 @@ nfs3svc_readlink (rpcsvc_request_t *req) return ret; nfs3_prep_readlink3args (&args, &fh); - if (xdr_to_readlink3args (req->msg, &args) <= 0) { + if (xdr_to_readlink3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -1653,17 +1683,19 @@ nfs3_read_reply (rpcsvc_request_t *req, nfsstat3 stat, count3 count, deviceid = nfs3_request_xlator_deviceid (req); nfs3_fill_read3res (&res, stat, count, poststat, is_eof, deviceid); if (stat == NFS3_OK) { - nfs_xdr_vector_round_up (vec, vcount, count); + xdr_vector_round_up (vec, vcount, count); /* iob can be zero if the file size was zero. If so, op_ret * would be 0 and count = 0. */ + if (count != 0) { nfs3svc_submit_vector_reply (req, (void *)&res, (nfs3_serializer) xdr_serialize_read3res_nocopy, vec, vcount, iobref); } else - nfs3svc_submit_reply (req, (void *)&res, + + nfs3svc_submit_reply (req, (void *)&res, (nfs3_serializer) xdr_serialize_read3res_nocopy); } else @@ -1695,7 +1727,7 @@ nfs3svc_read_cbk (call_frame_t *frame, void *cookie, xlator_t *this, is_eof = 1; err: - nfs3_log_read_res (nfs_rpcsvc_request_xid (cs->req), stat, op_errno, + nfs3_log_read_res (rpcsvc_request_xid (cs->req), stat, op_errno, op_ret, is_eof, vector, count); nfs3_read_reply (cs->req, stat, op_ret, vector, count, iobref, stbuf, is_eof); @@ -1725,7 +1757,7 @@ nfs3_read_fd_resume (void *carg) stat = nfs3_errno_to_nfsstat3 (-ret); nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "READ", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "READ", stat, -ret); nfs3_read_reply (cs->req, stat, 0, NULL, 0, NULL, NULL, 0); nfs3_call_state_wipe (cs); @@ -1753,7 +1785,7 @@ nfs3_read_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "READ", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "READ", stat, -ret); nfs3_read_reply (cs->req, stat, 0, NULL,0, NULL, NULL, 0); nfs3_call_state_wipe (cs); @@ -1777,7 +1809,7 @@ nfs3_read (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, return -1; } - nfs3_log_rw_call (nfs_rpcsvc_request_xid (req), "READ", fh, offset, + nfs3_log_rw_call (rpcsvc_request_xid (req), "READ", fh, offset, count, -1); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); @@ -1793,7 +1825,7 @@ nfs3_read (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "READ", stat, + nfs3_log_common_res (rpcsvc_request_xid (req), "READ", stat, -ret); nfs3_read_reply (req, stat, 0, NULL,0, NULL, NULL, 0); nfs3_call_state_wipe (cs); @@ -1815,16 +1847,16 @@ nfs3svc_read (rpcsvc_request_t *req) return ret; nfs3_prep_read3args (&args, &fh); - if (xdr_to_read3args (req->msg, &args) <= 0) { + if (xdr_to_read3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -1860,14 +1892,14 @@ nfs3svc_write_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, nfs3_call_state_t *cs = NULL; cs = frame->local; - nfs3 = nfs_rpcsvc_request_program_private (cs->req); + nfs3 = rpcsvc_request_program_private (cs->req); if (op_ret == -1) stat = nfs3_errno_to_nfsstat3 (op_errno); else stat = NFS3_OK; - nfs3_log_write_res (nfs_rpcsvc_request_xid (cs->req), stat, op_errno, + nfs3_log_write_res (rpcsvc_request_xid (cs->req), stat, op_errno, cs->maxcount, cs->writetype, nfs3->serverstart); nfs3_write_reply (cs->req, stat, cs->maxcount, cs->writetype, nfs3->serverstart, &cs->stbuf, postbuf); @@ -1957,7 +1989,7 @@ nfs3svc_write_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int sync_trusted = 0; cs = frame->local; - nfs3 = nfs_rpcsvc_request_program_private (cs->req); + nfs3 = rpcsvc_request_program_private (cs->req); if (op_ret == -1) { stat = nfs3_errno_to_nfsstat3 (op_errno); goto err; @@ -1987,7 +2019,7 @@ nfs3svc_write_cbk (call_frame_t *frame, void *cookie, xlator_t *this, err: if (ret < 0) { - nfs3_log_write_res (nfs_rpcsvc_request_xid (cs->req), stat, + nfs3_log_write_res (rpcsvc_request_xid (cs->req), stat, op_errno, cs->maxcount, cs->writetype, nfs3->serverstart); nfs3_write_reply (cs->req, stat, cs->maxcount, @@ -2022,8 +2054,9 @@ __nfs3_write_resume (nfs3_call_state_t *cs) * opaque data buffers to multiples of 4 bytes. */ cs->datavec.iov_len = cs->datacount; - ret = nfs_write (cs->nfsx, cs->vol, &nfu, cs->fd, cs->iob, &cs->datavec, - 1, cs->dataoffset, nfs3svc_write_cbk, cs); + ret = nfs_write (cs->nfsx, cs->vol, &nfu, cs->fd, cs->iobref, + &cs->datavec, 1, cs->dataoffset, nfs3svc_write_cbk, + cs); return ret; } @@ -2047,7 +2080,7 @@ nfs3_write_resume (void *carg) stat = nfs3_errno_to_nfsstat3 (-ret); nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "WRITE", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "WRITE", stat, -ret); nfs3_write_reply (cs->req, stat, 0, cs->writetype, 0, NULL, NULL); @@ -2074,7 +2107,7 @@ nfs3_write_open_resume (void *carg) stat = nfs3_errno_to_nfsstat3 (-ret); nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "WRITE", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "WRITE", stat, -ret); nfs3_write_reply (cs->req, stat, 0, cs->writetype, 0, NULL, NULL); @@ -2088,7 +2121,7 @@ nfs3err: int nfs3_write (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, count3 count, stable_how stable, struct iovec payload, - struct iobuf *iob) + struct iobref *iobref) { xlator_t *vol = NULL; nfsstat3 stat = NFS3ERR_SERVERFAULT; @@ -2101,7 +2134,7 @@ nfs3_write (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, return -1; } - nfs3_log_rw_call (nfs_rpcsvc_request_xid (req), "WRITE", fh, offset, + nfs3_log_rw_call (rpcsvc_request_xid (req), "WRITE", fh, offset, count, stable); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); @@ -2112,7 +2145,7 @@ nfs3_write (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, cs->datacount = count; cs->dataoffset = offset; cs->writetype = stable; - cs->iob = iob; + cs->iobref = iobref; cs->datavec = payload; @@ -2122,7 +2155,7 @@ nfs3_write (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "WRITE", + nfs3_log_common_res (rpcsvc_request_xid (req), "WRITE", stat, -ret); nfs3_write_reply (req, stat, 0, stable, 0, NULL, NULL); nfs3_call_state_wipe (cs); @@ -2140,99 +2173,46 @@ out: int -nfs3svc_write_vecsizer (rpcsvc_request_t *req, ssize_t *readsize, int *newbuf) +nfs3svc_write_vecsizer (int state, ssize_t *readsize, char *addr) { - ssize_t ret = RPCSVC_ACTOR_ERROR; - int state = 0; + int ret = 0; uint32_t fhlen = 0; uint32_t fhlen_n = 0; - write3args *args = NULL; - if (!req) - return ret; - - state = (long)nfs_rpcsvc_request_private (req); - *newbuf = 0; if (state == 0) { - nfs_rpcsvc_request_set_private (req, NFS3_VECWRITE_READFHLEN); + ret = NFS3_VECWRITE_READFHLEN; *readsize = 4; - ret = 0; } else if (state == NFS3_VECWRITE_READFHLEN) { - fhlen_n = *(uint32_t *)req->msg.iov_base; + fhlen_n = *(uint32_t *)(addr - 4); fhlen = ntohl (fhlen_n); - *readsize = nfs_xdr_length_round_up (fhlen, NFS3_FHSIZE); - nfs_rpcsvc_request_set_private (req, NFS3_VECWRITE_READFH); - ret = 0; + *readsize = xdr_length_round_up (fhlen, NFS3_FHSIZE); + ret = NFS3_VECWRITE_READFH; } else if (state == NFS3_VECWRITE_READFH) { *readsize = NFS3_WRITE_POSTFH_SIZE; - nfs_rpcsvc_request_set_private (req, NFS3_VECWRITE_READREST); - ret = 0; + ret = NFS3_VECWRITE_READREST; } else if (state == NFS3_VECWRITE_READREST) { - args = GF_CALLOC (1, sizeof (*args), gf_nfs_mt_write3args); - if (!args) - goto rpcerr; - - if (xdr_to_write3args_nocopy (req->msg, args, NULL) <= 0) { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_ARGS); - goto rpcerr; - } - nfs_rpcsvc_request_set_private (req, args); - ret = nfs_xdr_length_round_up (args->data.data_len, 1048576); - *readsize = ret; - *newbuf = 1; ret = 0; - } - -rpcerr: - return ret; -} - - -int -nfs3svc_write_vec (rpcsvc_request_t *req, struct iobuf *iob) -{ - write3args *args = NULL; - int ret = RPCSVC_ACTOR_ERROR; - struct iovec payload = {0, }; - struct nfs3_fh fh = {{0}, }; - - if ((!req) || (!iob)) - return ret; - - args = nfs_rpcsvc_request_private (req); - iobuf_to_iovec (iob, &payload); - iobuf_ref (iob); - memcpy (&fh, args->file.data.data_val, args->file.data.data_len); - ret = nfs3_write (req, &fh, args->offset, args->count, args->stable, - payload,iob); - xdr_free_write3args_nocopy (args); - GF_FREE (args); - if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { - gf_log (GF_NFS3, GF_LOG_ERROR, "WRITE procedure failed"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); - ret = RPCSVC_ACTOR_ERROR; - } + *readsize = 0; + } else + gf_log ("nfs", GF_LOG_ERROR, "state wrong"); return ret; } - int nfs3svc_write (rpcsvc_request_t *req) { struct nfs3_fh fh = {{0}, }; write3args args; int ret = RPCSVC_ACTOR_ERROR; - struct iovec payload = {0, }; if (!req) return ret; nfs3_prep_write3args (&args, &fh); - if (xdr_to_write3args_nocopy (req->msg, &args, &payload) <= 0) { + if (xdr_to_write3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_ARGS); + rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -2241,12 +2221,12 @@ nfs3svc_write (rpcsvc_request_t *req) * ourselves because the RPC call handler who called us will unref its * own ref of the record's iobuf when it is done handling the request. */ - nfs_rpcsvc_request_record_ref (req); + ret = nfs3_write (req, &fh, args.offset, args.count, args.stable, - payload, nfs_rpcsvc_request_record_iob (req)); + 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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -2254,6 +2234,12 @@ rpcerr: return ret; } +int +nfs3svc_write_vec (rpcsvc_request_t *req, struct iovec *payload, + int payload_count, struct iobref *iobref) +{ + return nfs3svc_write (req); +} int nfs3_create_reply (rpcsvc_request_t *req, nfsstat3 stat, struct nfs3_fh *newfh, @@ -2288,7 +2274,7 @@ nfs3svc_create_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = NFS3_OK; nfs3err: - nfs3_log_newfh_res (nfs_rpcsvc_request_xid (cs->req), "CREATE", stat, + nfs3_log_newfh_res (rpcsvc_request_xid (cs->req), "CREATE", stat, op_errno, &cs->fh); nfs3_create_reply (cs->req, stat, &cs->fh, postop, &cs->preparent, &cs->postparent); @@ -2334,7 +2320,7 @@ nfs3svc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, nfs3err: if (ret < 0) { - nfs3_log_newfh_res (nfs_rpcsvc_request_xid (cs->req), "CREATE", + nfs3_log_newfh_res (rpcsvc_request_xid (cs->req), "CREATE", stat, op_errno, &cs->fh); nfs3_create_reply (cs->req, stat, &cs->fh, buf, preparent, postparent); @@ -2396,20 +2382,23 @@ 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, "Create req retransmitted verf %x %x", + gf_log (GF_NFS3, GF_LOG_DEBUG, + "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, "File already exist new_verf %x %x" - "old_verf %x %x", cs->stbuf.ia_mtime, cs->stbuf.ia_atime, + gf_log (GF_NFS3, GF_LOG_DEBUG, + "File already exist new_verf %x %x" + "old_verf %x %x", cs->stbuf.ia_mtime, + cs->stbuf.ia_atime, buf->ia_mtime, buf->ia_atime); stat = NFS3ERR_EXIST; } nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "CREATE", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "CREATE", stat, op_errno); nfs3_create_reply (cs->req, stat, &cs->fh, buf, NULL, NULL); nfs3_call_state_wipe (cs); @@ -2430,7 +2419,8 @@ nfs3_create_exclusive (nfs3_call_state_t *cs) /* Storing verifier as a mtime and atime attribute, to store it * in stable storage */ - memcpy (&cs->stbuf.ia_atime, &cs->cookieverf, sizeof (cs->stbuf.ia_atime)); + memcpy (&cs->stbuf.ia_atime, &cs->cookieverf, + sizeof (cs->stbuf.ia_atime)); memcpy (&cs->stbuf.ia_mtime, ((char *) &cs->cookieverf) + sizeof (cs->stbuf.ia_atime), sizeof (cs->stbuf.ia_mtime)); @@ -2454,7 +2444,8 @@ nfs3_create_exclusive (nfs3_call_state_t *cs) ret = nfs_create (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, O_RDWR, cs->mode, nfs3svc_create_cbk, cs); } else - ret = nfs_create (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, O_RDWR, + ret = nfs_create (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, + O_RDWR, NFS_DEFAULT_CREATE_MODE, nfs3svc_create_cbk, cs); @@ -2486,7 +2477,7 @@ nfs3_create_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "CREATE", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "CREATE", stat, -ret); nfs3_create_reply (cs->req, stat, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -2508,7 +2499,7 @@ nfs3_create (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, if ((!req) || (!dirfh) || (!name) || (!sattr)) return -1; - nfs3_log_create_call (nfs_rpcsvc_request_xid (req), dirfh, name, mode); + nfs3_log_create_call (rpcsvc_request_xid (req), dirfh, name, mode); nfs3_validate_gluster_fh (dirfh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); nfs3_validate_strlen_or_goto (name, NFS_NAME_MAX, nfs3err, stat, ret); @@ -2521,8 +2512,9 @@ nfs3_create (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, /*In Exclusive create client is supposed to send cverf instead of * sattr*/ if (mode != EXCLUSIVE) - cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, &cs->stbuf, - &cs->mode); + cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, + &cs->stbuf, + &cs->mode); cs->createmode = mode; cs->parent = *dirfh; @@ -2532,7 +2524,7 @@ nfs3_create (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "CREATE", + nfs3_log_common_res (rpcsvc_request_xid (req), "CREATE", stat, -ret); nfs3_create_reply (req, stat, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -2557,9 +2549,9 @@ nfs3svc_create (rpcsvc_request_t *req) return ret; nfs3_prep_create3args (&args, &dirfh, name); - if (xdr_to_create3args (req->msg, &args) <= 0) { + if (xdr_to_create3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_ARGS); + rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -2567,7 +2559,8 @@ nfs3svc_create (rpcsvc_request_t *req) if (cval) cverf = *cval; else { - gf_log(GF_NFS3, GF_LOG_ERROR, "Error getting createverf3 from args"); + gf_log(GF_NFS3, GF_LOG_ERROR, + "Error getting createverf3 from args"); goto rpcerr; } @@ -2575,7 +2568,7 @@ nfs3svc_create (rpcsvc_request_t *req) &args.how.createhow3_u.obj_attributes, cverf); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { gf_log (GF_NFS3, GF_LOG_ERROR, "CREATE procedure failed"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -2616,7 +2609,7 @@ nfs3svc_mkdir_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = NFS3_OK; nfs3err: - nfs3_log_newfh_res (nfs_rpcsvc_request_xid (cs->req), "MKDIR", stat, + nfs3_log_newfh_res (rpcsvc_request_xid (cs->req), "MKDIR", stat, op_errno, &cs->fh); nfs3_mkdir_reply (cs->req, stat, &cs->fh, postop, &cs->preparent, &cs->postparent); @@ -2661,7 +2654,7 @@ nfs3svc_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, nfs3err: if (ret < 0) { - nfs3_log_newfh_res (nfs_rpcsvc_request_xid (cs->req), "MKDIR", + nfs3_log_newfh_res (rpcsvc_request_xid (cs->req), "MKDIR", stat, op_errno, &cs->fh); nfs3_mkdir_reply (cs->req, stat, &cs->fh, buf, preparent, postparent); @@ -2700,7 +2693,7 @@ nfs3_mkdir_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "MKDIR", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "MKDIR", stat, -ret); nfs3_mkdir_reply (cs->req, stat, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -2726,7 +2719,7 @@ nfs3_mkdir (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, return -1; } - nfs3_log_fh_entry_call (nfs_rpcsvc_request_xid (req), "MKDIR", dirfh, + nfs3_log_fh_entry_call (rpcsvc_request_xid (req), "MKDIR", dirfh, name); nfs3_validate_gluster_fh (dirfh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); @@ -2745,7 +2738,7 @@ nfs3_mkdir (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "MKDIR", + nfs3_log_common_res (rpcsvc_request_xid (req), "MKDIR", stat, -ret); nfs3_mkdir_reply (req, stat, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -2767,16 +2760,16 @@ nfs3svc_mkdir (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_mkdir3args (&args, &dirfh, name); - if (xdr_to_mkdir3args (req->msg, &args) <= 0) { + if (xdr_to_mkdir3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -2822,7 +2815,7 @@ nfs3svc_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = NFS3_OK; nfs3err: - nfs3_log_newfh_res (nfs_rpcsvc_request_xid (cs->req), "SYMLINK", stat, + nfs3_log_newfh_res (rpcsvc_request_xid (cs->req), "SYMLINK", stat, op_errno, &cs->fh); nfs3_symlink_reply (cs->req, stat, &cs->fh, buf, preparent, postparent); @@ -2852,7 +2845,7 @@ nfs3_symlink_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "SYMLINK", stat, -ret); nfs3_symlink_reply (cs->req, stat, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -2877,7 +2870,7 @@ nfs3_symlink (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, return -1; } - nfs3_log_symlink_call (nfs_rpcsvc_request_xid (req), dirfh, name, + nfs3_log_symlink_call (rpcsvc_request_xid (req), dirfh, name, target); nfs3_validate_gluster_fh (dirfh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); @@ -2901,7 +2894,7 @@ nfs3_symlink (rpcsvc_request_t *req, struct nfs3_fh *dirfh, char *name, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "SYMLINK", + nfs3_log_common_res (rpcsvc_request_xid (req), "SYMLINK", stat, -ret); nfs3_symlink_reply (req, stat, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -2927,9 +2920,9 @@ nfs3svc_symlink (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_symlink3args (&args, &dirfh, name, target); - if (xdr_to_symlink3args (req->msg, &args) <= 0) { + if (xdr_to_symlink3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_ARGS); + rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -2937,7 +2930,7 @@ nfs3svc_symlink (rpcsvc_request_t *req) &args.symlink.symlink_attributes); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { gf_log (GF_NFS3, GF_LOG_ERROR, "SYMLINK procedure failed"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -2979,7 +2972,7 @@ nfs3svc_mknod_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = NFS3_OK; nfs3err: - nfs3_log_newfh_res (nfs_rpcsvc_request_xid (cs->req), "MKNOD", stat, + nfs3_log_newfh_res (rpcsvc_request_xid (cs->req), "MKNOD", stat, op_errno, &cs->fh); nfs3_mknod_reply (cs->req, stat, &cs->fh, postop, &cs->preparent, &cs->postparent); @@ -3024,7 +3017,7 @@ nfs3svc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = nfs3_errno_to_nfsstat3 (-ret); nfs3err: if (ret < 0) { - nfs3_log_newfh_res (nfs_rpcsvc_request_xid (cs->req), "MKNOD", + nfs3_log_newfh_res (rpcsvc_request_xid (cs->req), "MKNOD", stat, op_errno, &cs->fh); nfs3_mknod_reply (cs->req, stat, &cs->fh, buf, preparent, @@ -3123,7 +3116,7 @@ nfs3_mknod_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "MKNOD", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "MKNOD", stat, -ret); nfs3_mknod_reply (cs->req, stat, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3150,7 +3143,7 @@ nfs3_mknod (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name, return -1; } - nfs3_log_mknod_call (nfs_rpcsvc_request_xid (req), fh, name, + nfs3_log_mknod_call (rpcsvc_request_xid (req), fh, name, nodedata->type); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); @@ -3166,13 +3159,15 @@ nfs3_mknod (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name, case NF3BLK: cs->devnums = nodedata->mknoddata3_u.device.spec; sattr = &nodedata->mknoddata3_u.device.dev_attributes; - cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, &cs->stbuf, + cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, + &cs->stbuf, &cs->mode); break; case NF3SOCK: case NF3FIFO: sattr = &nodedata->mknoddata3_u.pipe_attributes; - cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, &cs->stbuf, + cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, + &cs->stbuf, &cs->mode); break; default: @@ -3187,7 +3182,7 @@ nfs3_mknod (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "MKNOD", + nfs3_log_common_res (rpcsvc_request_xid (req), "MKNOD", stat, -ret); nfs3_mknod_reply (req, stat, NULL, NULL, NULL, NULL); /* Ret must be 0 after this so that the caller does not @@ -3212,16 +3207,16 @@ nfs3svc_mknod (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_mknod3args (&args, &fh, name); - if (xdr_to_mknod3args (req->msg, &args) <= 0) { + if (xdr_to_mknod3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -3265,14 +3260,14 @@ nfs3svc_remove_cbk (call_frame_t *frame, void *cookie, xlator_t *this, * finishes, the file is finally removed. */ openfd = fd_lookup (cs->resolvedloc.inode, 0); - nfs3 = nfs_rpcsvc_request_program_private (cs->req); + nfs3 = rpcsvc_request_program_private (cs->req); if (openfd) { fd_unref (openfd); nfs3_fdcache_remove (nfs3, openfd); } do_not_unref_cached_fd: - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "REMOVE", stat, + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "REMOVE", stat, op_errno); nfs3_remove_reply (cs->req, stat, preparent, postparent); nfs3_call_state_wipe (cs); @@ -3321,7 +3316,7 @@ nfs3_remove_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "REMOVE", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "REMOVE", stat, -ret); nfs3_remove_reply (cs->req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3345,7 +3340,7 @@ nfs3_remove (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name) return -1; } - nfs3_log_fh_entry_call (nfs_rpcsvc_request_xid (req), "REMOVE", fh, + nfs3_log_fh_entry_call (rpcsvc_request_xid (req), "REMOVE", fh, name); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); @@ -3361,7 +3356,7 @@ nfs3_remove (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "REMOVE", + nfs3_log_common_res (rpcsvc_request_xid (req), "REMOVE", stat, -ret); nfs3_remove_reply (req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3386,16 +3381,16 @@ nfs3svc_remove (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_remove3args (&args, &fh, name); - if (xdr_to_remove3args (req->msg, &args) <= 0) { + if (xdr_to_remove3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -3434,7 +3429,7 @@ nfs3svc_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = NFS3_OK; } - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "RMDIR", stat, + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "RMDIR", stat, op_errno); nfs3_rmdir_reply (cs->req, stat, preparent, postparent); nfs3_call_state_wipe (cs); @@ -3463,7 +3458,7 @@ nfs3_rmdir_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "RMDIR", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "RMDIR", stat, -ret); nfs3_rmdir_reply (cs->req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3488,7 +3483,7 @@ nfs3_rmdir (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name) return -1; } - nfs3_log_fh_entry_call (nfs_rpcsvc_request_xid (req), "RMDIR", fh, + nfs3_log_fh_entry_call (rpcsvc_request_xid (req), "RMDIR", fh, name); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); @@ -3504,7 +3499,7 @@ nfs3_rmdir (rpcsvc_request_t *req, struct nfs3_fh *fh, char *name) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "RMDIR", + nfs3_log_common_res (rpcsvc_request_xid (req), "RMDIR", stat, -ret); nfs3_rmdir_reply (req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3529,16 +3524,16 @@ nfs3svc_rmdir (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_rmdir3args (&args, &fh, name); - if (xdr_to_rmdir3args (req->msg, &args) <= 0) { + if (xdr_to_rmdir3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -3598,7 +3593,7 @@ nfs3svc_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } nfs3err: - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "RENAME", stat, + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "RENAME", stat, -ret); nfs3_rename_reply (cs->req, stat, buf, preoldparent, postoldparent, prenewparent, postnewparent); @@ -3629,7 +3624,7 @@ nfs3_rename_resume_dst (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "RENAME", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "RENAME", stat, -ret); nfs3_rename_reply (cs->req, stat, NULL, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3665,7 +3660,7 @@ nfs3_rename_resume_src (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "RENAME", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "RENAME", stat, -ret); nfs3_rename_reply (cs->req, stat, NULL, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3690,7 +3685,7 @@ nfs3_rename (rpcsvc_request_t *req, struct nfs3_fh *olddirfh, char *oldname, return -1; } - nfs3_log_rename_call (nfs_rpcsvc_request_xid (req), olddirfh, oldname, + nfs3_log_rename_call (rpcsvc_request_xid (req), olddirfh, oldname, newdirfh, newname); nfs3_validate_gluster_fh (olddirfh, stat, nfs3err); nfs3_validate_gluster_fh (newdirfh, stat, nfs3err); @@ -3720,7 +3715,7 @@ nfs3_rename (rpcsvc_request_t *req, struct nfs3_fh *olddirfh, char *oldname, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "RENAME", + nfs3_log_common_res (rpcsvc_request_xid (req), "RENAME", stat, -ret); nfs3_rename_reply (req, stat, NULL, NULL, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3747,16 +3742,16 @@ nfs3svc_rename (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_rename3args (&args, &olddirfh, oldname, &newdirfh, newname); - if (xdr_to_rename3args (req->msg, &args) <= 0) { + if (xdr_to_rename3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -3796,7 +3791,7 @@ nfs3svc_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, else stat = NFS3_OK; - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "LINK", stat, + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "LINK", stat, op_errno); nfs3_link_reply (cs->req, stat, buf, preparent, postparent); nfs3_call_state_wipe (cs); @@ -3827,7 +3822,7 @@ nfs3_link_resume_lnk (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "LINK", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "LINK", stat, -ret); nfs3_link_reply (cs->req, stat, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3858,7 +3853,7 @@ nfs3_link_resume_tgt (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "LINK", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "LINK", stat, -ret); nfs3_link_reply (cs->req, stat, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3907,7 +3902,7 @@ nfs3_link (rpcsvc_request_t *req, struct nfs3_fh *targetfh, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "LINK", stat, + nfs3_log_common_res (rpcsvc_request_xid (req), "LINK", stat, -ret); nfs3_link_reply (req, stat, NULL, NULL, NULL); nfs3_call_state_wipe (cs); @@ -3932,16 +3927,16 @@ nfs3svc_link (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_link3args (&args, &targetfh, &dirfh, newpath); - if (xdr_to_link3args (req->msg, &args) <= 0) { + if (xdr_to_link3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4013,14 +4008,14 @@ nfs3svc_readdir_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = NFS3_OK; nfs3err: if (cs->maxcount == 0) { - nfs3_log_readdir_res (nfs_rpcsvc_request_xid (cs->req), stat, + nfs3_log_readdir_res (rpcsvc_request_xid (cs->req), stat, op_errno, (uintptr_t)cs->fd, cs->dircount, is_eof); nfs3_readdir_reply (cs->req, stat, &cs->parent, (uintptr_t)cs->fd, buf, &cs->entries, cs->dircount, is_eof); } else { - nfs3_log_readdirp_res (nfs_rpcsvc_request_xid (cs->req), stat, + nfs3_log_readdirp_res (rpcsvc_request_xid (cs->req), stat, op_errno, (uintptr_t)cs->fd, cs->dircount, cs->maxcount, is_eof); nfs3_readdirp_reply (cs->req, stat, &cs->parent, @@ -4069,11 +4064,11 @@ err: goto ret; if (cs->maxcount == 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "READDIR", stat, op_errno); nfs3_readdir_reply (cs->req, stat, NULL, 0, NULL, NULL, 0, 0); } else { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "READDIRP", stat, op_errno); nfs3_readdirp_reply (cs->req, stat, NULL, 0, NULL, NULL, 0, 0, 0); @@ -4117,7 +4112,7 @@ nfs3_readdir_read_resume (void *carg) cs = (nfs3_call_state_t *)carg; nfs3_check_fh_resolve_status (cs, stat, nfs3err); - nfs3 = nfs_rpcsvc_request_program_private (cs->req); + nfs3 = rpcsvc_request_program_private (cs->req); ret = nfs3_verify_dircookie (nfs3, cs->fd, cs->cookie, cs->cookieverf, &stat); if (ret < 0) /* Stat already set by verifier function above. */ @@ -4129,12 +4124,12 @@ nfs3_readdir_read_resume (void *carg) nfs3err: if (ret < 0) { if (cs->maxcount == 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "READDIR", stat, -ret); nfs3_readdir_reply (cs->req, stat, NULL, 0, NULL, NULL, 0, 0); } else { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "READDIRP", stat, -ret); nfs3_readdirp_reply (cs->req, stat, NULL, 0, NULL, NULL, 0, 0, 0); @@ -4165,12 +4160,12 @@ nfs3_readdir_open_resume (void *carg) nfs3err: if (ret < 0) { if (cs->maxcount == 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "READDIR", stat, -ret); nfs3_readdir_reply (cs->req, stat, NULL, 0, NULL, NULL, 0, 0); } else { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "READDIRP", stat, -ret); nfs3_readdirp_reply (cs->req, stat, NULL, 0, NULL, NULL, 0, 0, 0); @@ -4198,7 +4193,7 @@ nfs3_readdir (rpcsvc_request_t *req, struct nfs3_fh *fh, cookie3 cookie, return -1; } - nfs3_log_readdir_call (nfs_rpcsvc_request_xid (req), fh, dircount, + nfs3_log_readdir_call (rpcsvc_request_xid (req), fh, dircount, maxcount); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); @@ -4219,12 +4214,12 @@ nfs3_readdir (rpcsvc_request_t *req, struct nfs3_fh *fh, cookie3 cookie, nfs3err: if (ret < 0) { if (maxcount == 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), + nfs3_log_common_res (rpcsvc_request_xid (req), "READDIR", stat, -ret); nfs3_readdir_reply (req, stat, NULL, 0, NULL, NULL, 0, 0); } else { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), + nfs3_log_common_res (rpcsvc_request_xid (req), "READDIRP", stat, -ret); nfs3_readdirp_reply (req, stat, NULL, 0, NULL, NULL, 0, 0, 0); @@ -4252,9 +4247,9 @@ nfs3svc_readdir (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_readdir3args (&ra, &fh); - if (xdr_to_readdir3args (req->msg, &ra) <= 0) { + if (xdr_to_readdir3args (req->msg[0], &ra) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_ARGS); + rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -4263,14 +4258,15 @@ nfs3svc_readdir (rpcsvc_request_t *req) if (cval) verf = *cval; else { - gf_log(GF_NFS3, GF_LOG_ERROR, "Error getting cookieverf from readdir args"); + gf_log(GF_NFS3, GF_LOG_ERROR, + "Error getting cookieverf from readdir args"); goto rpcerr; } 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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4291,9 +4287,9 @@ nfs3svc_readdirp (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_readdirp3args (&ra, &fh); - if (xdr_to_readdirp3args (req->msg, &ra) <= 0) { + if (xdr_to_readdirp3args (req->msg[0], &ra) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_ARGS); + rpcsvc_request_seterr (req, GARBAGE_ARGS); goto rpcerr; } @@ -4302,7 +4298,8 @@ nfs3svc_readdirp (rpcsvc_request_t *req) if (cval) cverf = *cval; else { - gf_log (GF_NFS3, GF_LOG_ERROR, "Error getting cookieverf from readdirp args"); + gf_log (GF_NFS3, GF_LOG_ERROR, + "Error getting cookieverf from readdirp args"); goto rpcerr; } @@ -4310,7 +4307,7 @@ nfs3svc_readdirp (rpcsvc_request_t *req) ra.maxcount); if ((ret < 0) && (ret != RPCSVC_ACTOR_IGNORE)) { gf_log (GF_NFS3, GF_LOG_ERROR, "READDIRP procedure failed"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4347,7 +4344,7 @@ nfs3_fsstat_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, else stat = NFS3_OK; - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "FSTAT", stat, + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "FSTAT", stat, op_errno); nfs3_fsstat_reply (cs->req, stat, &cs->fsstat, buf); nfs3_call_state_wipe (cs); @@ -4383,7 +4380,7 @@ nfs3_fsstat_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "FSTAT", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "FSTAT", stat, -ret); nfs3_fsstat_reply (cs->req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -4415,7 +4412,7 @@ nfs3_fsstat_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "FSTAT", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "FSTAT", stat, -ret); nfs3_fsstat_reply (cs->req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -4440,7 +4437,7 @@ nfs3_fsstat (rpcsvc_request_t *req, struct nfs3_fh *fh) return -1; } - nfs3_log_common_call (nfs_rpcsvc_request_xid (req), "FSSTAT", fh); + nfs3_log_common_call (rpcsvc_request_xid (req), "FSSTAT", fh); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); nfs3_map_fh_to_volume (nfs3, fh, req, vol, stat, nfs3err); @@ -4453,7 +4450,7 @@ nfs3_fsstat (rpcsvc_request_t *req, struct nfs3_fh *fh) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "FSTAT", + nfs3_log_common_res (rpcsvc_request_xid (req), "FSTAT", stat, -ret); nfs3_fsstat_reply (req, stat, NULL, NULL); nfs3_call_state_wipe (cs); @@ -4477,16 +4474,16 @@ nfs3svc_fsstat (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_fsstat3args (&args, &fh); - if (xdr_to_fsstat3args (req->msg, &args) <= 0) { + if (xdr_to_fsstat3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4503,7 +4500,7 @@ nfs3_fsinfo_reply (rpcsvc_request_t *req, nfsstat3 status, struct iatt *fsroot) uint64_t deviceid = 0; deviceid = nfs3_request_xlator_deviceid (req); - nfs3 = nfs_rpcsvc_request_program_private (req); + nfs3 = rpcsvc_request_program_private (req); nfs3_fill_fsinfo3res (nfs3, &res, status, fsroot, deviceid); nfs3svc_submit_reply (req, &res, @@ -4526,7 +4523,7 @@ nfs3svc_fsinfo_cbk (call_frame_t *frame, void *cookie, xlator_t *this, else status = NFS3_OK; - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "FSINFO", status, + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "FSINFO", status, op_errno); nfs3_fsinfo_reply (cs->req, status, buf); @@ -4559,7 +4556,7 @@ nfs3_fsinfo_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "FSINFO", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "FSINFO", stat, -ret); nfs3_fsinfo_reply (cs->req, stat, NULL); nfs3_call_state_wipe (cs); @@ -4583,7 +4580,7 @@ nfs3_fsinfo (rpcsvc_request_t *req, struct nfs3_fh *fh) return -1; } - nfs3_log_common_call (nfs_rpcsvc_request_xid (req), "FSINFO", fh); + nfs3_log_common_call (rpcsvc_request_xid (req), "FSINFO", fh); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); nfs3_map_fh_to_volume (nfs3, fh, req, vol, stat, nfs3err); @@ -4596,7 +4593,7 @@ nfs3_fsinfo (rpcsvc_request_t *req, struct nfs3_fh *fh) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "FSINFO", + nfs3_log_common_res (rpcsvc_request_xid (req), "FSINFO", stat, -ret); nfs3_fsinfo_reply (req, stat, NULL); nfs3_call_state_wipe (cs); @@ -4618,16 +4615,16 @@ nfs3svc_fsinfo (rpcsvc_request_t *req) return ret; nfs3_prep_fsinfo3args (&args, &root); - if (xdr_to_fsinfo3args (req->msg, &args) <= 0) { + if (xdr_to_fsinfo3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding arguments"); - nfs_rpcsvc_request_seterr (req, GARBAGE_ARGS); + 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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4669,7 +4666,7 @@ nfs3svc_pathconf_cbk (call_frame_t *frame, void *cookie, xlator_t *this, stat = NFS3_OK; } - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "PATHCONF", stat, + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "PATHCONF", stat, op_errno); nfs3_pathconf_reply (cs->req, stat, sbuf); nfs3_call_state_wipe (cs); @@ -4698,7 +4695,7 @@ nfs3_pathconf_resume (void *carg) stat = nfs3_errno_to_nfsstat3 (-ret); nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "PATHCONF", stat, -ret); nfs3_pathconf_reply (cs->req, stat, NULL); nfs3_call_state_wipe (cs); @@ -4721,7 +4718,7 @@ nfs3_pathconf (rpcsvc_request_t *req, struct nfs3_fh *fh) return -1; } - nfs3_log_common_call (nfs_rpcsvc_request_xid (req), "PATHCONF", fh); + nfs3_log_common_call (rpcsvc_request_xid (req), "PATHCONF", fh); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); nfs3_map_fh_to_volume (nfs3, fh, req, vol, stat, nfs3err); @@ -4734,7 +4731,7 @@ nfs3_pathconf (rpcsvc_request_t *req, struct nfs3_fh *fh) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "PATHCONF", + nfs3_log_common_res (rpcsvc_request_xid (req), "PATHCONF", stat, -ret); nfs3_pathconf_reply (req, stat, NULL); nfs3_call_state_wipe (cs); @@ -4758,16 +4755,16 @@ nfs3svc_pathconf (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_pathconf3args (&args, &fh); - if (xdr_to_pathconf3args (req->msg, &args) <= 0) { + if (xdr_to_pathconf3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4806,8 +4803,8 @@ nfs3svc_commit_cbk (call_frame_t *frame, void *cookie, xlator_t *this, else stat = NFS3_OK; - nfs3 = nfs_rpcsvc_request_program_private (cs->req); - nfs3_log_commit_res (nfs_rpcsvc_request_xid (cs->req), stat, op_errno, + nfs3 = rpcsvc_request_program_private (cs->req); + nfs3_log_commit_res (rpcsvc_request_xid (cs->req), stat, op_errno, nfs3->serverstart); nfs3_commit_reply (cs->req, stat, nfs3->serverstart, prebuf, postbuf); nfs3_call_state_wipe (cs); @@ -4843,7 +4840,7 @@ nfs3_commit_resume (void *carg) nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "COMMIT", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "COMMIT", stat, -ret); nfs3_commit_reply (cs->req, stat, cs->nfs3state->serverstart, NULL, NULL); @@ -4873,7 +4870,7 @@ nfs3_commit_open_resume (void *carg) stat = nfs3_errno_to_nfsstat3 (-ret); nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (cs->req), "COMMIT", + nfs3_log_common_res (rpcsvc_request_xid (cs->req), "COMMIT", stat, -ret); nfs3_commit_reply (cs->req, stat, 0, NULL, NULL); nfs3_call_state_wipe (cs); @@ -4899,7 +4896,7 @@ nfs3_commit (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, return -1; } - nfs3_log_rw_call (nfs_rpcsvc_request_xid (req), "COMMIT", fh, offset, + nfs3_log_rw_call (rpcsvc_request_xid (req), "COMMIT", fh, offset, count, -1); nfs3_validate_gluster_fh (fh, stat, nfs3err); nfs3_validate_nfs3_state (req, nfs3, stat, nfs3err, ret); @@ -4917,7 +4914,7 @@ nfs3_commit (rpcsvc_request_t *req, struct nfs3_fh *fh, offset3 offset, nfs3err: if (ret < 0) { - nfs3_log_common_res (nfs_rpcsvc_request_xid (req), "COMMIT", + nfs3_log_common_res (rpcsvc_request_xid (req), "COMMIT", stat, -ret); nfs3_commit_reply (req, stat, 0, NULL, NULL); nfs3_call_state_wipe (cs); @@ -4939,16 +4936,16 @@ nfs3svc_commit (rpcsvc_request_t *req) if (!req) return ret; nfs3_prep_commit3args (&args, &fh); - if (xdr_to_commit3args (req->msg, &args) <= 0) { + if (xdr_to_commit3args (req->msg[0], &args) <= 0) { gf_log (GF_NFS3, GF_LOG_ERROR, "Error decoding args"); - nfs_rpcsvc_request_seterr (req, GARBAGE_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"); - nfs_rpcsvc_request_seterr (req, SYSTEM_ERR); + rpcsvc_request_seterr (req, SYSTEM_ERR); ret = RPCSVC_ACTOR_ERROR; } @@ -4965,7 +4962,7 @@ rpcsvc_actor_t nfs3svc_actors[NFS3_PROC_COUNT] = { {"ACCESS", NFS3_ACCESS, nfs3svc_access, NULL, NULL}, {"READLINK", NFS3_READLINK, nfs3svc_readlink,NULL, NULL}, {"READ", NFS3_READ, nfs3svc_read, NULL, NULL}, - {"WRITE", NFS3_WRITE, nfs3svc_write, nfs3svc_write_vec, nfs3svc_write_vecsizer}, + {"WRITE", NFS3_WRITE, nfs3svc_write, nfs3svc_write_vec, nfs3svc_write_vecsizer}, {"CREATE", NFS3_CREATE, nfs3svc_create, NULL, NULL}, {"MKDIR", NFS3_MKDIR, nfs3svc_mkdir, NULL, NULL}, {"SYMLINK", NFS3_SYMLINK, nfs3svc_symlink,NULL, NULL}, @@ -4988,8 +4985,6 @@ rpcsvc_program_t nfs3prog = { .prognum = NFS_PROGRAM, .progver = NFS_V3, .progport = GF_NFS3_PORT, - .progaddrfamily = AF_INET, - .proghost = NULL, .actors = nfs3svc_actors, .numactors = NFS3_PROC_COUNT, @@ -5327,7 +5322,7 @@ nfs3_init_state (xlator_t *nfsx) struct nfs3_state *nfs3 = NULL; int ret = -1; unsigned int localpool = 0; - + struct nfs_state *nfs = NULL; if (!nfsx) return NULL; @@ -5339,6 +5334,7 @@ nfs3_init_state (xlator_t *nfsx) return NULL; } + nfs = nfsx->private; ret = nfs3_init_options (nfs3, nfsx); if (ret == -1) { gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to init options"); @@ -5371,6 +5367,12 @@ nfs3_init_state (xlator_t *nfsx) LOCK_INIT (&nfs3->fdlrulock); nfs3->fdcount = 0; + rpcsvc_create_listeners (nfs->rpcsvc, nfsx->options, nfsx->name); + if (ret == -1) { + gf_log (GF_NFS, GF_LOG_ERROR, "Unable to create listeners"); + goto free_localpool; + } + ret = 0; free_localpool: diff --git a/xlators/nfs/server/src/nfs3.h b/xlators/nfs/server/src/nfs3.h index bf4371a8a45..ce671a9c85f 100644 --- a/xlators/nfs/server/src/nfs3.h +++ b/xlators/nfs/server/src/nfs3.h @@ -184,6 +184,7 @@ struct nfs3_local { count3 datacount; offset3 dataoffset; struct iobuf *iob; + struct iobref *iobref; createmode3 createmode; uint64_t cookieverf; int sattrguardcheck; @@ -206,7 +207,7 @@ struct nfs3_local { }; #define nfs3_is_revalidate_lookup(cst) ((cst)->lookuptype == GF_NFS3_REVALIDATE) -#define nfs3_lookup_op(cst) (nfs_rpcsvc_request_procnum(cst->req) == NFS3_LOOKUP) +#define nfs3_lookup_op(cst) (rpcsvc_request_procnum(cst->req) == NFS3_LOOKUP) typedef struct nfs3_local nfs3_call_state_t; /* Queue of ops waiting for open fop to return. */ |