[PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem
This patch converts the inode semaphore to a mutex. I have tested it on XFS and compiled as much as one can consider on an ia64. Anyway your luck with it might be different. Modified-by: Ingo Molnar <mingo@elte.hu> (finished the conversion) Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:

committed by
Ingo Molnar

parent
794ee1baee
commit
1b1dcc1b57
@@ -67,11 +67,11 @@ static struct dentry *create_xa_root(struct super_block *sb)
|
||||
goto out;
|
||||
} else if (!xaroot->d_inode) {
|
||||
int err;
|
||||
down(&privroot->d_inode->i_sem);
|
||||
mutex_lock(&privroot->d_inode->i_mutex);
|
||||
err =
|
||||
privroot->d_inode->i_op->mkdir(privroot->d_inode, xaroot,
|
||||
0700);
|
||||
up(&privroot->d_inode->i_sem);
|
||||
mutex_unlock(&privroot->d_inode->i_mutex);
|
||||
|
||||
if (err) {
|
||||
dput(xaroot);
|
||||
@@ -219,7 +219,7 @@ static struct dentry *get_xa_file_dentry(const struct inode *inode,
|
||||
} else if (flags & XATTR_REPLACE || flags & FL_READONLY) {
|
||||
goto out;
|
||||
} else {
|
||||
/* inode->i_sem is down, so nothing else can try to create
|
||||
/* inode->i_mutex is down, so nothing else can try to create
|
||||
* the same xattr */
|
||||
err = xadir->d_inode->i_op->create(xadir->d_inode, xafile,
|
||||
0700 | S_IFREG, NULL);
|
||||
@@ -268,7 +268,7 @@ static struct file *open_xa_file(const struct inode *inode, const char *name,
|
||||
* and don't mess with f->f_pos, but the idea is the same. Do some
|
||||
* action on each and every entry in the directory.
|
||||
*
|
||||
* we're called with i_sem held, so there are no worries about the directory
|
||||
* we're called with i_mutex held, so there are no worries about the directory
|
||||
* changing underneath us.
|
||||
*/
|
||||
static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
|
||||
@@ -426,7 +426,7 @@ int xattr_readdir(struct file *file, filldir_t filler, void *buf)
|
||||
int res = -ENOTDIR;
|
||||
if (!file->f_op || !file->f_op->readdir)
|
||||
goto out;
|
||||
down(&inode->i_sem);
|
||||
mutex_lock(&inode->i_mutex);
|
||||
// down(&inode->i_zombie);
|
||||
res = -ENOENT;
|
||||
if (!IS_DEADDIR(inode)) {
|
||||
@@ -435,7 +435,7 @@ int xattr_readdir(struct file *file, filldir_t filler, void *buf)
|
||||
unlock_kernel();
|
||||
}
|
||||
// up(&inode->i_zombie);
|
||||
up(&inode->i_sem);
|
||||
mutex_unlock(&inode->i_mutex);
|
||||
out:
|
||||
return res;
|
||||
}
|
||||
@@ -480,7 +480,7 @@ static inline __u32 xattr_hash(const char *msg, int len)
|
||||
/* Generic extended attribute operations that can be used by xa plugins */
|
||||
|
||||
/*
|
||||
* inode->i_sem: down
|
||||
* inode->i_mutex: down
|
||||
*/
|
||||
int
|
||||
reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
|
||||
@@ -535,7 +535,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
|
||||
/* Resize it so we're ok to write there */
|
||||
newattrs.ia_size = buffer_size;
|
||||
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
|
||||
down(&xinode->i_sem);
|
||||
mutex_lock(&xinode->i_mutex);
|
||||
err = notify_change(fp->f_dentry, &newattrs);
|
||||
if (err)
|
||||
goto out_filp;
|
||||
@@ -598,7 +598,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
|
||||
}
|
||||
|
||||
out_filp:
|
||||
up(&xinode->i_sem);
|
||||
mutex_unlock(&xinode->i_mutex);
|
||||
fput(fp);
|
||||
|
||||
out:
|
||||
@@ -606,7 +606,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
|
||||
}
|
||||
|
||||
/*
|
||||
* inode->i_sem: down
|
||||
* inode->i_mutex: down
|
||||
*/
|
||||
int
|
||||
reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer,
|
||||
@@ -793,7 +793,7 @@ reiserfs_delete_xattrs_filler(void *buf, const char *name, int namelen,
|
||||
|
||||
}
|
||||
|
||||
/* This is called w/ inode->i_sem downed */
|
||||
/* This is called w/ inode->i_mutex downed */
|
||||
int reiserfs_delete_xattrs(struct inode *inode)
|
||||
{
|
||||
struct file *fp;
|
||||
@@ -946,7 +946,7 @@ int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
|
||||
|
||||
/*
|
||||
* Inode operation getxattr()
|
||||
* Preliminary locking: we down dentry->d_inode->i_sem
|
||||
* Preliminary locking: we down dentry->d_inode->i_mutex
|
||||
*/
|
||||
ssize_t
|
||||
reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
|
||||
@@ -970,7 +970,7 @@ reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
|
||||
/*
|
||||
* Inode operation setxattr()
|
||||
*
|
||||
* dentry->d_inode->i_sem down
|
||||
* dentry->d_inode->i_mutex down
|
||||
*/
|
||||
int
|
||||
reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
|
||||
@@ -1008,7 +1008,7 @@ reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
|
||||
/*
|
||||
* Inode operation removexattr()
|
||||
*
|
||||
* dentry->d_inode->i_sem down
|
||||
* dentry->d_inode->i_mutex down
|
||||
*/
|
||||
int reiserfs_removexattr(struct dentry *dentry, const char *name)
|
||||
{
|
||||
@@ -1091,7 +1091,7 @@ reiserfs_listxattr_filler(void *buf, const char *name, int namelen,
|
||||
/*
|
||||
* Inode operation listxattr()
|
||||
*
|
||||
* Preliminary locking: we down dentry->d_inode->i_sem
|
||||
* Preliminary locking: we down dentry->d_inode->i_mutex
|
||||
*/
|
||||
ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
|
||||
{
|
||||
@@ -1289,9 +1289,9 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
|
||||
if (!IS_ERR(dentry)) {
|
||||
if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) {
|
||||
struct inode *inode = dentry->d_parent->d_inode;
|
||||
down(&inode->i_sem);
|
||||
mutex_lock(&inode->i_mutex);
|
||||
err = inode->i_op->mkdir(inode, dentry, 0700);
|
||||
up(&inode->i_sem);
|
||||
mutex_unlock(&inode->i_mutex);
|
||||
if (err) {
|
||||
dput(dentry);
|
||||
dentry = NULL;
|
||||
|
Reference in New Issue
Block a user