nfs_nfsdsocket.c (211951) | nfs_nfsdsocket.c (216700) |
---|---|
1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 */ 33 34#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdsocket.c 211951 2010-08-28 21:41:18Z rmacklem $"); | 35__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdsocket.c 216700 2010-12-25 21:56:25Z rmacklem $"); |
36 37/* 38 * Socket operations for use by the nfs server. 39 */ 40 41#ifndef APPLEKEXT 42#include <fs/nfs/nfsport.h> 43 --- 305 unchanged lines hidden (view full) --- 349 * split into groups, based on whether they use a file handle or file 350 * handle plus name or ... 351 * The NFS V4 Compound RPC is performed separately by nfsrvd_compound(). 352 */ 353APPLESTATIC void 354nfsrvd_dorpc(struct nfsrv_descript *nd, int isdgram, 355 NFSPROC_T *p) 356{ | 36 37/* 38 * Socket operations for use by the nfs server. 39 */ 40 41#ifndef APPLEKEXT 42#include <fs/nfs/nfsport.h> 43 --- 305 unchanged lines hidden (view full) --- 349 * split into groups, based on whether they use a file handle or file 350 * handle plus name or ... 351 * The NFS V4 Compound RPC is performed separately by nfsrvd_compound(). 352 */ 353APPLESTATIC void 354nfsrvd_dorpc(struct nfsrv_descript *nd, int isdgram, 355 NFSPROC_T *p) 356{ |
357 int error = 0; | 357 int error = 0, lktype; |
358 vnode_t vp; 359 mount_t mp = NULL; 360 struct nfsrvfh fh; 361 struct nfsexstuff nes; 362 363 /* 364 * Get a locked vnode for the first file handle 365 */ --- 9 unchanged lines hidden (view full) --- 375 } else { 376 error = nfsrv_mtofh(nd, &fh); 377 if (error) { 378 if (error != EBADRPC) 379 printf("nfs dorpc err1=%d\n", error); 380 nd->nd_repstat = NFSERR_GARBAGE; 381 return; 382 } | 358 vnode_t vp; 359 mount_t mp = NULL; 360 struct nfsrvfh fh; 361 struct nfsexstuff nes; 362 363 /* 364 * Get a locked vnode for the first file handle 365 */ --- 9 unchanged lines hidden (view full) --- 375 } else { 376 error = nfsrv_mtofh(nd, &fh); 377 if (error) { 378 if (error != EBADRPC) 379 printf("nfs dorpc err1=%d\n", error); 380 nd->nd_repstat = NFSERR_GARBAGE; 381 return; 382 } |
383 if (nd->nd_procnum == NFSPROC_READ || 384 nd->nd_procnum == NFSPROC_READDIR || 385 nd->nd_procnum == NFSPROC_READLINK || 386 nd->nd_procnum == NFSPROC_GETATTR || 387 nd->nd_procnum == NFSPROC_ACCESS) 388 lktype = LK_SHARED; 389 else 390 lktype = LK_EXCLUSIVE; |
|
383 nes.nes_vfslocked = 0; 384 if (nd->nd_flag & ND_PUBLOOKUP) | 391 nes.nes_vfslocked = 0; 392 if (nd->nd_flag & ND_PUBLOOKUP) |
385 nfsd_fhtovp(nd, &nfs_pubfh, &vp, &nes, | 393 nfsd_fhtovp(nd, &nfs_pubfh, lktype, &vp, &nes, |
386 &mp, nfs_writerpc[nd->nd_procnum], p); 387 else | 394 &mp, nfs_writerpc[nd->nd_procnum], p); 395 else |
388 nfsd_fhtovp(nd, &fh, &vp, &nes, | 396 nfsd_fhtovp(nd, &fh, lktype, &vp, &nes, |
389 &mp, nfs_writerpc[nd->nd_procnum], p); 390 if (nd->nd_repstat == NFSERR_PROGNOTV4) 391 return; 392 } 393 } 394 395 /* 396 * For V2 and 3, set the ND_SAVEREPLY flag for the recent request --- 298 unchanged lines hidden (view full) --- 695 NFSINCRGLOBAL(newnfsstats.srvrpccnt[nd->nd_procnum]); 696 switch (op) { 697 case NFSV4OP_PUTFH: 698 error = nfsrv_mtofh(nd, &fh); 699 if (error) 700 goto nfsmout; 701 if (!nd->nd_repstat) { 702 nes.nes_vfslocked = vpnes.nes_vfslocked; | 397 &mp, nfs_writerpc[nd->nd_procnum], p); 398 if (nd->nd_repstat == NFSERR_PROGNOTV4) 399 return; 400 } 401 } 402 403 /* 404 * For V2 and 3, set the ND_SAVEREPLY flag for the recent request --- 298 unchanged lines hidden (view full) --- 703 NFSINCRGLOBAL(newnfsstats.srvrpccnt[nd->nd_procnum]); 704 switch (op) { 705 case NFSV4OP_PUTFH: 706 error = nfsrv_mtofh(nd, &fh); 707 if (error) 708 goto nfsmout; 709 if (!nd->nd_repstat) { 710 nes.nes_vfslocked = vpnes.nes_vfslocked; |
703 nfsd_fhtovp(nd, &fh, &nvp, &nes, &mp, | 711 nfsd_fhtovp(nd, &fh, LK_SHARED, &nvp, &nes, &mp, |
704 0, p); 705 } 706 /* For now, allow this for non-export FHs */ 707 if (!nd->nd_repstat) { 708 if (vp) 709 vrele(vp); 710 vp = nvp; 711 NFSVOPUNLOCK(vp, 0, p); 712 vpnes = nes; 713 } 714 break; 715 case NFSV4OP_PUTPUBFH: 716 if (nfs_pubfhset) { 717 nes.nes_vfslocked = vpnes.nes_vfslocked; | 712 0, p); 713 } 714 /* For now, allow this for non-export FHs */ 715 if (!nd->nd_repstat) { 716 if (vp) 717 vrele(vp); 718 vp = nvp; 719 NFSVOPUNLOCK(vp, 0, p); 720 vpnes = nes; 721 } 722 break; 723 case NFSV4OP_PUTPUBFH: 724 if (nfs_pubfhset) { 725 nes.nes_vfslocked = vpnes.nes_vfslocked; |
718 nfsd_fhtovp(nd, &nfs_pubfh, &nvp, | 726 nfsd_fhtovp(nd, &nfs_pubfh, LK_SHARED, &nvp, |
719 &nes, &mp, 0, p); 720 } else { 721 nd->nd_repstat = NFSERR_NOFILEHANDLE; 722 } 723 if (!nd->nd_repstat) { 724 if (vp) 725 vrele(vp); 726 vp = nvp; 727 NFSVOPUNLOCK(vp, 0, p); 728 vpnes = nes; 729 } 730 break; 731 case NFSV4OP_PUTROOTFH: 732 if (nfs_rootfhset) { 733 nes.nes_vfslocked = vpnes.nes_vfslocked; | 727 &nes, &mp, 0, p); 728 } else { 729 nd->nd_repstat = NFSERR_NOFILEHANDLE; 730 } 731 if (!nd->nd_repstat) { 732 if (vp) 733 vrele(vp); 734 vp = nvp; 735 NFSVOPUNLOCK(vp, 0, p); 736 vpnes = nes; 737 } 738 break; 739 case NFSV4OP_PUTROOTFH: 740 if (nfs_rootfhset) { 741 nes.nes_vfslocked = vpnes.nes_vfslocked; |
734 nfsd_fhtovp(nd, &nfs_rootfh, &nvp, | 742 nfsd_fhtovp(nd, &nfs_rootfh, LK_SHARED, &nvp, |
735 &nes, &mp, 0, p); 736 if (!nd->nd_repstat) { 737 if (vp) 738 vrele(vp); 739 vp = nvp; 740 NFSVOPUNLOCK(vp, 0, p); 741 vpnes = nes; 742 } --- 159 unchanged lines hidden (view full) --- 902 error = (*(nfsrv4_ops2[op]))(nd, isdgram, savevp, 903 vp, p, &savevpnes, &vpnes); 904 if (nfsv4_opflag[op].modifyfs) 905 NFS_ENDWRITE(mp); 906 } else { 907 if (nfsv4_opflag[op].retfh != 0) 908 panic("nfsrvd_compound"); 909 if (nfsv4_opflag[op].needscfh) { | 743 &nes, &mp, 0, p); 744 if (!nd->nd_repstat) { 745 if (vp) 746 vrele(vp); 747 vp = nvp; 748 NFSVOPUNLOCK(vp, 0, p); 749 vpnes = nes; 750 } --- 159 unchanged lines hidden (view full) --- 910 error = (*(nfsrv4_ops2[op]))(nd, isdgram, savevp, 911 vp, p, &savevpnes, &vpnes); 912 if (nfsv4_opflag[op].modifyfs) 913 NFS_ENDWRITE(mp); 914 } else { 915 if (nfsv4_opflag[op].retfh != 0) 916 panic("nfsrvd_compound"); 917 if (nfsv4_opflag[op].needscfh) { |
910 if (vp) { 911 VREF(vp); 912 if (nfsv4_opflag[op].modifyfs) 913 NFS_STARTWRITE(NULL, &mp); 914 NFSVOPLOCK(vp, LK_EXCLUSIVE | LK_RETRY, p); 915 } else { | 918 if (vp != NULL) { 919 if (vn_lock(vp, nfsv4_opflag[op].lktype) 920 != 0) 921 nd->nd_repstat = NFSERR_PERM; 922 } else |
916 nd->nd_repstat = NFSERR_NOFILEHANDLE; | 923 nd->nd_repstat = NFSERR_NOFILEHANDLE; |
924 if (nd->nd_repstat != 0) { |
|
917 if (op == NFSV4OP_SETATTR) { | 925 if (op == NFSV4OP_SETATTR) { |
918 /* 919 * Setattr reply requires a bitmap 920 * even for errors like these. 921 */ 922 NFSM_BUILD(tl, u_int32_t *, 923 NFSX_UNSIGNED); 924 *tl = 0; | 926 /* 927 * Setattr reply requires a 928 * bitmap even for errors like 929 * these. 930 */ 931 NFSM_BUILD(tl, u_int32_t *, 932 NFSX_UNSIGNED); 933 *tl = 0; |
925 } 926 break; 927 } | 934 } 935 break; 936 } |
937 VREF(vp); 938 if (nfsv4_opflag[op].modifyfs) 939 NFS_STARTWRITE(NULL, &mp); |
|
928 error = (*(nfsrv4_ops0[op]))(nd, isdgram, vp, 929 p, &vpnes); 930 if (nfsv4_opflag[op].modifyfs) 931 NFS_ENDWRITE(mp); 932 } else { 933 error = (*(nfsrv4_ops0[op]))(nd, isdgram, 934 NULL, p, &vpnes); 935 } --- 43 unchanged lines hidden --- | 940 error = (*(nfsrv4_ops0[op]))(nd, isdgram, vp, 941 p, &vpnes); 942 if (nfsv4_opflag[op].modifyfs) 943 NFS_ENDWRITE(mp); 944 } else { 945 error = (*(nfsrv4_ops0[op]))(nd, isdgram, 946 NULL, p, &vpnes); 947 } --- 43 unchanged lines hidden --- |