diff options
Diffstat (limited to 'contrib/amd/amd/nfs_subr.c')
-rw-r--r-- | contrib/amd/amd/nfs_subr.c | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/contrib/amd/amd/nfs_subr.c b/contrib/amd/amd/nfs_subr.c index d06d008..540202a 100644 --- a/contrib/amd/amd/nfs_subr.c +++ b/contrib/amd/amd/nfs_subr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: nfs_subr.c,v 1.3 1999/01/13 23:31:00 ezk Exp $ + * $Id: nfs_subr.c,v 1.6.2.3 2001/04/14 21:08:22 ezk Exp $ * */ @@ -108,6 +108,7 @@ nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) static nfsattrstat res; am_node *mp; int retry; + time_t now = clocktime(); #ifdef DEBUG amuDebug(D_TRACE) @@ -122,33 +123,31 @@ nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) plog(XLOG_DEBUG, "\tretry=%d", retry); #endif /* DEBUG */ - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.ns_status = nfs_error(retry); } else { nfsattrstat *attrp = &mp->am_attr; #ifdef DEBUG amuDebug(D_TRACE) - plog(XLOG_DEBUG, "\tstat(%s), size = %d", mp->am_path, - (int) attrp->ns_u.ns_attr_u.na_size); + plog(XLOG_DEBUG, "\tstat(%s), size = %d, mtime=%ld", + mp->am_path, + (int) attrp->ns_u.ns_attr_u.na_size, + (long) attrp->ns_u.ns_attr_u.na_mtime.nt_seconds); #endif /* DEBUG */ + /* Delay unmount of what was looked up */ + if (mp->am_timeo_w < 4 * gopt.am_timeo_w) + mp->am_timeo_w += gopt.am_timeo_w; + mp->am_ttl = now + mp->am_timeo_w; + mp->am_stats.s_getattr++; return attrp; } -#ifndef MNT2_NFS_OPT_SYMTTL - /* - * This code is needed to defeat Solaris 2.4's (and newer) symlink values - * cache. It forces the last-modified time of the symlink to be current. - * It is not needed if the O/S has an nfs flag to turn off the - * symlink-cache at mount time (such as Irix 5.x and 6.x). -Erez. - */ - if (++res.ns_u.ns_attr_u.na_mtime.nt_useconds == 0) - ++res.ns_u.ns_attr_u.na_mtime.nt_seconds; -#endif /* not MNT2_NFS_OPT_SYMTTL */ - return &res; } @@ -182,16 +181,26 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) static nfsdiropres res; am_node *mp; int retry; + uid_t uid; + gid_t gid; #ifdef DEBUG amuDebug(D_TRACE) plog(XLOG_DEBUG, "lookup:"); #endif /* DEBUG */ + /* finally, find the effective uid/gid from RPC request */ + if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) + plog(XLOG_ERROR, "cannot get uid/gid from RPC credentials"); + sprintf(opt_uid, "%d", (int) uid); + sprintf(opt_gid, "%d", (int) gid); + mp = fh_to_mp2(&argp->da_fhandle, &retry); if (mp == 0) { - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.dr_status = nfs_error(retry); } else { int error; @@ -203,9 +212,6 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) ap = (*mp->am_mnt->mf_ops->lookuppn) (mp, argp->da_name, &error, VLOOK_CREATE); if (ap == 0) { if (error < 0) { -#ifdef DEBUG - dlog("Not sending RPC reply"); -#endif /* DEBUG */ amd_stats.d_drops++; return 0; } @@ -289,8 +295,10 @@ nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) mp = fh_to_mp2(argp, &retry); if (mp == 0) { readlink_retry: - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.rlr_status = nfs_error(retry); } else { char *ln = do_readlink(mp, &retry, (nfsattrstat **) 0); @@ -367,8 +375,10 @@ unlink_or_rmdir(nfsdiropargs *argp, struct svc_req *rqstp, int unlinkp) am_node *mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_DELETE); if (mp == 0) { - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res = nfs_error(retry); goto out; } @@ -500,8 +510,10 @@ nfsproc_readdir_2_svc(nfsreaddirargs *argp, struct svc_req *rqstp) mp = fh_to_mp2(&argp->rda_fhandle, &retry); if (mp == 0) { - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.rdr_status = nfs_error(retry); } else { #ifdef DEBUG @@ -533,8 +545,10 @@ nfsproc_statfs_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) mp = fh_to_mp2(argp, &retry); if (mp == 0) { - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.sfr_status = nfs_error(retry); } else { nfsstatfsokres *fp; |