[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
@@ -87,7 +87,7 @@ struct ext3_inode_info {
|
||||
#ifdef CONFIG_EXT3_FS_XATTR
|
||||
/*
|
||||
* Extended attributes can be read independently of the main file
|
||||
* data. Taking i_sem even when reading would cause contention
|
||||
* data. Taking i_mutex even when reading would cause contention
|
||||
* between readers of EAs and writers of regular file data, so
|
||||
* instead we synchronize on xattr_sem when reading or changing
|
||||
* EAs.
|
||||
|
@@ -219,6 +219,7 @@ extern int dir_notify_enable;
|
||||
#include <linux/prio_tree.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#include <asm/atomic.h>
|
||||
#include <asm/semaphore.h>
|
||||
@@ -484,7 +485,7 @@ struct inode {
|
||||
unsigned long i_blocks;
|
||||
unsigned short i_bytes;
|
||||
spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
|
||||
struct semaphore i_sem;
|
||||
struct mutex i_mutex;
|
||||
struct rw_semaphore i_alloc_sem;
|
||||
struct inode_operations *i_op;
|
||||
struct file_operations *i_fop; /* former ->i_op->default_file_ops */
|
||||
@@ -1191,7 +1192,7 @@ int sync_inode(struct inode *inode, struct writeback_control *wbc);
|
||||
* directory. The name should be stored in the @name (with the
|
||||
* understanding that it is already pointing to a a %NAME_MAX+1 sized
|
||||
* buffer. get_name() should return %0 on success, a negative error code
|
||||
* or error. @get_name will be called without @parent->i_sem held.
|
||||
* or error. @get_name will be called without @parent->i_mutex held.
|
||||
*
|
||||
* get_parent:
|
||||
* @get_parent should find the parent directory for the given @child which
|
||||
@@ -1213,7 +1214,7 @@ int sync_inode(struct inode *inode, struct writeback_control *wbc);
|
||||
* nfsd_find_fh_dentry() in either the @obj or @parent parameters.
|
||||
*
|
||||
* Locking rules:
|
||||
* get_parent is called with child->d_inode->i_sem down
|
||||
* get_parent is called with child->d_inode->i_mutex down
|
||||
* get_name is not (which is possibly inconsistent)
|
||||
*/
|
||||
|
||||
|
@@ -8,11 +8,11 @@
|
||||
#include <asm/semaphore.h>
|
||||
|
||||
struct jffs2_inode_info {
|
||||
/* We need an internal semaphore similar to inode->i_sem.
|
||||
/* We need an internal mutex similar to inode->i_mutex.
|
||||
Unfortunately, we can't used the existing one, because
|
||||
either the GC would deadlock, or we'd have to release it
|
||||
before letting GC proceed. Or we'd have to put ugliness
|
||||
into the GC code so it didn't attempt to obtain the i_sem
|
||||
into the GC code so it didn't attempt to obtain the i_mutex
|
||||
for the inode(s) which are already locked */
|
||||
struct semaphore sem;
|
||||
|
||||
|
@@ -294,7 +294,7 @@ fill_post_wcc(struct svc_fh *fhp)
|
||||
/*
|
||||
* Lock a file handle/inode
|
||||
* NOTE: both fh_lock and fh_unlock are done "by hand" in
|
||||
* vfs.c:nfsd_rename as it needs to grab 2 i_sem's at once
|
||||
* vfs.c:nfsd_rename as it needs to grab 2 i_mutex's at once
|
||||
* so, any changes here should be reflected there.
|
||||
*/
|
||||
static inline void
|
||||
@@ -317,7 +317,7 @@ fh_lock(struct svc_fh *fhp)
|
||||
}
|
||||
|
||||
inode = dentry->d_inode;
|
||||
down(&inode->i_sem);
|
||||
mutex_lock(&inode->i_mutex);
|
||||
fill_pre_wcc(fhp);
|
||||
fhp->fh_locked = 1;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ fh_unlock(struct svc_fh *fhp)
|
||||
|
||||
if (fhp->fh_locked) {
|
||||
fill_post_wcc(fhp);
|
||||
up(&fhp->fh_dentry->d_inode->i_sem);
|
||||
mutex_unlock(&fhp->fh_dentry->d_inode->i_mutex);
|
||||
fhp->fh_locked = 0;
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ struct pipe_inode_info {
|
||||
memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
|
||||
#define PIPE_SIZE PAGE_SIZE
|
||||
|
||||
#define PIPE_SEM(inode) (&(inode).i_sem)
|
||||
#define PIPE_MUTEX(inode) (&(inode).i_mutex)
|
||||
#define PIPE_WAIT(inode) (&(inode).i_pipe->wait)
|
||||
#define PIPE_READERS(inode) ((inode).i_pipe->readers)
|
||||
#define PIPE_WRITERS(inode) ((inode).i_pipe->writers)
|
||||
|
@@ -1857,7 +1857,7 @@ void padd_item(char *item, int total_length, int length);
|
||||
#define GET_BLOCK_CREATE 1 /* add anything you need to find block */
|
||||
#define GET_BLOCK_NO_HOLE 2 /* return -ENOENT for file holes */
|
||||
#define GET_BLOCK_READ_DIRECT 4 /* read the tail if indirect item not found */
|
||||
#define GET_BLOCK_NO_ISEM 8 /* i_sem is not held, don't preallocate */
|
||||
#define GET_BLOCK_NO_IMUX 8 /* i_mutex is not held, don't preallocate */
|
||||
#define GET_BLOCK_NO_DANGLE 16 /* don't leave any transactions running */
|
||||
|
||||
int restart_transaction(struct reiserfs_transaction_handle *th,
|
||||
|
Reference in New Issue
Block a user