From owner-freebsd-questions Thu Feb 14 22:58: 6 2002 Delivered-To: freebsd-questions@freebsd.org Received: from web14604.mail.yahoo.com (web14604.mail.yahoo.com [216.136.224.84]) by hub.freebsd.org (Postfix) with SMTP id BB3D937B402 for ; Thu, 14 Feb 2002 22:58:01 -0800 (PST) Message-ID: <20020215065801.85515.qmail@web14604.mail.yahoo.com> Received: from [61.11.22.88] by web14604.mail.yahoo.com via HTTP; Thu, 14 Feb 2002 22:58:01 PST Date: Thu, 14 Feb 2002 22:58:01 -0800 (PST) From: Balaji Subject: error in nfs-updatecache..plz help To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-543270655-1013756281=:83835" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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

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-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message