All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Btrfs send fixup
@ 2014-02-25 18:32 David Sterba
  2014-02-25 18:32 ` [PATCH 1/2] btrfs: send: fix old buffer length in fs_path_ensure_buf David Sterba
  2014-02-25 18:33 ` [PATCH 2/2] btrfs: send: simplify allocation code " David Sterba
  0 siblings, 2 replies; 4+ messages in thread
From: David Sterba @ 2014-02-25 18:32 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

A fix for the problem that Filipe pointed out and a cleanup in the same code,
depends on the first patch.

Based on btrfs-next/master.

David Sterba (2):
  btrfs: send: fix old buffer length in fs_path_ensure_buf
  btrfs: send: simplify allocation code in fs_path_ensure_buf

 fs/btrfs/send.c |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)

-- 
1.7.9


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] btrfs: send: fix old buffer length in fs_path_ensure_buf
  2014-02-25 18:32 [PATCH 0/2] Btrfs send fixup David Sterba
@ 2014-02-25 18:32 ` David Sterba
  2014-02-25 18:39   ` Filipe David Manana
  2014-02-25 18:33 ` [PATCH 2/2] btrfs: send: simplify allocation code " David Sterba
  1 sibling, 1 reply; 4+ messages in thread
From: David Sterba @ 2014-02-25 18:32 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

In "btrfs: send: lower memory requirements in common case" the code to
save the old_buf_len was incorrectly moved to a wrong place and broke
the original logic.

Reported-by: Filipe David Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/send.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index b6d416ce6b3b..613f4bc93571 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -288,6 +288,9 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
 	if (p->buf_len >= len)
 		return 0;
 
+	path_len = p->end - p->start;
+	old_buf_len = p->buf_len;
+
 	/*
 	 * First time the inline_buf does not suffice
 	 */
@@ -310,9 +313,6 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
 		p->buf_len = ksize(p->buf);
 	}
 
-	path_len = p->end - p->start;
-	old_buf_len = p->buf_len;
-
 	if (p->reversed) {
 		tmp_buf = p->buf + old_buf_len - path_len - 1;
 		p->end = p->buf + p->buf_len - 1;
-- 
1.7.9


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] btrfs: send: simplify allocation code in fs_path_ensure_buf
  2014-02-25 18:32 [PATCH 0/2] Btrfs send fixup David Sterba
  2014-02-25 18:32 ` [PATCH 1/2] btrfs: send: fix old buffer length in fs_path_ensure_buf David Sterba
@ 2014-02-25 18:33 ` David Sterba
  1 sibling, 0 replies; 4+ messages in thread
From: David Sterba @ 2014-02-25 18:33 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/send.c |   30 ++++++++++++------------------
 1 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 613f4bc93571..31b9c59eb087 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -294,24 +294,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)
-			return -ENOMEM;
-		/*
-		 * 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->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
+	 */
+	p->buf_len = ksize(p->buf);
 
 	if (p->reversed) {
 		tmp_buf = p->buf + old_buf_len - path_len - 1;
-- 
1.7.9


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] btrfs: send: fix old buffer length in fs_path_ensure_buf
  2014-02-25 18:32 ` [PATCH 1/2] btrfs: send: fix old buffer length in fs_path_ensure_buf David Sterba
@ 2014-02-25 18:39   ` Filipe David Manana
  0 siblings, 0 replies; 4+ messages in thread
From: Filipe David Manana @ 2014-02-25 18:39 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs

On Tue, Feb 25, 2014 at 6:32 PM, David Sterba <dsterba@suse.cz> wrote:
> In "btrfs: send: lower memory requirements in common case" the code to
> save the old_buf_len was incorrectly moved to a wrong place and broke
> the original logic.
>
> Reported-by: Filipe David Manana <fdmanana@gmail.com>
> Signed-off-by: David Sterba <dsterba@suse.cz>

Reviewed-by: Filipe David Manana <fdmanana@gmail.com>

Thanks David.

> ---
>  fs/btrfs/send.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index b6d416ce6b3b..613f4bc93571 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -288,6 +288,9 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
>         if (p->buf_len >= len)
>                 return 0;
>
> +       path_len = p->end - p->start;
> +       old_buf_len = p->buf_len;
> +
>         /*
>          * First time the inline_buf does not suffice
>          */
> @@ -310,9 +313,6 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
>                 p->buf_len = ksize(p->buf);
>         }
>
> -       path_len = p->end - p->start;
> -       old_buf_len = p->buf_len;
> -
>         if (p->reversed) {
>                 tmp_buf = p->buf + old_buf_len - path_len - 1;
>                 p->end = p->buf + p->buf_len - 1;
> --
> 1.7.9
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Filipe David Manana,

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-25 18:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-25 18:32 [PATCH 0/2] Btrfs send fixup David Sterba
2014-02-25 18:32 ` [PATCH 1/2] btrfs: send: fix old buffer length in fs_path_ensure_buf David Sterba
2014-02-25 18:39   ` Filipe David Manana
2014-02-25 18:33 ` [PATCH 2/2] btrfs: send: simplify allocation code " David Sterba

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.