Skip to contentSkip to conversation

more BKL removal after get_sb pushdown

PATCH In review Arnd Bergmann 7 participants 24 messages Sep 16, 2010 – Sep 18, 2010

Subsystems (12)
Networking Network drivers VFS USB +8 more subsystems
lore
Share & tools
lore
#0 lore raw

cover more BKL removal after get_sb pushdown

These patches have not been posted yet, I did some of them only when going through the list of remaining BKL users and found them to be simple to fix myself.

Most of these patches only apply on top of the pushdown into the get_sb operation, which is now in linux-next, so I'm planning to keep them in the same series instead of going through maintainer trees.

The full series can be found in
git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl.git vfs

Arnd Bergmann (12):
BKL: Remove BKL from usbfs
BKL: Remove BKL from fat
BKL: Remove BKL from isofs
BKL: Remove BKL from autofs4
BKL: Remove BKL from ReiserFS
BKL: Remove BKL from capifs
BKL: Remove BKL from USB gadgetfs
BKL: Remove BKL from afs
BKL: Remove BKL from ecryptfs
BKL: Remove BKL from jffs2
BKL: Remove BKL from squashfs
BKL: Remove BKL from OCFS2

 drivers/isdn/capi/capifs.c |    8 +-------
 drivers/usb/core/inode.c   |    6 ------
 drivers/usb/gadget/inode.c |   13 ++-----------
 fs/afs/super.c             |   10 ----------
 fs/autofs4/root.c          |   12 +++++++-----
 fs/ecryptfs/file.c         |    3 ---
 fs/ecryptfs/main.c         |    4 ----
 fs/fat/inode.c             |    5 -----
 fs/fat/namei_msdos.c       |    7 +++----
 fs/fat/namei_vfat.c        |    7 +++----
 fs/isofs/dir.c             |    6 +++---
 fs/isofs/inode.c           |   16 ++++++----------
 fs/isofs/namei.c           |    8 ++++----
 fs/isofs/rock.c            |    8 ++++----
 fs/jffs2/fs.c              |    4 ----
 fs/jffs2/super.c           |   12 +-----------
 fs/ocfs2/dlmfs/dlmfs.c     |    9 +--------
 fs/ocfs2/stack_user.c      |    3 ---
 fs/ocfs2/super.c           |   12 ------------
 fs/reiserfs/super.c        |    6 ------
 fs/squashfs/super.c        |   11 -----------
 21 files changed, 35 insertions(+), 135 deletions(-)
Cc Greg Kroah-Hartman <[email protected]>
Cc Jan Blunck <[email protected]>
Cc OGAWA Hirofumi <[email protected]>
Cc Jan Blunck <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc David Brownell <[email protected]>
Cc David Howells <[email protected]>
Cc Dustin Kirkland <[email protected]>
Cc Tyler Hicks <[email protected]>
Cc David Woodhouse <[email protected]>
Cc Phillip Lougher <[email protected]>
Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>
#1 lore raw

PATCH 1/12 BKL: Remove BKL from usbfs

Nothing in there has a race that can be prevented by holding the BKL.

Cc Greg Kroah-Hartman <[email protected]>
Cc Jan Blunck <[email protected]>
---
 drivers/usb/core/inode.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/usb/core/inode.c +0 -6
index 73ec8c2..9e2ec9f 100644
@@ -39,7 +39,6 @@
 #include <linux/parser.h>
 #include <linux/notifier.h>
 #include <linux/seq_file.h>
-#include <linux/smp_lock.h>
 #include <linux/usb/hcd.h>
 #include <asm/byteorder.h>
 #include "usb.h"
@@ -457,8 +456,6 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
 	struct inode *inode;
 	struct dentry *root;
 
-	lock_kernel();
-
 	sb->s_blocksize = PAGE_CACHE_SIZE;
 	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
 	sb->s_magic = USBDEVICE_SUPER_MAGIC;
@@ -468,7 +465,6 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
 
 	if (!inode) {
 		dbg("%s: could not get inode!",__func__);
-		unlock_kernel();
 		return -ENOMEM;
 	}
 
@@ -476,11 +472,9 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
 	if (!root) {
 		dbg("%s: could not get root dentry!",__func__);
 		iput(inode);
-		unlock_kernel();
 		return -ENOMEM;
 	}
 	sb->s_root = root;
-	unlock_kernel();
 	return 0;
 }
 
Signature · 1 line
1.7.1
#3 lore raw

PATCH 2/12 BKL: Remove BKL from fat

In reply to Arnd Bergmann

The lock_kernel in fat_put_super is not needed because it only protects the super block itself and we know that no other thread can reach it because we are about to kfree the object.

In the two fill_super functions, this converts the locking to use lock_super like elsewhere in the fat code. This is probably not needed either, but is consistent and puts us on the safe side.

Cc OGAWA Hirofumi <[email protected]>
Cc Jan Blunck <[email protected]>
---
 fs/fat/inode.c       |    5 -----
 fs/fat/namei_msdos.c |    7 +++----
 fs/fat/namei_vfat.c  |    7 +++----
 3 files changed, 6 insertions(+), 13 deletions(-)
fs/fat/inode.c +0 -5
index 8300580..ad6998a 100644
@@ -14,7 +14,6 @@
 #include <linux/init.h>
 #include <linux/time.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 #include <linux/seq_file.h>
 #include <linux/pagemap.h>
 #include <linux/mpage.h>
