aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2014-02-25 13:33:08 -0500
committerJosef Bacik <jbacik@fb.com>2014-03-10 15:16:59 -0400
commit9c9ca00bd31989f1a3dcbf54e97c979024e44409 (patch)
tree62681e801a8ba701155ebf7448055085fa9dc1e7 /fs/btrfs
parent1b2782c8ed24db03ad49942fa37c9f196b7c4af3 (diff)
btrfs: send: simplify allocation code in fs_path_ensure_buf
Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/send.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 246df8513c8a..ba23fef3c5e5 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -352,24 +352,18 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
352 /* 352 /*
353 * First time the inline_buf does not suffice 353 * First time the inline_buf does not suffice
354 */ 354 */
355 if (p->buf == p->inline_buf) { 355 if (p->buf == p->inline_buf)
356 p->buf = kmalloc(len, GFP_NOFS); 356 tmp_buf = kmalloc(len, GFP_NOFS);
357 if (!p->buf) 357 else
358 return -ENOMEM; 358 tmp_buf = krealloc(p->buf, len, GFP_NOFS);
359 /* 359 if (!tmp_buf)
360 * The real size of the buffer is bigger, this will let the 360 return -ENOMEM;
361 * fast path happen most of the time 361 p->buf = tmp_buf;
362 */ 362 /*
363 p->buf_len = ksize(p->buf); 363 * The real size of the buffer is bigger, this will let the fast path
364 } else { 364 * happen most of the time
365 char *tmp; 365 */
366 366 p->buf_len = ksize(p->buf);
367 tmp = krealloc(p->buf, len, GFP_NOFS);
368 if (!tmp)
369 return -ENOMEM;
370 p->buf = tmp;
371 p->buf_len = ksize(p->buf);
372 }
373 367
374 if (p->reversed) { 368 if (p->reversed) {
375 tmp_buf = p->buf + old_buf_len - path_len - 1; 369 tmp_buf = p->buf + old_buf_len - path_len - 1;