[PATCH] sem2mutex: HPFS

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Ingo Molnar 2006-03-23 03:00:42 -08:00 committed by Linus Torvalds
parent 1d5599e397
commit 7bf6d78dd9
4 changed files with 40 additions and 39 deletions

View File

@ -9,6 +9,7 @@
//#define DBG //#define DBG
//#define DEBUG_LOCKS //#define DEBUG_LOCKS
#include <linux/mutex.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/hpfs_fs.h> #include <linux/hpfs_fs.h>
@ -57,8 +58,8 @@ struct hpfs_inode_info {
unsigned i_ea_uid : 1; /* file's uid is stored in ea */ unsigned i_ea_uid : 1; /* file's uid is stored in ea */
unsigned i_ea_gid : 1; /* file's gid is stored in ea */ unsigned i_ea_gid : 1; /* file's gid is stored in ea */
unsigned i_dirty : 1; unsigned i_dirty : 1;
struct semaphore i_sem; struct mutex i_mutex;
struct semaphore i_parent; struct mutex i_parent_mutex;
loff_t **i_rddir_off; loff_t **i_rddir_off;
struct inode vfs_inode; struct inode vfs_inode;
}; };

View File

@ -186,9 +186,9 @@ void hpfs_write_inode(struct inode *i)
kfree(hpfs_inode->i_rddir_off); kfree(hpfs_inode->i_rddir_off);
hpfs_inode->i_rddir_off = NULL; hpfs_inode->i_rddir_off = NULL;
} }
down(&hpfs_inode->i_parent); mutex_lock(&hpfs_inode->i_parent_mutex);
if (!i->i_nlink) { if (!i->i_nlink) {
up(&hpfs_inode->i_parent); mutex_unlock(&hpfs_inode->i_parent_mutex);
return; return;
} }
parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir); parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir);
@ -199,14 +199,14 @@ void hpfs_write_inode(struct inode *i)
hpfs_read_inode(parent); hpfs_read_inode(parent);
unlock_new_inode(parent); unlock_new_inode(parent);
} }
down(&hpfs_inode->i_sem); mutex_lock(&hpfs_inode->i_mutex);
hpfs_write_inode_nolock(i); hpfs_write_inode_nolock(i);
up(&hpfs_inode->i_sem); mutex_unlock(&hpfs_inode->i_mutex);
iput(parent); iput(parent);
} else { } else {
mark_inode_dirty(i); mark_inode_dirty(i);
} }
up(&hpfs_inode->i_parent); mutex_unlock(&hpfs_inode->i_parent_mutex);
} }
void hpfs_write_inode_nolock(struct inode *i) void hpfs_write_inode_nolock(struct inode *i)

View File