@@ -489,8 +488,6 @@ static void fat_put_super(struct super_block *sb)
 {
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 
-	lock_kernel();
-
 	if (sb->s_dirt)
 		fat_write_super(sb);
 
@@ -504,8 +501,6 @@ static void fat_put_super(struct super_block *sb)
 
 	sb->s_fs_info = NULL;
 	kfree(sbi);
-
-	unlock_kernel();
 }
 
 static struct kmem_cache *fat_inode_cachep;
fs/fat/namei_msdos.c +3 -4
index e2b0b97..bbca5c1 100644
@@ -9,7 +9,6 @@
 #include <linux/module.h>
 #include <linux/time.h>
 #include <linux/buffer_head.h>
-#include <linux/smp_lock.h>     /* For lock_kernel() */
 #include "fat.h"
 
 /* Characters that are undesirable in an MS-DOS file name */
@@ -663,16 +662,16 @@ static int msdos_fill_super(struct super_block *sb, void *data, int silent)
 {
 	int res;
 
-	lock_kernel();
+	lock_super(sb);
 	res = fat_fill_super(sb, data, silent, &msdos_dir_inode_operations, 0);
 	if (res) {
-		unlock_kernel();
+		unlock_super(sb);
 		return res;
 	}
 
 	sb->s_flags |= MS_NOATIME;
 	sb->s_root->d_op = &msdos_dentry_operations;
-	unlock_kernel();
+	unlock_super(sb);
 	return 0;
 }
 
fs/fat/namei_vfat.c +3 -4
index 9006ad9..6f0f6c9 100644
@@ -21,7 +21,6 @@
 #include <linux/slab.h>
 #include <linux/buffer_head.h>
 #include <linux/namei.h>
-#include <linux/smp_lock.h>     /* For lock_kernel() */
 #include "fat.h"
 
 /*
@@ -1056,10 +1055,10 @@ static int vfat_fill_super(struct super_block *sb, void *data, int silent)
 {
 	int res;
 
-	lock_kernel();
+	lock_super(sb);
 	res = fat_fill_super(sb, data, silent, &vfat_dir_inode_operations, 1);
 	if (res) {
-		unlock_kernel();
+		unlock_super(sb);
 		return res;
 	}
 
@@ -1068,7 +1067,7 @@ static int vfat_fill_super(struct super_block *sb, void *data, int silent)
 	else
 		sb->s_root->d_op = &vfat_dentry_ops;
 
-	unlock_kernel();
+	unlock_super(sb);
 	return 0;
 }
 
Signature · 1 line
1.7.1
#4 lore raw

PATCH 3/12 BKL: Remove BKL from isofs

In reply to Arnd Bergmann

As in other file systems, we can replace the big kernel lock with {un,}lock_super in isofs. This means we can now access multiple file systems concurrently, but it also means that we serialize readdir and lookup across sleeping operations which previously released the big kernel lock. This should not matter though, as these operations are in practice serialized through the hardware access.

The isofs_get_blocks functions now does not take any lock any more, it used to recursively get the BKL. After looking at the code for hours, I convinced myself that it was never needed here anyway, because it only reads constant fields of the inode and writes to a buffer head array that is at this time only visible to the caller.

---
 fs/isofs/dir.c   |    6 +++---
 fs/isofs/inode.c |   16 ++++++----------
 fs/isofs/namei.c |    8 ++++----
 fs/isofs/rock.c  |    8 ++++----
 4 files changed, 17 insertions(+), 21 deletions(-)
fs/isofs/dir.c +3 -3
index e0aca9a..4e6c000 100644
@@ -10,7 +10,6 @@
  *
  *  isofs directory handling functions
  */
-#include <linux/smp_lock.h>
 #include <linux/gfp.h>
 #include "isofs.h"
 
@@ -255,18 +254,19 @@ static int isofs_readdir(struct file *filp,
 	char *tmpname;
 	struct iso_directory_record *tmpde;
 	struct inode *inode = filp->f_path.dentry->d_inode;
+	struct super_block *sb = inode->i_sb;
 
 	tmpname = (char *)__get_free_page(GFP_KERNEL);
 	if (tmpname == NULL)
 		return -ENOMEM;
 
-	lock_kernel();
+	lock_super(sb);
 	tmpde = (struct iso_directory_record *) (tmpname+1024);
 
 	result = do_isofs_readdir(inode, filp, dirent, filldir, tmpname, tmpde);
 
 	free_page((unsigned long) tmpname);
-	unlock_kernel();
+	unlock_super(sb);
 	return result;
 }
 
fs/isofs/inode.c +6 -10
index 05baf77..57209f1 100644
@@ -17,7 +17,6 @@
 #include <linux/slab.h>
 #include <linux/nls.h>
 #include <linux/ctype.h>
-#include <linux/smp_lock.h>
 #include <linux/statfs.h>
 #include <linux/cdrom.h>
 #include <linux/parser.h>
@@ -44,11 +43,11 @@ static void isofs_put_super(struct super_block *sb)
 	struct isofs_sb_info *sbi = ISOFS_SB(sb);
 
 #ifdef CONFIG_JOLIET
-	lock_kernel();
+	lock_super(sb);
 
 	unload_nls(sbi->s_nls_iocharset);
 
-	unlock_kernel();
+	unlock_super(sb);
 #endif
 
 	kfree(sbi);
@@ -571,13 +570,13 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
 	int table, error = -EINVAL;
 	unsigned int vol_desc_start;
 
