From: David Sterba <dsterba@suse.cz>
To: Filipe David Manana <fdmanana@gmail.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v2] btrfs: send: lower memory requirements in common case
Date: Tue, 25 Feb 2014 19:07:05 +0100 [thread overview]
Message-ID: <20140225180705.GC16073@suse.cz> (raw)
In-Reply-To: <CAL3q7H47h8v-gE_U+4tFSAfTtyjQhFH6NR9oZxuLA_HjEMw1Fg@mail.gmail.com>
On Thu, Feb 20, 2014 at 12:00:23PM +0000, Filipe David Manana wrote:
> > } else {
> > - if (is_vmalloc_addr(p->buf)) {
> > - tmp_buf = vmalloc(len);
> > - if (!tmp_buf)
> > - return -ENOMEM;
> > - memcpy(tmp_buf, p->buf, p->buf_len);
> > - vfree(p->buf);
> > - } else {
> > - tmp_buf = krealloc(p->buf, len, GFP_NOFS);
> > - if (!tmp_buf) {
> > - tmp_buf = vmalloc(len);
> > - if (!tmp_buf)
> > - return -ENOMEM;
> > - memcpy(tmp_buf, p->buf, p->buf_len);
> > - kfree(p->buf);
> > - }
> > - }
> > - p->buf = tmp_buf;
> > - p->buf_len = len;
> > + char *tmp;
> > +
> > + tmp = krealloc(p->buf, len, GFP_NOFS);
> > + if (!tmp)
> > + return -ENOMEM;
> > + p->buf = tmp;
> > + p->buf_len = ksize(p->buf);
> > }
> > +
> > + path_len = p->end - p->start;
> > + old_buf_len = p->buf_len;
>
> I think this is not correct here. old_buf_len doesn't get assigned the
> old buffer's length but instead the new length. So this assignment
> should be before the if-then-else that allocates/reallocates the path
> buffer, just like it was done previously before this change.
You're right, I'll send a fix. Thanks.
prev parent reply other threads:[~2014-02-25 18:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-05 15:17 [PATCH v2] btrfs: send: lower memory requirements in common case David Sterba
2014-02-20 12:00 ` Filipe David Manana
2014-02-25 18:07 ` David Sterba [this message]
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=20140225180705.GC16073@suse.cz \
--to=dsterba@suse.cz \
--cc=fdmanana@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.