@ -60,7 +60,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (dee.read_only) if (dee.read_only)
result->i_mode &= ~0222; result->i_mode &= ~0222;
down(&hpfs_i(dir)->i_sem); mutex_lock(&hpfs_i(dir)->i_mutex);
r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
if (r == 1) if (r == 1)
goto bail3; goto bail3;
@ -101,11 +101,11 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
hpfs_write_inode_nolock(result); hpfs_write_inode_nolock(result);
} }
d_instantiate(dentry, result); d_instantiate(dentry, result);
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
unlock_kernel(); unlock_kernel();
return 0; return 0;
bail3: bail3:
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
iput(result); iput(result);
bail2: bail2:
hpfs_brelse4(&qbh0); hpfs_brelse4(&qbh0);
@ -168,7 +168,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
result->i_data.a_ops = &hpfs_aops; result->i_data.a_ops = &hpfs_aops;
hpfs_i(result)->mmu_private = 0; hpfs_i(result)->mmu_private = 0;
down(&hpfs_i(dir)->i_sem); mutex_lock(&hpfs_i(dir)->i_mutex);
r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
if (r == 1) if (r == 1)
goto bail2; goto bail2;
@ -193,12 +193,12 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
hpfs_write_inode_nolock(result); hpfs_write_inode_nolock(result);
} }
d_instantiate(dentry, result); d_instantiate(dentry, result);
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
unlock_kernel(); unlock_kernel();
return 0; return 0;
bail2: bail2:
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
iput(result); iput(result);
bail1: bail1:
brelse(bh); brelse(bh);
@ -254,7 +254,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
result->i_blocks = 1; result->i_blocks = 1;
init_special_inode(result, mode, rdev); init_special_inode(result, mode, rdev);
down(&hpfs_i(dir)->i_sem); mutex_lock(&hpfs_i(dir)->i_mutex);
r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
if (r == 1) if (r == 1)
goto bail2; goto bail2;
@ -271,12 +271,12 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
hpfs_write_inode_nolock(result); hpfs_write_inode_nolock(result);
d_instantiate(dentry, result); d_instantiate(dentry, result);
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
brelse(bh); brelse(bh);
unlock_kernel(); unlock_kernel();
return 0; return 0;
bail2: bail2:
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
iput(result); iput(result);
bail1: bail1:
brelse(bh); brelse(bh);
@ -333,7 +333,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
result->i_op = &page_symlink_inode_operations; result->i_op = &page_symlink_inode_operations;
result->i_data.a_ops = &hpfs_symlink_aops; result->i_data.a_ops = &hpfs_symlink_aops;
down(&hpfs_i(dir)->i_sem); mutex_lock(&hpfs_i(dir)->i_mutex);
r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0); r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
if (r == 1) if (r == 1)
goto bail2; goto bail2;
@ -352,11 +352,11 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
hpfs_write_inode_nolock(result); hpfs_write_inode_nolock(result);
d_instantiate(dentry, result); d_instantiate(dentry, result);
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
unlock_kernel(); unlock_kernel();
return 0; return 0;
bail2: bail2:
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
iput(result); iput(result);
bail1: bail1:
brelse(bh); brelse(bh);
@ -382,8 +382,8 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
lock_kernel(); lock_kernel();
hpfs_adjust_length((char *)name, &len); hpfs_adjust_length((char *)name, &len);
again: again:
down(&hpfs_i(inode)->i_parent); mutex_lock(&hpfs_i(inode)->i_parent_mutex);
down(&hpfs_i(dir)->i_sem); mutex_lock(&hpfs_i(dir)->i_mutex);
err = -ENOENT; err = -ENOENT;
de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh); de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh);
if (!de) if (!de)
@ -410,8 +410,8 @@ again:
if (rep++) if (rep++)
break; break;
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
up(&hpfs_i(inode)->i_parent); mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
d_drop(dentry); d_drop(dentry);
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (atomic_read(&dentry->d_count) > 1 || if (atomic_read(&dentry->d_count) > 1 ||
@ -442,8 +442,8 @@ again:
out1: out1:
hpfs_brelse4(&qbh); hpfs_brelse4(&qbh);
out: out:
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
up(&hpfs_i(inode)->i_parent); mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
unlock_kernel(); unlock_kernel();
return err; return err;
} }
@ -463,8 +463,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
hpfs_adjust_length((char *)name, &len); hpfs_adjust_length((char *)name, &len);
lock_kernel(); lock_kernel();
down(&hpfs_i(inode)->i_parent); mutex_lock(&hpfs_i(inode)->i_parent_mutex);
down(&hpfs_i(dir)->i_sem); mutex_lock(&hpfs_i(dir)->i_mutex);
err = -ENOENT; err = -ENOENT;
de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh); de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh);
if (!de) if (!de)
@ -502,8 +502,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
out1: out1:
hpfs_brelse4(&qbh); hpfs_brelse4(&qbh);
out: out:
up(&hpfs_i(dir)->i_sem); mutex_unlock(&hpfs_i(dir)->i_mutex);
up(&hpfs_i(inode)->i_parent); mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
unlock_kernel(); unlock_kernel();
return err; return err;
} }
@ -565,12 +565,12 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
lock_kernel(); lock_kernel();
/* order doesn't matter, due to VFS exclusion */ /* order doesn't matter, due to VFS exclusion */
down(&hpfs_i(i)->i_parent); mutex_lock(&hpfs_i(i)->i_parent_mutex);
if (new_inode) if (new_inode)
down(&hpfs_i(new_inode)->i_parent); mutex_lock(&hpfs_i(new_inode)->i_parent_mutex);
down(&hpfs_i(old_dir)->i_sem); mutex_lock(&hpfs_i(old_dir)->i_mutex);
if (new_dir != old_dir) if (new_dir != old_dir)
down(&hpfs_i(new_dir)->i_sem); mutex_lock(&hpfs_i(new_dir)->i_mutex);
/* Erm? Moving over the empty non-busy directory is perfectly legal */ /* Erm? Moving over the empty non-busy directory is perfectly legal */
if (new_inode && S_ISDIR(new_inode->i_mode)) { if (new_inode && S_ISDIR(new_inode->i_mode)) {
@ -650,11 +650,11 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
hpfs_decide_conv(i, (char *)new_name, new_len); hpfs_decide_conv(i, (char *)new_name, new_len);
end1: end1:
if (old_dir != new_dir) if (old_dir != new_dir)
up(&hpfs_i(new_dir)->i_sem); mutex_unlock(&hpfs_i(new_dir)->i_mutex);
up(&hpfs_i(old_dir)->i_sem); mutex_unlock(&hpfs_i(old_dir)->i_mutex);
up(&hpfs_i(i)->i_parent); mutex_unlock(&hpfs_i(i)->i_parent_mutex);
if (new_inode) if (new_inode)
up(&hpfs_i(new_inode)->i_parent); mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex);
unlock_kernel(); unlock_kernel();
return err; return err;
} }

View File

@ -181,8 +181,8 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR) { SLAB_CTOR_CONSTRUCTOR) {
init_MUTEX(&ei->i_sem); mutex_init(&ei->i_mutex);
init_MUTEX(&ei->i_parent); mutex_init(&ei->i_parent_mutex);
inode_init_once(&ei->vfs_inode); inode_init_once(&ei->vfs_inode);
} }
} }