-	lock_kernel();
+	lock_super(s);
 
 	save_mount_options(s, data);
 
 	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
 	if (!sbi) {
-		unlock_kernel();
+		unlock_super(s);
 		return -ENOMEM;
 	}
 	s->s_fs_info = sbi;
@@ -904,7 +903,7 @@ root_found:
 
 	kfree(opt.iocharset);
 
-	unlock_kernel();
+	unlock_super(s);
 	return 0;
 
 	/*
@@ -942,9 +941,9 @@ out_freebh:
 	brelse(bh);
 out_freesbi:
 	kfree(opt.iocharset);
+	unlock_super(s);
 	kfree(sbi);
 	s->s_fs_info = NULL;
-	unlock_kernel();
 	return error;
 }
 
@@ -983,8 +982,6 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
 	int section, rv, error;
 	struct iso_inode_info *ei = ISOFS_I(inode);
 
-	lock_kernel();
-
 	error = -EIO;
 	rv = 0;
 	if (iblock < 0 || iblock != iblock_s) {
@@ -1060,7 +1057,6 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
 
 	error = 0;
 abort:
-	unlock_kernel();
 	return rv != 0 ? rv : error;
 }
 
fs/isofs/namei.c +4 -4
index ab438be..cf67973 100644
@@ -6,7 +6,6 @@
  *  (C) 1991  Linus Torvalds - minix filesystem
  */
 
-#include <linux/smp_lock.h>
 #include <linux/gfp.h>
 #include "isofs.h"
 
@@ -168,6 +167,7 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
 	int found;
 	unsigned long uninitialized_var(block);
 	unsigned long uninitialized_var(offset);
+	struct super_block *sb = dir->i_sb;
 	struct inode *inode;
 	struct page *page;
 
@@ -177,7 +177,7 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
 	if (!page)
 		return ERR_PTR(-ENOMEM);
 
-	lock_kernel();
+	lock_super(sb);
 	found = isofs_find_entry(dir, dentry,
 				&block, &offset,
 				page_address(page),
@@ -188,10 +188,10 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
 	if (found) {
 		inode = isofs_iget(dir->i_sb, block, offset);
 		if (IS_ERR(inode)) {
-			unlock_kernel();
+			unlock_super(sb);
 			return ERR_CAST(inode);
 		}
 	}
-	unlock_kernel();
+	unlock_super(sb);
 	return d_splice_alias(inode, dentry);
 }
fs/isofs/rock.c +4 -4
index 96a685c..0599c65 100644
@@ -8,7 +8,6 @@
 
 #include <linux/slab.h>
 #include <linux/pagemap.h>
-#include <linux/smp_lock.h>
 
 #include "isofs.h"
 #include "rock.h"
@@ -661,6 +660,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
 {
 	struct inode *inode = page->mapping->host;
 	struct iso_inode_info *ei = ISOFS_I(inode);
+	struct super_block *sb = inode->i_sb;
 	char *link = kmap(page);
 	unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
 	struct buffer_head *bh;
@@ -678,7 +678,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
 
 	init_rock_state(&rs, inode);
 	block = ei->i_iget5_block;
-	lock_kernel();
+	lock_super(sb);
 	bh = sb_bread(inode->i_sb, block);
 	if (!bh)
 		goto out_noread;
@@ -748,7 +748,7 @@ repeat:
 		goto fail;
 	brelse(bh);
 	*rpnt = '\0';
-	unlock_kernel();
+	unlock_super(sb);
 	SetPageUptodate(page);
 	kunmap(page);
 	unlock_page(page);
@@ -765,7 +765,7 @@ out_bad_span:
 	printk("symlink spans iso9660 blocks\n");
 fail:
 	brelse(bh);
-	unlock_kernel();
+	unlock_super(sb);
 error:
 	SetPageError(page);
 	kunmap(page);
Signature · 1 line
1.7.1
#5 lore raw

PATCH 4/12 BKL: Remove BKL from autofs4

In reply to Arnd Bergmann

autofs4 uses the BKL only to guard its ioctl operations. This can be trivially converted to use a mutex, as we have done with most device drivers before.

Cc "H. Peter Anvin" <[email protected]>
---
 fs/autofs4/root.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
fs/autofs4/root.c +7 -5
index cb1bd38..9dd29c2 100644
@@ -19,7 +19,7 @@
 #include <linux/param.h>
 #include <linux/time.h>
 #include <linux/compat.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 
 #include "autofs_i.h"
 
@@ -978,15 +978,17 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
 	}
 }
 
+static DEFINE_MUTEX(autofs4_ioctl_mutex);
+
 static long autofs4_root_ioctl(struct file *filp,
 			       unsigned int cmd, unsigned long arg)
 {
 	long ret;
 	struct inode *inode = filp->f_dentry->d_inode;
 
-	lock_kernel();
+	mutex_lock(&autofs4_ioctl_mutex);
 	ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
-	unlock_kernel();
+	mutex_unlock(&autofs4_ioctl_mutex);
 
 	return ret;
 }
@@ -998,13 +1000,13 @@ static long autofs4_root_compat_ioctl(struct file *filp,
 	struct inode *inode = filp->f_path.dentry->d_inode;
 	int ret;
 
-	lock_kernel();
+	mutex_lock(&autofs4_ioctl_mutex);
 	if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
 		ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
 	else
 		ret = autofs4_root_ioctl_unlocked(inode, filp, cmd,
 			(unsigned long)compat_ptr(arg));
-	unlock_kernel();
+	mutex_unlock(&autofs4_ioctl_mutex);
 
 	return ret;
 }
Signature · 1 line
1.7.1
#6 lore raw

