public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: Return number of compressed extents directly in compress_file_range
Date: Tue, 2 Jul 2019 12:40:45 +0800	[thread overview]
Message-ID: <393056e8-8753-907e-5dc7-4dc4119bd1e8@oracle.com> (raw)
In-Reply-To: <20190701165055.15483-1-nborisov@suse.com>

On 2/7/19 12:50 AM, Nikolay Borisov wrote:
> compress_file_range returns a void, yet uses a function parameter as a
> return value. Make that more idiomatic by simply returning the number
> of compressed extents directly. Also track such extents in more aptly
> named variables. No functional changes
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Looks good.

Reviewed-by: Anand Jain <anand.jain@oracle.com>


> ---
>   fs/btrfs/inode.c | 20 +++++++++++---------
>   1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 4e183c2d3555..3b0bf5ea9eb6 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -440,8 +440,7 @@ static inline void inode_should_defrag(struct btrfs_inode *inode,
>    * are written in the same order that the flusher thread sent them
>    * down.
>    */
> -static noinline void compress_file_range(struct async_chunk *async_chunk,
> -					 int *num_added)
> +static noinline int compress_file_range(struct async_chunk *async_chunk)
>   {
>   	struct inode *inode = async_chunk->inode;
>   	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
> @@ -457,6 +456,7 @@ static noinline void compress_file_range(struct async_chunk *async_chunk,
>   	int i;
>   	int will_compress;
>   	int compress_type = fs_info->compress_type;
> +	int compressed_extents = 0;
>   	int redirty = 0;
>   
>   	inode_should_defrag(BTRFS_I(inode), start, end, end - start + 1,
> @@ -619,7 +619,7 @@ static noinline void compress_file_range(struct async_chunk *async_chunk,
>   		 */
>   		total_in = ALIGN(total_in, PAGE_SIZE);
>   		if (total_compressed + blocksize <= total_in) {
> -			*num_added += 1;
> +			compressed_extents += 1;
>   
>   			/*
>   			 * The async work queues will take care of doing actual
> @@ -636,7 +636,7 @@ static noinline void compress_file_range(struct async_chunk *async_chunk,
>   				cond_resched();
>   				goto again;
>   			}
> -			return;
> +			return compressed_extents;
>   		}
>   	}
>   	if (pages) {
> @@ -675,9 +675,9 @@ static noinline void compress_file_range(struct async_chunk *async_chunk,
>   		extent_range_redirty_for_io(inode, start, end);
>   	add_async_extent(async_chunk, start, end - start + 1, 0, NULL, 0,
>   			 BTRFS_COMPRESS_NONE);
> -	*num_added += 1;
> +	compressed_extents += 1;
>   
> -	return;
> +	return compressed_extents;
>   
>   free_pages_out:
>   	for (i = 0; i < nr_pages; i++) {
> @@ -685,6 +685,8 @@ static noinline void compress_file_range(struct async_chunk *async_chunk,
>   		put_page(pages[i]);
>   	}
>   	kfree(pages);
> +
> +	return 0;
>   }
>   
>   static void free_async_extent_pages(struct async_extent *async_extent)
> @@ -1122,12 +1124,12 @@ static noinline int cow_file_range(struct inode *inode,
>   static noinline void async_cow_start(struct btrfs_work *work)
>   {
>   	struct async_chunk *async_chunk;
> -	int num_added = 0;
> +	int compressed_extents = 0;
>   
>   	async_chunk = container_of(work, struct async_chunk, work);
>   
> -	compress_file_range(async_chunk, &num_added);
> -	if (num_added == 0) {
> +	compressed_extents = compress_file_range(async_chunk);
> +	if (compressed_extents == 0) {
>   		btrfs_add_delayed_iput(async_chunk->inode);
>   		async_chunk->inode = NULL;
>   	}
> 


  parent reply	other threads:[~2019-07-02  4:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 16:50 [PATCH 1/2] btrfs: Return number of compressed extents directly in compress_file_range Nikolay Borisov
2019-07-01 16:50 ` [PATCH 2/2] btrfs: Move free_pages_out label in inline extent handling branch " Nikolay Borisov
2019-07-02  2:20   ` Qu Wenruo
2019-07-02  4:39   ` Anand Jain
2019-07-02  2:20 ` [PATCH 1/2] btrfs: Return number of compressed extents directly " Qu Wenruo
2019-07-02  4:40 ` Anand Jain [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-07-17 11:41 Nikolay Borisov
2019-07-25 15:51 ` 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=393056e8-8753-907e-5dc7-4dc4119bd1e8@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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