From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 09/10] btrfs: Remove fail2 label from btrfs_submit_compressed_read
Date: Thu, 2 Jul 2020 16:14:21 +0200 [thread overview]
Message-ID: <20200702141421.GS27795@twin.jikos.cz> (raw)
In-Reply-To: <20200702134650.16550-10-nborisov@suse.com>
On Thu, Jul 02, 2020 at 04:46:49PM +0300, Nikolay Borisov wrote:
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/compression.c | 23 +++++++++--------------
> 1 file changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> index 2033ce17e5c6..c28ee9fcd15d 100644
> --- a/fs/btrfs/compression.c
> +++ b/fs/btrfs/compression.c
> @@ -661,8 +661,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
> u64 em_len;
> u64 em_start;
> struct extent_map *em;
> - blk_status_t ret = BLK_STS_RESOURCE;
> - int faili = 0;
> + blk_status_t ret;
> const u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
> u8 *sums;
>
> @@ -712,12 +711,16 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
> cb->compressed_pages[pg_index] = alloc_page(GFP_NOFS |
> __GFP_HIGHMEM);
> if (!cb->compressed_pages[pg_index]) {
> - faili = pg_index - 1;
> - ret = BLK_STS_RESOURCE;
> - goto fail2;
> + int i;
> +
> + for (i = 0; i < pg_index; i++)
> + __free_page(cb->compressed_pages[i]);
> +
> + kfree(cb->compressed_pages);
> + kfree(cb);
> + return BLK_STS_RESOURCE;
No, that's pushing the error cleanup code to the main code path.
> }
> }
> - faili = nr_pages - 1;
> cb->nr_pages = nr_pages;
>
> add_ra_bio_pages(inode, em_start + em_len, cb);
> @@ -801,14 +804,6 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
>
> return 0;
>
> -fail2:
> - while (faili >= 0) {
> - __free_page(cb->compressed_pages[faili]);
> - faili--;
> - }
> -
> - kfree(cb->compressed_pages);
> - kfree(cb);
> out:
> free_extent_map(em);
> return ret;
If there's anything to fix in this function, it's the labels and
variable naming. 'faili' should be eg. last_index, fail1 -> out_free_cb,
fail2 -> out_free_pages, and out -> out_free_map.
next prev parent reply other threads:[~2020-07-02 14:14 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 13:46 [PATCH 00/10] A bunch of misc cleanups Nikolay Borisov
2020-07-02 13:46 ` [PATCH 01/10] btrfs: Always initialize btrfs_bio::tgtdev_map/raid_map pointers Nikolay Borisov
2020-07-02 14:04 ` Johannes Thumshirn
2020-07-03 8:31 ` Nikolay Borisov
2020-07-03 15:57 ` David Sterba
2020-07-06 6:38 ` Johannes Thumshirn
2020-07-02 13:46 ` [PATCH 02/10] btrfs: raid56: Remove redundant check in rbio_add_io_page Nikolay Borisov
2020-07-02 14:12 ` Johannes Thumshirn
2020-07-02 13:46 ` [PATCH 03/10] btrfs: raid56: Assign bio in while() Nikolay Borisov
2020-07-02 14:14 ` Johannes Thumshirn
2020-07-02 13:46 ` [PATCH 04/10] btrfs: raid56: Remove out label in __raid56_parity_recover Nikolay Borisov
2020-07-02 14:02 ` David Sterba
2020-07-02 14:51 ` Nikolay Borisov
2020-07-02 13:46 ` [PATCH 05/10] btrfs: raid56: Use in_range where applicable Nikolay Borisov
2020-07-02 14:19 ` Johannes Thumshirn
2020-07-03 15:45 ` David Sterba
2020-07-02 13:46 ` [PATCH 06/10] btrfs: raid56: Don't opencode swap() Nikolay Borisov
2020-07-02 14:20 ` Johannes Thumshirn
2020-07-02 13:46 ` [PATCH 07/10] btrfs: Remove fail label in check_compressed_csum Nikolay Borisov
2020-07-02 14:10 ` David Sterba
2020-07-02 13:46 ` [PATCH 08/10] btrfs: Remove fail1 label in btrfs_submit_compressed_read Nikolay Borisov
2020-07-02 14:03 ` David Sterba
2020-07-02 13:46 ` [PATCH 09/10] btrfs: Remove fail2 label from btrfs_submit_compressed_read Nikolay Borisov
2020-07-02 14:14 ` David Sterba [this message]
2020-07-02 13:46 ` [PATCH 10/10] btrfs: Remove out label in btrfs_submit_compressed_read Nikolay Borisov
2020-07-02 14:23 ` Johannes Thumshirn
2020-07-03 16:21 ` [PATCH 00/10] A bunch of misc cleanups 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=20200702141421.GS27795@twin.jikos.cz \
--to=dsterba@suse.cz \
--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