linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liu Bo <bo.li.liu@oracle.com>
To: Davide Italiano <dccitaliano@gmail.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: Improve FL_KEEP_SIZE handling in fallocate.
Date: Fri, 26 Jun 2015 11:35:02 +0800	[thread overview]
Message-ID: <20150626033501.GC9860@localhost.localdomain> (raw)
In-Reply-To: <1428383355-1686-2-git-send-email-dccitaliano@gmail.com>

On Mon, Apr 06, 2015 at 10:09:15PM -0700, Davide Italiano wrote:
> - 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.

Looks good.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

> 
> Signed-off-by: Davide Italiano <dccitaliano@gmail.com>
> ---
>  fs/btrfs/file.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 30982bb..f649bfc 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -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),
> -- 
> 2.3.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-06-26  3:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07  5:09 [PATCH] Improve FL_KEEP_SIZE handling Davide Italiano
2015-04-07  5:09 ` [PATCH] Btrfs: Improve FL_KEEP_SIZE handling in fallocate Davide Italiano
2015-04-20 20:49   ` Davide Italiano
2015-06-25 17:55     ` Davide Italiano
2015-06-26  3:35   ` Liu Bo [this message]
2015-06-26 14:08   ` David Sterba
2015-07-22 17:45     ` Davide Italiano
2015-10-21 17:16       ` Davide Italiano
2016-03-17 14:29         ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150626033501.GC9860@localhost.localdomain \
    --to=bo.li.liu@oracle.com \
    --cc=dccitaliano@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).