From: Simon Wilkinson Date: Fri, 23 Apr 2010 17:39:14 +0000 (+0100) Subject: Linux: Remove the BKL X-Git-Tag: openafs-devel-1_5_75~108 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=196d2c7f9e3250008bf6aed2e172ec6d54e4ffb7 Linux: Remove the BKL Recent investigations suggest that we no long require the BKL on Linux. As an experiment, remove it. Change-Id: I764fe1f6e9761ada5a0a86ba59450c0615bb1e78 Reviewed-on: http://gerrit.openafs.org/1823 Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear --- diff --git a/src/afs/LINUX/osi_export.c b/src/afs/LINUX/osi_export.c index 59a84db..5b300e0 100644 --- a/src/afs/LINUX/osi_export.c +++ b/src/afs/LINUX/osi_export.c @@ -545,13 +545,11 @@ static struct dentry *afs_export_get_dentry(struct super_block *sb, cred_t *credp; credp = crref(); - lock_kernel(); AFS_GLOCK(); dp = get_dentry_from_fid(credp, inump); AFS_GUNLOCK(); - unlock_kernel(); crfree(credp); return dp; @@ -609,7 +607,6 @@ static int afs_export_get_name(struct dentry *parent, char *name, afs_InitFakeStat(&fakestate); credp = crref(); - lock_kernel(); AFS_GLOCK(); vcp = VTOAFS(child->d_inode); @@ -818,7 +815,6 @@ done: } afs_PutFakeStat(&fakestate); AFS_GUNLOCK(); - unlock_kernel(); crfree(credp); code = afs_CheckCode(code, &treq, 102); return -code; @@ -846,7 +842,6 @@ static struct dentry *afs_export_get_parent(struct dentry *child) } credp = crref(); - lock_kernel(); AFS_GLOCK(); vcp = VTOAFS(child->d_inode); @@ -938,7 +933,6 @@ static struct dentry *afs_export_get_parent(struct dentry *child) done: AFS_GUNLOCK(); - unlock_kernel(); crfree(credp); return dp; diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 132c800..c0c589b 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -204,7 +204,6 @@ osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) newattrs.ia_ctime = CURRENT_TIME; /* avoid notify_change() since it wants to update dentry->d_parent */ - lock_kernel(); code = inode_change_ok(inode, &newattrs); if (!code) { #ifdef INODE_SETATTR_NOT_VOID @@ -216,7 +215,6 @@ osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) inode_setattr(inode, &newattrs); #endif } - unlock_kernel(); if (!code) truncate_inode_pages(&inode->i_data, asize); code = -code; diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index f5a0bd2..1191cf2 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -272,24 +272,20 @@ afs_xsetgroups(int gidsetsize, gid_t * grouplist) afs_uint32 junk; int old_pag; - lock_kernel(); old_pag = PagInCred(cr); crfree(cr); - unlock_kernel(); code = (*sys_setgroupsp) (gidsetsize, grouplist); if (code) { return code; } - lock_kernel(); cr = crref(); if (old_pag != NOPAG && PagInCred(cr) == NOPAG) { /* re-install old pag if there's room. */ code = __setpag(&cr, old_pag, &junk, 0); } crfree(cr); - unlock_kernel(); /* Linux syscall ABI returns errno as negative */ return (-code); @@ -305,10 +301,8 @@ afs_xsetgroups32(int gidsetsize, gid_t * grouplist) afs_uint32 junk; int old_pag; - lock_kernel(); old_pag = PagInCred(cr); crfree(cr); - unlock_kernel(); code = (*sys_setgroups32p) (gidsetsize, grouplist); @@ -316,14 +310,12 @@ afs_xsetgroups32(int gidsetsize, gid_t * grouplist) return code; } - lock_kernel(); cr = crref(); if (old_pag != NOPAG && PagInCred(cr) == NOPAG) { /* re-install old pag if there's room. */ code = __setpag(&cr, old_pag, &junk, 0); } crfree(cr); - unlock_kernel(); /* Linux syscall ABI returns errno as negative */ return (-code); @@ -339,24 +331,20 @@ asmlinkage long afs32_xsetgroups(int gidsetsize, gid_t *grouplist) afs_uint32 junk; int old_pag; - lock_kernel(); old_pag = PagInCred(cr); crfree(cr); - unlock_kernel(); code = (*sys32_setgroupsp)(gidsetsize, grouplist); if (code) { return code; } - lock_kernel(); cr = crref(); if (old_pag != NOPAG && PagInCred(cr) == NOPAG) { /* re-install old pag if there's room. */ code = __setpag(&cr, old_pag, &junk, 0); } crfree(cr); - unlock_kernel(); /* Linux syscall ABI returns errno as negative */ return (-code); @@ -374,24 +362,20 @@ afs32_xsetgroups(int gidsetsize, u16 * grouplist) afs_uint32 junk; int old_pag; - lock_kernel(); old_pag = PagInCred(cr); crfree(cr); - unlock_kernel(); code = (*sys32_setgroupsp) (gidsetsize, grouplist); if (code) { return code; } - lock_kernel(); cr = crref(); if (old_pag != NOPAG && PagInCred(cr) == NOPAG) { /* re-install old pag if there's room. */ code = __setpag(&cr, old_pag, &junk, 0); } crfree(cr); - unlock_kernel(); /* Linux syscall ABI returns errno as negative */ return (-code); @@ -407,24 +391,20 @@ afs32_xsetgroups32(int gidsetsize, gid_t * grouplist) afs_uint32 junk; int old_pag; - lock_kernel(); old_pag = PagInCred(cr); crfree(cr); - unlock_kernel(); code = (*sys32_setgroups32p) (gidsetsize, grouplist); if (code) { return code; } - lock_kernel(); cr = crref(); if (old_pag != NOPAG && PagInCred(cr) == NOPAG) { /* re-install old pag if there's room. */ code = __setpag(&cr, old_pag, &junk, 0); } crfree(cr); - unlock_kernel(); /* Linux syscall ABI returns errno as negative */ return (-code); diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index b7d1c1a..1d3406d 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -208,7 +208,6 @@ afs_notify_change(struct dentry *dp, struct iattr *iattrp) VATTR_NULL(&vattr); iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */ - lock_kernel(); AFS_GLOCK(); code = afs_setattr(VTOAFS(ip), &vattr, credp); if (!code) { @@ -216,7 +215,6 @@ afs_notify_change(struct dentry *dp, struct iattr *iattrp) vattr2inode(ip, &vattr); } AFS_GUNLOCK(); - unlock_kernel(); crfree(credp); return -code; } diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 8c42134..0e18504 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -53,21 +53,6 @@ extern struct backing_dev_info *afs_backing_dev_info; extern struct vcache *afs_globalVp; extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp); -/* Some uses of BKL are perhaps not needed for bypass or memcache-- - * why don't we try it out? */ -extern struct afs_cacheOps afs_UfsCacheOps; - -static inline void -afs_maybe_lock_kernel(void) { - if(afs_cacheType == &afs_UfsCacheOps) - lock_kernel(); -} - -static inline void -afs_maybe_unlock_kernel(void) { - if(afs_cacheType == &afs_UfsCacheOps) - unlock_kernel(); -} /* This function converts a positive error code from AFS into a negative * code suitable for passing into the Linux VFS layer. It checks that the @@ -212,7 +197,6 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) cred_t *credp = crref(); struct afs_fakestat_state fakestat; - afs_maybe_lock_kernel(); AFS_GLOCK(); AFS_STATCNT(afs_readdir); @@ -364,7 +348,6 @@ out: afs_PutFakeStat(&fakestat); out1: AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); return code; } @@ -416,11 +399,9 @@ afs_linux_open(struct inode *ip, struct file *fp) cred_t *credp = crref(); int code; - afs_maybe_lock_kernel(); AFS_GLOCK(); code = afs_open(&vcp, fp->f_flags, credp); AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); crfree(credp); return afs_convert_code(code); @@ -433,7 +414,6 @@ afs_linux_release(struct inode *ip, struct file *fp) cred_t *credp = crref(); int code = 0; - afs_maybe_lock_kernel(); AFS_GLOCK(); code = afs_close(vcp, fp->f_flags, credp); ObtainWriteLock(&vcp->lock, 807); @@ -443,7 +423,6 @@ afs_linux_release(struct inode *ip, struct file *fp) } ReleaseWriteLock(&vcp->lock); AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); crfree(credp); return afs_convert_code(code); @@ -460,11 +439,9 @@ afs_linux_fsync(struct file *fp, int datasync) struct inode *ip = FILE_INODE(fp); cred_t *credp = crref(); - afs_maybe_lock_kernel(); AFS_GLOCK(); code = afs_fsync(VTOAFS(ip), credp); AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); crfree(credp); return afs_convert_code(code); @@ -781,7 +758,6 @@ afs_linux_revalidate(struct dentry *dp) if (afs_shuttingdown) return EIO; - afs_maybe_lock_kernel(); AFS_GLOCK(); #ifdef notyet @@ -792,7 +768,6 @@ afs_linux_revalidate(struct dentry *dp) check_bad_parent(dp); /* check and correct mvid */ AFS_GUNLOCK(); - unlock_kernel(); return 0; } #endif @@ -814,7 +789,6 @@ afs_linux_revalidate(struct dentry *dp) afs_fill_inode(AFSTOV(vcp), &vattr); AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); return afs_convert_code(code); } @@ -850,7 +824,6 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags) int valid; struct afs_fakestat_state fakestate; - afs_maybe_lock_kernel(); AFS_GLOCK(); afs_InitFakeStat(&fakestate); @@ -963,7 +936,6 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags) shrink_dcache_parent(dp); d_drop(dp); } - afs_maybe_unlock_kernel(); return valid; bad_dentry: @@ -1034,7 +1006,6 @@ afs_linux_create(struct inode *dip, struct dentry *dp, int mode) vattr.va_mode = mode; vattr.va_type = mode & S_IFMT; - afs_maybe_lock_kernel(); AFS_GLOCK(); code = afs_create(VTOAFS(dip), (char *)name, &vattr, NONEXCL, mode, &vcp, credp); @@ -1051,7 +1022,6 @@ afs_linux_create(struct inode *dip, struct dentry *dp, int mode) } AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); crfree(credp); return afs_convert_code(code); } @@ -1072,7 +1042,6 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp) struct dentry *newdp = NULL; int code; - afs_maybe_lock_kernel(); AFS_GLOCK(); code = afs_lookup(VTOAFS(dip), (char *)comp, &vcp, credp); @@ -1100,7 +1069,6 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp) dput(alias); } else { iput(ip); - afs_maybe_unlock_kernel(); crfree(credp); return alias; } @@ -1108,7 +1076,6 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp) } newdp = d_splice_alias(ip, dp); - afs_maybe_unlock_kernel(); crfree(credp); /* It's ok for the file to not be found. That's noted by the caller by @@ -1212,8 +1179,6 @@ afs_linux_unlink(struct inode *dip, struct dentry *dp) const char *name = dp->d_name.name; struct vcache *tvc = VTOAFS(dp->d_inode); - afs_maybe_lock_kernel(); - if (VREFCOUNT(tvc) > 1 && tvc->opens > 0 && !(tvc->f.states & CUnlinked)) { @@ -1226,7 +1191,6 @@ afs_linux_unlink(struct inode *dip, struct dentry *dp) d_drop(dp); } - afs_maybe_unlock_kernel(); crfree(credp); return afs_convert_code(code); } @@ -1262,7 +1226,6 @@ afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode) struct vattr vattr; const char *name = dp->d_name.name; - afs_maybe_lock_kernel(); VATTR_NULL(&vattr); vattr.va_mask = ATTR_MODE; vattr.va_mode = mode; @@ -1281,7 +1244,6 @@ afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode) } AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); crfree(credp); return afs_convert_code(code); } @@ -1327,7 +1289,6 @@ afs_linux_rename(struct inode *oldip, struct dentry *olddp, struct dentry *rehash = NULL; /* Prevent any new references during rename operation. */ - afs_maybe_lock_kernel(); if (!d_unhashed(newdp)) { d_drop(newdp); @@ -1347,8 +1308,6 @@ afs_linux_rename(struct inode *oldip, struct dentry *olddp, if (rehash) d_rehash(rehash); - afs_maybe_unlock_kernel(); - crfree(credp); return afs_convert_code(code); } @@ -1664,7 +1623,6 @@ afs_linux_fillpage(struct file *fp, struct page *pp) setup_uio(auio, iovecp, (char *)address, offset, PAGE_SIZE, UIO_READ, AFS_UIOSYS); - afs_maybe_lock_kernel(); AFS_GLOCK(); AFS_DISCON_LOCK(); afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, ICL_TYPE_POINTER, ip, @@ -1678,7 +1636,6 @@ afs_linux_fillpage(struct file *fp, struct page *pp) code); AFS_DISCON_UNLOCK(); AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); if (!code) { /* XXX valid for no-cache also? Check last bits of files... :) * Cognate code goes in afs_NoCacheFetchProc. */ @@ -1871,9 +1828,7 @@ afs_linux_bypass_readpage(struct file *fp, struct page *pp) ancr->length = PAGE_SIZE; credp = crref(); - afs_maybe_lock_kernel(); code = afs_ReadNoCache(VTOAFS(FILE_INODE(fp)), ancr, credp); - afs_maybe_unlock_kernel(); crfree(credp); return afs_convert_code(code); @@ -2085,7 +2040,6 @@ afs_linux_page_writeback(struct inode *ip, struct page *pp, buffer = kmap(pp) + offset; base = page_offset(pp) + offset; - afs_maybe_lock_kernel(); AFS_GLOCK(); afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, page_count(pp), @@ -2105,7 +2059,6 @@ afs_linux_page_writeback(struct inode *ip, struct page *pp, ICL_TYPE_INT32, code); AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); kunmap(pp); return code; @@ -2135,7 +2088,6 @@ afs_linux_writepage_sync(struct inode *ip, struct page *pp, credp = crref(); code = afs_linux_page_writeback(ip, pp, offset, count, credp); - afs_maybe_lock_kernel(); AFS_GLOCK(); ObtainWriteLock(&vcp->lock, 533); if (code > 0) @@ -2143,7 +2095,6 @@ afs_linux_writepage_sync(struct inode *ip, struct page *pp, afs_linux_complete_writeback(vcp); ReleaseWriteLock(&vcp->lock); AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); crfree(credp); if (code1) @@ -2224,7 +2175,6 @@ afs_linux_writepage(struct page *pp) code = afs_linux_page_writeback(inode, pp, 0, to, credp); - afs_maybe_lock_kernel(); AFS_GLOCK(); ObtainWriteLock(&vcp->lock, 538); @@ -2240,7 +2190,6 @@ afs_linux_writepage(struct page *pp) ReleaseWriteLock(&vcp->lock); crfree(credp); AFS_GUNLOCK(); - afs_maybe_unlock_kernel(); done: end_page_writeback(pp); @@ -2427,7 +2376,6 @@ afs_symlink_filler(struct file *file, struct page *page) char *p = (char *)kmap(page); int code; - afs_maybe_lock_kernel(); AFS_GLOCK(); code = afs_linux_ireadlink(ip, p, PAGE_SIZE, AFS_UIOSYS); AFS_GUNLOCK(); @@ -2435,7 +2383,6 @@ afs_symlink_filler(struct file *file, struct page *page) if (code < 0) goto fail; p[code] = '\0'; /* null terminate? */ - afs_maybe_unlock_kernel(); SetPageUptodate(page); kunmap(page); @@ -2443,8 +2390,6 @@ afs_symlink_filler(struct file *file, struct page *page) return 0; fail: - afs_maybe_unlock_kernel(); - SetPageError(page); kunmap(page); unlock_page(page); diff --git a/src/afs/afs_syscall.c b/src/afs/afs_syscall.c index b6425fa..d3496bf 100644 --- a/src/afs/afs_syscall.c +++ b/src/afs/afs_syscall.c @@ -595,7 +595,6 @@ Afs_syscall() } #endif #ifdef AFS_LINUX20_ENV - lock_kernel(); /* setup uap for use below - pull out the magic decoder ring to know * which syscalls have folded argument lists. */ @@ -898,7 +897,6 @@ Afs_syscall() #endif #ifdef AFS_LINUX20_ENV code = -code; - unlock_kernel(); #endif return code; }