Re: [PATCH 04/12] BKL: Remove BKL from autofs4

Quoted 9 lines · Arnd Bergmann

autofs4 uses the BKL only to guard its ioctl operations. This can be trivially converted to use a mutex, as we have done with most device drivers before.

Cc "H. Peter Anvin" <[email protected]>
---
 fs/autofs4/root.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

You may want to Cc: the maintainer, Ian Kent.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#7 lore raw

Re: [PATCH 04/12] BKL: Remove BKL from autofs4

Quoted 5 lines · On Thursday 16 September 2010 19:49:53 H. Peter Anvin wrote:
Quoted 4 lines · Arnd Bergmann

autofs4 uses the BKL only to guard its ioctl operations. This can be trivially converted to use a mutex, as we have done with most device drivers before.

Quoted 7 lines
Quoted 5 lines
Cc "H. Peter Anvin" <[email protected]>
---
 fs/autofs4/root.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

You may want to Cc: the maintainer, Ian Kent.

Ah, sorry about this. I looked at the wrong MAINTAINERS entry.

I also forgot to Cc you about autofs3, adding more to the confusion. ;)

Do you think the time has come to move autofs3 to drivers/staging as we deprecate the BKL?

Arnd

#8 lore raw

Re: [PATCH 04/12] BKL: Remove BKL from autofs4

Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · On Thursday 16 September 2010 19:49:53 H. Peter Anvin wrote:
Quoted 9 lines · Arnd Bergmann

autofs4 uses the BKL only to guard its ioctl operations. This can be trivially converted to use a mutex, as we have done with most device drivers before.

Cc "H. Peter Anvin" <[email protected]>
---
 fs/autofs4/root.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
Quoted 9 lines
Quoted 1 line

You may want to Cc: the maintainer, Ian Kent.

Ah, sorry about this. I looked at the wrong MAINTAINERS entry.

I also forgot to Cc you about autofs3, adding more to the confusion. ;)

Do you think the time has come to move autofs3 to drivers/staging as we deprecate the BKL?

I'm leaving that up to Ian. I have offered for years to just plain kill off autofs3.

-hpa

maintainer
#9 lore raw

Re: [PATCH 04/12] BKL: Remove BKL from autofs4

Quoted 17 lines · H. Peter Anvin
Quoted 16 lines · Arnd Bergmann
Quoted 5 lines · On Thursday 16 September 2010 19:49:53 H. Peter Anvin wrote:
Quoted 4 lines · Arnd Bergmann

autofs4 uses the BKL only to guard its ioctl operations. This can be trivially converted to use a mutex, as we have done with most device drivers before.

Quoted 7 lines
Quoted 5 lines
Cc "H. Peter Anvin" <[email protected]>
---
 fs/autofs4/root.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

You may want to Cc: the maintainer, Ian Kent.

Ah, sorry about this. I looked at the wrong MAINTAINERS entry.

Quoted 8 lines
Quoted 5 lines

I also forgot to Cc you about autofs3, adding more to the confusion. ;)

Do you think the time has come to move autofs3 to drivers/staging as we deprecate the BKL?

I'm leaving that up to Ian. I have offered for years to just plain kill off autofs3.

Yeah, my bad, again.
Now I want to wait for David Howells VFS automount series, which we're working on now, since that will be a significant change.

Quoted 2 lines

-hpa

maintainer
#10 lore raw

Re: [PATCH 04/12] BKL: Remove BKL from autofs4

In reply to Arnd Bergmann
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · On Thursday 16 September 2010 19:49:53 H. Peter Anvin wrote:
Quoted 9 lines · Arnd Bergmann

autofs4 uses the BKL only to guard its ioctl operations. This can be trivially converted to use a mutex, as we have done with most device drivers before.

Cc "H. Peter Anvin" <[email protected]>
---
 fs/autofs4/root.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
Quoted 8 lines
Quoted 1 line

You may want to Cc: the maintainer, Ian Kent.

Ah, sorry about this. I looked at the wrong MAINTAINERS entry.

I also forgot to Cc you about autofs3, adding more to the confusion. ;)

Do you think the time has come to move autofs3 to drivers/staging as we deprecate the BKL?

Umm ... what's this process, the drivers/staging?

Quoted 2 lines

Arnd

#11 lore raw

Re: [PATCH 04/12] BKL: Remove BKL from autofs4

Quoted 9 lines · On Friday 17 September 2010 03:33:11 Ian Kent wrote:
Quoted 6 lines · Arnd Bergmann

Ah, sorry about this. I looked at the wrong MAINTAINERS entry.

I also forgot to Cc you about autofs3, adding more to the confusion. ;)

Do you think the time has come to move autofs3 to drivers/staging as we deprecate the BKL?

Umm ... what's this process, the drivers/staging?

We use drivers/staging now both for getting code into the kernel and for getting it out of there. Moving autofs3 to drivers/staging/autofs/ would serve as a last warning to everyone using it, but users could still use it while it's there. If anyone is interested, they can submit fixes (BKL removal and whatever else is needed) to get it back into the mainline. If it doesn't happen, Greg would finally remove it two kernel releases later.

My hope is that we can move all modules that still use the BKL after 2.6.37 to drivers/staging, unless we have someone already working on the patches.

Arnd

#12 lore raw

Re: [PATCH 04/12] BKL: Remove BKL from autofs4

Quoted 19 lines · Arnd Bergmann
Quoted 9 lines · On Friday 17 September 2010 03:33:11 Ian Kent wrote:
Quoted 6 lines · Arnd Bergmann

