public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 2/5] metadump: support writing discontiguous io cursors
Date: Thu, 23 Jan 2014 21:23:52 +1100	[thread overview]
Message-ID: <1390472635-17225-3-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1390472635-17225-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

To handle discontiguous buffers, metadump needs to be able to handle
io cursrors that use discontiguous buffer mappings. Factor
write_buf() to extract the data copy routine and use that to
implement support for both flat and discontiguous buffer maps.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 db/metadump.c | 45 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 9 deletions(-)

diff --git a/db/metadump.c b/db/metadump.c
index 4104fcb..a8bc297 100644
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -166,12 +166,34 @@ write_index(void)
 	return 0;
 }
 
+/*
+ * Return 0 for success, -errno for failure.
+ */
+static int
+write_buf_segment(
+	char		*data,
+	__int64_t	off,
+	int		len)
+{
+	int		i;
+	int		ret;
+
+	for (i = 0; i < len; i++, off++, data += BBSIZE) {
+		block_index[cur_index] = cpu_to_be64(off);
+		memcpy(&block_buffer[cur_index << BBSHIFT], data, BBSIZE);
+		if (++cur_index == num_indicies) {
+			ret = write_index();
+			if (ret)
+				return -EIO;
+		}
+	}
+	return 0;
+}
+
 static int
 write_buf(
 	iocur_t		*buf)
 {
-	char		*data;
-	__int64_t	off;
 	int		i;
 	int		ret;
 
@@ -191,15 +213,20 @@ write_buf(
 		}
 	}
 
-	for (i = 0, off = buf->bb, data = buf->data;
-			i < buf->blen;
-			i++, off++, data += BBSIZE) {
-		block_index[cur_index] = cpu_to_be64(off);
-		memcpy(&block_buffer[cur_index << BBSHIFT], data, BBSIZE);
-		if (++cur_index == num_indicies) {
-			ret = write_index();
+	/* handle discontiguous buffers */
+	if (!buf->bbmap) {
+		ret = write_buf_segment(buf->data, buf->bb, buf->blen);
+		if (ret)
+			return ret;
+	} else {
+		int	len = 0;
+		for (i = 0; i < buf->bbmap->nmaps; i++) {
+			ret = write_buf_segment(buf->data + BBTOB(len),
+						buf->bbmap->b[i].bm_bn,
+						buf->bbmap->b[i].bm_len);
 			if (ret)
 				return ret;
+			len += buf->bbmap->b[i].bm_len;
 		}
 	}
 	return seenint() ? -EINTR : 0;
-- 
1.8.4.rc3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2014-01-23 10:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-23 10:23 [PATCH 0/5] metadump: discontiguous directory block support Dave Chinner
2014-01-23 10:23 ` [PATCH 1/5] metadump: sanitise write_buf/index return values Dave Chinner
2014-02-03 11:08   ` Christoph Hellwig
2014-02-13 19:30   ` Mark Tinguely
2014-02-14  2:20     ` Dave Chinner
2014-02-14 19:51       ` Mark Tinguely
2014-02-14 20:54         ` Mark Tinguely
2014-01-23 10:23 ` Dave Chinner [this message]
2014-02-03 15:06   ` [PATCH 2/5] metadump: support writing discontiguous io cursors Christoph Hellwig
2014-01-23 10:23 ` [PATCH 3/5] metadump: separate single block objects from multiblock objects Dave Chinner
2014-02-03 15:09   ` Christoph Hellwig
2014-02-03 22:19     ` Dave Chinner
2014-01-23 10:23 ` [PATCH 4/5] metadump: walk single fsb objects a block at a time Dave Chinner
2014-02-03 15:43   ` Christoph Hellwig
2014-01-23 10:23 ` [PATCH 5/5] metadump: fully support discontiguous directory blocks Dave Chinner
2014-02-03 21:15   ` Christoph Hellwig
2014-02-03  3:19 ` [PATCH 0/5] metadump: discontiguous directory block support Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390472635-17225-3-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox