public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock
@ 2010-10-23 11:37 Alessio Igor Bogani
  2010-10-23 11:37 ` [PATCH 2/6] udf: Remove BKL Alessio Igor Bogani
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Alessio Igor Bogani @ 2010-10-23 11:37 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Tim Bird, LKML, Alessio Igor Bogani

This work was supported by a hardware donation from the CE Linux Forum.

Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
---
 fs/udf/super.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 76f3d6d..60b5179 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -48,7 +48,7 @@
 #include <linux/stat.h>
 #include <linux/cdrom.h>
 #include <linux/nls.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include <linux/buffer_head.h>
 #include <linux/vfs.h>
 #include <linux/vmalloc.h>
@@ -568,7 +568,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
 	if (!udf_parse_options(options, &uopt, true))
 		return -EINVAL;
 
-	lock_kernel();
+	mutex_lock(&sb->s_lock);
 	sbi->s_flags = uopt.flags;
 	sbi->s_uid   = uopt.uid;
 	sbi->s_gid   = uopt.gid;
@@ -591,7 +591,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
 		udf_open_lvid(sb);
 
 out_unlock:
-	unlock_kernel();
+	mutex_unlock(&sb->s_lock);
 	return error;
 }
 
@@ -1880,7 +1880,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	struct kernel_lb_addr rootdir, fileset;
 	struct udf_sb_info *sbi;
 
-	lock_kernel();
+	mutex_lock(&sb->s_lock);
 
 	uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
 	uopt.uid = -1;
@@ -1891,7 +1891,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 	sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
 	if (!sbi) {
-		unlock_kernel();
+		mutex_unlock(&sb->s_lock);
 		return -ENOMEM;
 	}
 
@@ -2039,7 +2039,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 		goto error_out;
 	}
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
-	unlock_kernel();
+	mutex_unlock(&sb->s_lock);
 	return 0;
 
 error_out:
@@ -2060,7 +2060,7 @@ error_out:
 	kfree(sbi);
 	sb->s_fs_info = NULL;
 
-	unlock_kernel();
+	mutex_unlock(&sb->s_lock);
 	return -EINVAL;
 }
 
@@ -2099,7 +2099,7 @@ static void udf_put_super(struct super_block *sb)
 
 	sbi = UDF_SB(sb);
 
-	lock_kernel();
+	mutex_lock(&sb->s_lock);
 
 	if (sbi->s_vat_inode)
 		iput(sbi->s_vat_inode);
@@ -2117,7 +2117,7 @@ static void udf_put_super(struct super_block *sb)
 	kfree(sb->s_fs_info);
 	sb->s_fs_info = NULL;
 
-	unlock_kernel();
+	mutex_unlock(&sb->s_lock);
 }
 
 static int udf_sync_fs(struct super_block *sb, int wait)
@@ -2180,7 +2180,7 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb,
 	uint16_t ident;
 	struct spaceBitmapDesc *bm;
 
-	lock_kernel();
+	mutex_lock(&sb->s_lock);
 
 	loc.logicalBlockNum = bitmap->s_extPosition;
 	loc.partitionReferenceNum = UDF_SB(sb)->s_partition;
@@ -2220,7 +2220,7 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb,
 	brelse(bh);
 
 out:
-	unlock_kernel();
+	mutex_unlock(&sb->s_lock);
 
 	return accum;
 }
@@ -2234,7 +2234,7 @@ static unsigned int udf_count_free_table(struct super_block *sb,
 	int8_t etype;
 	struct extent_position epos;
 
-	lock_kernel();
+	mutex_lock(&sb->s_lock);
 
 	epos.block = UDF_I(table)->i_location;
 	epos.offset = sizeof(struct unallocSpaceEntry);
@@ -2245,7 +2245,7 @@ static unsigned int udf_count_free_table(struct super_block *sb,
 
 	brelse(epos.bh);
 
-	unlock_kernel();
+	mutex_unlock(&sb->s_lock);
 
 	return accum;
 }
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/6] udf: Remove BKL
  2010-10-23 11:37 [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Alessio Igor Bogani
@ 2010-10-23 11:37 ` Alessio Igor Bogani
  2010-10-23 11:37 ` [PATCH 3/6] " Alessio Igor Bogani
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alessio Igor Bogani @ 2010-10-23 11:37 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Tim Bird, LKML, Alessio Igor Bogani

The readdir function seems already enough protected by i_mutex held
by VFS invoking call.

This work was supported by a hardware donation from the CE Linux Forum.

Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
---
 fs/udf/dir.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index 51552bf..eb8bfe2 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -30,7 +30,6 @@
 #include <linux/errno.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
 
 #include "udf_i.h"
@@ -190,18 +189,14 @@ static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
 	struct inode *dir = filp->f_path.dentry->d_inode;
 	int result;
 
-	lock_kernel();
-
 	if (filp->f_pos == 0) {
 		if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) {
-			unlock_kernel();
 			return 0;
 		}
 		filp->f_pos++;
 	}
 
 	result = do_udf_readdir(dir, filp, filldir, dirent);
-	unlock_kernel();
  	return result;
 }
 
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/6] udf: Remove BKL
  2010-10-23 11:37 [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Alessio Igor Bogani
  2010-10-23 11:37 ` [PATCH 2/6] udf: Remove BKL Alessio Igor Bogani
@ 2010-10-23 11:37 ` Alessio Igor Bogani
  2010-10-23 11:37 ` [PATCH 4/6] udf: Replace BKL Alessio Igor Bogani
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alessio Igor Bogani @ 2010-10-23 11:37 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Tim Bird, LKML, Alessio Igor Bogani

The lookup, create, mknod, mkdir, rmdir, unlink and symlink functions seems
already adequately protected by i_mutex held by VFS invoking calls.

In get_parent the BKL seems unecessary.

The rename function instead should be protected by lock_rename again
by VFS.

This work was supported by a hardware donation from the CE Linux Forum.

Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
---
 fs/udf/namei.c |   38 +++-----------------------------------
 1 files changed, 3 insertions(+), 35 deletions(-)

diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index bf5fc67..3e9cb90 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -27,7 +27,6 @@
 #include <linux/errno.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
 #include <linux/sched.h>
 #include <linux/crc-itu-t.h>
@@ -263,7 +262,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
 	if (dentry->d_name.len > UDF_NAME_LEN - 2)
 		return ERR_PTR(-ENAMETOOLONG);
 
-	lock_kernel();
 #ifdef UDF_RECOVERY
 	/* temporary shorthand for specifying files by inode number */
 	if (!strncmp(dentry->d_name.name, ".B=", 3)) {
@@ -275,7 +273,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
 		};
 		inode = udf_iget(dir->i_sb, lb);
 		if (!inode) {
-			unlock_kernel();
 			return ERR_PTR(-EACCES);
 		}
 	} else
@@ -291,11 +288,9 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
 		loc = lelb_to_cpu(cfi.icb.extLocation);
 		inode = udf_iget(dir->i_sb, &loc);
 		if (!inode) {
-			unlock_kernel();
 			return ERR_PTR(-EACCES);
 		}
 	}
-	unlock_kernel();
 
 	return d_splice_alias(inode, dentry);
 }
@@ -562,12 +557,9 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
 	int err;
 	struct udf_inode_info *iinfo;
 
-	lock_kernel();
 	inode = udf_new_inode(dir, mode, &err);
-	if (!inode) {
-		unlock_kernel();
+	if (!inode)
 		return err;
-	}
 
 	iinfo = UDF_I(inode);
 	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
@@ -583,7 +575,6 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
 		inode->i_nlink--;
 		mark_inode_dirty(inode);
 		iput(inode);
-		unlock_kernel();
 		return err;
 	}
 	cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
@@ -596,7 +587,6 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
 	if (fibh.sbh != fibh.ebh)
 		brelse(fibh.ebh);
 	brelse(fibh.sbh);
-	unlock_kernel();
 	d_instantiate(dentry, inode);
 
 	return 0;
@@ -614,7 +604,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
 	if (!old_valid_dev(rdev))
 		return -EINVAL;
 
-	lock_kernel();
 	err = -EIO;
 	inode = udf_new_inode(dir, mode, &err);
 	if (!inode)
@@ -627,7 +616,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
 		inode->i_nlink--;
 		mark_inode_dirty(inode);
 		iput(inode);
-		unlock_kernel();
 		return err;
 	}
 	cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
@@ -646,7 +634,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
 	err = 0;
 
 out:
-	unlock_kernel();
 	return err;
 }
 
@@ -659,7 +646,6 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 	struct udf_inode_info *dinfo = UDF_I(dir);
 	struct udf_inode_info *iinfo;
 
-	lock_kernel();
 	err = -EMLINK;
 	if (dir->i_nlink >= (256 << sizeof(dir->i_nlink)) - 1)
 		goto out;
@@ -712,7 +698,6 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 	err = 0;
 
 out:
-	unlock_kernel();
 	return err;
 }
 
@@ -794,7 +779,6 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
 	struct kernel_lb_addr tloc;
 
 	retval = -ENOENT;
-	lock_kernel();
 	fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi);
 	if (!fi)
 		goto out;
@@ -826,7 +810,6 @@ end_rmdir:
 	brelse(fibh.sbh);
 
 out:
-	unlock_kernel();
 	return retval;
 }
 
@@ -840,7 +823,6 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
 	struct kernel_lb_addr tloc;
 
 	retval = -ENOENT;
-	lock_kernel();
 	fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi);
 	if (!fi)
 		goto out;
@@ -870,7 +852,6 @@ end_unlink:
 	brelse(fibh.sbh);
 
 out:
-	unlock_kernel();
 	return retval;
 }
 
@@ -893,7 +874,6 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 	struct buffer_head *bh;
 	struct udf_inode_info *iinfo;
 
-	lock_kernel();
 	inode = udf_new_inode(dir, S_IFLNK | S_IRWXUGO, &err);
 	if (!inode)
 		goto out;
@@ -1044,7 +1024,6 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 
 out:
 	kfree(name);
-	unlock_kernel();
 	return err;
 
 out_no_entry:
@@ -1062,17 +1041,12 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
 	int err;
 	struct buffer_head *bh;
 
-	lock_kernel();
-	if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) {
-		unlock_kernel();
+	if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1)
 		return -EMLINK;
-	}
 
 	fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
-	if (!fi) {
-		unlock_kernel();
+	if (!fi)
 		return err;
-	}
 	cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
 	cfi.icb.extLocation = cpu_to_lelb(UDF_I(inode)->i_location);
 	bh = UDF_SB(inode->i_sb)->s_lvid_bh;
@@ -1103,7 +1077,6 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
 	mark_inode_dirty(inode);
 	atomic_inc(&inode->i_count);
 	d_instantiate(dentry, inode);
-	unlock_kernel();
 
 	return 0;
 }
@@ -1124,7 +1097,6 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
 	struct kernel_lb_addr tloc;
 	struct udf_inode_info *old_iinfo = UDF_I(old_inode);
 
-	lock_kernel();
 	ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi);
 	if (ofi) {
 		if (ofibh.sbh != ofibh.ebh)
@@ -1248,7 +1220,6 @@ end_rename:
 			brelse(nfibh.ebh);
 		brelse(nfibh.sbh);
 	}
-	unlock_kernel();
 
 	return retval;
 }
@@ -1261,7 +1232,6 @@ static struct dentry *udf_get_parent(struct dentry *child)
 	struct fileIdentDesc cfi;
 	struct udf_fileident_bh fibh;
 
-	lock_kernel();
 	if (!udf_find_entry(child->d_inode, &dotdot, &fibh, &cfi))
 		goto out_unlock;
 
@@ -1273,11 +1243,9 @@ static struct dentry *udf_get_parent(struct dentry *child)
 	inode = udf_iget(child->d_inode->i_sb, &tloc);
 	if (!inode)
 		goto out_unlock;
-	unlock_kernel();
 
 	return d_obtain_alias(inode);
 out_unlock:
-	unlock_kernel();
 	return ERR_PTR(-EACCES);
 }
 
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/6] udf: Replace BKL
  2010-10-23 11:37 [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Alessio Igor Bogani
  2010-10-23 11:37 ` [PATCH 2/6] udf: Remove BKL Alessio Igor Bogani
  2010-10-23 11:37 ` [PATCH 3/6] " Alessio Igor Bogani
@ 2010-10-23 11:37 ` Alessio Igor Bogani
  2010-10-23 11:37 ` [PATCH 5/6] udf: Remove BKL Alessio Igor Bogani
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alessio Igor Bogani @ 2010-10-23 11:37 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Tim Bird, LKML, Alessio Igor Bogani

Replace BKL with i_mutex in udf_symlink_filler function.

This work was supported by a hardware donation from the CE Linux Forum.

Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
---
 fs/udf/symlink.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index 1606478..cdf4492 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -27,7 +27,7 @@
 #include <linux/mm.h>
 #include <linux/stat.h>
 #include <linux/pagemap.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include <linux/buffer_head.h>
 #include "udf_i.h"
 
@@ -79,8 +79,8 @@ static int udf_symlink_filler(struct file *file, struct page *page)
 	unsigned char *p = kmap(page);
 	struct udf_inode_info *iinfo;
 
-	lock_kernel();
 	iinfo = UDF_I(inode);
+	mutex_lock(&inode->i_mutex);
 	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
 		symlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr;
 	} else {
@@ -95,14 +95,14 @@ static int udf_symlink_filler(struct file *file, struct page *page)
 	udf_pc_to_char(inode->i_sb, symlink, inode->i_size, p);
 	brelse(bh);
 
-	unlock_kernel();
+	mutex_unlock(&inode->i_mutex);
 	SetPageUptodate(page);
 	kunmap(page);
 	unlock_page(page);
 	return 0;
 
 out:
-	unlock_kernel();
+	mutex_unlock(&inode->i_mutex);
 	SetPageError(page);
 	kunmap(page);
 	unlock_page(page);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/6] udf: Remove BKL
  2010-10-23 11:37 [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Alessio Igor Bogani
                   ` (2 preceding siblings ...)
  2010-10-23 11:37 ` [PATCH 4/6] udf: Replace BKL Alessio Igor Bogani
@ 2010-10-23 11:37 ` Alessio Igor Bogani
  2010-10-23 11:37 ` [PATCH 6/6] udf: Replace BKL Alessio Igor Bogani
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alessio Igor Bogani @ 2010-10-23 11:37 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Tim Bird, LKML, Alessio Igor Bogani

In the udf_ioctl function replace the bkl with s_lock only for udf_relocate_blocks
function invoked from the first one.

In the udf_release_file function the data should be already protected by use
of i_mutex.

This work was supported by a hardware donation from the CE Linux Forum.

Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
---
 fs/udf/file.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/udf/file.c b/fs/udf/file.c
index 66b9e7e..75a9e99 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -32,7 +32,7 @@
 #include <linux/string.h> /* memset */
 #include <linux/capability.h>
 #include <linux/errno.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include <linux/pagemap.h>
 #include <linux/buffer_head.h>
 #include <linux/aio.h>
@@ -149,8 +149,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	long old_block, new_block;
 	int result = -EINVAL;
 
-	lock_kernel();
-
 	if (file_permission(filp, MAY_READ) != 0) {
 		udf_debug("no permission to access inode %lu\n", inode->i_ino);
 		result = -EPERM;
@@ -180,8 +178,10 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			result = -EFAULT;
 			goto out;
 		}
+		mutex_lock(&inode->i_sb->s_lock);
 		result = udf_relocate_blocks(inode->i_sb,
 						old_block, &new_block);
+		mutex_unlock(&inode->i_sb->s_lock);
 		if (result == 0)
 			result = put_user(new_block, (long __user *)arg);
 		goto out;
@@ -196,7 +196,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	}
 
 out:
-	unlock_kernel();
 	return result;
 }
 
@@ -204,10 +203,8 @@ static int udf_release_file(struct inode *inode, struct file *filp)
 {
 	if (filp->f_mode & FMODE_WRITE) {
 		mutex_lock(&inode->i_mutex);
-		lock_kernel();
 		udf_discard_prealloc(inode);
 		udf_truncate_tail_extent(inode);
-		unlock_kernel();
 		mutex_unlock(&inode->i_mutex);
 	}
 	return 0;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/6] udf: Replace BKL
  2010-10-23 11:37 [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Alessio Igor Bogani
                   ` (3 preceding siblings ...)
  2010-10-23 11:37 ` [PATCH 5/6] udf: Remove BKL Alessio Igor Bogani
@ 2010-10-23 11:37 ` Alessio Igor Bogani
  2010-10-23 11:46 ` [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Christoph Hellwig
  2010-10-23 11:53 ` Arnd Bergmann
  6 siblings, 0 replies; 8+ messages in thread
From: Alessio Igor Bogani @ 2010-10-23 11:37 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Tim Bird, LKML, Alessio Igor Bogani

The call to udf_truncate() is moved into i_mutex protected section.
So we can remove BKL from itself.

Replace BKL with i_mutex in udf_evict_inode() and in udf_block_map().

Remove BKL from udf_get_block() because alla code path calls that function
with i_mutex held.

In udf_write_inode() protect udf_update_inode() call only if it isn't called
with i_mutex already held.

This work was supported by a hardware donation from the CE Linux Forum.

Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
---
 fs/udf/inode.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index fc48f37..ecc8b61 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -31,7 +31,7 @@
 
 #include "udfdecl.h"
 #include <linux/mm.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include <linux/module.h>
 #include <linux/pagemap.h>
 #include <linux/buffer_head.h>
@@ -78,10 +78,10 @@ void udf_evict_inode(struct inode *inode)
 	if (!inode->i_nlink && !is_bad_inode(inode)) {
 		want_delete = 1;
 		inode->i_size = 0;
+		mutex_lock(&inode->i_mutex);
 		udf_truncate(inode);
-		lock_kernel();
 		udf_update_inode(inode, IS_SYNC(inode));
-		unlock_kernel();
+		mutex_unlock(&inode->i_mutex);
 	}
 	invalidate_inode_buffers(inode);
 	end_writeback(inode);
@@ -97,9 +97,9 @@ void udf_evict_inode(struct inode *inode)
 	kfree(iinfo->i_ext.i_data);
 	iinfo->i_ext.i_data = NULL;
 	if (want_delete) {
-		lock_kernel();
+		mutex_lock(&inode->i_mutex);
 		udf_free_inode(inode);
-		unlock_kernel();
+		mutex_unlock(&inode->i_mutex);
 	}
 }
 
@@ -303,8 +303,6 @@ static int udf_get_block(struct inode *inode, sector_t block,
 	new = 0;
 	bh = NULL;
 
-	lock_kernel();
-
 	iinfo = UDF_I(inode);
 	if (block == iinfo->i_next_alloc_block + 1) {
 		iinfo->i_next_alloc_block++;
@@ -324,7 +322,6 @@ static int udf_get_block(struct inode *inode, sector_t block,
 	map_bh(bh_result, inode->i_sb, phys);
 
 abort:
-	unlock_kernel();
 	return err;
 }
 
@@ -1022,7 +1019,6 @@ void udf_truncate(struct inode *inode)
 	if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
 		return;
 
-	lock_kernel();
 	iinfo = UDF_I(inode);
 	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
 		if (inode->i_sb->s_blocksize <
@@ -1031,7 +1027,6 @@ void udf_truncate(struct inode *inode)
 			udf_expand_file_adinicb(inode, inode->i_size, &err);
 			if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
 				inode->i_size = iinfo->i_lenAlloc;
-				unlock_kernel();
 				return;
 			} else
 				udf_truncate_extents(inode);
@@ -1053,7 +1048,6 @@ void udf_truncate(struct inode *inode)
 		udf_sync_inode(inode);
 	else
 		mark_inode_dirty(inode);
-	unlock_kernel();
 }
 
 static void __udf_read_inode(struct inode *inode)
@@ -1375,9 +1369,12 @@ int udf_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
 	int ret;
 
-	lock_kernel();
+	if (wbc->sync_mode == WB_SYNC_ALL)
+		return udf_sync_inode(inode);
+
+	mutex_lock(&inode->i_mutex);
 	ret = udf_update_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
-	unlock_kernel();
+	mutex_unlock(&inode->i_mutex);
 
 	return ret;
 }
@@ -2048,7 +2045,7 @@ long udf_block_map(struct inode *inode, sector_t block)
 	struct extent_position epos = {};
 	int ret;
 
-	lock_kernel();
+	mutex_lock(&inode->i_mutex);
 
 	if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) ==
 						(EXT_RECORDED_ALLOCATED >> 30))
@@ -2056,7 +2053,7 @@ long udf_block_map(struct inode *inode, sector_t block)
 	else
 		ret = 0;
 
-	unlock_kernel();
+	mutex_unlock(&inode->i_mutex);
 	brelse(epos.bh);
 
 	if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_VARCONV))
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock
  2010-10-23 11:37 [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Alessio Igor Bogani
                   ` (4 preceding siblings ...)
  2010-10-23 11:37 ` [PATCH 6/6] udf: Replace BKL Alessio Igor Bogani
@ 2010-10-23 11:46 ` Christoph Hellwig
  2010-10-23 11:53 ` Arnd Bergmann
  6 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2010-10-23 11:46 UTC (permalink / raw)
  To: Alessio Igor Bogani; +Cc: Arnd Bergmann, Tim Bird, LKML

No new uses of s_lock/lock_super/unlock_super, please.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock
  2010-10-23 11:37 [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Alessio Igor Bogani
                   ` (5 preceding siblings ...)
  2010-10-23 11:46 ` [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Christoph Hellwig
@ 2010-10-23 11:53 ` Arnd Bergmann
  6 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2010-10-23 11:53 UTC (permalink / raw)
  To: Alessio Igor Bogani; +Cc: Tim Bird, LKML

On Saturday 23 October 2010, Alessio Igor Bogani wrote:
> This work was supported by a hardware donation from the CE Linux Forum.
> 
> Signed-off-by: Alessio Igor Bogani <abogani@texware.it>

Hi Alessio,

Thanks a lot for joining in on the effort. Your patches look good for the
most part, but there are a few details you should change before they
go upstream. Most importantly, the subject lines of patches are currently
not unique and they tell very little about what is going on. You can
probably merge the three "remove BKL" patches into one and explain
why that is safe in a combined changelog.

> @@ -568,7 +568,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
>  	if (!udf_parse_options(options, &uopt, true))
>  		return -EINVAL;
>  
> -	lock_kernel();
> +	mutex_lock(&sb->s_lock);
>  	sbi->s_flags = uopt.flags;
>  	sbi->s_uid   = uopt.uid;
>  	sbi->s_gid   = uopt.gid;

As I recently learned, there is also an effort to get rid of sb->s_lock, so
the change in super.c is not all that helpful. When you need a per-filesystem
mutex, please instead add a new one to udf_sb_info. There is already the
s_alloc_mutex. While I haven't looked at that, maybe it can be extended to
cover the other areas that are under s_lock with your patch. Watch out for
put_super freeing sb_info under the lock though.

	Arnd

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-10-23 11:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-23 11:37 [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Alessio Igor Bogani
2010-10-23 11:37 ` [PATCH 2/6] udf: Remove BKL Alessio Igor Bogani
2010-10-23 11:37 ` [PATCH 3/6] " Alessio Igor Bogani
2010-10-23 11:37 ` [PATCH 4/6] udf: Replace BKL Alessio Igor Bogani
2010-10-23 11:37 ` [PATCH 5/6] udf: Remove BKL Alessio Igor Bogani
2010-10-23 11:37 ` [PATCH 6/6] udf: Replace BKL Alessio Igor Bogani
2010-10-23 11:46 ` [PATCH 1/6] udf: Replace BKL with superblock's mutex s_lock Christoph Hellwig
2010-10-23 11:53 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox