331} 332 333/* 334 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 335 * What should be in this set is open to debate, but I believe that since 336 * I/O system calls on ufs are never interrupted by signals the set should 337 * be minimal. My reasoning is that many current programs that use signals 338 * such as SIGALRM will not expect file I/O system calls to be interrupted 339 * by them and break. 340 */ 341#ifdef KERNEL 342 343struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 344 345#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ 346 sigmask(SIGHUP)|sigmask(SIGQUIT)) 347 348/* 349 * Socket errors ignored for connectionless sockets?? 350 * For now, ignore them all 351 */ 352#define NFSIGNORE_SOERROR(s, e) \ 353 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 354 ((s) & PR_CONNREQUIRED) == 0) 355 356/* 357 * Nfs outstanding request list element 358 */ 359struct nfsreq { 360 TAILQ_ENTRY(nfsreq) r_chain; 361 struct mbuf *r_mreq; 362 struct mbuf *r_mrep; 363 struct mbuf *r_md; 364 caddr_t r_dpos; 365 struct nfsmount *r_nmp; 366 struct vnode *r_vp; 367 u_long r_xid; 368 int r_flags; /* flags on request, see below */ 369 int r_retry; /* max retransmission count */ 370 int r_rexmit; /* current retrans count */ 371 int r_timer; /* tick counter on reply */ 372 int r_procnum; /* NFS procedure number */ 373 int r_rtt; /* RTT for rpc */ 374 struct proc *r_procp; /* Proc that did I/O system call */ 375}; 376 377/* 378 * Queue head for nfsreq's 379 */ 380extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq; 381 382/* Flag values for r_flags */ 383#define R_TIMING 0x01 /* timing request (in mntp) */ 384#define R_SENT 0x02 /* request has been sent */ 385#define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 386#define R_INTR 0x08 /* intr mnt, signal pending */ 387#define R_SOCKERR 0x10 /* Fatal error on socket */ 388#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 389#define R_MUSTRESEND 0x40 /* Must resend request */ 390#define R_GETONEREP 0x80 /* Probe for one reply only */ 391 392/* 393 * A list of nfssvc_sock structures is maintained with all the sockets 394 * that require service by the nfsd. 395 * The nfsuid structs hang off of the nfssvc_sock structs in both lru 396 * and uid hash lists. 397 */ 398#ifndef NFS_UIDHASHSIZ 399#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ 400#endif 401#define NUIDHASH(sock, uid) \ 402 (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) 403#ifndef NFS_WDELAYHASHSIZ 404#define NFS_WDELAYHASHSIZ 16 /* and with this */ 405#endif 406#define NWDELAYHASH(sock, f) \ 407 (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) 408#ifndef NFS_MUIDHASHSIZ 409#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */ 410#endif 411#define NMUIDHASH(nmp, uid) \ 412 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) 413#define NFSNOHASH(fhsum) \ 414 (&nfsnodehashtbl[(fhsum) & nfsnodehash]) 415 416/* 417 * Network address hash list element 418 */ 419union nethostaddr { 420 u_long had_inetaddr; 421 struct mbuf *had_nam; 422}; 423 424struct nfsuid { 425 TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ 426 LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ 427 int nu_flag; /* Flags */ 428 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 429 struct ucred nu_cr; /* Cred uid mapped to */ 430 int nu_expire; /* Expiry time (sec) */ 431 struct timeval nu_timestamp; /* Kerb. timestamp */ 432 u_long nu_nickname; /* Nickname on server */ 433 NFSKERBKEY_T nu_key; /* and session key */ 434}; 435 436#define nu_inetaddr nu_haddr.had_inetaddr 437#define nu_nam nu_haddr.had_nam 438/* Bits for nu_flag */ 439#define NU_INETADDR 0x1 440#define NU_NAM 0x2 441#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) 442 443struct nfssvc_sock { 444 TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ 445 TAILQ_HEAD(, nfsuid) ns_uidlruhead; 446 struct file *ns_fp; 447 struct socket *ns_so; 448 struct mbuf *ns_nam; 449 struct mbuf *ns_raw; 450 struct mbuf *ns_rawend; 451 struct mbuf *ns_rec; 452 struct mbuf *ns_recend; 453 struct mbuf *ns_frag; 454 int ns_flag; 455 int ns_solock; 456 int ns_cc; 457 int ns_reclen; 458 int ns_numuids; 459 u_long ns_sref; 460 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ 461 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; 462 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; 463}; 464 465/* Bits for "ns_flag" */ 466#define SLP_VALID 0x01 467#define SLP_DOREC 0x02 468#define SLP_NEEDQ 0x04 469#define SLP_DISCONN 0x08 470#define SLP_GETSTREAM 0x10 471#define SLP_LASTFRAG 0x20 472#define SLP_ALLFLAGS 0xff 473 474extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; 475extern int nfssvc_sockhead_flag; 476#define SLP_INIT 0x01 477#define SLP_WANTINIT 0x02 478 479/* 480 * One of these structures is allocated for each nfsd. 481 */ 482struct nfsd { 483 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ 484 int nfsd_flag; /* NFSD_ flags */ 485 struct nfssvc_sock *nfsd_slp; /* Current socket */ 486 int nfsd_authlen; /* Authenticator len */ 487 u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 488 int nfsd_verflen; /* and the Verifier */ 489 u_char nfsd_verfstr[RPCVERF_MAXSIZ]; 490 struct proc *nfsd_procp; /* Proc ptr */ 491 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ 492}; 493 494/* Bits for "nfsd_flag" */ 495#define NFSD_WAITING 0x01 496#define NFSD_REQINPROG 0x02 497#define NFSD_NEEDAUTH 0x04 498#define NFSD_AUTHFAIL 0x08 499 500/* 501 * This structure is used by the server for describing each request. 502 * Some fields are used only when write request gathering is performed. 503 */ 504struct nfsrv_descript { 505 u_quad_t nd_time; /* Write deadline (usec) */ 506 off_t nd_off; /* Start byte offset */ 507 off_t nd_eoff; /* and end byte offset */ 508 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ 509 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ 510 LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ 511 struct mbuf *nd_mrep; /* Request mbuf list */ 512 struct mbuf *nd_md; /* Current dissect mbuf */ 513 struct mbuf *nd_mreq; /* Reply mbuf list */ 514 struct mbuf *nd_nam; /* and socket addr */ 515 struct mbuf *nd_nam2; /* return socket addr */ 516 caddr_t nd_dpos; /* Current dissect pos */ 517 int nd_procnum; /* RPC # */ 518 int nd_stable; /* storage type */ 519 int nd_flag; /* nd_flag */ 520 int nd_len; /* Length of this write */ 521 int nd_repstat; /* Reply status */ 522 u_long nd_retxid; /* Reply xid */ 523 u_long nd_duration; /* Lease duration */ 524 struct timeval nd_starttime; /* Time RPC initiated */ 525 fhandle_t nd_fh; /* File handle */ 526 struct ucred nd_cr; /* Credentials */ 527}; 528 529/* Bits for "nd_flag" */ 530#define ND_READ LEASE_READ 531#define ND_WRITE LEASE_WRITE 532#define ND_CHECK 0x04 533#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) 534#define ND_NFSV3 0x08 535#define ND_NQNFS 0x10 536#define ND_KERBNICK 0x20 537#define ND_KERBFULL 0x40 538#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) 539 540extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head; 541extern int nfsd_head_flag; 542#define NFSD_CHECKSLP 0x01 543 544/* 545 * These macros compare nfsrv_descript structures. 546 */ 547#define NFSW_CONTIG(o, n) \ 548 ((o)->nd_eoff >= (n)->nd_off && \ 549 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) 550 551#define NFSW_SAMECRED(o, n) \ 552 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ 553 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ 554 sizeof (struct ucred))) 555 556 557int nfs_init __P((struct vfsconf *vfsp)); 558int nfs_reply __P((struct nfsreq *)); 559int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); 560int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); 561int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *)); 562int nfs_sndlock __P((int *,struct nfsreq *)); 563void nfs_sndunlock __P((int *flagp)); 564int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 565int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int)); 566int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *)); 567int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *)); 568int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *)); 569int nfs_asyncio __P((struct buf *,struct ucred *)); 570int nfs_doio __P((struct buf *,struct ucred *,struct proc *)); 571int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *)); 572int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *)); 573int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *)); 574int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 575void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *)); 576void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **)); 577void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **)); 578int netaddr_match __P((int,union nethostaddr *,struct mbuf *)); 579int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *)); 580int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *)); 581int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int)); 582void nfsm_adj __P((struct mbuf *,int,int)); 583int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *)); 584void nfsrv_initcache __P((void)); 585int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T)); 586int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int)); 587int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *)); 588int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); 589void nfs_nhinit __P((void)); 590void nfs_timer __P((void*)); 591u_long nfs_hash __P((nfsfh_t *,int)); 592int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); 593int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); 594void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); 595void nfsrv_cleancache __P((void)); 596int nfs_connect __P((struct nfsmount *,struct nfsreq *)); 597void nfs_disconnect __P((struct nfsmount *)); 598int nfs_getattrcache __P((struct vnode *,struct vattr *)); 599int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); 600int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *)); 601int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); 602void nfsrv_init __P((int)); 603void nfs_clearcommit __P((struct mount *)); 604int nfsrv_errmap __P((struct nfsrv_descript *, int)); 605void nfsrvw_sort __P((gid_t [],int)); 606void nfsrv_setcred __P((struct ucred *,struct ucred *)); 607int nfs_writebp __P((struct buf *,int)); 608int nfsrv_object_create __P(( struct vnode * )); 609void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); 610int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, 611 struct proc *, struct mbuf **)); 612int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, 613 struct proc *p)); 614 615int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 616 struct proc *procp, struct mbuf **mrq)); 617int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 618 struct proc *procp, struct mbuf **mrq)); 619int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 620 struct proc *procp, struct mbuf **mrq)); 621int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **, 622 struct ucred *,struct nfssvc_sock *,struct mbuf *, 623 int *,int)); 624int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 625 struct proc *procp, struct mbuf **mrq)); 626int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 627 struct proc *procp, struct mbuf **mrq)); 628int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 629 struct proc *procp, struct mbuf **mrq)); 630int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 631 struct proc *procp, struct mbuf **mrq)); 632int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 633 struct proc *procp, struct mbuf **mrq)); 634int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 635 struct proc *procp, struct mbuf **mrq)); 636int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 637 struct proc *procp, struct mbuf **mrq)); 638int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 639 struct proc *procp, struct mbuf **mrq)); 640int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, 641 struct nfssvc_sock *slp, struct proc *procp, 642 struct mbuf **mrq)); 643int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 644 struct proc *procp, struct mbuf **mrq)); 645int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 646 struct proc *procp, struct mbuf **mrq)); 647int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, 648 struct nfssvc_sock *slp, struct proc *procp, 649 struct mbuf **mrq)); 650int nfsrv_readlink __P((struct nfsrv_descript *nfsd, 651 struct nfssvc_sock *slp, struct proc *procp, 652 struct mbuf **mrq)); 653int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 654 struct proc *procp, struct mbuf **mrq)); 655int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 656 struct proc *procp, struct mbuf **mrq)); 657int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 658 struct proc *procp, struct mbuf **mrq)); 659int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 660 struct proc *procp, struct mbuf **mrq)); 661int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 662 struct proc *procp, struct mbuf **mrq)); 663int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 664 struct proc *procp, struct mbuf **mrq)); 665int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 666 struct proc *procp, struct mbuf **mrq)); 667void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); 668void nfsrv_slpderef __P((struct nfssvc_sock *slp)); 669#endif /* KERNEL */ 670 671#endif
| 333} 334 335/* 336 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 337 * What should be in this set is open to debate, but I believe that since 338 * I/O system calls on ufs are never interrupted by signals the set should 339 * be minimal. My reasoning is that many current programs that use signals 340 * such as SIGALRM will not expect file I/O system calls to be interrupted 341 * by them and break. 342 */ 343#ifdef KERNEL 344 345struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 346 347#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ 348 sigmask(SIGHUP)|sigmask(SIGQUIT)) 349 350/* 351 * Socket errors ignored for connectionless sockets?? 352 * For now, ignore them all 353 */ 354#define NFSIGNORE_SOERROR(s, e) \ 355 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 356 ((s) & PR_CONNREQUIRED) == 0) 357 358/* 359 * Nfs outstanding request list element 360 */ 361struct nfsreq { 362 TAILQ_ENTRY(nfsreq) r_chain; 363 struct mbuf *r_mreq; 364 struct mbuf *r_mrep; 365 struct mbuf *r_md; 366 caddr_t r_dpos; 367 struct nfsmount *r_nmp; 368 struct vnode *r_vp; 369 u_long r_xid; 370 int r_flags; /* flags on request, see below */ 371 int r_retry; /* max retransmission count */ 372 int r_rexmit; /* current retrans count */ 373 int r_timer; /* tick counter on reply */ 374 int r_procnum; /* NFS procedure number */ 375 int r_rtt; /* RTT for rpc */ 376 struct proc *r_procp; /* Proc that did I/O system call */ 377}; 378 379/* 380 * Queue head for nfsreq's 381 */ 382extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq; 383 384/* Flag values for r_flags */ 385#define R_TIMING 0x01 /* timing request (in mntp) */ 386#define R_SENT 0x02 /* request has been sent */ 387#define R_SOFTTERM 0x04 /* soft mnt, too many retries */ 388#define R_INTR 0x08 /* intr mnt, signal pending */ 389#define R_SOCKERR 0x10 /* Fatal error on socket */ 390#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */ 391#define R_MUSTRESEND 0x40 /* Must resend request */ 392#define R_GETONEREP 0x80 /* Probe for one reply only */ 393 394/* 395 * A list of nfssvc_sock structures is maintained with all the sockets 396 * that require service by the nfsd. 397 * The nfsuid structs hang off of the nfssvc_sock structs in both lru 398 * and uid hash lists. 399 */ 400#ifndef NFS_UIDHASHSIZ 401#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */ 402#endif 403#define NUIDHASH(sock, uid) \ 404 (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ]) 405#ifndef NFS_WDELAYHASHSIZ 406#define NFS_WDELAYHASHSIZ 16 /* and with this */ 407#endif 408#define NWDELAYHASH(sock, f) \ 409 (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ]) 410#ifndef NFS_MUIDHASHSIZ 411#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */ 412#endif 413#define NMUIDHASH(nmp, uid) \ 414 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ]) 415#define NFSNOHASH(fhsum) \ 416 (&nfsnodehashtbl[(fhsum) & nfsnodehash]) 417 418/* 419 * Network address hash list element 420 */ 421union nethostaddr { 422 u_long had_inetaddr; 423 struct mbuf *had_nam; 424}; 425 426struct nfsuid { 427 TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ 428 LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ 429 int nu_flag; /* Flags */ 430 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ 431 struct ucred nu_cr; /* Cred uid mapped to */ 432 int nu_expire; /* Expiry time (sec) */ 433 struct timeval nu_timestamp; /* Kerb. timestamp */ 434 u_long nu_nickname; /* Nickname on server */ 435 NFSKERBKEY_T nu_key; /* and session key */ 436}; 437 438#define nu_inetaddr nu_haddr.had_inetaddr 439#define nu_nam nu_haddr.had_nam 440/* Bits for nu_flag */ 441#define NU_INETADDR 0x1 442#define NU_NAM 0x2 443#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO) 444 445struct nfssvc_sock { 446 TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ 447 TAILQ_HEAD(, nfsuid) ns_uidlruhead; 448 struct file *ns_fp; 449 struct socket *ns_so; 450 struct mbuf *ns_nam; 451 struct mbuf *ns_raw; 452 struct mbuf *ns_rawend; 453 struct mbuf *ns_rec; 454 struct mbuf *ns_recend; 455 struct mbuf *ns_frag; 456 int ns_flag; 457 int ns_solock; 458 int ns_cc; 459 int ns_reclen; 460 int ns_numuids; 461 u_long ns_sref; 462 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ 463 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; 464 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ]; 465}; 466 467/* Bits for "ns_flag" */ 468#define SLP_VALID 0x01 469#define SLP_DOREC 0x02 470#define SLP_NEEDQ 0x04 471#define SLP_DISCONN 0x08 472#define SLP_GETSTREAM 0x10 473#define SLP_LASTFRAG 0x20 474#define SLP_ALLFLAGS 0xff 475 476extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead; 477extern int nfssvc_sockhead_flag; 478#define SLP_INIT 0x01 479#define SLP_WANTINIT 0x02 480 481/* 482 * One of these structures is allocated for each nfsd. 483 */ 484struct nfsd { 485 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ 486 int nfsd_flag; /* NFSD_ flags */ 487 struct nfssvc_sock *nfsd_slp; /* Current socket */ 488 int nfsd_authlen; /* Authenticator len */ 489 u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ 490 int nfsd_verflen; /* and the Verifier */ 491 u_char nfsd_verfstr[RPCVERF_MAXSIZ]; 492 struct proc *nfsd_procp; /* Proc ptr */ 493 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */ 494}; 495 496/* Bits for "nfsd_flag" */ 497#define NFSD_WAITING 0x01 498#define NFSD_REQINPROG 0x02 499#define NFSD_NEEDAUTH 0x04 500#define NFSD_AUTHFAIL 0x08 501 502/* 503 * This structure is used by the server for describing each request. 504 * Some fields are used only when write request gathering is performed. 505 */ 506struct nfsrv_descript { 507 u_quad_t nd_time; /* Write deadline (usec) */ 508 off_t nd_off; /* Start byte offset */ 509 off_t nd_eoff; /* and end byte offset */ 510 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ 511 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ 512 LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ 513 struct mbuf *nd_mrep; /* Request mbuf list */ 514 struct mbuf *nd_md; /* Current dissect mbuf */ 515 struct mbuf *nd_mreq; /* Reply mbuf list */ 516 struct mbuf *nd_nam; /* and socket addr */ 517 struct mbuf *nd_nam2; /* return socket addr */ 518 caddr_t nd_dpos; /* Current dissect pos */ 519 int nd_procnum; /* RPC # */ 520 int nd_stable; /* storage type */ 521 int nd_flag; /* nd_flag */ 522 int nd_len; /* Length of this write */ 523 int nd_repstat; /* Reply status */ 524 u_long nd_retxid; /* Reply xid */ 525 u_long nd_duration; /* Lease duration */ 526 struct timeval nd_starttime; /* Time RPC initiated */ 527 fhandle_t nd_fh; /* File handle */ 528 struct ucred nd_cr; /* Credentials */ 529}; 530 531/* Bits for "nd_flag" */ 532#define ND_READ LEASE_READ 533#define ND_WRITE LEASE_WRITE 534#define ND_CHECK 0x04 535#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK) 536#define ND_NFSV3 0x08 537#define ND_NQNFS 0x10 538#define ND_KERBNICK 0x20 539#define ND_KERBFULL 0x40 540#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL) 541 542extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head; 543extern int nfsd_head_flag; 544#define NFSD_CHECKSLP 0x01 545 546/* 547 * These macros compare nfsrv_descript structures. 548 */ 549#define NFSW_CONTIG(o, n) \ 550 ((o)->nd_eoff >= (n)->nd_off && \ 551 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH)) 552 553#define NFSW_SAMECRED(o, n) \ 554 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ 555 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ 556 sizeof (struct ucred))) 557 558 559int nfs_init __P((struct vfsconf *vfsp)); 560int nfs_reply __P((struct nfsreq *)); 561int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int)); 562int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *)); 563int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *)); 564int nfs_sndlock __P((int *,struct nfsreq *)); 565void nfs_sndunlock __P((int *flagp)); 566int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 567int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int)); 568int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *)); 569int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *)); 570int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *)); 571int nfs_asyncio __P((struct buf *,struct ucred *)); 572int nfs_doio __P((struct buf *,struct ucred *,struct proc *)); 573int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *)); 574int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *)); 575int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *)); 576int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *)); 577void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *)); 578void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **)); 579void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **)); 580int netaddr_match __P((int,union nethostaddr *,struct mbuf *)); 581int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *)); 582int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *)); 583int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int)); 584void nfsm_adj __P((struct mbuf *,int,int)); 585int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *)); 586void nfsrv_initcache __P((void)); 587int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T)); 588int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int)); 589int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *)); 590int nfs_adv __P((struct mbuf **,caddr_t *,int,int)); 591void nfs_nhinit __P((void)); 592void nfs_timer __P((void*)); 593u_long nfs_hash __P((nfsfh_t *,int)); 594int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **)); 595int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **)); 596void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *)); 597void nfsrv_cleancache __P((void)); 598int nfs_connect __P((struct nfsmount *,struct nfsreq *)); 599void nfs_disconnect __P((struct nfsmount *)); 600int nfs_getattrcache __P((struct vnode *,struct vattr *)); 601int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long)); 602int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *)); 603int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *)); 604void nfsrv_init __P((int)); 605void nfs_clearcommit __P((struct mount *)); 606int nfsrv_errmap __P((struct nfsrv_descript *, int)); 607void nfsrvw_sort __P((gid_t [],int)); 608void nfsrv_setcred __P((struct ucred *,struct ucred *)); 609int nfs_writebp __P((struct buf *,int)); 610int nfsrv_object_create __P(( struct vnode * )); 611void nfsrv_wakenfsd __P((struct nfssvc_sock *slp)); 612int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, 613 struct proc *, struct mbuf **)); 614int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, 615 struct proc *p)); 616 617int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 618 struct proc *procp, struct mbuf **mrq)); 619int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 620 struct proc *procp, struct mbuf **mrq)); 621int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 622 struct proc *procp, struct mbuf **mrq)); 623int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **, 624 struct ucred *,struct nfssvc_sock *,struct mbuf *, 625 int *,int)); 626int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 627 struct proc *procp, struct mbuf **mrq)); 628int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 629 struct proc *procp, struct mbuf **mrq)); 630int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 631 struct proc *procp, struct mbuf **mrq)); 632int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 633 struct proc *procp, struct mbuf **mrq)); 634int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 635 struct proc *procp, struct mbuf **mrq)); 636int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 637 struct proc *procp, struct mbuf **mrq)); 638int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 639 struct proc *procp, struct mbuf **mrq)); 640int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 641 struct proc *procp, struct mbuf **mrq)); 642int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, 643 struct nfssvc_sock *slp, struct proc *procp, 644 struct mbuf **mrq)); 645int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 646 struct proc *procp, struct mbuf **mrq)); 647int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 648 struct proc *procp, struct mbuf **mrq)); 649int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, 650 struct nfssvc_sock *slp, struct proc *procp, 651 struct mbuf **mrq)); 652int nfsrv_readlink __P((struct nfsrv_descript *nfsd, 653 struct nfssvc_sock *slp, struct proc *procp, 654 struct mbuf **mrq)); 655int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 656 struct proc *procp, struct mbuf **mrq)); 657int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 658 struct proc *procp, struct mbuf **mrq)); 659int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 660 struct proc *procp, struct mbuf **mrq)); 661int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 662 struct proc *procp, struct mbuf **mrq)); 663int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 664 struct proc *procp, struct mbuf **mrq)); 665int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 666 struct proc *procp, struct mbuf **mrq)); 667int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, 668 struct proc *procp, struct mbuf **mrq)); 669void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag)); 670void nfsrv_slpderef __P((struct nfssvc_sock *slp)); 671#endif /* KERNEL */ 672 673#endif
|