Date: Thu, 14 Feb 2002 22:58:01 -0800 (PST) From: Balaji <balajir12@yahoo.com> To: freebsd-questions@freebsd.org Subject: error in nfs-updatecache..plz help Message-ID: <20020215065801.85515.qmail@web14604.mail.yahoo.com>
next in thread | raw e-mail | index | archive | help
--0-543270655-1013756281=:83835 Content-Type: text/plain; charset=us-ascii Hi, We want to log cache entries in a file when nfsd updates cache in nfs/nfs srvcache.c, we have used vn_open and vn_rdwr, but it is giving page faults when it encounters VCALL in server nfs code. This might be because of NDINIT not giving required vnode ptr. Here enclosed is the code of nfs_srvcache.c. The part of the code in red is the code that we've added. -------------------------------------------------------- > /* > * Update a request cache entry after the rpc has been done > */ > void > nfsrv updatecache(nd, repvalid, repmbuf) > register struct nfsrv descript *nd; > int repvalid; > struct mbuf *repmbuf; > { > register struct nfsrvcache *rp; > struct proc *p = curproc; > struct nameidata *ndp; > > int error, resid; > > if (!nd->nd nam2) > return; > loop: > for (rp = NFSRCHASH(nd->nd retxid)->lh first; rp != 0; > rp = rp->rc hash.le next) { > if (nd->nd retxid == rp->rc xid && nd->nd procnum == rp->rc proc > && > netaddr match(NETFAMILY(rp), &rp->rc haddr, nd->nd nam)) { > NFS DPF(RC, ("U%03x", rp->rc xid & 0xfff)); > if ((rp->rc flag & RC LOCKED) != 0) { > rp->rc flag |= RC WANTED; > (void) tsleep((caddr t)rp, PZERO-1, "nfsrc", 0); > goto loop; > } > rp->rc flag |= RC LOCKED; > if (rp->rc state == RC DONE) { > /* > * This can occur if the cache is too small. > * Retransmits of the same request aren't > * dropped so we may see the operation > * complete more then once. > */ > if (rp->rc flag & RC REPMBUF) { > m freem(rp->rc reply); > rp->rc flag &= ~RC REPMBUF; > } > } > rp->rc state = RC DONE; > /* > * If we have a valid reply update status and save > * the reply for non-idempotent rpc's. > */ > if (repvalid && nonidempotent[nd->nd procnum]) { > > /*Code to open the cache file*/ > > ndp = malloc(sizeof(struct nameidata),M TEMP,M WAITOK); > NDINIT(ndp,LOOKUP,NOFOLLOW,UIO USERSPACE,"/usr/cache",p); > > error = namei(ndp); > error = vn open(ndp,FWRITE,0); > > NDFREE(ndp,NDF ONLY PNBUF); > VOP UNLOCK(ndp->ni vp,0,p); > > if(error < 0) { > uprintf("Error in vn open().\n"); > } > else { > printf("File open!!!!\n"); > } > > if ((nd->nd flag & ND NFSV3) == 0 && > nfsv2 repstat[nfsv2 procid[nd->nd procnum]]) { > rp->rc status = nd->nd repstat; > rp->rc flag |= RC REPSTATUS; > } else { > rp->rc reply = m copym(repmbuf, > 0, M COPYALL, M WAIT); > rp->rc flag |= RC REPMBUF; > } > /* Code to write cache entries to a file */ > > VOP LEASE(ndp->ni vp, p, p->p cred, LEASE WRITE); > error = vn rdwr(UIO WRITE, ndp->ni vp, (caddr t)rp, sizeof(struct > nfsrvcache), 0, UIO SYSSPACE, IO APPEND|IO UNIT, p->p ucred, (int > *)0, p); > > /*Close cache file after writting to it*/ > vn close(ndp->ni vp, FWRITE, p->p ucred, p); > } > rp->rc flag &= ~RC LOCKED; > if (rp->rc flag & RC WANTED) { > rp->rc flag &= ~RC WANTED; > wakeup((caddr t)rp); > } > return; > } > } > NFS DPF(RC, ("L%03x", nd->nd retxid & 0xfff)); > } --------------------------------- Do You Yahoo!? Got something to say? Say it better with Yahoo! Video Mail --0-543270655-1013756281=:83835 Content-Type: text/html; charset=us-ascii <P>Hi, <BR>We want to log cache entries in a file when nfsd updates cache in nfs/nfs srvcache.c, we have used vn_open and vn_rdwr, but it is giving page faults when it encounters VCALL in server nfs code. This <BR>might be because of NDINIT not giving required vnode ptr. Here enclosed is the code of nfs_srvcache.c. The part of the code in red is the code that we've added.</P> <P><BR>-------------------------------------------------------- <BR>> /* <BR>> * Update a request cache entry after the rpc has been done <BR>> */ <BR>> void <BR>> nfsrv updatecache(nd, repvalid, repmbuf) <BR>> register struct nfsrv descript *nd; <BR>> int repvalid; <BR>> struct mbuf *repmbuf; <BR>> { <BR>> register struct nfsrvcache *rp; <BR>> struct proc *p = curproc; <BR>> struct nameidata *ndp; <BR>> <BR>> int error, resid; <BR>> <BR>> if (!nd->nd nam2) <BR>> return; <BR>> loop: <BR>> for (rp = NFSRCHASH(nd->nd retxid)->lh first; rp != 0; <BR>> rp = rp->rc hash.le next) { <BR>> if (nd->nd retxid == rp->rc xid && nd->nd procnum == rp->rc proc <BR>> && <BR>> netaddr match(NETFAMILY(rp), &rp->rc haddr, nd->nd nam)) { <BR>> NFS DPF(RC, ("U%03x", rp->rc xid & 0xfff)); <BR>> if ((rp->rc flag & RC LOCKED) != 0) { <BR>> rp->rc flag |= RC WANTED; <BR>> (void) tsleep((caddr t)rp, PZERO-1, "nfsrc", 0); <BR>> goto loop; <BR>> } <BR>> rp->rc flag |= RC LOCKED; <BR>> if (rp->rc state == RC DONE) { <BR>> /* <BR>> * This can occur if the cache is too small. <BR>> * Retransmits of the same request aren't <BR>> * dropped so we may see the operation <BR>> * complete more then once. <BR>> */ <BR>> if (rp->rc flag & RC REPMBUF) { <BR>> m freem(rp->rc reply); <BR>> rp->rc flag &= ~RC REPMBUF; <BR>> } <BR>> } <BR>> rp->rc state = RC DONE; <BR>> /* <BR>> * If we have a valid reply update status and save <BR>> * the reply for non-idempotent rpc's. <BR>> */ <BR>> if (repvalid && nonidempotent[nd->nd procnum]) { <BR>> <BR><FONT color=red>> /*Code to open the cache file*/ <BR>> <BR>> ndp = malloc(sizeof(struct nameidata),M TEMP,M WAITOK); <BR>> NDINIT(ndp,LOOKUP,NOFOLLOW,UIO USERSPACE,"/usr/cache",p); <BR>> <BR>> error = namei(ndp); <BR>> error = vn open(ndp,FWRITE,0); <BR>> <BR>> NDFREE(ndp,NDF ONLY PNBUF); <BR>> VOP UNLOCK(ndp->ni vp,0,p); <BR>> <BR>> if(error < 0) { <BR>> uprintf("Error in vn open().\n"); <BR>> } <BR>> else { <BR>> printf("File open!!!!\n"); <BR>> }</FONT> <BR>> <BR>> if ((nd->nd flag & ND NFSV3) == 0 && <BR>> nfsv2 repstat[nfsv2 procid[nd->nd procnum]]) { <BR>> rp->rc status = nd->nd repstat; <BR>> rp->rc flag |= RC REPSTATUS; <BR>> } else { <BR>> rp->rc reply = m copym(repmbuf, <BR>> 0, M COPYALL, M WAIT); <BR>> rp->rc flag |= RC REPMBUF; <BR>> } <BR><FONT color=red>> /* Code to write cache entries to a file */ <BR>> <BR>> VOP LEASE(ndp->ni vp, p, p->p cred, LEASE WRITE); <BR>> error = vn rdwr(UIO WRITE, ndp->ni vp, (caddr t)rp, sizeof(struct <BR>> nfsrvcache), 0, UIO SYSSPACE, IO APPEND|IO UNIT, p->p ucred, (int <BR>> *)0, p); <BR>> <BR>> /*Close cache file after writting to it*/ <BR>> vn close(ndp->ni vp, FWRITE, p->p ucred, p); <BR></FONT>> } <BR>> rp->rc flag &= ~RC LOCKED; <BR>> if (rp->rc flag & RC WANTED) { <BR>> rp->rc flag &= ~RC WANTED; <BR>> wakeup((caddr t)rp); <BR>> } <BR>> return; <BR>> } <BR>> } <BR>> NFS DPF(RC, ("L%03x", nd->nd retxid & 0xfff)); <BR>> }</P><p><br><hr size=1><b>Do You Yahoo!?</b><br> Got something to say? Say it better with <a href="http://rd.yahoo.com/mail_us/tag/?http://promo.yahoo.com/videomail/">Yahoo! Video Mail</a> --0-543270655-1013756281=:83835-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020215065801.85515.qmail>