提交 9c9ca00b 编写于 作者: D David Sterba 提交者: Josef Bacik

btrfs: send: simplify allocation code in fs_path_ensure_buf

Signed-off-by: NDavid Sterba <dsterba@suse.cz>
Signed-off-by: NJosef Bacik <jbacik@fb.com>
上级 1b2782c8
......@@ -352,24 +352,18 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
/*
* First time the inline_buf does not suffice
*/
if (p->buf == p->inline_buf) {
p->buf = kmalloc(len, GFP_NOFS);
if (!p->buf)
if (p->buf == p->inline_buf)
tmp_buf = kmalloc(len, GFP_NOFS);
else
tmp_buf = krealloc(p->buf, len, GFP_NOFS);
if (!tmp_buf)
return -ENOMEM;
p->buf = tmp_buf;
/*
* The real size of the buffer is bigger, this will let the
* fast path happen most of the time
* The real size of the buffer is bigger, this will let the fast path
* happen most of the time
*/
p->buf_len = ksize(p->buf);
} else {
char *tmp;
tmp = krealloc(p->buf, len, GFP_NOFS);
if (!tmp)
return -ENOMEM;
p->buf = tmp;
p->buf_len = ksize(p->buf);
}
if (p->reversed) {
tmp_buf = p->buf + old_buf_len - path_len - 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册