Ah, sorry about this. I looked at the wrong MAINTAINERS entry.

I also forgot to Cc you about autofs3, adding more to the confusion. ;)

Do you think the time has come to move autofs3 to drivers/staging as we deprecate the BKL?

Umm ... what's this process, the drivers/staging?

We use drivers/staging now both for getting code into the kernel and for getting it out of there. Moving autofs3 to drivers/staging/autofs/ would serve as a last warning to everyone using it, but users could still use it while it's there. If anyone is interested, they can submit fixes (BKL removal and whatever else is needed) to get it back into the mainline. If it doesn't happen, Greg would finally remove it two kernel releases later.

Quoted 3 lines

My hope is that we can move all modules that still use the BKL after 2.6.37 to drivers/staging, unless we have someone already working on the patches.

That sounds fine with me, send me patches whenever you want to and I will gladly take them.

thanks,

greg k-h

#13 lore raw

PATCH 5/12 BKL: Remove BKL from ReiserFS

In reply to Arnd Bergmann

The BKL only got into reiserfs through the pushdown into ->fill_super. This function is already sufficiently serialized using reiserfs_write_lock(), so we can safely remove the BKL here.

---
 fs/reiserfs/super.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
fs/reiserfs/super.c +0 -6
index 6874489..b8df814 100644
@@ -28,7 +28,6 @@
 #include <linux/mount.h>
 #include <linux/namei.h>
 #include <linux/crc32.h>
-#include <linux/smp_lock.h>
 
 struct file_system_type reiserfs_fs_type;
 
@@ -1628,8 +1627,6 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
 	char *qf_names[MAXQUOTAS] = {};
 	unsigned int qfmt = 0;
 
-	lock_kernel();
-
 	save_mount_options(s, data);
 
 	sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
@@ -1887,8 +1884,6 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
 	spin_lock_init(&sbi->bitmap_lock);
 
 	reiserfs_write_unlock(s);
-
-	unlock_kernel();
 	return (0);
 
 error:
@@ -1911,7 +1906,6 @@ error:
 	kfree(sbi);
 
 	s->s_fs_info = NULL;
-	unlock_kernel();
 	return errval;
 }
 
Signature · 1 line
1.7.1
#14 lore raw

PATCH 6/12 BKL: Remove BKL from capifs

In reply to Arnd Bergmann

The BKL is only used in fill_super, which is protected by the superblocks s_umount rw_semaphore. Therefore it is safe to remove the BKL entirely.

---
 drivers/isdn/capi/capifs.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/isdn/capi/capifs.c +1 -7
index c559b52..b0dcdbc 100644
@@ -17,7 +17,6 @@
 #include <linux/init.h>
 #include <linux/ctype.h>
 #include <linux/sched.h>	/* current */
-#include <linux/smp_lock.h>	/* For lock_kernel() */
 
 #include "capifs.h"
 
@@ -100,8 +99,6 @@ capifs_fill_super(struct super_block *s, void *data, int silent)
 {
 	struct inode * inode;
 
-	lock_kernel();
-
 	s->s_blocksize = 1024;
 	s->s_blocksize_bits = 10;
 	s->s_magic = CAPIFS_SUPER_MAGIC;
@@ -119,15 +116,12 @@ capifs_fill_super(struct super_block *s, void *data, int silent)
 	inode->i_nlink = 2;
 
 	s->s_root = d_alloc_root(inode);
-	if (s->s_root) {
-		unlock_kernel();
+	if (s->s_root)
 		return 0;
-	}
 
 	printk("capifs: get root dentry failed\n");
 	iput(inode);
 fail:
-	unlock_kernel();
 	return -ENOMEM;
 }
 
Signature · 1 line
1.7.1
maintainer
#15 lore raw

Re: [PATCH 06/12] BKL: Remove BKL from capifs

From: Arnd Bergmann <[email protected]>
Date: Thu, 16 Sep 2010 19:46:19 +0200

Quoted 5 lines

The BKL is only used in fill_super, which is protected by the superblocks s_umount rw_semaphore. Therefore it is safe to remove the BKL entirely.

I've searched Linus's tree, net-2.6, and net-next-2.6 and I cannot find one reference to lock_kernel() in drivers/isdn/capi/capifs.c in any of them.

What did you write this patch against?

#16 lore raw

Re: [PATCH 06/12] BKL: Remove BKL from capifs

Quoted 7 lines · On Saturday 18 September 2010 01:35:30 David Miller wrote:

From: Arnd Bergmann <[email protected]>
Date: Thu, 16 Sep 2010 19:46:19 +0200

Quoted 3 lines

The BKL is only used in fill_super, which is protected by the superblocks s_umount rw_semaphore. Therefore it is safe to remove the BKL entirely.

Quoted 8 lines
Quoted 2 lines

I've searched Linus's tree, net-2.6, and net-next-2.6 and I cannot find one reference to lock_kernel() in drivers/isdn/capi/capifs.c in any of them.

What did you write this patch against?

As I wrote in my [PATCH 0/12], it applies on top of the pushdown of the BKL into the get_sb operation, and I intend to submit it to Linus with the full series.

I agree that this particular patch is a bit pointless because all it does is to undo the change from the pushdown. I guess that at the time when the first patch was written, the BKL was still present in other parts of capifs.

Arnd

#17 lore raw

PATCH 7/12 BKL: Remove BKL from USB gadgetfs

In reply to Arnd Bergmann

