Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23061
b: refs/heads/master
c: 9746151
h: refs/heads/master
i:
  23059: 0ae5cc7
v: v3
  • Loading branch information
Arjan van de Ven authored and Linus Torvalds committed Mar 23, 2006
1 parent 10b7e3a commit 64757ed
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7bf6d78dd93ccc52cd2cac5066c4b84834e4f1f2
refs/heads/master: 97461518610fb1679f67333bb699bb81136e49fe
4 changes: 2 additions & 2 deletions trunk/fs/ext3/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ static int ext3_release_file (struct inode * inode, struct file * filp)
if ((filp->f_mode & FMODE_WRITE) &&
(atomic_read(&inode->i_writecount) == 1))
{
down(&EXT3_I(inode)->truncate_sem);
mutex_lock(&EXT3_I(inode)->truncate_mutex);
ext3_discard_reservation(inode);
up(&EXT3_I(inode)->truncate_sem);
mutex_unlock(&EXT3_I(inode)->truncate_mutex);
}
if (is_dx(inode) && filp->private_data)
ext3_htree_free_dir_info(filp->private_data);
Expand Down
14 changes: 7 additions & 7 deletions trunk/fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
if (!create || err == -EIO)
goto cleanup;

down(&ei->truncate_sem);
mutex_lock(&ei->truncate_mutex);

/*
* If the indirect block is missing while we are reading
Expand All @@ -723,7 +723,7 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
}
partial = ext3_get_branch(inode, depth, offsets, chain, &err);
if (!partial) {
up(&ei->truncate_sem);
mutex_unlock(&ei->truncate_mutex);
if (err)
goto cleanup;
clear_buffer_new(bh_result);
Expand Down Expand Up @@ -759,13 +759,13 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
err = ext3_splice_branch(handle, inode, iblock, chain,
partial, left);
/*
* i_disksize growing is protected by truncate_sem. Don't forget to
* i_disksize growing is protected by truncate_mutex. Don't forget to
* protect it if you're about to implement concurrent
* ext3_get_block() -bzzz
*/
if (!err && extend_disksize && inode->i_size > ei->i_disksize)
ei->i_disksize = inode->i_size;
up(&ei->truncate_sem);
mutex_unlock(&ei->truncate_mutex);
if (err)
goto cleanup;

Expand Down Expand Up @@ -1227,7 +1227,7 @@ static int journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
* ext3_file_write() -> generic_file_write() -> __alloc_pages() -> ...
*
* Same applies to ext3_get_block(). We will deadlock on various things like
* lock_journal and i_truncate_sem.
* lock_journal and i_truncate_mutex.
*
* Setting PF_MEMALLOC here doesn't work - too many internal memory
* allocations fail.
Expand Down Expand Up @@ -2161,7 +2161,7 @@ void ext3_truncate(struct inode * inode)
* From here we block out all ext3_get_block() callers who want to
* modify the block allocation tree.
*/
down(&ei->truncate_sem);
mutex_lock(&ei->truncate_mutex);

if (n == 1) { /* direct blocks */
ext3_free_data(handle, inode, NULL, i_data+offsets[0],
Expand Down Expand Up @@ -2228,7 +2228,7 @@ void ext3_truncate(struct inode * inode)

ext3_discard_reservation(inode);

up(&ei->truncate_sem);
mutex_unlock(&ei->truncate_mutex);
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
ext3_mark_inode_dirty(handle, inode);

Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/ext3/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
* need to allocate reservation structure for this inode
* before set the window size
*/
down(&ei->truncate_sem);
mutex_lock(&ei->truncate_mutex);
if (!ei->i_block_alloc_info)
ext3_init_block_alloc_info(inode);

if (ei->i_block_alloc_info){
struct ext3_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node;
rsv->rsv_goal_size = rsv_window_size;
}
up(&ei->truncate_sem);
mutex_unlock(&ei->truncate_mutex);
return 0;
}
case EXT3_IOC_GROUP_EXTEND: {
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
#ifdef CONFIG_EXT3_FS_XATTR
init_rwsem(&ei->xattr_sem);
#endif
init_MUTEX(&ei->truncate_sem);
mutex_init(&ei->truncate_mutex);
inode_init_once(&ei->vfs_inode);
}
}
Expand Down
7 changes: 4 additions & 3 deletions trunk/include/linux/ext3_fs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/rwsem.h>
#include <linux/rbtree.h>
#include <linux/seqlock.h>
#include <linux/mutex.h>

struct ext3_reserve_window {
__u32 _rsv_start; /* First byte reserved */
Expand Down Expand Up @@ -122,16 +123,16 @@ struct ext3_inode_info {
__u16 i_extra_isize;

/*
* truncate_sem is for serialising ext3_truncate() against
* truncate_mutex is for serialising ext3_truncate() against
* ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's
* data tree are chopped off during truncate. We can't do that in
* ext3 because whenever we perform intermediate commits during
* truncate, the inode and all the metadata blocks *must* be in a
* consistent state which allows truncation of the orphans to restart
* during recovery. Hence we must fix the get_block-vs-truncate race
* by other means, so we have truncate_sem.
* by other means, so we have truncate_mutex.
*/
struct semaphore truncate_sem;
struct mutex truncate_mutex;
struct inode vfs_inode;
};

Expand Down

0 comments on commit 64757ed

Please sign in to comment.