Sdiff nfs3_vnops.c


12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. 29 * All rights reserved. 30 */ 31 32 #pragma ident "@(#)nfs3_vnops.c 1.272 05/10/11 SMI" 33 34 #include <sys/param.h> 35 #include <sys/types.h> 36 #include <sys/systm.h> 37 #include <sys/cred.h> 38 #include <sys/time.h> 39 #include <sys/vnode.h> 40 #include <sys/vfs.h> 41 #include <sys/file.h> 42 #include <sys/filio.h> 43 #include <sys/uio.h> 44 #include <sys/buf.h> 45 #include <sys/mman.h> 46 #include <sys/pathname.h> 47 #include <sys/dirent.h> 48 #include <sys/debug.h> 49 #include <sys/vmsystm.h> 50 #include <sys/fcntl.h> 51 #include <sys/flock.h>
69 #include <rpc/clnt.h> 70 71 #include <nfs/nfs.h> 72 #include <nfs/nfs_clnt.h> 73 #include <nfs/rnode.h> 74 #include <nfs/nfs_acl.h> 75 #include <nfs/lm.h> 76 77 #include <vm/hat.h> 78 #include <vm/as.h> 79 #include <vm/page.h> 80 #include <vm/pvn.h> 81 #include <vm/seg.h> 82 #include <vm/seg_map.h> 83 #include <vm/seg_kpm.h> 84 #include <vm/seg_vn.h> 85 86 #include <fs/fs_subr.h> 87 88 #include <sys/ddi.h> 89 90 static int nfs3_rdwrlbn(vnode_t *, page_t *, u_offset_t, size_t, int, 91 cred_t *); 92 static int nfs3write(vnode_t *, caddr_t, u_offset_t, int, cred_t *, 93 stable_how *); 94 static int nfs3read(vnode_t *, caddr_t, offset_t, int, size_t *, cred_t *); 95 static int nfs3setattr(vnode_t *, struct vattr *, int, cred_t *); 96 static int nfs3_accessx(void *, int, cred_t *); 97 static int nfs3lookup_dnlc(vnode_t *, char *, vnode_t **, cred_t *); 98 static int nfs3lookup_otw(vnode_t *, char *, vnode_t **, cred_t *, int); 99 static int nfs3create(vnode_t *, char *, struct vattr *, enum vcexcl, 100 int, vnode_t **, cred_t *, int); 101 static int nfs3excl_create_settimes(vnode_t *, struct vattr *, cred_t *); 102 static int nfs3mknod(vnode_t *, char *, struct vattr *, enum vcexcl, 103 int, vnode_t **, cred_t *); 104 static int nfs3rename(vnode_t *, char *, vnode_t *, char *, cred_t *); 105 static int do_nfs3readdir(vnode_t *, rddir_cache *, cred_t *); 106 static void nfs3readdir(vnode_t *, rddir_cache *, cred_t *); 107 static void nfs3readdirplus(vnode_t *, rddir_cache *, cred_t *); 108 static int nfs3_bio(struct buf *, stable_how *, cred_t *);
436 ssize_t count; 437 int error; 438 int douprintf; 439 failinfo_t fi; 440 char *sv_hostname; 441 442 mi = VTOMI(vp); 443 ASSERT(nfs_zone() == VTOMI(vp)->mi_zone); 444 sv_hostname = VTOR(vp)->r_server->sv_hostname; 445 446 douprintf = 1; 447 args.file = *VTOFH3(vp); 448 fi.vp = vp; 449 fi.fhp = (caddr_t)&args.file; 450 fi.copyproc = nfs3copyfh; 451 fi.lookupproc = nfs3lookup; 452 fi.xattrdirproc = acl_getxattrdir3; 453 454 res.uiop = uiop; 455 456 offset = uiop->uio_loffset; 457 count = uiop->uio_resid; 458 459 do { 460 if (mi->mi_io_kstats) { 461 mutex_enter(&mi->mi_lock); 462 kstat_runq_enter(KSTAT_IO_PTR(mi->mi_io_kstats)); 463 mutex_exit(&mi->mi_lock); 464 } 465 466 do { 467 tsize = MIN(mi->mi_tsize, count); 468 args.offset = (offset3)offset; 469 args.count = (count3)tsize; 470 res.size = (uint_t)tsize; 471 error = rfs3call(mi, NFSPROC3_READ, 472 xdr_READ3args, (caddr_t)&args, 473 xdr_READ3uiores, (caddr_t)&res, cr, 474 &douprintf, &res.status, 0, &fi); 475 } while (error == ENFS_TRYAGAIN);
1029 failinfo_t fi; 1030 rnode_t *rp; 1031 struct vattr va; 1032 hrtime_t t; 1033 1034 rp = VTOR(vp); 1035 mi = VTOMI(vp); 1036 ASSERT(nfs_zone() == mi->mi_zone); 1037 douprintf = 1; 1038 1039 args.file = *VTOFH3(vp); 1040 fi.vp = vp; 1041 fi.fhp = (caddr_t)&args.file; 1042 fi.copyproc = nfs3copyfh; 1043 fi.lookupproc = nfs3lookup; 1044 fi.xattrdirproc = acl_getxattrdir3; 1045 1046 res.pov.fres.vp = vp; 1047 res.pov.fres.vap = &va; 1048 1049 *residp = count; 1050 do { 1051 if (mi->mi_io_kstats) { 1052 mutex_enter(&mi->mi_lock); 1053 kstat_runq_enter(KSTAT_IO_PTR(mi->mi_io_kstats)); 1054 mutex_exit(&mi->mi_lock); 1055 } 1056 1057 do { 1058 if ((vp->v_flag & VNOCACHE) || 1059 (rp->r_flags & RDIRECTIO) || 1060 (mi->mi_flags & MI_DIRECTIO)) 1061 tsize = MIN(mi->mi_tsize, count); 1062 else 1063 tsize = MIN(mi->mi_curread, count); 1064 res.data.data_val = base; 1065 res.data.data_len = tsize; 1066 args.offset = (offset3)offset; 1067 args.count = (count3)tsize; 1068 t = gethrtime();


12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. 29 * All rights reserved. 30 */ 31 32 /* Copyright (c) 2006, The Ohio State University. All rights reserved. 33 * 34 * Portions of this source code is developed by the team members of 35 * The Ohio State University's Network-Based Computing Laboratory (NBCL), 36 * headed by Professor Dhabaleswar K. (DK) Panda. 37 * 38 * Acknowledgements to contributions from developors: 39 * Ranjit Noronha: noronha@cse.ohio-state.edu 40 * Lei Chai : chail@cse.ohio-state.edu 41 * Weikuan Yu : yuw@cse.ohio-state.edu 42 * 43 */ 44 45 #pragma ident "@(#)nfs3_vnops.c 1.272 05/10/11 SMI" 46 47 #include <sys/param.h> 48 #include <sys/types.h> 49 #include <sys/systm.h> 50 #include <sys/cred.h> 51 #include <sys/time.h> 52 #include <sys/vnode.h> 53 #include <sys/vfs.h> 54 #include <sys/file.h> 55 #include <sys/filio.h> 56 #include <sys/uio.h> 57 #include <sys/buf.h> 58 #include <sys/mman.h> 59 #include <sys/pathname.h> 60 #include <sys/dirent.h> 61 #include <sys/debug.h> 62 #include <sys/vmsystm.h> 63 #include <sys/fcntl.h> 64 #include <sys/flock.h>
82 #include <rpc/clnt.h> 83 84 #include <nfs/nfs.h> 85 #include <nfs/nfs_clnt.h> 86 #include <nfs/rnode.h> 87 #include <nfs/nfs_acl.h> 88 #include <nfs/lm.h> 89 90 #include <vm/hat.h> 91 #include <vm/as.h> 92 #include <vm/page.h> 93 #include <vm/pvn.h> 94 #include <vm/seg.h> 95 #include <vm/seg_map.h> 96 #include <vm/seg_kpm.h> 97 #include <vm/seg_vn.h> 98 99 #include <fs/fs_subr.h> 100 101 #include <sys/ddi.h> 102 #include <rpc/rpc_rdma.h> 103 104 static int nfs3_rdwrlbn(vnode_t *, page_t *, u_offset_t, size_t, int, 105 cred_t *); 106 static int nfs3write(vnode_t *, caddr_t, u_offset_t, int, cred_t *, 107 stable_how *); 108 static int nfs3read(vnode_t *, caddr_t, offset_t, int, size_t *, cred_t *); 109 static int nfs3setattr(vnode_t *, struct vattr *, int, cred_t *); 110 static int nfs3_accessx(void *, int, cred_t *); 111 static int nfs3lookup_dnlc(vnode_t *, char *, vnode_t **, cred_t *); 112 static int nfs3lookup_otw(vnode_t *, char *, vnode_t **, cred_t *, int); 113 static int nfs3create(vnode_t *, char *, struct vattr *, enum vcexcl, 114 int, vnode_t **, cred_t *, int); 115 static int nfs3excl_create_settimes(vnode_t *, struct vattr *, cred_t *); 116 static int nfs3mknod(vnode_t *, char *, struct vattr *, enum vcexcl, 117 int, vnode_t **, cred_t *); 118 static int nfs3rename(vnode_t *, char *, vnode_t *, char *, cred_t *); 119 static int do_nfs3readdir(vnode_t *, rddir_cache *, cred_t *); 120 static void nfs3readdir(vnode_t *, rddir_cache *, cred_t *); 121 static void nfs3readdirplus(vnode_t *, rddir_cache *, cred_t *); 122 static int nfs3_bio(struct buf *, stable_how *, cred_t *);
450 ssize_t count; 451 int error; 452 int douprintf; 453 failinfo_t fi; 454 char *sv_hostname; 455 456 mi = VTOMI(vp); 457 ASSERT(nfs_zone() == VTOMI(vp)->mi_zone); 458 sv_hostname = VTOR(vp)->r_server->sv_hostname; 459 460 douprintf = 1; 461 args.file = *VTOFH3(vp); 462 fi.vp = vp; 463 fi.fhp = (caddr_t)&args.file; 464 fi.copyproc = nfs3copyfh; 465 fi.lookupproc = nfs3lookup; 466 fi.xattrdirproc = acl_getxattrdir3; 467 468 res.uiop = uiop; 469 470 res.wlist = NULL; 471 472 offset = uiop->uio_loffset; 473 count = uiop->uio_resid; 474 475 do { 476 if (mi->mi_io_kstats) { 477 mutex_enter(&mi->mi_lock); 478 kstat_runq_enter(KSTAT_IO_PTR(mi->mi_io_kstats)); 479 mutex_exit(&mi->mi_lock); 480 } 481 482 do { 483 tsize = MIN(mi->mi_tsize, count); 484 args.offset = (offset3)offset; 485 args.count = (count3)tsize; 486 res.size = (uint_t)tsize; 487 error = rfs3call(mi, NFSPROC3_READ, 488 xdr_READ3args, (caddr_t)&args, 489 xdr_READ3uiores, (caddr_t)&res, cr, 490 &douprintf, &res.status, 0, &fi); 491 } while (error == ENFS_TRYAGAIN);
1045 failinfo_t fi; 1046 rnode_t *rp; 1047 struct vattr va; 1048 hrtime_t t; 1049 1050 rp = VTOR(vp); 1051 mi = VTOMI(vp); 1052 ASSERT(nfs_zone() == mi->mi_zone); 1053 douprintf = 1; 1054 1055 args.file = *VTOFH3(vp); 1056 fi.vp = vp; 1057 fi.fhp = (caddr_t)&args.file; 1058 fi.copyproc = nfs3copyfh; 1059 fi.lookupproc = nfs3lookup; 1060 fi.xattrdirproc = acl_getxattrdir3; 1061 1062 res.pov.fres.vp = vp; 1063 res.pov.fres.vap = &va; 1064 1065 res.wlist = NULL; 1066 1067 *residp = count; 1068 do { 1069 if (mi->mi_io_kstats) { 1070 mutex_enter(&mi->mi_lock); 1071 kstat_runq_enter(KSTAT_IO_PTR(mi->mi_io_kstats)); 1072 mutex_exit(&mi->mi_lock); 1073 } 1074 1075 do { 1076 if ((vp->v_flag & VNOCACHE) || 1077 (rp->r_flags & RDIRECTIO) || 1078 (mi->mi_flags & MI_DIRECTIO)) 1079 tsize = MIN(mi->mi_tsize, count); 1080 else 1081 tsize = MIN(mi->mi_curread, count); 1082 res.data.data_val = base; 1083 res.data.data_len = tsize; 1084 args.offset = (offset3)offset; 1085 args.count = (count3)tsize; 1086 t = gethrtime();