The BKL is only used in fill_super, which is protected by the superblocks s_umount rw_semaphore. Therefore it is safe to remove the BKL entirely.

---
 drivers/usb/gadget/inode.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
drivers/usb/gadget/inode.c +2 -11
index 82a88d3..3f1d771 100644
@@ -33,7 +33,6 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/poll.h>
-#include <linux/smp_lock.h>
 
 #include <linux/device.h>
 #include <linux/moduleparam.h>
@@ -2043,19 +2042,13 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
 	struct dentry	*d;
 	struct dev_data	*dev;
 
-	lock_kernel();
-
-	if (the_device) {
-		unlock_kernel();
+	if (the_device)
 		return -ESRCH;
-	}
 
 	/* fake probe to determine $CHIP */
 	(void) usb_gadget_register_driver (&probe_driver);
-	if (!CHIP) {
-		unlock_kernel();
+	if (!CHIP)
 		return -ENODEV;
-	}
 
 	/* superblock */
 	sb->s_blocksize = PAGE_CACHE_SIZE;
@@ -2092,7 +2085,6 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
 	 * from binding to a controller.
 	 */
 	the_device = dev;
-	unlock_kernel();
 	return 0;
 
 enomem3:
@@ -2102,7 +2094,6 @@ enomem2:
 enomem1:
 	iput (inode);
 enomem0:
-	unlock_kernel();
 	return -ENOMEM;
 }
 
Signature · 1 line
1.7.1
#18 lore raw

PATCH 8/12 BKL: Remove BKL from afs

In reply to Arnd Bergmann

The BKL is only used in put_super and fill_super, which are both protected by the superblocks s_umount rw_semaphore. Therefore it is safe to remove the BKL entirely.

---
 fs/afs/super.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)
fs/afs/super.c +0 -10
index 6c2fef4..eacf76d 100644
@@ -19,7 +19,6 @@
 #include <linux/mount.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/parser.h>
@@ -302,15 +301,12 @@ static int afs_fill_super(struct super_block *sb, void *data)
 	struct inode *inode = NULL;
 	int ret;
 
-	lock_kernel();
-
 	_enter("");
 
 	/* allocate a superblock info record */
 	as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
 	if (!as) {
 		_leave(" = -ENOMEM");
-		unlock_kernel();
 		return -ENOMEM;
 	}
 
@@ -344,7 +340,6 @@ static int afs_fill_super(struct super_block *sb, void *data)
 	sb->s_root = root;
 
 	_leave(" = 0");
-	unlock_kernel();
 	return 0;
 
 error_inode:
@@ -358,7 +353,6 @@ error:
 	sb->s_fs_info = NULL;
 
 	_leave(" = %d", ret);
-	unlock_kernel();
 	return ret;
 }
 
@@ -458,12 +452,8 @@ static void afs_put_super(struct super_block *sb)
 
 	_enter("");
 
-	lock_kernel();
-
 	afs_put_volume(as->volume);
 
-	unlock_kernel();
-
 	_leave("");
 }
 
Signature · 1 line
1.7.1
#19 lore raw

PATCH 9/12 BKL: Remove BKL from ecryptfs

In reply to Arnd Bergmann

The BKL is only used in fill_super, which is protected by the superblocks s_umount rw_semaphorei, and in fasync, which does not do anything that could require the BKL. Therefore it is safe to remove the BKL entirely.

---
 fs/ecryptfs/file.c |    3 ---
 fs/ecryptfs/main.c |    4 ----
 2 files changed, 0 insertions(+), 7 deletions(-)
fs/ecryptfs/file.c +0 -3
index 622c951..2b9a644 100644
@@ -31,7 +31,6 @@
 #include <linux/security.h>
 #include <linux/compat.h>
 #include <linux/fs_stack.h>
-#include <linux/smp_lock.h>
 #include "ecryptfs_kernel.h"
 
 /**
@@ -284,11 +283,9 @@ static int ecryptfs_fasync(int fd, struct file *file, int flag)
 	int rc = 0;
 	struct file *lower_file = NULL;
 
-	lock_kernel();
 	lower_file = ecryptfs_file_to_lower(file);
 	if (lower_file->f_op && lower_file->f_op->fasync)
 		rc = lower_file->f_op->fasync(fd, lower_file, flag);
-	unlock_kernel();
 	return rc;
 }
 
fs/ecryptfs/main.c +0 -4
index c4af92f..cbd4e18 100644
@@ -36,7 +36,6 @@
 #include <linux/parser.h>
 #include <linux/fs_stack.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>     /* For lock_kernel() */
 #include "ecryptfs_kernel.h"
 
 /**
@@ -551,7 +550,6 @@ static int ecryptfs_get_sb(struct file_system_type *fs_type, int flags,
 	const char *err = "Getting sb failed";
 	int rc;
 
-	lock_kernel();
 	sbi = kmem_cache_zalloc(ecryptfs_sb_info_cache, GFP_KERNEL);
 	if (!sbi) {
 		rc = -ENOMEM;
@@ -610,7 +608,6 @@ static int ecryptfs_get_sb(struct file_system_type *fs_type, int flags,
 		goto out;
 	}
 	simple_set_mnt(mnt, s);
-	unlock_kernel();
 	return 0;
 
 out:
@@ -619,7 +616,6 @@ out:
 		kmem_cache_free(ecryptfs_sb_info_cache, sbi);
 	}
 	printk(KERN_ERR "%s; rc = [%d]\n", err, rc);
-	unlock_kernel();
 	return rc;
 }
 
Signature · 1 line
1.7.1
#20 lore raw

PATCH 10/12 BKL: Remove BKL from jffs2

In reply to Arnd Bergmann

The BKL is only used in put_super, fill_super and remount_fs that are all three protected by the superblocks s_umount rw_semaphore. Therefore it is safe to remove the BKL entirely.

Cc David Woodhouse <[email protected]>
---
 fs/jffs2/fs.c    |    4 ----
 fs/jffs2/super.c |   12 +-----------
 2 files changed, 1 insertions(+), 15 deletions(-)
fs/jffs2/fs.c +0 -4
index 6b2964a..d9beb06 100644
@@ -21,7 +21,6 @@
 #include <linux/vmalloc.h>
 #include <linux/vfs.h>
 #include <linux/crc32.h>
-#include <linux/smp_lock.h>
 #include "nodelist.h"
 
 static int jffs2_flash_setup(struct jffs2_sb_info *c);
@@ -391,7 +390,6 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)
 	   This also catches the case where it was stopped and this
 	   is just a remount to restart it.
 	   Flush the writebuffer, if neccecary, else we loose it */
