From: David Sterba <dave@jikos.cz>
To: Josef Bacik <jbacik@fusionio.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: cleanup pages properly when ENOMEM in compression
Date: Fri, 5 Oct 2012 22:06:17 +0200 [thread overview]
Message-ID: <20121005200617.GA15720@twin.jikos.cz> (raw)
In-Reply-To: <1349459359-2298-1-git-send-email-jbacik@fusionio.com>
On Fri, Oct 05, 2012 at 01:49:19PM -0400, Josef Bacik wrote:
> --- a/fs/btrfs/compression.c
> +++ b/fs/btrfs/compression.c
> @@ -577,6 +577,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
> u64 em_start;
> struct extent_map *em;
> int ret = -ENOMEM;
> + int faili = 0;
> u32 *sums;
>
> tree = &BTRFS_I(inode)->io_tree;
> @@ -626,8 +627,11 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
> for (pg_index = 0; pg_index < nr_pages; pg_index++) {
> cb->compressed_pages[pg_index] = alloc_page(GFP_NOFS |
> __GFP_HIGHMEM);
> - if (!cb->compressed_pages[pg_index])
> + if (!cb->compressed_pages[pg_index]) {
> + faili = pg_index - 1;
> + ret = -ENOMEM;
> goto fail2;
> + }
> }
> cb->nr_pages = nr_pages;
>
> @@ -713,8 +717,10 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
> return 0;
>
> fail2:
> - for (pg_index = 0; pg_index < nr_pages; pg_index++)
> - free_page((unsigned long)cb->compressed_pages[pg_index]);
> + while (faili >= 0) {
> + __free_page(cb->compressed_pages[pg_index]);
^^^^^^^^
s/pg_index/faili/
Also, faili (how do you pronounce that?) is initialized to 0, the while
loop will always fire (and burn a page), initialize it to -1.
Other than that, I like the fix, thanks.
> + faili--;
> + }
>
> kfree(cb->compressed_pages);
> fail1:
david
next prev parent reply other threads:[~2012-10-05 20:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-05 17:49 [PATCH] Btrfs: cleanup pages properly when ENOMEM in compression Josef Bacik
2012-10-05 20:06 ` David Sterba [this message]
2012-10-05 20:32 ` 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=20121005200617.GA15720@twin.jikos.cz \
--to=dave@jikos.cz \
--cc=jbacik@fusionio.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).