linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sahil Kang <sahil.kang@asilaycomputing.com>
To: dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org, sahil.kang@asilaycomputing.com
Subject: Re: [PATCH] Tidy while loop in end_compressed_writeback
Date: Mon, 24 Apr 2017 00:44:05 -0700	[thread overview]
Message-ID: <f46f81a7-4481-dd86-453b-d41d0f3a12bd@asilaycomputing.com> (raw)
In-Reply-To: <1ff02889-4c01-acb6-cfc0-48433a86bdf8@asilaycomputing.com>

Hi David,

I think my previous email may have failed to send.
Can you merge my patch below?
It's a minor update that I think improves readability.

Thanks,
Sahil

On 04/19/2017 05:43 AM, Sahil Kang wrote:
> Hi,
>
> This is my first patch so it's a minor code change.
> I think removing the early continue from the loop makes the function a 
> little easier to follow.
> Please have a look and I'd appreciate any feedback.
>
> Thanks,
> Sahil
>
>
> From 98afe83a570180e841fefe3fd48d450accc42ea3 Mon Sep 17 00:00:00 2001
> From: Sahil Kang <sahil.kang@asilaycomputing.com>
> Date: Wed, 19 Apr 2017 04:47:00 -0700
> Subject: [PATCH] Tidy while loop in end_compressed_writeback
>
> Instead of continuing early in the loop when ret is 0,
> we can decrement/increment nr_pages/index by 1 at the ending.
> The for loop will not execute when ret is 0 anyway.
>
> Signed-off-by: Sahil Kang <sahil.kang@asilaycomputing.com>
> ---
>  fs/btrfs/compression.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> index c473c42..c653297 100644
> --- a/fs/btrfs/compression.c
> +++ b/fs/btrfs/compression.c
> @@ -238,17 +238,14 @@ static noinline void 
> end_compressed_writeback(struct inode *inode,
>          ret = find_get_pages_contig(inode->i_mapping, index,
>                       min_t(unsigned long,
>                       nr_pages, ARRAY_SIZE(pages)), pages);
> -        if (ret == 0) {
> -            nr_pages -= 1;
> -            index += 1;
> -            continue;
> -        }
>          for (i = 0; i < ret; i++) {
>              if (cb->errors)
>                  SetPageError(pages[i]);
>              end_page_writeback(pages[i]);
>              page_cache_release(pages[i]);
>          }
> +
> +        ret = ret ? ret : 1; /* set ret to 1 if it's 0 */
>          nr_pages -= ret;
>          index += ret;
>      }


  reply	other threads:[~2017-04-24  7:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19 12:43 [PATCH] Tidy while loop in end_compressed_writeback Sahil Kang
2017-04-24  7:44 ` Sahil Kang [this message]
2017-04-26 19:15 ` Sahil Kang
2017-05-02 16:01 ` David Sterba
2017-05-02 18:19   ` Sahil Kang

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=f46f81a7-4481-dd86-453b-d41d0f3a12bd@asilaycomputing.com \
    --to=sahil.kang@asilaycomputing.com \
    --cc=dsterba@suse.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).