Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 112949
b: refs/heads/master
c: 2a43a87
h: refs/heads/master
i:
  112947: 61b53db
v: v3
  • Loading branch information
Aneesh Kumar K.V authored and Theodore Ts'o committed Sep 13, 2008
1 parent 8238a4c commit 8136def
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 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: 7ee1ec4ca30c6df8e989615cdaacb75f2af4fa6b
refs/heads/master: 2a43a878001cc5cb7c3c7be2e8dad0a1aeb939b0
3 changes: 1 addition & 2 deletions trunk/fs/ext4/ext4.h
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,7 @@ extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);

/* migrate.c */
extern int ext4_ext_migrate(struct inode *, struct file *, unsigned int,
unsigned long);
extern int ext4_ext_migrate(struct inode *);
/* namei.c */
extern int ext4_orphan_add(handle_t *, struct inode *);
extern int ext4_orphan_del(handle_t *, struct inode *);
Expand Down
21 changes: 20 additions & 1 deletion trunk/fs/ext4/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,26 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}

case EXT4_IOC_MIGRATE:
return ext4_ext_migrate(inode, filp, cmd, arg);
{
int err;
if (!is_owner_or_cap(inode))
return -EACCES;

err = mnt_want_write(filp->f_path.mnt);
if (err)
return err;
/*
* inode_mutex prevent write and truncate on the file.
* Read still goes through. We take i_data_sem in
* ext4_ext_swap_inode_data before we switch the
* inode format to prevent read.
*/
mutex_lock(&(inode->i_mutex));
err = ext4_ext_migrate(inode);
mutex_unlock(&(inode->i_mutex));
mnt_drop_write(filp->f_path.mnt);
return err;
}

default:
return -ENOTTY;
Expand Down
10 changes: 1 addition & 9 deletions trunk/fs/ext4/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,7 @@ static int free_ext_block(handle_t *handle, struct inode *inode)

}

int ext4_ext_migrate(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
int ext4_ext_migrate(struct inode *inode)
{
handle_t *handle;
int retval = 0, i;
Expand Down Expand Up @@ -515,12 +514,6 @@ int ext4_ext_migrate(struct inode *inode, struct file *filp,
* trascation that created the inode. Later as and
* when we add extents we extent the journal
*/
/*
* inode_mutex prevent write and truncate on the file. Read still goes
* through. We take i_data_sem in ext4_ext_swap_inode_data before we
* switch the inode format to prevent read.
*/
mutex_lock(&(inode->i_mutex));
/*
* Even though we take i_mutex we can still cause block allocation
* via mmap write to holes. If we have allocated new blocks we fail
Expand Down Expand Up @@ -623,7 +616,6 @@ int ext4_ext_migrate(struct inode *inode, struct file *filp,
tmp_inode->i_nlink = 0;

ext4_journal_stop(handle);
mutex_unlock(&(inode->i_mutex));

if (tmp_inode)
iput(tmp_inode);
Expand Down

0 comments on commit 8136def

Please sign in to comment.