17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55a59a8b3Srsb * Common Development and Distribution License (the "License"). 65a59a8b3Srsb * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 220fbb751dSJohn Levon * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 235206eae7SVitaliy Gusev * 245206eae7SVitaliy Gusev * Copyright 2011, 2012 Nexenta Systems, Inc. All rights reserved. 25*8cd81a20SJerry Jelinek * Copyright 2013 Joyent, Inc. All rights reserved. 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * This is the loadable module wrapper. 307c478bd9Sstevel@tonic-gate */ 317c478bd9Sstevel@tonic-gate #include <sys/systm.h> 327c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 337c478bd9Sstevel@tonic-gate #include <sys/syscall.h> 347c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 357c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <nfs/nfs.h> 387c478bd9Sstevel@tonic-gate #include <nfs/nfs_clnt.h> 397c478bd9Sstevel@tonic-gate #include <nfs/nfs4.h> 407c478bd9Sstevel@tonic-gate #include <nfs/rnode4.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * The global tag list. 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate ctag_t nfs4_ctags[] = NFS4_TAG_INITIALIZER; 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * The NFS Version 4 client VFS. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate static vfsdef_t vfw4 = { 517c478bd9Sstevel@tonic-gate VFSDEF_VERSION, 527c478bd9Sstevel@tonic-gate "nfs4", 537c478bd9Sstevel@tonic-gate nfs4init, 54*8cd81a20SJerry Jelinek VSW_CANREMOUNT|VSW_NOTZONESAFE|VSW_STATS, 557c478bd9Sstevel@tonic-gate NULL 567c478bd9Sstevel@tonic-gate }; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate struct modlfs modlfs4 = { 597c478bd9Sstevel@tonic-gate &mod_fsops, 607c478bd9Sstevel@tonic-gate "network filesystem version 4", 617c478bd9Sstevel@tonic-gate &vfw4 627c478bd9Sstevel@tonic-gate }; 637c478bd9Sstevel@tonic-gate 645206eae7SVitaliy Gusev uint_t nfs4_max_transfer_size = 32 * 1024; 655206eae7SVitaliy Gusev uint_t nfs4_max_transfer_size_cots = 1024 * 1024; 665206eae7SVitaliy Gusev uint_t nfs4_max_transfer_size_rdma = 1024 * 1024; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate int 697c478bd9Sstevel@tonic-gate nfs4tsize(void) 707c478bd9Sstevel@tonic-gate { 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * For the moment, just return nfs4_max_transfer_size until we 737c478bd9Sstevel@tonic-gate * can query the appropriate transport. 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate return (nfs4_max_transfer_size); 767c478bd9Sstevel@tonic-gate } 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate uint_t 797c478bd9Sstevel@tonic-gate nfs4_tsize(struct knetconfig *knp) 807c478bd9Sstevel@tonic-gate { 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate if (knp->knc_semantics == NC_TPI_COTS_ORD || 837c478bd9Sstevel@tonic-gate knp->knc_semantics == NC_TPI_COTS) 847c478bd9Sstevel@tonic-gate return (nfs4_max_transfer_size_cots); 857c478bd9Sstevel@tonic-gate if (knp->knc_semantics == NC_TPI_RDMA) 867c478bd9Sstevel@tonic-gate return (nfs4_max_transfer_size_rdma); 877c478bd9Sstevel@tonic-gate return (nfs4_max_transfer_size); 887c478bd9Sstevel@tonic-gate } 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate uint_t 917c478bd9Sstevel@tonic-gate rfs4_tsize(struct svc_req *req) 927c478bd9Sstevel@tonic-gate { 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate if (req->rq_xprt->xp_type == T_COTS_ORD || 957c478bd9Sstevel@tonic-gate req->rq_xprt->xp_type == T_COTS) 967c478bd9Sstevel@tonic-gate return (nfs4_max_transfer_size_cots); 977c478bd9Sstevel@tonic-gate if (req->rq_xprt->xp_type == T_RDMA) 987c478bd9Sstevel@tonic-gate return (nfs4_max_transfer_size_rdma); 997c478bd9Sstevel@tonic-gate return (nfs4_max_transfer_size); 1007c478bd9Sstevel@tonic-gate } 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate int 1037c478bd9Sstevel@tonic-gate nfs4_setopts(vnode_t *vp, model_t model, struct nfs_args *buf) 1047c478bd9Sstevel@tonic-gate { 1057c478bd9Sstevel@tonic-gate mntinfo4_t *mi; /* mount info, pointed at by vfs */ 1067c478bd9Sstevel@tonic-gate STRUCT_HANDLE(nfs_args, args); 1077c478bd9Sstevel@tonic-gate int flags; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #ifdef lint 1107c478bd9Sstevel@tonic-gate model = model; 1117c478bd9Sstevel@tonic-gate #endif 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate STRUCT_SET_HANDLE(args, model, buf); 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate flags = STRUCT_FGET(args, flags); 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * Set option fields in mount info record 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate mi = VTOMI4(vp); 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate if (flags & NFSMNT_NOAC) { 1247c478bd9Sstevel@tonic-gate mutex_enter(&mi->mi_lock); 1257c478bd9Sstevel@tonic-gate mi->mi_flags |= MI4_NOAC; 1267c478bd9Sstevel@tonic-gate mutex_exit(&mi->mi_lock); 1277c478bd9Sstevel@tonic-gate PURGE_ATTRCACHE4(vp); 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate mutex_enter(&mi->mi_lock); 1317c478bd9Sstevel@tonic-gate if (flags & NFSMNT_NOCTO) 1327c478bd9Sstevel@tonic-gate mi->mi_flags |= MI4_NOCTO; 1337c478bd9Sstevel@tonic-gate if (flags & NFSMNT_LLOCK) 1347c478bd9Sstevel@tonic-gate mi->mi_flags |= MI4_LLOCK; 1357c478bd9Sstevel@tonic-gate if (flags & NFSMNT_GRPID) 1367c478bd9Sstevel@tonic-gate mi->mi_flags |= MI4_GRPID; 1377c478bd9Sstevel@tonic-gate mutex_exit(&mi->mi_lock); 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate if (flags & NFSMNT_RETRANS) { 1407c478bd9Sstevel@tonic-gate if (STRUCT_FGET(args, retrans) < 0) 1417c478bd9Sstevel@tonic-gate return (EINVAL); 1427c478bd9Sstevel@tonic-gate mi->mi_retrans = STRUCT_FGET(args, retrans); 1437c478bd9Sstevel@tonic-gate } 1447c478bd9Sstevel@tonic-gate if (flags & NFSMNT_TIMEO) { 1457c478bd9Sstevel@tonic-gate if (STRUCT_FGET(args, timeo) <= 0) 1467c478bd9Sstevel@tonic-gate return (EINVAL); 1477c478bd9Sstevel@tonic-gate mi->mi_timeo = STRUCT_FGET(args, timeo); 1487c478bd9Sstevel@tonic-gate } 1497c478bd9Sstevel@tonic-gate if (flags & NFSMNT_RSIZE) { 1507c478bd9Sstevel@tonic-gate if (STRUCT_FGET(args, rsize) <= 0) 1517c478bd9Sstevel@tonic-gate return (EINVAL); 1527c478bd9Sstevel@tonic-gate mi->mi_tsize = MIN(mi->mi_tsize, STRUCT_FGET(args, rsize)); 1537c478bd9Sstevel@tonic-gate mi->mi_curread = MIN(mi->mi_curread, mi->mi_tsize); 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate if (flags & NFSMNT_WSIZE) { 1567c478bd9Sstevel@tonic-gate if (STRUCT_FGET(args, wsize) <= 0) 1577c478bd9Sstevel@tonic-gate return (EINVAL); 1587c478bd9Sstevel@tonic-gate mi->mi_stsize = MIN(mi->mi_stsize, STRUCT_FGET(args, wsize)); 1597c478bd9Sstevel@tonic-gate mi->mi_curwrite = MIN(mi->mi_curwrite, mi->mi_stsize); 1607c478bd9Sstevel@tonic-gate } 1617c478bd9Sstevel@tonic-gate if (flags & NFSMNT_ACREGMIN) { 1627c478bd9Sstevel@tonic-gate if (STRUCT_FGET(args, acregmin) < 0) 1637c478bd9Sstevel@tonic-gate mi->mi_acregmin = SEC2HR(ACMINMAX); 1647c478bd9Sstevel@tonic-gate else 1657c478bd9Sstevel@tonic-gate mi->mi_acregmin = SEC2HR(MIN(STRUCT_FGET(args, 1667c478bd9Sstevel@tonic-gate acregmin), ACMINMAX)); 1677c478bd9Sstevel@tonic-gate } 1687c478bd9Sstevel@tonic-gate if (flags & NFSMNT_ACREGMAX) { 1697c478bd9Sstevel@tonic-gate if (STRUCT_FGET(args, acregmax) < 0) 1707c478bd9Sstevel@tonic-gate mi->mi_acregmax = SEC2HR(ACMAXMAX); 1717c478bd9Sstevel@tonic-gate else 1727c478bd9Sstevel@tonic-gate mi->mi_acregmax = SEC2HR(MIN(STRUCT_FGET(args, 1737c478bd9Sstevel@tonic-gate acregmax), ACMAXMAX)); 1747c478bd9Sstevel@tonic-gate } 1757c478bd9Sstevel@tonic-gate if (flags & NFSMNT_ACDIRMIN) { 1767c478bd9Sstevel@tonic-gate if (STRUCT_FGET(args, acdirmin) < 0) 1777c478bd9Sstevel@tonic-gate mi->mi_acdirmin = SEC2HR(ACMINMAX); 1787c478bd9Sstevel@tonic-gate else 1797c478bd9Sstevel@tonic-gate mi->mi_acdirmin = SEC2HR(MIN(STRUCT_FGET(args, 1807c478bd9Sstevel@tonic-gate acdirmin), ACMINMAX)); 1817c478bd9Sstevel@tonic-gate } 1827c478bd9Sstevel@tonic-gate if (flags & NFSMNT_ACDIRMAX) { 1837c478bd9Sstevel@tonic-gate if (STRUCT_FGET(args, acdirmax) < 0) 1847c478bd9Sstevel@tonic-gate mi->mi_acdirmax = SEC2HR(ACMAXMAX); 1857c478bd9Sstevel@tonic-gate else 1867c478bd9Sstevel@tonic-gate mi->mi_acdirmax = SEC2HR(MIN(STRUCT_FGET(args, 1877c478bd9Sstevel@tonic-gate acdirmax), ACMAXMAX)); 1887c478bd9Sstevel@tonic-gate } 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate return (0); 1917c478bd9Sstevel@tonic-gate } 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate /* 1947c478bd9Sstevel@tonic-gate * This returns 1 if the seqid should be bumped upon receiving this 1957c478bd9Sstevel@tonic-gate * 'res->status' for a seqid dependent operation; otherwise return 0. 1967c478bd9Sstevel@tonic-gate */ 1977c478bd9Sstevel@tonic-gate int 1987c478bd9Sstevel@tonic-gate nfs4_need_to_bump_seqid(COMPOUND4res_clnt *res) 1997c478bd9Sstevel@tonic-gate { 2007c478bd9Sstevel@tonic-gate int i, seqid_dep_op = 0; 2017c478bd9Sstevel@tonic-gate nfs_resop4 *resop; 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate resop = res->array; 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate for (i = 0; i < res->array_len; i++) { 2067c478bd9Sstevel@tonic-gate switch (resop[i].resop) { 2077c478bd9Sstevel@tonic-gate case OP_CLOSE: 2087c478bd9Sstevel@tonic-gate case OP_OPEN: 2097c478bd9Sstevel@tonic-gate case OP_OPEN_CONFIRM: 2107c478bd9Sstevel@tonic-gate case OP_OPEN_DOWNGRADE: 2117c478bd9Sstevel@tonic-gate case OP_LOCK: 2127c478bd9Sstevel@tonic-gate case OP_LOCKU: 2137c478bd9Sstevel@tonic-gate seqid_dep_op = 1; 2147c478bd9Sstevel@tonic-gate break; 2157c478bd9Sstevel@tonic-gate default: 2167c478bd9Sstevel@tonic-gate continue; 2177c478bd9Sstevel@tonic-gate } 2187c478bd9Sstevel@tonic-gate } 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate if (!seqid_dep_op) 2217c478bd9Sstevel@tonic-gate return (0); 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate switch (res->status) { 2247c478bd9Sstevel@tonic-gate case NFS4ERR_STALE_CLIENTID: 2257c478bd9Sstevel@tonic-gate case NFS4ERR_STALE_STATEID: 2267c478bd9Sstevel@tonic-gate case NFS4ERR_BAD_STATEID: 2277c478bd9Sstevel@tonic-gate case NFS4ERR_BAD_SEQID: 2287c478bd9Sstevel@tonic-gate case NFS4ERR_BADXDR: 2297c478bd9Sstevel@tonic-gate case NFS4ERR_OLD_STATEID: 2307c478bd9Sstevel@tonic-gate case NFS4ERR_RESOURCE: 2317c478bd9Sstevel@tonic-gate case NFS4ERR_NOFILEHANDLE: 2327c478bd9Sstevel@tonic-gate return (0); 2337c478bd9Sstevel@tonic-gate default: 2347c478bd9Sstevel@tonic-gate return (1); 2357c478bd9Sstevel@tonic-gate } 2367c478bd9Sstevel@tonic-gate } 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate /* 2397c478bd9Sstevel@tonic-gate * Returns 1 if the error is a RPC error that we should retry. 2407c478bd9Sstevel@tonic-gate */ 2417c478bd9Sstevel@tonic-gate int 2427c478bd9Sstevel@tonic-gate nfs4_rpc_retry_error(int error) 2437c478bd9Sstevel@tonic-gate { 2447c478bd9Sstevel@tonic-gate switch (error) { 2457c478bd9Sstevel@tonic-gate case ETIMEDOUT: 2467c478bd9Sstevel@tonic-gate case ECONNREFUSED: 2477c478bd9Sstevel@tonic-gate case ENETDOWN: 2487c478bd9Sstevel@tonic-gate case ENETUNREACH: 2497c478bd9Sstevel@tonic-gate case ENETRESET: 2507c478bd9Sstevel@tonic-gate case ECONNABORTED: 2517c478bd9Sstevel@tonic-gate case EHOSTUNREACH: 2527c478bd9Sstevel@tonic-gate case ECONNRESET: 2537c478bd9Sstevel@tonic-gate return (1); 2547c478bd9Sstevel@tonic-gate default: 2557c478bd9Sstevel@tonic-gate return (0); 2567c478bd9Sstevel@tonic-gate } 2577c478bd9Sstevel@tonic-gate } 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate char * 2607c478bd9Sstevel@tonic-gate nfs4_stat_to_str(nfsstat4 error) 2617c478bd9Sstevel@tonic-gate { 2627c478bd9Sstevel@tonic-gate static char buf[40]; 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate switch (error) { 2657c478bd9Sstevel@tonic-gate case NFS4_OK: 2667c478bd9Sstevel@tonic-gate return ("NFS4_OK"); 2677c478bd9Sstevel@tonic-gate case NFS4ERR_PERM: 2687c478bd9Sstevel@tonic-gate return ("NFS4ERR_PERM"); 2697c478bd9Sstevel@tonic-gate case NFS4ERR_NOENT: 2707c478bd9Sstevel@tonic-gate return ("NFS4ERR_NOENT"); 2717c478bd9Sstevel@tonic-gate case NFS4ERR_IO: 2727c478bd9Sstevel@tonic-gate return ("NFS4ERR_IO"); 2737c478bd9Sstevel@tonic-gate case NFS4ERR_NXIO: 2747c478bd9Sstevel@tonic-gate return ("NFS4ERR_NXIO"); 2757c478bd9Sstevel@tonic-gate case NFS4ERR_ACCESS: 2767c478bd9Sstevel@tonic-gate return ("NFS4ERR_ACCESS"); 2777c478bd9Sstevel@tonic-gate case NFS4ERR_EXIST: 2787c478bd9Sstevel@tonic-gate return ("NFS4ERR_EXIST"); 2797c478bd9Sstevel@tonic-gate case NFS4ERR_XDEV: 2807c478bd9Sstevel@tonic-gate return ("NFS4ERR_XDEV"); 2817c478bd9Sstevel@tonic-gate case NFS4ERR_NOTDIR: 2827c478bd9Sstevel@tonic-gate return ("NFS4ERR_NOTDIR"); 2837c478bd9Sstevel@tonic-gate case NFS4ERR_ISDIR: 2847c478bd9Sstevel@tonic-gate return ("NFS4ERR_ISDIR"); 2857c478bd9Sstevel@tonic-gate case NFS4ERR_INVAL: 2867c478bd9Sstevel@tonic-gate return ("NFS4ERR_INVAL"); 2877c478bd9Sstevel@tonic-gate case NFS4ERR_FBIG: 2887c478bd9Sstevel@tonic-gate return ("NFS4ERR_FBIG"); 2897c478bd9Sstevel@tonic-gate case NFS4ERR_NOSPC: 2907c478bd9Sstevel@tonic-gate return ("NFS4ERR_NOSPC"); 2917c478bd9Sstevel@tonic-gate case NFS4ERR_ROFS: 2927c478bd9Sstevel@tonic-gate return ("NFS4ERR_ROFS"); 2937c478bd9Sstevel@tonic-gate case NFS4ERR_MLINK: 2947c478bd9Sstevel@tonic-gate return ("NFS4ERR_MLINK"); 2957c478bd9Sstevel@tonic-gate case NFS4ERR_NAMETOOLONG: 2967c478bd9Sstevel@tonic-gate return ("NFS4ERR_NAMETOOLONG"); 2977c478bd9Sstevel@tonic-gate case NFS4ERR_NOTEMPTY: 2987c478bd9Sstevel@tonic-gate return ("NFSS4ERR_NOTEMPTY"); 2997c478bd9Sstevel@tonic-gate case NFS4ERR_DQUOT: 3007c478bd9Sstevel@tonic-gate return ("NFS4ERR_DQUOT"); 3017c478bd9Sstevel@tonic-gate case NFS4ERR_STALE: 3027c478bd9Sstevel@tonic-gate return ("NFS4ERR_STALE"); 3037c478bd9Sstevel@tonic-gate case NFS4ERR_BADHANDLE: 3047c478bd9Sstevel@tonic-gate return ("NFS4ERR_BADHANDLE"); 3057c478bd9Sstevel@tonic-gate case NFS4ERR_BAD_COOKIE: 3067c478bd9Sstevel@tonic-gate return ("NFS4ERR_BAD_COOKIE"); 3077c478bd9Sstevel@tonic-gate case NFS4ERR_NOTSUPP: 3087c478bd9Sstevel@tonic-gate return ("NFS4ERR_NOTSUPP"); 3097c478bd9Sstevel@tonic-gate case NFS4ERR_TOOSMALL: 3107c478bd9Sstevel@tonic-gate return ("NFS4ERR_TOOSMALL"); 3117c478bd9Sstevel@tonic-gate case NFS4ERR_SERVERFAULT: 3127c478bd9Sstevel@tonic-gate return ("NFS4ERR_SERVERFAULT"); 3137c478bd9Sstevel@tonic-gate case NFS4ERR_BADTYPE: 3147c478bd9Sstevel@tonic-gate return ("NFS4ERR_BADTYPE"); 3157c478bd9Sstevel@tonic-gate case NFS4ERR_DELAY: 3167c478bd9Sstevel@tonic-gate return ("NFS4ERR_DELAY"); 3177c478bd9Sstevel@tonic-gate case NFS4ERR_SAME: 3187c478bd9Sstevel@tonic-gate return ("NFS4ERR_SAME"); 3197c478bd9Sstevel@tonic-gate case NFS4ERR_DENIED: 3207c478bd9Sstevel@tonic-gate return ("NFS4ERR_DENIED"); 3217c478bd9Sstevel@tonic-gate case NFS4ERR_EXPIRED: 3227c478bd9Sstevel@tonic-gate return ("NFS4ERR_EXPIRED"); 3237c478bd9Sstevel@tonic-gate case NFS4ERR_LOCKED: 3247c478bd9Sstevel@tonic-gate return ("NFS4ERR_LOCKED"); 3257c478bd9Sstevel@tonic-gate case NFS4ERR_GRACE: 3267c478bd9Sstevel@tonic-gate return ("NFS4ERR_GRACE"); 3277c478bd9Sstevel@tonic-gate case NFS4ERR_FHEXPIRED: 3287c478bd9Sstevel@tonic-gate return ("NFS4ERR_FHEXPIRED"); 3297c478bd9Sstevel@tonic-gate case NFS4ERR_SHARE_DENIED: 3307c478bd9Sstevel@tonic-gate return ("NFS4ERR_SHARE_DENIED"); 3317c478bd9Sstevel@tonic-gate case NFS4ERR_WRONGSEC: 3327c478bd9Sstevel@tonic-gate return ("NFS4ERR_WRONGSEC"); 3337c478bd9Sstevel@tonic-gate case NFS4ERR_CLID_INUSE: 3347c478bd9Sstevel@tonic-gate return ("NFS4ERR_CLID_INUSE"); 3357c478bd9Sstevel@tonic-gate case NFS4ERR_RESOURCE: 3367c478bd9Sstevel@tonic-gate return ("NFS4ERR_RESOURCE"); 3377c478bd9Sstevel@tonic-gate case NFS4ERR_MOVED: 3387c478bd9Sstevel@tonic-gate return ("NFS4ERR_MOVED"); 3397c478bd9Sstevel@tonic-gate case NFS4ERR_NOFILEHANDLE: 3407c478bd9Sstevel@tonic-gate return ("NFS4ERR_NOFILEHANDLE"); 3417c478bd9Sstevel@tonic-gate case NFS4ERR_MINOR_VERS_MISMATCH: 3427c478bd9Sstevel@tonic-gate return ("NFS4ERR_MINOR_VERS_MISMATCH"); 3437c478bd9Sstevel@tonic-gate case NFS4ERR_STALE_CLIENTID: 3447c478bd9Sstevel@tonic-gate return ("NFS4ERR_STALE_CLIENTID"); 3457c478bd9Sstevel@tonic-gate case NFS4ERR_STALE_STATEID: 3467c478bd9Sstevel@tonic-gate return ("NFS4ERR_STALE_STATEID"); 3477c478bd9Sstevel@tonic-gate case NFS4ERR_OLD_STATEID: 3487c478bd9Sstevel@tonic-gate return ("NFS4ERR_OLD_STATEID"); 3497c478bd9Sstevel@tonic-gate case NFS4ERR_BAD_STATEID: 3507c478bd9Sstevel@tonic-gate return ("NFS4ERR_BAD_STATEID"); 3517c478bd9Sstevel@tonic-gate case NFS4ERR_BAD_SEQID: 3527c478bd9Sstevel@tonic-gate return ("NFS4ERR_BAD_SEQID"); 3537c478bd9Sstevel@tonic-gate case NFS4ERR_NOT_SAME: 3547c478bd9Sstevel@tonic-gate return ("NFS4ERR_NOT_SAME"); 3557c478bd9Sstevel@tonic-gate case NFS4ERR_LOCK_RANGE: 3567c478bd9Sstevel@tonic-gate return ("NFS4ERR_LOCK_RANGE"); 3577c478bd9Sstevel@tonic-gate case NFS4ERR_SYMLINK: 3587c478bd9Sstevel@tonic-gate return ("NFS4ERR_SYMLINK"); 3597c478bd9Sstevel@tonic-gate case NFS4ERR_RESTOREFH: 3607c478bd9Sstevel@tonic-gate return ("NFS4ERR_RESTOREFH"); 3617c478bd9Sstevel@tonic-gate case NFS4ERR_LEASE_MOVED: 3627c478bd9Sstevel@tonic-gate return ("NFS4ERR_LEASE_MOVED"); 3637c478bd9Sstevel@tonic-gate case NFS4ERR_ATTRNOTSUPP: 3647c478bd9Sstevel@tonic-gate return ("NFS4ERR_ATTRNOTSUPP"); 3657c478bd9Sstevel@tonic-gate case NFS4ERR_NO_GRACE: 3667c478bd9Sstevel@tonic-gate return ("NFS4ERR_NO_GRACE"); 3677c478bd9Sstevel@tonic-gate case NFS4ERR_RECLAIM_BAD: 3687c478bd9Sstevel@tonic-gate return ("NFS4ERR_RECLAIM_BAD"); 3697c478bd9Sstevel@tonic-gate case NFS4ERR_RECLAIM_CONFLICT: 3707c478bd9Sstevel@tonic-gate return ("NFS4ERR_RECLAIM_CONFLICT"); 3717c478bd9Sstevel@tonic-gate case NFS4ERR_BADXDR: 3727c478bd9Sstevel@tonic-gate return ("NFS4ERR_BADXDR"); 3737c478bd9Sstevel@tonic-gate case NFS4ERR_LOCKS_HELD: 3747c478bd9Sstevel@tonic-gate return ("NFS4ERR_LOCKS_HELD"); 3757c478bd9Sstevel@tonic-gate case NFS4ERR_OPENMODE: 3767c478bd9Sstevel@tonic-gate return ("NFS4ERR_OPENMODE"); 3777c478bd9Sstevel@tonic-gate case NFS4ERR_BADOWNER: 3787c478bd9Sstevel@tonic-gate return ("NFS4ERR_BADOWNER"); 3797c478bd9Sstevel@tonic-gate case NFS4ERR_BADCHAR: 3807c478bd9Sstevel@tonic-gate return ("NFS4ERR_BADCHAR"); 3817c478bd9Sstevel@tonic-gate case NFS4ERR_BADNAME: 3827c478bd9Sstevel@tonic-gate return ("NFS4ERR_BADNAME"); 3837c478bd9Sstevel@tonic-gate case NFS4ERR_BAD_RANGE: 3847c478bd9Sstevel@tonic-gate return ("NFS4ERR_BAD_RANGE"); 3857c478bd9Sstevel@tonic-gate case NFS4ERR_LOCK_NOTSUPP: 3867c478bd9Sstevel@tonic-gate return ("NFS4ERR_LOCK_NOTSUPP"); 3877c478bd9Sstevel@tonic-gate case NFS4ERR_OP_ILLEGAL: 3887c478bd9Sstevel@tonic-gate return ("NFS4ERR_OP_ILLEGAL"); 3897c478bd9Sstevel@tonic-gate case NFS4ERR_DEADLOCK: 3907c478bd9Sstevel@tonic-gate return ("NFS4ERR_DEADLOCK"); 3917c478bd9Sstevel@tonic-gate case NFS4ERR_FILE_OPEN: 3927c478bd9Sstevel@tonic-gate return ("NFS4ERR_FILE_OPEN"); 3937c478bd9Sstevel@tonic-gate case NFS4ERR_ADMIN_REVOKED: 3947c478bd9Sstevel@tonic-gate return ("NFS4ERR_ADMIN_REVOKED"); 3957c478bd9Sstevel@tonic-gate case NFS4ERR_CB_PATH_DOWN: 3967c478bd9Sstevel@tonic-gate return ("NFS4ERR_CB_PATH_DOWN"); 3977c478bd9Sstevel@tonic-gate default: 3987c478bd9Sstevel@tonic-gate (void) snprintf(buf, 40, "Unknown error %d", (int)error); 3997c478bd9Sstevel@tonic-gate return (buf); 4007c478bd9Sstevel@tonic-gate } 4017c478bd9Sstevel@tonic-gate } 4027c478bd9Sstevel@tonic-gate 4037c478bd9Sstevel@tonic-gate char * 4047c478bd9Sstevel@tonic-gate nfs4_recov_action_to_str(nfs4_recov_t what) 4057c478bd9Sstevel@tonic-gate { 4067c478bd9Sstevel@tonic-gate static char buf[40]; 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate switch (what) { 4097c478bd9Sstevel@tonic-gate case NR_STALE: 4107c478bd9Sstevel@tonic-gate return ("NR_STALE"); 4117c478bd9Sstevel@tonic-gate case NR_FAILOVER: 4127c478bd9Sstevel@tonic-gate return ("NR_FAILOVER"); 4137c478bd9Sstevel@tonic-gate case NR_CLIENTID: 4147c478bd9Sstevel@tonic-gate return ("NR_CLIENTID"); 4157c478bd9Sstevel@tonic-gate case NR_OPENFILES: 4167c478bd9Sstevel@tonic-gate return ("NR_OPENFILES"); 4177c478bd9Sstevel@tonic-gate case NR_WRONGSEC: 4187c478bd9Sstevel@tonic-gate return ("NR_WRONGSEC"); 4197c478bd9Sstevel@tonic-gate case NR_EXPIRED: 4207c478bd9Sstevel@tonic-gate return ("NR_EXPIRED"); 4217c478bd9Sstevel@tonic-gate case NR_BAD_STATEID: 4227c478bd9Sstevel@tonic-gate return ("NR_BAD_STATEID"); 4237c478bd9Sstevel@tonic-gate case NR_FHEXPIRED: 4247c478bd9Sstevel@tonic-gate return ("NR_FHEXPIRED"); 4257c478bd9Sstevel@tonic-gate case NR_BADHANDLE: 4267c478bd9Sstevel@tonic-gate return ("NR_BADHANDLE"); 4277c478bd9Sstevel@tonic-gate case NR_BAD_SEQID: 4287c478bd9Sstevel@tonic-gate return ("NR_BAD_SEQID"); 4297c478bd9Sstevel@tonic-gate case NR_OLDSTATEID: 4307c478bd9Sstevel@tonic-gate return ("NR_OLDSTATEID"); 4317c478bd9Sstevel@tonic-gate case NR_GRACE: 4327c478bd9Sstevel@tonic-gate return ("NR_GRACE"); 4337c478bd9Sstevel@tonic-gate case NR_DELAY: 4347c478bd9Sstevel@tonic-gate return ("NR_DELAY"); 4357c478bd9Sstevel@tonic-gate case NR_LOST_LOCK: 4367c478bd9Sstevel@tonic-gate return ("NR_LOST_LOCK"); 4377c478bd9Sstevel@tonic-gate case NR_LOST_STATE_RQST: 4387c478bd9Sstevel@tonic-gate return ("NR_LOST_STATE_RQST"); 4392f172c55SRobert Thurlow case NR_MOVED: 4402f172c55SRobert Thurlow return ("NR_MOVED"); 4417c478bd9Sstevel@tonic-gate default: 4427c478bd9Sstevel@tonic-gate (void) snprintf(buf, 40, "Unknown, code %d", (int)what); 4437c478bd9Sstevel@tonic-gate return (buf); 4447c478bd9Sstevel@tonic-gate } 4457c478bd9Sstevel@tonic-gate } 4467c478bd9Sstevel@tonic-gate 4477c478bd9Sstevel@tonic-gate char * 4487c478bd9Sstevel@tonic-gate nfs4_op_to_str(nfs_opnum4 op) 4497c478bd9Sstevel@tonic-gate { 4507c478bd9Sstevel@tonic-gate static char buf[40]; 4517c478bd9Sstevel@tonic-gate 4527c478bd9Sstevel@tonic-gate switch (REAL_OP4(op)) { 4537c478bd9Sstevel@tonic-gate case OP_ACCESS: 4547c478bd9Sstevel@tonic-gate return ("OP_ACCESS"); 4557c478bd9Sstevel@tonic-gate case OP_CLOSE: 4567c478bd9Sstevel@tonic-gate return ("OP_CLOSE"); 4577c478bd9Sstevel@tonic-gate case OP_COMMIT: 4587c478bd9Sstevel@tonic-gate return ("OP_COMMIT"); 4597c478bd9Sstevel@tonic-gate case OP_CREATE: 4607c478bd9Sstevel@tonic-gate return ("OP_CREATE"); 4617c478bd9Sstevel@tonic-gate case OP_DELEGPURGE: 4627c478bd9Sstevel@tonic-gate return ("OP_DELEGPURGE"); 4637c478bd9Sstevel@tonic-gate case OP_DELEGRETURN: 4647c478bd9Sstevel@tonic-gate return ("OP_DELEGRETURN"); 4657c478bd9Sstevel@tonic-gate case OP_GETATTR: 4667c478bd9Sstevel@tonic-gate return ("OP_GETATTR"); 4677c478bd9Sstevel@tonic-gate case OP_GETFH: 4687c478bd9Sstevel@tonic-gate return ("OP_GETFH"); 4697c478bd9Sstevel@tonic-gate case OP_LINK: 4707c478bd9Sstevel@tonic-gate return ("OP_LINK"); 4717c478bd9Sstevel@tonic-gate case OP_LOCK: 4727c478bd9Sstevel@tonic-gate return ("OP_LOCK"); 4737c478bd9Sstevel@tonic-gate case OP_LOCKT: 4747c478bd9Sstevel@tonic-gate return ("OP_LOCKT"); 4757c478bd9Sstevel@tonic-gate case OP_LOCKU: 4767c478bd9Sstevel@tonic-gate return ("OP_LOCKU"); 4777c478bd9Sstevel@tonic-gate case OP_LOOKUP: 4787c478bd9Sstevel@tonic-gate return ("OP_LOOKUP"); 4797c478bd9Sstevel@tonic-gate case OP_LOOKUPP: 4807c478bd9Sstevel@tonic-gate return ("OP_LOOKUPP"); 4817c478bd9Sstevel@tonic-gate case OP_NVERIFY: 4827c478bd9Sstevel@tonic-gate return ("OP_NVERIFY"); 4837c478bd9Sstevel@tonic-gate case OP_OPEN: 4847c478bd9Sstevel@tonic-gate return ("OP_OPEN"); 4857c478bd9Sstevel@tonic-gate case OP_OPENATTR: 4867c478bd9Sstevel@tonic-gate return ("OP_OPENATTR"); 4877c478bd9Sstevel@tonic-gate case OP_OPEN_CONFIRM: 4887c478bd9Sstevel@tonic-gate return ("OP_OPEN_CONFIRM"); 4897c478bd9Sstevel@tonic-gate case OP_OPEN_DOWNGRADE: 4907c478bd9Sstevel@tonic-gate return ("OP_OPEN_DOWNGRADE"); 4917c478bd9Sstevel@tonic-gate case OP_PUTFH: 4927c478bd9Sstevel@tonic-gate return ("OP_PUTFH"); 4937c478bd9Sstevel@tonic-gate case OP_PUTPUBFH: 4947c478bd9Sstevel@tonic-gate return ("OP_PUTPUBFH"); 4957c478bd9Sstevel@tonic-gate case OP_PUTROOTFH: 4967c478bd9Sstevel@tonic-gate return ("OP_PUTROOTFH"); 4977c478bd9Sstevel@tonic-gate case OP_READ: 4987c478bd9Sstevel@tonic-gate return ("OP_READ"); 4997c478bd9Sstevel@tonic-gate case OP_READDIR: 5007c478bd9Sstevel@tonic-gate return ("OP_READDIR"); 5017c478bd9Sstevel@tonic-gate case OP_READLINK: 5027c478bd9Sstevel@tonic-gate return ("OP_READLINK"); 5037c478bd9Sstevel@tonic-gate case OP_REMOVE: 5047c478bd9Sstevel@tonic-gate return ("OP_REMOVE"); 5057c478bd9Sstevel@tonic-gate case OP_RENAME: 5067c478bd9Sstevel@tonic-gate return ("OP_RENAME"); 5077c478bd9Sstevel@tonic-gate case OP_RENEW: 5087c478bd9Sstevel@tonic-gate return ("OP_RENEW"); 5097c478bd9Sstevel@tonic-gate case OP_RESTOREFH: 5107c478bd9Sstevel@tonic-gate return ("OP_RESTOREFH"); 5117c478bd9Sstevel@tonic-gate case OP_SAVEFH: 5127c478bd9Sstevel@tonic-gate return ("OP_SAVEFH"); 5137c478bd9Sstevel@tonic-gate case OP_SECINFO: 5147c478bd9Sstevel@tonic-gate return ("OP_SECINFO"); 5157c478bd9Sstevel@tonic-gate case OP_SETATTR: 5167c478bd9Sstevel@tonic-gate return ("OP_SETATTR"); 5177c478bd9Sstevel@tonic-gate case OP_SETCLIENTID: 5187c478bd9Sstevel@tonic-gate return ("OP_SETCLIENTID"); 5197c478bd9Sstevel@tonic-gate case OP_SETCLIENTID_CONFIRM: 5207c478bd9Sstevel@tonic-gate return ("OP_SETCLIENTID_CONFIRM"); 5217c478bd9Sstevel@tonic-gate case OP_VERIFY: 5227c478bd9Sstevel@tonic-gate return ("OP_VERIFY"); 5237c478bd9Sstevel@tonic-gate case OP_WRITE: 5247c478bd9Sstevel@tonic-gate return ("OP_WRITE"); 5257c478bd9Sstevel@tonic-gate case OP_RELEASE_LOCKOWNER: 5267c478bd9Sstevel@tonic-gate return ("OP_RELEASE_LOCKOWNER"); 5277c478bd9Sstevel@tonic-gate case OP_ILLEGAL: 5287c478bd9Sstevel@tonic-gate return ("OP_ILLEGAL"); 5297c478bd9Sstevel@tonic-gate default: 5307c478bd9Sstevel@tonic-gate (void) snprintf(buf, 40, "Unknown op %d", (int)op); 5317c478bd9Sstevel@tonic-gate return (buf); 5327c478bd9Sstevel@tonic-gate } 5337c478bd9Sstevel@tonic-gate } 534