10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
51488Srsb * Common Development and Distribution License (the "License").
61488Srsb * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*12633Sjohn.levon@sun.com * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate */
240Sstevel@tonic-gate
250Sstevel@tonic-gate /*
260Sstevel@tonic-gate * This is the loadable module wrapper.
270Sstevel@tonic-gate */
280Sstevel@tonic-gate #include <sys/systm.h>
290Sstevel@tonic-gate #include <sys/modctl.h>
300Sstevel@tonic-gate #include <sys/syscall.h>
310Sstevel@tonic-gate #include <sys/ddi.h>
320Sstevel@tonic-gate #include <sys/cmn_err.h>
330Sstevel@tonic-gate
340Sstevel@tonic-gate #include <nfs/nfs.h>
350Sstevel@tonic-gate #include <nfs/nfs_clnt.h>
360Sstevel@tonic-gate #include <nfs/nfs4.h>
370Sstevel@tonic-gate #include <nfs/rnode4.h>
380Sstevel@tonic-gate
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate * The global tag list.
410Sstevel@tonic-gate */
420Sstevel@tonic-gate ctag_t nfs4_ctags[] = NFS4_TAG_INITIALIZER;
430Sstevel@tonic-gate
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate * The NFS Version 4 client VFS.
460Sstevel@tonic-gate */
470Sstevel@tonic-gate static vfsdef_t vfw4 = {
480Sstevel@tonic-gate VFSDEF_VERSION,
490Sstevel@tonic-gate "nfs4",
500Sstevel@tonic-gate nfs4init,
51*12633Sjohn.levon@sun.com VSW_CANREMOUNT|VSW_NOTZONESAFE|VSW_STATS|VSW_ZMOUNT,
520Sstevel@tonic-gate NULL
530Sstevel@tonic-gate };
540Sstevel@tonic-gate
550Sstevel@tonic-gate struct modlfs modlfs4 = {
560Sstevel@tonic-gate &mod_fsops,
570Sstevel@tonic-gate "network filesystem version 4",
580Sstevel@tonic-gate &vfw4
590Sstevel@tonic-gate };
600Sstevel@tonic-gate
610Sstevel@tonic-gate static uint_t nfs4_max_transfer_size = 32 * 1024;
620Sstevel@tonic-gate static uint_t nfs4_max_transfer_size_cots = 1024 * 1024;
630Sstevel@tonic-gate static uint_t nfs4_max_transfer_size_rdma = 1024 * 1024;
640Sstevel@tonic-gate
650Sstevel@tonic-gate int
nfs4tsize(void)660Sstevel@tonic-gate nfs4tsize(void)
670Sstevel@tonic-gate {
680Sstevel@tonic-gate /*
690Sstevel@tonic-gate * For the moment, just return nfs4_max_transfer_size until we
700Sstevel@tonic-gate * can query the appropriate transport.
710Sstevel@tonic-gate */
720Sstevel@tonic-gate return (nfs4_max_transfer_size);
730Sstevel@tonic-gate }
740Sstevel@tonic-gate
750Sstevel@tonic-gate uint_t
nfs4_tsize(struct knetconfig * knp)760Sstevel@tonic-gate nfs4_tsize(struct knetconfig *knp)
770Sstevel@tonic-gate {
780Sstevel@tonic-gate
790Sstevel@tonic-gate if (knp->knc_semantics == NC_TPI_COTS_ORD ||
800Sstevel@tonic-gate knp->knc_semantics == NC_TPI_COTS)
810Sstevel@tonic-gate return (nfs4_max_transfer_size_cots);
820Sstevel@tonic-gate if (knp->knc_semantics == NC_TPI_RDMA)
830Sstevel@tonic-gate return (nfs4_max_transfer_size_rdma);
840Sstevel@tonic-gate return (nfs4_max_transfer_size);
850Sstevel@tonic-gate }
860Sstevel@tonic-gate
870Sstevel@tonic-gate uint_t
rfs4_tsize(struct svc_req * req)880Sstevel@tonic-gate rfs4_tsize(struct svc_req *req)
890Sstevel@tonic-gate {
900Sstevel@tonic-gate
910Sstevel@tonic-gate if (req->rq_xprt->xp_type == T_COTS_ORD ||
920Sstevel@tonic-gate req->rq_xprt->xp_type == T_COTS)
930Sstevel@tonic-gate return (nfs4_max_transfer_size_cots);
940Sstevel@tonic-gate if (req->rq_xprt->xp_type == T_RDMA)
950Sstevel@tonic-gate return (nfs4_max_transfer_size_rdma);
960Sstevel@tonic-gate return (nfs4_max_transfer_size);
970Sstevel@tonic-gate }
980Sstevel@tonic-gate
990Sstevel@tonic-gate int
nfs4_setopts(vnode_t * vp,model_t model,struct nfs_args * buf)1000Sstevel@tonic-gate nfs4_setopts(vnode_t *vp, model_t model, struct nfs_args *buf)
1010Sstevel@tonic-gate {
1020Sstevel@tonic-gate mntinfo4_t *mi; /* mount info, pointed at by vfs */
1030Sstevel@tonic-gate STRUCT_HANDLE(nfs_args, args);
1040Sstevel@tonic-gate int flags;
1050Sstevel@tonic-gate
1060Sstevel@tonic-gate #ifdef lint
1070Sstevel@tonic-gate model = model;
1080Sstevel@tonic-gate #endif
1090Sstevel@tonic-gate
1100Sstevel@tonic-gate STRUCT_SET_HANDLE(args, model, buf);
1110Sstevel@tonic-gate
1120Sstevel@tonic-gate flags = STRUCT_FGET(args, flags);
1130Sstevel@tonic-gate
1140Sstevel@tonic-gate /*
1150Sstevel@tonic-gate * Set option fields in mount info record
1160Sstevel@tonic-gate */
1170Sstevel@tonic-gate mi = VTOMI4(vp);
1180Sstevel@tonic-gate
1190Sstevel@tonic-gate
1200Sstevel@tonic-gate if (flags & NFSMNT_NOAC) {
1210Sstevel@tonic-gate mutex_enter(&mi->mi_lock);
1220Sstevel@tonic-gate mi->mi_flags |= MI4_NOAC;
1230Sstevel@tonic-gate mutex_exit(&mi->mi_lock);
1240Sstevel@tonic-gate PURGE_ATTRCACHE4(vp);
1250Sstevel@tonic-gate }
1260Sstevel@tonic-gate
1270Sstevel@tonic-gate mutex_enter(&mi->mi_lock);
1280Sstevel@tonic-gate if (flags & NFSMNT_NOCTO)
1290Sstevel@tonic-gate mi->mi_flags |= MI4_NOCTO;
1300Sstevel@tonic-gate if (flags & NFSMNT_LLOCK)
1310Sstevel@tonic-gate mi->mi_flags |= MI4_LLOCK;
1320Sstevel@tonic-gate if (flags & NFSMNT_GRPID)
1330Sstevel@tonic-gate mi->mi_flags |= MI4_GRPID;
1340Sstevel@tonic-gate mutex_exit(&mi->mi_lock);
1350Sstevel@tonic-gate
1360Sstevel@tonic-gate if (flags & NFSMNT_RETRANS) {
1370Sstevel@tonic-gate if (STRUCT_FGET(args, retrans) < 0)
1380Sstevel@tonic-gate return (EINVAL);
1390Sstevel@tonic-gate mi->mi_retrans = STRUCT_FGET(args, retrans);
1400Sstevel@tonic-gate }
1410Sstevel@tonic-gate if (flags & NFSMNT_TIMEO) {
1420Sstevel@tonic-gate if (STRUCT_FGET(args, timeo) <= 0)
1430Sstevel@tonic-gate return (EINVAL);
1440Sstevel@tonic-gate mi->mi_timeo = STRUCT_FGET(args, timeo);
1450Sstevel@tonic-gate }
1460Sstevel@tonic-gate if (flags & NFSMNT_RSIZE) {
1470Sstevel@tonic-gate if (STRUCT_FGET(args, rsize) <= 0)
1480Sstevel@tonic-gate return (EINVAL);
1490Sstevel@tonic-gate mi->mi_tsize = MIN(mi->mi_tsize, STRUCT_FGET(args, rsize));
1500Sstevel@tonic-gate mi->mi_curread = MIN(mi->mi_curread, mi->mi_tsize);
1510Sstevel@tonic-gate }
1520Sstevel@tonic-gate if (flags & NFSMNT_WSIZE) {
1530Sstevel@tonic-gate if (STRUCT_FGET(args, wsize) <= 0)
1540Sstevel@tonic-gate return (EINVAL);
1550Sstevel@tonic-gate mi->mi_stsize = MIN(mi->mi_stsize, STRUCT_FGET(args, wsize));
1560Sstevel@tonic-gate mi->mi_curwrite = MIN(mi->mi_curwrite, mi->mi_stsize);
1570Sstevel@tonic-gate }
1580Sstevel@tonic-gate if (flags & NFSMNT_ACREGMIN) {
1590Sstevel@tonic-gate if (STRUCT_FGET(args, acregmin) < 0)
1600Sstevel@tonic-gate mi->mi_acregmin = SEC2HR(ACMINMAX);
1610Sstevel@tonic-gate else
1620Sstevel@tonic-gate mi->mi_acregmin = SEC2HR(MIN(STRUCT_FGET(args,
16311291SRobert.Thurlow@Sun.COM acregmin), ACMINMAX));
1640Sstevel@tonic-gate }
1650Sstevel@tonic-gate if (flags & NFSMNT_ACREGMAX) {
1660Sstevel@tonic-gate if (STRUCT_FGET(args, acregmax) < 0)
1670Sstevel@tonic-gate mi->mi_acregmax = SEC2HR(ACMAXMAX);
1680Sstevel@tonic-gate else
1690Sstevel@tonic-gate mi->mi_acregmax = SEC2HR(MIN(STRUCT_FGET(args,
17011291SRobert.Thurlow@Sun.COM acregmax), ACMAXMAX));
1710Sstevel@tonic-gate }
1720Sstevel@tonic-gate if (flags & NFSMNT_ACDIRMIN) {
1730Sstevel@tonic-gate if (STRUCT_FGET(args, acdirmin) < 0)
1740Sstevel@tonic-gate mi->mi_acdirmin = SEC2HR(ACMINMAX);
1750Sstevel@tonic-gate else
1760Sstevel@tonic-gate mi->mi_acdirmin = SEC2HR(MIN(STRUCT_FGET(args,
17711291SRobert.Thurlow@Sun.COM acdirmin), ACMINMAX));
1780Sstevel@tonic-gate }
1790Sstevel@tonic-gate if (flags & NFSMNT_ACDIRMAX) {
1800Sstevel@tonic-gate if (STRUCT_FGET(args, acdirmax) < 0)
1810Sstevel@tonic-gate mi->mi_acdirmax = SEC2HR(ACMAXMAX);
1820Sstevel@tonic-gate else
1830Sstevel@tonic-gate mi->mi_acdirmax = SEC2HR(MIN(STRUCT_FGET(args,
18411291SRobert.Thurlow@Sun.COM acdirmax), ACMAXMAX));
1850Sstevel@tonic-gate }
1860Sstevel@tonic-gate
1870Sstevel@tonic-gate return (0);
1880Sstevel@tonic-gate }
1890Sstevel@tonic-gate
1900Sstevel@tonic-gate /*
1910Sstevel@tonic-gate * This returns 1 if the seqid should be bumped upon receiving this
1920Sstevel@tonic-gate * 'res->status' for a seqid dependent operation; otherwise return 0.
1930Sstevel@tonic-gate */
1940Sstevel@tonic-gate int
nfs4_need_to_bump_seqid(COMPOUND4res_clnt * res)1950Sstevel@tonic-gate nfs4_need_to_bump_seqid(COMPOUND4res_clnt *res)
1960Sstevel@tonic-gate {
1970Sstevel@tonic-gate int i, seqid_dep_op = 0;
1980Sstevel@tonic-gate nfs_resop4 *resop;
1990Sstevel@tonic-gate
2000Sstevel@tonic-gate resop = res->array;
2010Sstevel@tonic-gate
2020Sstevel@tonic-gate for (i = 0; i < res->array_len; i++) {
2030Sstevel@tonic-gate switch (resop[i].resop) {
2040Sstevel@tonic-gate case OP_CLOSE:
2050Sstevel@tonic-gate case OP_OPEN:
2060Sstevel@tonic-gate case OP_OPEN_CONFIRM:
2070Sstevel@tonic-gate case OP_OPEN_DOWNGRADE:
2080Sstevel@tonic-gate case OP_LOCK:
2090Sstevel@tonic-gate case OP_LOCKU:
2100Sstevel@tonic-gate seqid_dep_op = 1;
2110Sstevel@tonic-gate break;
2120Sstevel@tonic-gate default:
2130Sstevel@tonic-gate continue;
2140Sstevel@tonic-gate }
2150Sstevel@tonic-gate }
2160Sstevel@tonic-gate
2170Sstevel@tonic-gate if (!seqid_dep_op)
2180Sstevel@tonic-gate return (0);
2190Sstevel@tonic-gate
2200Sstevel@tonic-gate switch (res->status) {
2210Sstevel@tonic-gate case NFS4ERR_STALE_CLIENTID:
2220Sstevel@tonic-gate case NFS4ERR_STALE_STATEID:
2230Sstevel@tonic-gate case NFS4ERR_BAD_STATEID:
2240Sstevel@tonic-gate case NFS4ERR_BAD_SEQID:
2250Sstevel@tonic-gate case NFS4ERR_BADXDR:
2260Sstevel@tonic-gate case NFS4ERR_OLD_STATEID:
2270Sstevel@tonic-gate case NFS4ERR_RESOURCE:
2280Sstevel@tonic-gate case NFS4ERR_NOFILEHANDLE:
2290Sstevel@tonic-gate return (0);
2300Sstevel@tonic-gate default:
2310Sstevel@tonic-gate return (1);
2320Sstevel@tonic-gate }
2330Sstevel@tonic-gate }
2340Sstevel@tonic-gate
2350Sstevel@tonic-gate /*
2360Sstevel@tonic-gate * Returns 1 if the error is a RPC error that we should retry.
2370Sstevel@tonic-gate */
2380Sstevel@tonic-gate int
nfs4_rpc_retry_error(int error)2390Sstevel@tonic-gate nfs4_rpc_retry_error(int error)
2400Sstevel@tonic-gate {
2410Sstevel@tonic-gate switch (error) {
2420Sstevel@tonic-gate case ETIMEDOUT:
2430Sstevel@tonic-gate case ECONNREFUSED:
2440Sstevel@tonic-gate case ENETDOWN:
2450Sstevel@tonic-gate case ENETUNREACH:
2460Sstevel@tonic-gate case ENETRESET:
2470Sstevel@tonic-gate case ECONNABORTED:
2480Sstevel@tonic-gate case EHOSTUNREACH:
2490Sstevel@tonic-gate case ECONNRESET:
2500Sstevel@tonic-gate return (1);
2510Sstevel@tonic-gate default:
2520Sstevel@tonic-gate return (0);
2530Sstevel@tonic-gate }
2540Sstevel@tonic-gate }
2550Sstevel@tonic-gate
2560Sstevel@tonic-gate char *
nfs4_stat_to_str(nfsstat4 error)2570Sstevel@tonic-gate nfs4_stat_to_str(nfsstat4 error)
2580Sstevel@tonic-gate {
2590Sstevel@tonic-gate static char buf[40];
2600Sstevel@tonic-gate
2610Sstevel@tonic-gate switch (error) {
2620Sstevel@tonic-gate case NFS4_OK:
2630Sstevel@tonic-gate return ("NFS4_OK");
2640Sstevel@tonic-gate case NFS4ERR_PERM:
2650Sstevel@tonic-gate return ("NFS4ERR_PERM");
2660Sstevel@tonic-gate case NFS4ERR_NOENT:
2670Sstevel@tonic-gate return ("NFS4ERR_NOENT");
2680Sstevel@tonic-gate case NFS4ERR_IO:
2690Sstevel@tonic-gate return ("NFS4ERR_IO");
2700Sstevel@tonic-gate case NFS4ERR_NXIO:
2710Sstevel@tonic-gate return ("NFS4ERR_NXIO");
2720Sstevel@tonic-gate case NFS4ERR_ACCESS:
2730Sstevel@tonic-gate return ("NFS4ERR_ACCESS");
2740Sstevel@tonic-gate case NFS4ERR_EXIST:
2750Sstevel@tonic-gate return ("NFS4ERR_EXIST");
2760Sstevel@tonic-gate case NFS4ERR_XDEV:
2770Sstevel@tonic-gate return ("NFS4ERR_XDEV");
2780Sstevel@tonic-gate case NFS4ERR_NOTDIR:
2790Sstevel@tonic-gate return ("NFS4ERR_NOTDIR");
2800Sstevel@tonic-gate case NFS4ERR_ISDIR:
2810Sstevel@tonic-gate return ("NFS4ERR_ISDIR");
2820Sstevel@tonic-gate case NFS4ERR_INVAL:
2830Sstevel@tonic-gate return ("NFS4ERR_INVAL");
2840Sstevel@tonic-gate case NFS4ERR_FBIG:
2850Sstevel@tonic-gate return ("NFS4ERR_FBIG");
2860Sstevel@tonic-gate case NFS4ERR_NOSPC:
2870Sstevel@tonic-gate return ("NFS4ERR_NOSPC");
2880Sstevel@tonic-gate case NFS4ERR_ROFS:
2890Sstevel@tonic-gate return ("NFS4ERR_ROFS");
2900Sstevel@tonic-gate case NFS4ERR_MLINK:
2910Sstevel@tonic-gate return ("NFS4ERR_MLINK");
2920Sstevel@tonic-gate case NFS4ERR_NAMETOOLONG:
2930Sstevel@tonic-gate return ("NFS4ERR_NAMETOOLONG");
2940Sstevel@tonic-gate case NFS4ERR_NOTEMPTY:
2950Sstevel@tonic-gate return ("NFSS4ERR_NOTEMPTY");
2960Sstevel@tonic-gate case NFS4ERR_DQUOT:
2970Sstevel@tonic-gate return ("NFS4ERR_DQUOT");
2980Sstevel@tonic-gate case NFS4ERR_STALE:
2990Sstevel@tonic-gate return ("NFS4ERR_STALE");
3000Sstevel@tonic-gate case NFS4ERR_BADHANDLE:
3010Sstevel@tonic-gate return ("NFS4ERR_BADHANDLE");
3020Sstevel@tonic-gate case NFS4ERR_BAD_COOKIE:
3030Sstevel@tonic-gate return ("NFS4ERR_BAD_COOKIE");
3040Sstevel@tonic-gate case NFS4ERR_NOTSUPP:
3050Sstevel@tonic-gate return ("NFS4ERR_NOTSUPP");
3060Sstevel@tonic-gate case NFS4ERR_TOOSMALL:
3070Sstevel@tonic-gate return ("NFS4ERR_TOOSMALL");
3080Sstevel@tonic-gate case NFS4ERR_SERVERFAULT:
3090Sstevel@tonic-gate return ("NFS4ERR_SERVERFAULT");
3100Sstevel@tonic-gate case NFS4ERR_BADTYPE:
3110Sstevel@tonic-gate return ("NFS4ERR_BADTYPE");
3120Sstevel@tonic-gate case NFS4ERR_DELAY:
3130Sstevel@tonic-gate return ("NFS4ERR_DELAY");
3140Sstevel@tonic-gate case NFS4ERR_SAME:
3150Sstevel@tonic-gate return ("NFS4ERR_SAME");
3160Sstevel@tonic-gate case NFS4ERR_DENIED:
3170Sstevel@tonic-gate return ("NFS4ERR_DENIED");
3180Sstevel@tonic-gate case NFS4ERR_EXPIRED:
3190Sstevel@tonic-gate return ("NFS4ERR_EXPIRED");
3200Sstevel@tonic-gate case NFS4ERR_LOCKED:
3210Sstevel@tonic-gate return ("NFS4ERR_LOCKED");
3220Sstevel@tonic-gate case NFS4ERR_GRACE:
3230Sstevel@tonic-gate return ("NFS4ERR_GRACE");
3240Sstevel@tonic-gate case NFS4ERR_FHEXPIRED:
3250Sstevel@tonic-gate return ("NFS4ERR_FHEXPIRED");
3260Sstevel@tonic-gate case NFS4ERR_SHARE_DENIED:
3270Sstevel@tonic-gate return ("NFS4ERR_SHARE_DENIED");
3280Sstevel@tonic-gate case NFS4ERR_WRONGSEC:
3290Sstevel@tonic-gate return ("NFS4ERR_WRONGSEC");
3300Sstevel@tonic-gate case NFS4ERR_CLID_INUSE:
3310Sstevel@tonic-gate return ("NFS4ERR_CLID_INUSE");
3320Sstevel@tonic-gate case NFS4ERR_RESOURCE:
3330Sstevel@tonic-gate return ("NFS4ERR_RESOURCE");
3340Sstevel@tonic-gate case NFS4ERR_MOVED:
3350Sstevel@tonic-gate return ("NFS4ERR_MOVED");
3360Sstevel@tonic-gate case NFS4ERR_NOFILEHANDLE:
3370Sstevel@tonic-gate return ("NFS4ERR_NOFILEHANDLE");
3380Sstevel@tonic-gate case NFS4ERR_MINOR_VERS_MISMATCH:
3390Sstevel@tonic-gate return ("NFS4ERR_MINOR_VERS_MISMATCH");
3400Sstevel@tonic-gate case NFS4ERR_STALE_CLIENTID:
3410Sstevel@tonic-gate return ("NFS4ERR_STALE_CLIENTID");
3420Sstevel@tonic-gate case NFS4ERR_STALE_STATEID:
3430Sstevel@tonic-gate return ("NFS4ERR_STALE_STATEID");
3440Sstevel@tonic-gate case NFS4ERR_OLD_STATEID:
3450Sstevel@tonic-gate return ("NFS4ERR_OLD_STATEID");
3460Sstevel@tonic-gate case NFS4ERR_BAD_STATEID:
3470Sstevel@tonic-gate return ("NFS4ERR_BAD_STATEID");
3480Sstevel@tonic-gate case NFS4ERR_BAD_SEQID:
3490Sstevel@tonic-gate return ("NFS4ERR_BAD_SEQID");
3500Sstevel@tonic-gate case NFS4ERR_NOT_SAME:
3510Sstevel@tonic-gate return ("NFS4ERR_NOT_SAME");
3520Sstevel@tonic-gate case NFS4ERR_LOCK_RANGE:
3530Sstevel@tonic-gate return ("NFS4ERR_LOCK_RANGE");
3540Sstevel@tonic-gate case NFS4ERR_SYMLINK:
3550Sstevel@tonic-gate return ("NFS4ERR_SYMLINK");
3560Sstevel@tonic-gate case NFS4ERR_RESTOREFH:
3570Sstevel@tonic-gate return ("NFS4ERR_RESTOREFH");
3580Sstevel@tonic-gate case NFS4ERR_LEASE_MOVED:
3590Sstevel@tonic-gate return ("NFS4ERR_LEASE_MOVED");
3600Sstevel@tonic-gate case NFS4ERR_ATTRNOTSUPP:
3610Sstevel@tonic-gate return ("NFS4ERR_ATTRNOTSUPP");
3620Sstevel@tonic-gate case NFS4ERR_NO_GRACE:
3630Sstevel@tonic-gate return ("NFS4ERR_NO_GRACE");
3640Sstevel@tonic-gate case NFS4ERR_RECLAIM_BAD:
3650Sstevel@tonic-gate return ("NFS4ERR_RECLAIM_BAD");
3660Sstevel@tonic-gate case NFS4ERR_RECLAIM_CONFLICT:
3670Sstevel@tonic-gate return ("NFS4ERR_RECLAIM_CONFLICT");
3680Sstevel@tonic-gate case NFS4ERR_BADXDR:
3690Sstevel@tonic-gate return ("NFS4ERR_BADXDR");
3700Sstevel@tonic-gate case NFS4ERR_LOCKS_HELD:
3710Sstevel@tonic-gate return ("NFS4ERR_LOCKS_HELD");
3720Sstevel@tonic-gate case NFS4ERR_OPENMODE:
3730Sstevel@tonic-gate return ("NFS4ERR_OPENMODE");
3740Sstevel@tonic-gate case NFS4ERR_BADOWNER:
3750Sstevel@tonic-gate return ("NFS4ERR_BADOWNER");
3760Sstevel@tonic-gate case NFS4ERR_BADCHAR:
3770Sstevel@tonic-gate return ("NFS4ERR_BADCHAR");
3780Sstevel@tonic-gate case NFS4ERR_BADNAME:
3790Sstevel@tonic-gate return ("NFS4ERR_BADNAME");
3800Sstevel@tonic-gate case NFS4ERR_BAD_RANGE:
3810Sstevel@tonic-gate return ("NFS4ERR_BAD_RANGE");
3820Sstevel@tonic-gate case NFS4ERR_LOCK_NOTSUPP:
3830Sstevel@tonic-gate return ("NFS4ERR_LOCK_NOTSUPP");
3840Sstevel@tonic-gate case NFS4ERR_OP_ILLEGAL:
3850Sstevel@tonic-gate return ("NFS4ERR_OP_ILLEGAL");
3860Sstevel@tonic-gate case NFS4ERR_DEADLOCK:
3870Sstevel@tonic-gate return ("NFS4ERR_DEADLOCK");
3880Sstevel@tonic-gate case NFS4ERR_FILE_OPEN:
3890Sstevel@tonic-gate return ("NFS4ERR_FILE_OPEN");
3900Sstevel@tonic-gate case NFS4ERR_ADMIN_REVOKED:
3910Sstevel@tonic-gate return ("NFS4ERR_ADMIN_REVOKED");
3920Sstevel@tonic-gate case NFS4ERR_CB_PATH_DOWN:
3930Sstevel@tonic-gate return ("NFS4ERR_CB_PATH_DOWN");
3940Sstevel@tonic-gate default:
3950Sstevel@tonic-gate (void) snprintf(buf, 40, "Unknown error %d", (int)error);
3960Sstevel@tonic-gate return (buf);
3970Sstevel@tonic-gate }
3980Sstevel@tonic-gate }
3990Sstevel@tonic-gate
4000Sstevel@tonic-gate char *
nfs4_recov_action_to_str(nfs4_recov_t what)4010Sstevel@tonic-gate nfs4_recov_action_to_str(nfs4_recov_t what)
4020Sstevel@tonic-gate {
4030Sstevel@tonic-gate static char buf[40];
4040Sstevel@tonic-gate
4050Sstevel@tonic-gate switch (what) {
4060Sstevel@tonic-gate case NR_STALE:
4070Sstevel@tonic-gate return ("NR_STALE");
4080Sstevel@tonic-gate case NR_FAILOVER:
4090Sstevel@tonic-gate return ("NR_FAILOVER");
4100Sstevel@tonic-gate case NR_CLIENTID:
4110Sstevel@tonic-gate return ("NR_CLIENTID");
4120Sstevel@tonic-gate case NR_OPENFILES:
4130Sstevel@tonic-gate return ("NR_OPENFILES");
4140Sstevel@tonic-gate case NR_WRONGSEC:
4150Sstevel@tonic-gate return ("NR_WRONGSEC");
4160Sstevel@tonic-gate case NR_EXPIRED:
4170Sstevel@tonic-gate return ("NR_EXPIRED");
4180Sstevel@tonic-gate case NR_BAD_STATEID:
4190Sstevel@tonic-gate return ("NR_BAD_STATEID");
4200Sstevel@tonic-gate case NR_FHEXPIRED:
4210Sstevel@tonic-gate return ("NR_FHEXPIRED");
4220Sstevel@tonic-gate case NR_BADHANDLE:
4230Sstevel@tonic-gate return ("NR_BADHANDLE");
4240Sstevel@tonic-gate case NR_BAD_SEQID:
4250Sstevel@tonic-gate return ("NR_BAD_SEQID");
4260Sstevel@tonic-gate case NR_OLDSTATEID:
4270Sstevel@tonic-gate return ("NR_OLDSTATEID");
4280Sstevel@tonic-gate case NR_GRACE:
4290Sstevel@tonic-gate return ("NR_GRACE");
4300Sstevel@tonic-gate case NR_DELAY:
4310Sstevel@tonic-gate return ("NR_DELAY");
4320Sstevel@tonic-gate case NR_LOST_LOCK:
4330Sstevel@tonic-gate return ("NR_LOST_LOCK");
4340Sstevel@tonic-gate case NR_LOST_STATE_RQST:
4350Sstevel@tonic-gate return ("NR_LOST_STATE_RQST");
43611291SRobert.Thurlow@Sun.COM case NR_MOVED:
43711291SRobert.Thurlow@Sun.COM return ("NR_MOVED");
4380Sstevel@tonic-gate default:
4390Sstevel@tonic-gate (void) snprintf(buf, 40, "Unknown, code %d", (int)what);
4400Sstevel@tonic-gate return (buf);
4410Sstevel@tonic-gate }
4420Sstevel@tonic-gate }
4430Sstevel@tonic-gate
4440Sstevel@tonic-gate char *
nfs4_op_to_str(nfs_opnum4 op)4450Sstevel@tonic-gate nfs4_op_to_str(nfs_opnum4 op)
4460Sstevel@tonic-gate {
4470Sstevel@tonic-gate static char buf[40];
4480Sstevel@tonic-gate
4490Sstevel@tonic-gate switch (REAL_OP4(op)) {
4500Sstevel@tonic-gate case OP_ACCESS:
4510Sstevel@tonic-gate return ("OP_ACCESS");
4520Sstevel@tonic-gate case OP_CLOSE:
4530Sstevel@tonic-gate return ("OP_CLOSE");
4540Sstevel@tonic-gate case OP_COMMIT:
4550Sstevel@tonic-gate return ("OP_COMMIT");
4560Sstevel@tonic-gate case OP_CREATE:
4570Sstevel@tonic-gate return ("OP_CREATE");
4580Sstevel@tonic-gate case OP_DELEGPURGE:
4590Sstevel@tonic-gate return ("OP_DELEGPURGE");
4600Sstevel@tonic-gate case OP_DELEGRETURN:
4610Sstevel@tonic-gate return ("OP_DELEGRETURN");
4620Sstevel@tonic-gate case OP_GETATTR:
4630Sstevel@tonic-gate return ("OP_GETATTR");
4640Sstevel@tonic-gate case OP_GETFH:
4650Sstevel@tonic-gate return ("OP_GETFH");
4660Sstevel@tonic-gate case OP_LINK:
4670Sstevel@tonic-gate return ("OP_LINK");
4680Sstevel@tonic-gate case OP_LOCK:
4690Sstevel@tonic-gate return ("OP_LOCK");
4700Sstevel@tonic-gate case OP_LOCKT:
4710Sstevel@tonic-gate return ("OP_LOCKT");
4720Sstevel@tonic-gate case OP_LOCKU:
4730Sstevel@tonic-gate return ("OP_LOCKU");
4740Sstevel@tonic-gate case OP_LOOKUP:
4750Sstevel@tonic-gate return ("OP_LOOKUP");
4760Sstevel@tonic-gate case OP_LOOKUPP:
4770Sstevel@tonic-gate return ("OP_LOOKUPP");
4780Sstevel@tonic-gate case OP_NVERIFY:
4790Sstevel@tonic-gate return ("OP_NVERIFY");
4800Sstevel@tonic-gate case OP_OPEN:
4810Sstevel@tonic-gate return ("OP_OPEN");
4820Sstevel@tonic-gate case OP_OPENATTR:
4830Sstevel@tonic-gate return ("OP_OPENATTR");
4840Sstevel@tonic-gate case OP_OPEN_CONFIRM:
4850Sstevel@tonic-gate return ("OP_OPEN_CONFIRM");
4860Sstevel@tonic-gate case OP_OPEN_DOWNGRADE:
4870Sstevel@tonic-gate return ("OP_OPEN_DOWNGRADE");
4880Sstevel@tonic-gate case OP_PUTFH:
4890Sstevel@tonic-gate return ("OP_PUTFH");
4900Sstevel@tonic-gate case OP_PUTPUBFH:
4910Sstevel@tonic-gate return ("OP_PUTPUBFH");
4920Sstevel@tonic-gate case OP_PUTROOTFH:
4930Sstevel@tonic-gate return ("OP_PUTROOTFH");
4940Sstevel@tonic-gate case OP_READ:
4950Sstevel@tonic-gate return ("OP_READ");
4960Sstevel@tonic-gate case OP_READDIR:
4970Sstevel@tonic-gate return ("OP_READDIR");
4980Sstevel@tonic-gate case OP_READLINK:
4990Sstevel@tonic-gate return ("OP_READLINK");
5000Sstevel@tonic-gate case OP_REMOVE:
5010Sstevel@tonic-gate return ("OP_REMOVE");
5020Sstevel@tonic-gate case OP_RENAME:
5030Sstevel@tonic-gate return ("OP_RENAME");
5040Sstevel@tonic-gate case OP_RENEW:
5050Sstevel@tonic-gate return ("OP_RENEW");
5060Sstevel@tonic-gate case OP_RESTOREFH:
5070Sstevel@tonic-gate return ("OP_RESTOREFH");
5080Sstevel@tonic-gate case OP_SAVEFH:
5090Sstevel@tonic-gate return ("OP_SAVEFH");
5100Sstevel@tonic-gate case OP_SECINFO:
5110Sstevel@tonic-gate return ("OP_SECINFO");
5120Sstevel@tonic-gate case OP_SETATTR:
5130Sstevel@tonic-gate return ("OP_SETATTR");
5140Sstevel@tonic-gate case OP_SETCLIENTID:
5150Sstevel@tonic-gate return ("OP_SETCLIENTID");
5160Sstevel@tonic-gate case OP_SETCLIENTID_CONFIRM:
5170Sstevel@tonic-gate return ("OP_SETCLIENTID_CONFIRM");
5180Sstevel@tonic-gate case OP_VERIFY:
5190Sstevel@tonic-gate return ("OP_VERIFY");
5200Sstevel@tonic-gate case OP_WRITE:
5210Sstevel@tonic-gate return ("OP_WRITE");
5220Sstevel@tonic-gate case OP_RELEASE_LOCKOWNER:
5230Sstevel@tonic-gate return ("OP_RELEASE_LOCKOWNER");
5240Sstevel@tonic-gate case OP_ILLEGAL:
5250Sstevel@tonic-gate return ("OP_ILLEGAL");
5260Sstevel@tonic-gate default:
5270Sstevel@tonic-gate (void) snprintf(buf, 40, "Unknown op %d", (int)op);
5280Sstevel@tonic-gate return (buf);
5290Sstevel@tonic-gate }
5300Sstevel@tonic-gate }
531