-	lock_kernel();
 	if (!(sb->s_flags & MS_RDONLY)) {
 		jffs2_stop_garbage_collect_thread(c);
 		mutex_lock(&c->alloc_sem);
@@ -403,8 +401,6 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)
 		jffs2_start_garbage_collect_thread(c);
 
 	*flags |= MS_NOATIME;
-
-	unlock_kernel();
 	return 0;
 }
 
fs/jffs2/super.c +1 -11
index 58dd9cf..d1ae5df 100644
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/fs.h>
@@ -148,17 +147,13 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent)
 	struct jffs2_sb_info *c;
 	int ret;
 
-	lock_kernel();
-
 	D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():"
 		  " New superblock for device %d (\"%s\")\n",
 		  sb->s_mtd->index, sb->s_mtd->name));
 
 	c = kzalloc(sizeof(*c), GFP_KERNEL);
-	if (!c) {
-		unlock_kernel();
+	if (!c)
 		return -ENOMEM;
-	}
 
 	c->mtd = sb->s_mtd;
 	c->os_priv = sb;
@@ -181,7 +176,6 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent)
 	sb->s_flags |= MS_POSIXACL;
 #endif
 	ret = jffs2_do_fill_super(sb, data, silent);
-	unlock_kernel();
 	return ret;
 }
 
@@ -199,8 +193,6 @@ static void jffs2_put_super (struct super_block *sb)
 
 	D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n"));
 
-	lock_kernel();
-
 	if (sb->s_dirt)
 		jffs2_write_super(sb);
 
@@ -222,8 +214,6 @@ static void jffs2_put_super (struct super_block *sb)
 	if (c->mtd->sync)
 		c->mtd->sync(c->mtd);
 
-	unlock_kernel();
-
 	D1(printk(KERN_DEBUG "jffs2_put_super returning\n"));
 }
 
Signature · 1 line
1.7.1
#21 lore raw

PATCH 11/12 BKL: Remove BKL from squashfs

In reply to Arnd Bergmann

The BKL is only used in put_super and fill_super, which are both protected by the superblocks s_umount rw_semaphore. Therefore it is safe to remove the BKL entirely.

Cc Phillip Lougher <[email protected]>
---
 fs/squashfs/super.c |   11 -----------
 1 files changed, 0 insertions(+), 11 deletions(-)
fs/squashfs/super.c +0 -11
index ab1a401..07a4f11 100644
@@ -30,7 +30,6 @@
 #include <linux/fs.h>
 #include <linux/vfs.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 #include <linux/mutex.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
@@ -87,14 +86,11 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
 	u64 lookup_table_start, xattr_id_table_start;
 	int err;
 
-	lock_kernel();
-
 	TRACE("Entered squashfs_fill_superblock\n");
 
 	sb->s_fs_info = kzalloc(sizeof(*msblk), GFP_KERNEL);
 	if (sb->s_fs_info == NULL) {
 		ERROR("Failed to allocate squashfs_sb_info\n");
-		unlock_kernel();
 		return -ENOMEM;
 	}
 	msblk = sb->s_fs_info;
@@ -304,7 +300,6 @@ allocate_root:
 
 	TRACE("Leaving squashfs_fill_super\n");
 	kfree(sblk);
-	unlock_kernel();
 	return 0;
 
 failed_mount:
@@ -319,13 +314,11 @@ failed_mount:
 	kfree(sb->s_fs_info);
 	sb->s_fs_info = NULL;
 	kfree(sblk);
-	unlock_kernel();
 	return err;
 
 failure:
 	kfree(sb->s_fs_info);
 	sb->s_fs_info = NULL;
-	unlock_kernel();
 	return -ENOMEM;
 }
 
@@ -360,8 +353,6 @@ static int squashfs_remount(struct super_block *sb, int *flags, char *data)
 
 static void squashfs_put_super(struct super_block *sb)
 {
-	lock_kernel();
-
 	if (sb->s_fs_info) {
 		struct squashfs_sb_info *sbi = sb->s_fs_info;
 		squashfs_cache_delete(sbi->block_cache);
@@ -376,8 +367,6 @@ static void squashfs_put_super(struct super_block *sb)
 		kfree(sb->s_fs_info);
 		sb->s_fs_info = NULL;
 	}
-
-	unlock_kernel();
 }
 
 
Signature · 1 line
1.7.1
#22 lore raw

