Remove redundant check under lock scope in fallocate()
PATCH 1/1 Remove redundant check under lock scope in fallocate()
The check for indirect files is already done in ext4_fallocate() and outside of the lock scope. I removed it entirely from ext4_zero_range and ext4_collapse range.
Davide Italiano (1):
ext4: Remove redundant check under lock scope
fs/ext4/extents.c | 16 ---------------- 1 file changed, 16 deletions(-)
Signature · 1 line
2.3.4
PATCH 1/1 ext4: Remove redundant check under lock scope
ext4_zero_range() and ext4_collapse_range() duplicate the check in ext4_fallocate(). The checks are made with inode lock held when there's no need for that. Remove them, reducing the scope of the lock.
--- fs/ext4/extents.c | 16 ---------------- 1 file changed, 16 deletions(-)
fs/ext4/extents.c +0 -15
@@ -4810,15 +4810,6 @@ static long ext4_zero_range(struct file *file, loff_t offset, flags |=EXT4_GET_BLOCKS_KEEP_SIZE ;mutex_lock (&inode->i_mutex); - -/* -* Indirect files do not support unwritten extnets -*/ -if (!(ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS ))) { - ret = -EOPNOTSUPP ; - goto out_mutex; - } -if (!(mode &FALLOC_FL_KEEP_SIZE ) && offset + len >i_size_read (inode)) { new_size = offset + len;
@@ -5445,13 +5436,6 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) ret = -EINVAL ; goto out_mutex; } - -/* Currently just for extent based files */ -if (!ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS )) { - ret = -EOPNOTSUPP ; - goto out_mutex; - }
Re: [PATCH] ext4: Remove redundant check under lock scope
Quoted 4 lines · Davide Italiano
ext4_zero_range()andext4_collapse_range()duplicate the check inext4_fallocate(). The checks are made with inode lock held when there's no need for that. Remove them, reducing the scope of the lock.
NAK. Other task can convert indirect<=>extent via ioctl(, EXT4_IOC_SETFLAGS, flags)
->ext4_ext_migrate()
->ext4_int_migrate()
So we _must_ recheck EXT4_INODE_EXTENTS after we grab i_mutex.
Quoted 47 lines
Signed-off-by Davide Italiano <[email protected]>--- fs/ext4/extents.c | 16 ---------------- 1 file changed, 16 deletions(-)fs/ext4/extents.c +0
-16@@ -4810,15 +4810,6 @@ static long ext4_zero_range(struct file *file, loff_t offset, flags |=EXT4_GET_BLOCKS_KEEP_SIZE ;mutex_lock (&inode->i_mutex); - -/* -* Indirect files do not support unwritten extnets -*/ -if (!(ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS ))) { - ret = -EOPNOTSUPP ; - goto out_mutex; - } -if (!(mode &FALLOC_FL_KEEP_SIZE ) && offset + len >i_size_read (inode)) { new_size = offset + len;@@ -5445,13 +5436,6 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) ret = -EINVAL ; goto out_mutex; } - -/* Currently just for extent based files */ -if (!ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS )) { - ret = -EOPNOTSUPP ; - goto out_mutex; - } -truncate_pagecache (inode, ioffset);/* Wait for existing dio to complete */ Signature · 6 lines
2.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] ext4: Remove redundant check under lock scope
Quoted 51 lines · Dmitry Monakhov
Quoted 4 lines · Davide Italiano
ext4_zero_range()andext4_collapse_range()duplicate the check inext4_fallocate(). The checks are made with inode lock held when there's no need for that. Remove them, reducing the scope of the lock.NAK. Other task can convert indirect<=>extent via
ioctl(, EXT4_IOC_SETFLAGS, flags)
->ext4_ext_migrate()
->ext4_int_migrate()
So we _must_ recheckEXT4_INODE_EXTENTSafter we grabi_mutex.Quoted 39 lines
Signed-off-by Davide Italiano <[email protected]>--- fs/ext4/extents.c | 16 ---------------- 1 file changed, 16 deletions(-)fs/ext4/extents.c +0
-16@@ -4810,15 +4810,6 @@ static long ext4_zero_range(struct file *file, loff_t offset, flags |=EXT4_GET_BLOCKS_KEEP_SIZE ;mutex_lock (&inode->i_mutex); - -/* -* Indirect files do not support unwritten extnets -*/ -if (!(ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS ))) { - ret = -EOPNOTSUPP ; - goto out_mutex; - } -if (!(mode &FALLOC_FL_KEEP_SIZE ) && offset + len >i_size_read (inode)) { new_size = offset + len;@@ -5445,13 +5436,6 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) ret = -EINVAL ; goto out_mutex; } - -/* Currently just for extent based files */ -if (!ext4_test_inode_flag (inode,EXT4_INODE_EXTENTS )) { - ret = -EOPNOTSUPP ; - goto out_mutex; - } -truncate_pagecache (inode, ioffset);
Quoted 8 lines
Quoted 8 lines
fs/ext4/extents.c +0
-1/* Wait for existing dio to complete */ --2.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks, this explains it. Do you think it's worth adding a comment explaining this behaviour?
--
Davide