From ccced3dc40a25c1bbfb6b998b273d02a9add0795 Mon Sep 17 00:00:00 2001 From: Adam Kwolek Date: Thu, 9 Jun 2011 13:00:55 +1000 Subject: [PATCH] FIX: Move buffer to next location When no output file is given save_stripes() should collect amount of stripes in passed buffer. Currently all stripes are saved in the same area in passed buffer. This causes that last stripe is returned on buffer begin only. Increase buffer (buf) pointer when save_stripes() is about switch to next stripe operation. This allows for proper buffer filling as input parameter length directs. Signed-off-by: Adam Kwolek Signed-off-by: Krzysztof Wojcik Signed-off-by: NeilBrown --- restripe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/restripe.c b/restripe.c index 0c8ac08..9c83e2e 100644 --- a/restripe.c +++ b/restripe.c @@ -652,10 +652,14 @@ int save_stripes(int *source, unsigned long long *offsets, fdisk[0], fdisk[1], bufs); } } - if (dest) + if (dest) { for (i = 0; i < nwrites; i++) if (write(dest[i], buf, len) != len) return -1; + } else { + /* build next stripe in buffer */ + buf += len; + } length -= len; start += len; }