* [PATCH] Remove redundant check under lock scope in fallocate() @ 2015-04-07 5:35 Davide Italiano 2015-04-07 5:35 ` [PATCH] ext4: Remove redundant check under lock scope Davide Italiano 0 siblings, 1 reply; 4+ messages in thread From: Davide Italiano @ 2015-04-07 5:35 UTC (permalink / raw) To: linux-ext4; +Cc: Davide Italiano 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(-) -- 2.3.4 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ext4: Remove redundant check under lock scope 2015-04-07 5:35 [PATCH] Remove redundant check under lock scope in fallocate() Davide Italiano @ 2015-04-07 5:35 ` Davide Italiano 2015-04-07 10:13 ` Dmitry Monakhov 0 siblings, 1 reply; 4+ messages in thread From: Davide Italiano @ 2015-04-07 5:35 UTC (permalink / raw) To: linux-ext4; +Cc: Davide Italiano 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. Signed-off-by: Davide Italiano <dccitaliano@gmail.com> --- fs/ext4/extents.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index bed4308..9e6fa09 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -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; - } ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Remove redundant check under lock scope 2015-04-07 5:35 ` [PATCH] ext4: Remove redundant check under lock scope Davide Italiano @ 2015-04-07 10:13 ` Dmitry Monakhov 2015-04-07 18:15 ` Davide Italiano 0 siblings, 1 reply; 4+ messages in thread From: Dmitry Monakhov @ 2015-04-07 10:13 UTC (permalink / raw) To: Davide Italiano, linux-ext4; +Cc: Davide Italiano [-- Attachment #1: Type: text/plain, Size: 1882 bytes --] Davide Italiano <dccitaliano@gmail.com> writes: > 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. 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. > > Signed-off-by: Davide Italiano <dccitaliano@gmail.com> > --- > fs/ext4/extents.c | 16 ---------------- > 1 file changed, 16 deletions(-) > > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c > index bed4308..9e6fa09 100644 > --- a/fs/ext4/extents.c > +++ b/fs/ext4/extents.c > @@ -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 */ > -- > 2.3.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 472 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Remove redundant check under lock scope 2015-04-07 10:13 ` Dmitry Monakhov @ 2015-04-07 18:15 ` Davide Italiano 0 siblings, 0 replies; 4+ messages in thread From: Davide Italiano @ 2015-04-07 18:15 UTC (permalink / raw) To: Dmitry Monakhov; +Cc: linux-ext4 On Tue, Apr 7, 2015 at 3:13 AM, Dmitry Monakhov <dmonlist@gmail.com> wrote: > > Davide Italiano <dccitaliano@gmail.com> writes: > > > 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. > 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. > > > > Signed-off-by: Davide Italiano <dccitaliano@gmail.com> > > --- > > fs/ext4/extents.c | 16 ---------------- > > 1 file changed, 16 deletions(-) > > > > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c > > index bed4308..9e6fa09 100644 > > --- a/fs/ext4/extents.c > > +++ b/fs/ext4/extents.c > > @@ -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 */ > > -- > > 2.3.4 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in > > the body of a message to majordomo@vger.kernel.org > > 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-07 18:15 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-04-07 5:35 [PATCH] Remove redundant check under lock scope in fallocate() Davide Italiano 2015-04-07 5:35 ` [PATCH] ext4: Remove redundant check under lock scope Davide Italiano 2015-04-07 10:13 ` Dmitry Monakhov 2015-04-07 18:15 ` Davide Italiano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).