ext4_get_blocks_wrap take the truncate_mutex early.
PATCH 1/2 ext4_get_blocks_wrap take the truncate_mutex early.
When doing a migrate from ext3 to ext4 inode we need to make sure the test for inode type and walking inode data happens inside lock. To make this happen move truncate_mutex early before checking the i_flags.
This actually should enable us to remove the verify_chain().
I haven't done any performance benchmark with this change.
Signed-off-by Aneesh Kumar K.V <[email protected]>
--- fs/ext4/extents.c | 7 +++-- fs/ext4/inode.c | 69 +++++----------------------------------------- include/linux/ext4_fs.h | 15 +++++++--- 3 files changed, 23 insertions(+), 68 deletions(-)
fs/ext4/extents.c +4 -3
@@ -1977,6 +1977,10 @@ void ext4_ext_release(struct super_block *sb)#endif } +/* +* Need to be called with +* mutex_lock(&EXT4_I(inode)->truncate_mutex); +*/ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, ext4_fsblk_t iblock, unsigned long max_blocks, struct buffer_head *bh_result,
@@ -1991,7 +1995,6 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,__clear_bit (BH_New, &bh_result->b_state);ext_debug ("blocks %d/%lu requested for inode %u\n" , (int ) iblock, max_blocks, (unsigned ) inode->i_ino); -mutex_lock (&EXT4_I (inode)->truncate_mutex);/* check in cache */ goal =ext4_ext_in_cache (inode, iblock, &newex);
@@ -2127,8 +2130,6 @@ out2:ext4_ext_drop_refs (path);kfree (path); } -mutex_unlock (&EXT4_I (inode)->truncate_mutex); -return err ? err : allocated; }
fs/ext4/inode.c +8 -61
125 lines not on this page · raw message
include/linux/ext4_fs.h +11 -4
@@ -988,11 +988,18 @@ ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, unsigned long max_blocks, struct buffer_head *bh, int create, int extend_disksize) { - if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) - return ext4_ext_get_blocks(handle, inode, block, max_blocks, + int retval; +mutex_lock (&EXT4_I (inode)->truncate_mutex); +if (EXT4_I (inode)->i_flags &EXT4_EXTENTS_FL ) { + retval =ext4_ext_get_blocks (handle, inode, block, max_blocks, bh, create, extend_disksize); -return ext4_get_blocks_handle (handle, inode, block, max_blocks, bh, - create, extend_disksize); + }else { + retval =ext4_get_blocks_handle (handle, inode, block, max_blocks, + bh, create, extend_disksize); + } +mutex_unlock (&EXT4_I (inode)->truncate_mutex); + +return retval; }
Signature · 1 line
1.5.2.2.571.ge1341-dirty
PATCH 2/2 Add EXT4_IOC_MIGRATE ioctl
From: Aneesh Kumar K.V <[email protected]>
The below patch add ioctl for migrating ext3 indirect block mapped inode to ext4 extent mapped inode.
Signed-off-by Aneesh Kumar K.V <[email protected]>
--- fs/ext4/Makefile | 2 +- fs/ext4/ioctl.c | 3 + fs/ext4/migrate.c | 655 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/ext4_fs.h | 4 + 4 files changed, 663 insertions(+), 1 deletions(-) create mode 100644 fs/ext4/migrate.c
fs/ext4/Makefile +1 -1
@@ -6,7 +6,7 @@ obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o ext4dev-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \ - ext4_jbd2.o + ext4_jbd2.o migrate.o ext4dev-$(CONFIG_EXT4DEV_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o ext4dev-$(CONFIG_EXT4DEV_FS_POSIX_ACL) += acl.o
fs/ext4/ioctl.c +3 -0
@@ -248,6 +248,9 @@ flags_err:return err; } +case EXT4_IOC_MIGRATE : +return ext4_ext_migrate (inode, filp, cmd, arg); +default :return -ENOTTY ; }
fs/ext4/migrate.c new file +655 -0
655 lines not on this page · raw message
include/linux/ext4_fs.h +4 -0
@@ -242,6 +242,7 @@ struct ext4_new_group_data {#endif #define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long) +#define EXT4_IOC_MIGRATE _IO('f', 7)/* * ioctl commands in 32 bit emulation
@@ -872,6 +873,9 @@ extern int ext4_ioctl (struct inode *, 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 );/* namei.c */ extern int ext4_orphan_add (handle_t *,struct inode *);extern int ext4_orphan_del (handle_t *,struct inode *);
Signature · 1 line
1.5.2.2.571.ge1341-dirty