Messages in this thread Patch in this message | | | Date | Thu, 22 Jan 1998 18:36:01 -0500 | From | Bill Hawes <> | Subject | Re: patch for 2.1.80 knfsd |
| |
Bill Hawes wrote: > > The attached patch has some minor fixes and improvements for 2.1.80
Sorry, forget to attach the patch ...--- linux-2.1.80/include/linux/nfsd/nfsfh.h.old Wed Jan 21 00:13:18 1998 +++ linux-2.1.80/include/linux/nfsd/nfsfh.h Thu Jan 22 00:21:15 1998 @@ -116,12 +116,16 @@ dfprintk(FILEOP, "nfsd: fh_lock(%x/%ld) locked = %d\n", SVCFH_DEV(fhp), SVCFH_INO(fhp), fhp->fh_locked); */ - if (!fhp->fh_locked) { - down(&inode->i_sem); - if (!fhp->fh_pre_mtime) - fhp->fh_pre_mtime = inode->i_mtime; - fhp->fh_locked = 1; + if (fhp->fh_locked) { + printk(KERN_WARNING "fh_lock: %s/%s already locked!\n", + fhp->fh_dentry->d_parent->d_name.name, + fhp->fh_dentry->d_name.name); + return; } + down(&inode->i_sem); + if (!fhp->fh_pre_mtime) + fhp->fh_pre_mtime = inode->i_mtime; + fhp->fh_locked = 1; } /* @@ -130,9 +134,8 @@ static inline void fh_unlock(struct svc_fh *fhp) { - struct inode *inode = fhp->fh_dentry->d_inode; - if (fhp->fh_locked) { + struct inode *inode = fhp->fh_dentry->d_inode; if (!fhp->fh_post_version) fhp->fh_post_version = inode->i_version; fhp->fh_locked = 0; --- linux-2.1.80/fs/nfsd/nfsfh.c.old Tue Jan 13 10:38:30 1998 +++ linux-2.1.80/fs/nfsd/nfsfh.c Thu Jan 22 17:38:06 1998 @@ -999,21 +999,19 @@ u32 fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) { + struct knfs_fh *fh = &fhp->fh_handle; struct svc_export *exp; struct dentry *dentry; struct inode *inode; - struct knfs_fh *fh = &fhp->fh_handle; u32 error = 0; - if(fhp->fh_dverified) - goto out; - - dprintk("nfsd: fh_lookup(exp %x/%ld fh %p)\n", - fh->fh_xdev, fh->fh_xino, fh->fh_dcookie); + dprintk("nfsd: fh_verify(exp %x/%ld cookie %p)\n", + fh->fh_xdev, fh->fh_xino, fh->fh_dcookie); + if(fhp->fh_dverified) + goto check_type; /* * Look up the export entry. - * N.B. We need to lock this while in use ... */ error = nfserr_stale; exp = exp_get(rqstp->rq_client, fh->fh_xdev, fh->fh_xino); @@ -1057,6 +1055,8 @@ * spec says this is incorrect (implementation notes for the * write call). */ +check_type: + dentry = fhp->fh_dentry; inode = dentry->d_inode; if (type > 0 && (inode->i_mode & S_IFMT) != type) { error = (type == S_IFDIR)? nfserr_notdir : nfserr_isdir; @@ -1069,9 +1069,11 @@ /* Finally, check access permissions. */ error = nfsd_permission(fhp->fh_export, dentry, access); +#ifdef NFSD_PARANOIA if (error) printk("fh_verify: %s/%s permission failure, acc=%x, error=%d\n", dentry->d_parent->d_name.name, dentry->d_name.name, access, error); +#endif out: return error; --- linux-2.1.80/fs/nfsd/nfssvc.c.old Sat Dec 20 16:58:31 1997 +++ linux-2.1.80/fs/nfsd/nfssvc.c Thu Jan 22 12:44:08 1998 @@ -42,6 +42,7 @@ extern struct svc_program nfsd_program; static void nfsd(struct svc_rqst *rqstp); struct timeval nfssvc_boot = { 0, 0 }; +static int nfsd_active = 0; int nfsd_svc(unsigned short port, int nrservs) @@ -97,6 +98,7 @@ oldumask = current->fs->umask; /* Set umask to 0. */ current->fs->umask = 0; nfssvc_boot = xtime; /* record boot time */ + nfsd_active++; lockd_up(); /* start lockd */ /* @@ -160,6 +162,11 @@ /* Release lockd */ lockd_down(); + if (!--nfsd_active) { + printk("nfsd: last server exiting\n"); + /* revoke all exports */ + nfsd_export_shutdown(); + } /* Destroy the thread */ svc_exit_thread(rqstp); --- linux-2.1.80/fs/nfsd/export.c.old Sun Nov 30 11:33:43 1997 +++ linux-2.1.80/fs/nfsd/export.c Thu Jan 22 16:30:47 1998 @@ -433,19 +433,37 @@ int exp_writelock(void) { + /* fast track */ + if (!hash_count && !hash_lock) { + lock_it: + hash_lock = 1; + return 0; + } + + current->sigpending = 0; want_lock++; - while (hash_count || hash_lock) + while (hash_count || hash_lock) { interruptible_sleep_on(&hash_wait); + if (signal_pending(current)) + break; + } want_lock--; - if (signal_pending(current)) - return -EINTR; - hash_lock = 1; - return 0; + + /* restore the task's signals */ + spin_lock_irq(¤t->sigmask_lock); + recalc_sigpending(current); + spin_unlock_irq(¤t->sigmask_lock); + + if (!hash_count && !hash_lock) + goto lock_it; + return -EINTR; } void exp_unlock(void) { + if (!hash_count && !hash_lock) + printk(KERN_WARNING "exp_unlock: not locked!\n"); if (hash_count) hash_count--; else | |