Improve FL_KEEP_SIZE handling
PATCH 1/1 Improve FL_KEEP_SIZE handling
This matches the logic of ext4. I think it's more correct passing (offset + len) to inode_newsize_ok() rather than rounding up to block size.
The call can be skipped in some cases too. It works for me but I'm new to this code so I might miss something. Let me know what you think.
Davide Italiano (1):
Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
fs/btrfs/file.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Signature · 1 line
2.3.4
PATCH 1/1 Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
- We call inode_size_ok() only if FL_KEEP_SIZE isn't specified.
- As an optimisation we can skip the call if (off + len) isn't greater than the current size of the file. This operation is called under the lock so the less work we do, the better.
- If we call inode_size_ok() pass to it the correct value rather than a more conservative estimation.
--- fs/btrfs/file.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/btrfs/file.c +7 -3
@@ -2586,9 +2586,13 @@ static long btrfs_fallocate(struct file *file, int mode, }mutex_lock (&inode->i_mutex); - ret =inode_newsize_ok (inode, alloc_end); -if (ret) - goto out; + +if (!(mode &FALLOC_FL_KEEP_SIZE ) && + offset + len > inode->i_size) { + ret =inode_newsize_ok (inode, offset + len); +if (ret) + goto out; + }if (alloc_start > inode->i_size) { ret = btrfs_cont_expand(inode, i_size_read(inode),
Signature · 1 line
2.3.4
Re: [PATCH] Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
Quoted 34 lines · Davide Italiano
- We call
inode_size_ok()only ifFL_KEEP_SIZEisn't specified.
- As an optimisation we can skip the call if (off + len) isn't greater than the current size of the file. This operation is called under the lock so the less work we do, the better.
- If we callinode_size_ok()pass to it the correct value rather than a more conservative estimation.Signed-off-by Davide Italiano <[email protected]>--- fs/btrfs/file.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)fs/btrfs/file.c +7
-4@@ -2586,9 +2586,13 @@ static long btrfs_fallocate(struct file *file, int mode, }mutex_lock (&inode->i_mutex); - ret =inode_newsize_ok (inode, alloc_end); -if (ret) - goto out; + +if (!(mode &FALLOC_FL_KEEP_SIZE ) && + offset + len > inode->i_size) { + ret =inode_newsize_ok (inode, offset + len); +if (ret) + goto out; + }if (alloc_start > inode->i_size) { ret = btrfs_cont_expand(inode, i_size_read(inode), --
Quoted 2 lines
2.3.4
Any comment on this?
Re: [PATCH] Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
Quoted 32 lines · Davide Italiano
Quoted 31 lines · Davide Italiano
- We call
inode_size_ok()only ifFL_KEEP_SIZEisn't specified.
- As an optimisation we can skip the call if (off + len) isn't greater than the current size of the file. This operation is called under the lock so the less work we do, the better.
- If we callinode_size_ok()pass to it the correct value rather than a more conservative estimation.Signed-off-by Davide Italiano <[email protected]>--- fs/btrfs/file.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)fs/btrfs/file.c +7
-3@@ -2586,9 +2586,13 @@ static long btrfs_fallocate(struct file *file, int mode, }mutex_lock (&inode->i_mutex); - ret =inode_newsize_ok (inode, alloc_end); -if (ret) - goto out; + +if (!(mode &FALLOC_FL_KEEP_SIZE ) && + offset + len > inode->i_size) { + ret =inode_newsize_ok (inode, offset + len); +if (ret) + goto out; + }
Quoted 7 lines
Quoted 5 lines
fs/btrfs/file.c +0
-1if (alloc_start > inode->i_size) { ret = btrfs_cont_expand(inode, i_size_read(inode), --2.3.4
Any comment on this?
Very gentle ping after couple of months.
Re: [PATCH] Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
In reply to Davide ItalianoQuoted 6 lines · Davide Italiano
- We call
inode_size_ok()only ifFL_KEEP_SIZEisn't specified.
- As an optimisation we can skip the call if (off + len) isn't greater than the current size of the file. This operation is called under the lock so the less work we do, the better.
- If we callinode_size_ok()pass to it the correct value rather than a more conservative estimation.
Looks good.
Quoted 34 lines
Signed-off-by Davide Italiano <[email protected]>--- fs/btrfs/file.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)fs/btrfs/file.c +7
-3@@ -2586,9 +2586,13 @@ static long btrfs_fallocate(struct file *file, int mode, }mutex_lock (&inode->i_mutex); - ret =inode_newsize_ok (inode, alloc_end); -if (ret) - goto out; + +if (!(mode &FALLOC_FL_KEEP_SIZE ) && + offset + len > inode->i_size) { + ret =inode_newsize_ok (inode, offset + len); +if (ret) + goto out; + }if (alloc_start > inode->i_size) { ret = btrfs_cont_expand(inode, i_size_read(inode),Signature · 6 lines
2.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
In reply to Davide ItalianoQuoted 8 lines · Davide Italiano
- We call
inode_size_ok()only ifFL_KEEP_SIZEisn't specified.
- As an optimisation we can skip the call if (off + len) isn't greater than the current size of the file. This operation is called under the lock so the less work we do, the better.
- If we callinode_size_ok()pass to it the correct value rather than a more conservative estimation.Signed-off-by Davide Italiano <[email protected]>
Re: [PATCH] Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
Quoted 11 lines · David Sterba
Quoted 8 lines · Davide Italiano
- We call
inode_size_ok()only ifFL_KEEP_SIZEisn't specified.
- As an optimisation we can skip the call if (off + len) isn't greater than the current size of the file. This operation is called under the lock so the less work we do, the better.
- If we callinode_size_ok()pass to it the correct value rather than a more conservative estimation.Signed-off-by Davide Italiano <[email protected]>Reviewed-by David Sterba <[email protected]>
Hi Chris, this has been around for a while and it's been reviewed by multiple people. Any chances you can pull in your branch?
Thanks,
--
Davide
Re: [PATCH] Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
Quoted 13 lines · Davide Italiano
Quoted 11 lines · David Sterba
Quoted 8 lines · Davide Italiano
- We call
inode_size_ok()only ifFL_KEEP_SIZEisn't specified.
- As an optimisation we can skip the call if (off + len) isn't greater than the current size of the file. This operation is called under the lock so the less work we do, the better.
- If we callinode_size_ok()pass to it the correct value rather than a more conservative estimation.Signed-off-by Davide Italiano <[email protected]>Reviewed-by David Sterba <[email protected]>
Quoted 7 lines
Hi Chris, this has been around for a while and it's been reviewed by multiple people. Any chances you can pull in your branch?
Thanks,
--
Davide
Any chance to get this in?
Re: [PATCH] Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
Quoted 10 lines · Davide Italiano
Quoted 9 lines · Davide Italiano
Quoted 8 lines · David Sterba
Quoted 7 lines · Davide Italiano
- We call
inode_size_ok()only ifFL_KEEP_SIZEisn't specified.
- As an optimisation we can skip the call if (off + len) isn't greater than the current size of the file. This operation is called under the lock so the less work we do, the better.
- If we callinode_size_ok()pass to it the correct value rather than a more conservative estimation.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Davide Italiano <[email protected]>Reviewed-by David Sterba <[email protected]>Hi Chris, this has been around for a while and it's been reviewed by multiple people. Any chances you can pull in your branch?
I'm adding this patch to my for-next, sorry for late response.