Btrfs send fixup
cover Btrfs send fixup
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(-)
Signature · 1 line
1.7.9
PATCH 1/2 btrfs: send: fix old buffer length in fs_path_ensure_buf
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.
--- fs/btrfs/send.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/send.c +3 -3
@@ -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 ;
Signature · 1 line
1.7.9
PATCH 2/2 btrfs: send: simplify allocation code in fs_path_ensure_buf
In reply to David Sterba--- fs/btrfs/send.c | 30 ++++++++++++------------------ 1 files changed, 12 insertions(+), 18 deletions(-)
fs/btrfs/send.c +12 -18
@@ -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 ;
Signature · 1 line
1.7.9
Re: [PATCH 1/2] btrfs: send: fix old buffer length in fs_path_ensure_buf
In reply to David SterbaQuoted 6 lines · David Sterba
In "btrfs: send: lower memory requirements in common case" the code to save the
old_buf_lenwas incorrectly moved to a wrong place and broke the original logic.Reported-by Filipe David Manana <[email protected]>Signed-off-by David Sterba <[email protected]>
Thanks David.
Quoted 35 lines
--- fs/btrfs/send.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)fs/btrfs/send.c +3
-4@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 5 lines
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."