PATCH 12/12 BKL: Remove BKL from OCFS2

In reply to Arnd Bergmann

The BKL in ocfs2/dlmfs is used in put_super, fill_super and remount_fs that are all three protected by the superblocks s_umount rw_semaphore.

The use in ocfs2_control_open is evidently unrelated and the function is protected by ocfs2_control_lock.

Therefore it is safe to remove the BKL entirely.

Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>
---
 fs/ocfs2/dlmfs/dlmfs.c |    9 +--------
 fs/ocfs2/stack_user.c  |    3 ---
 fs/ocfs2/super.c       |   12 ------------
 3 files changed, 1 insertions(+), 23 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +1 -8
index 667d7ce..c2903b8 100644
@@ -44,7 +44,6 @@
 #include <linux/string.h>
 #include <linux/backing-dev.h>
 #include <linux/poll.h>
-#include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
 
@@ -589,27 +588,21 @@ static int dlmfs_fill_super(struct super_block * sb,
 	struct inode * inode;
 	struct dentry * root;
 
-	lock_kernel();
-
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
 	sb->s_blocksize = PAGE_CACHE_SIZE;
 	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
 	sb->s_magic = DLMFS_MAGIC;
 	sb->s_op = &dlmfs_ops;
 	inode = dlmfs_get_root_inode(sb);
-	if (!inode) {
-		unlock_kernel();
+	if (!inode)
 		return -ENOMEM;
-	}
 
 	root = d_alloc_root(inode);
 	if (!root) {
 		iput(inode);
-		unlock_kernel();
 		return -ENOMEM;
 	}
 	sb->s_root = root;
-	unlock_kernel();
 	return 0;
 }
 
fs/ocfs2/stack_user.c +0 -3
index 2dc57bc..0e68f54 100644
@@ -22,7 +22,6 @@
 #include <linux/miscdevice.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 #include <linux/reboot.h>
 #include <asm/uaccess.h>
 
@@ -612,12 +611,10 @@ static int ocfs2_control_open(struct inode *inode, struct file *file)
 		return -ENOMEM;
 	p->op_this_node = -1;
 
-	lock_kernel();
 	mutex_lock(&ocfs2_control_lock);
 	file->private_data = p;
 	list_add(&p->op_list, &ocfs2_control_private_list);
 	mutex_unlock(&ocfs2_control_lock);
-	unlock_kernel();
 
 	return 0;
 }
fs/ocfs2/super.c +0 -12
index b7e4f2d..b7d7243 100644
@@ -609,8 +609,6 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
 	struct mount_options parsed_options;
 	struct ocfs2_super *osb = OCFS2_SB(sb);
 
-	lock_kernel();
-
 	if (!ocfs2_parse_options(sb, data, &parsed_options, 1) ||
 	    !ocfs2_check_set_options(sb, &parsed_options)) {
 		ret = -EINVAL;
@@ -717,7 +715,6 @@ unlock_osb:
 							MS_POSIXACL : 0);
 	}
 out:
-	unlock_kernel();
 	return ret;
 }
 
@@ -1002,8 +999,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
 	char nodestr[8];
 	struct ocfs2_blockcheck_stats stats;
 
-	lock_kernel();
-
 	mlog_entry("%p, %p, %i", sb, data, silent);
 
 	if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) {
@@ -1181,7 +1176,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
 			atomic_set(&osb->vol_state, VOLUME_DISABLED);
 			wake_up(&osb->osb_mount_event);
 			mlog_exit(status);
-			unlock_kernel();
 			return status;
 		}
 	}
@@ -1196,7 +1190,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
 	ocfs2_orphan_scan_start(osb);
 
 	mlog_exit(status);
-	unlock_kernel();
 	return status;
 
 read_super_error:
@@ -1212,7 +1205,6 @@ read_super_error:
 	}
 
 	mlog_exit(status);
-	unlock_kernel();
 	return status;
 }
 
@@ -1645,13 +1637,9 @@ static void ocfs2_put_super(struct super_block *sb)
 {
 	mlog_entry("(0x%p)\n", sb);
 
-	lock_kernel();
-
 	ocfs2_sync_blockdev(sb);
 	ocfs2_dismount_volume(sb, 0);
 
-	unlock_kernel();
-
 	mlog_exit_void();
 }
 
Signature · 1 line
1.7.1
#23 lore raw

Re: [PATCH 12/12] BKL: Remove BKL from OCFS2

Quoted 2 lines · Arnd Bergmann

The BKL in ocfs2/dlmfs is used in put_super, fill_super and remount_fs that are all three protected by the superblocks s_umount rw_semaphore.

Those look good, thanks.

Quoted 2 lines

The use in ocfs2_control_open is evidently unrelated and the function is protected by ocfs2_control_lock.

<snip>

fs/ocfs2/stack_user.c static int ocfs2_control_open(struct inode *inode, struct file *file) · line 620

Quoted 13 lines
fs/ocfs2/stack_user.c +0 -2
@@ -612,12 +611,10 @@ static int ocfs2_control_open(struct inode *inode, struct file *file)
 		return -ENOMEM;
 	p->op_this_node = -1;
 
-	lock_kernel();
 	mutex_lock(&ocfs2_control_lock);
 	file->private_data = p;
 	list_add(&p->op_list, &ocfs2_control_private_list);
 	mutex_unlock(&ocfs2_control_lock);
-	unlock_kernel();
 
 	return 0;
 }

My guess is that this one is good to go too. Joel?

	--Mark

--
Mark Fasheh