From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 3/5] metadump: separate single block objects from multiblock objects
Date: Thu, 23 Jan 2014 21:23:53 +1100 [thread overview]
Message-ID: <1390472635-17225-4-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>
When trying to dump objects, we have to treat multi-block objects
differently to single block objects. Separate out the code paths for
single block vs multi-block objects so we can add a separate path
for multi-block objects.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
db/metadump.c | 119 ++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 82 insertions(+), 37 deletions(-)
diff --git a/db/metadump.c b/db/metadump.c
index a8bc297..9fc08ed 100644
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -1361,9 +1361,79 @@ obfuscate_attr_blocks(
}
}
-/* inode copy routines */
+static int
+process_single_fsb_objects(
+ xfs_dfiloff_t o,
+ xfs_dfsbno_t s,
+ xfs_dfilblks_t c,
+ typnm_t btype,
+ xfs_dfiloff_t last)
+{
+ int ret = 0;
+
+ push_cur();
+ set_cur(&typtab[btype], XFS_FSB_TO_DADDR(mp, s), c * blkbb,
+ DB_RING_IGN, NULL);
+
+ if (!iocur_top->data) {
+ xfs_agnumber_t agno = XFS_FSB_TO_AGNO(mp, s);
+ xfs_agblock_t agbno = XFS_FSB_TO_AGBNO(mp, s);
+
+ print_warning("cannot read %s block %u/%u (%llu)",
+ typtab[btype].name, agno, agbno, s);
+ if (stop_on_read_error)
+ ret = -EIO;
+ goto out_pop;
+
+ }
+
+ if (dont_obfuscate) {
+ ret = write_buf(iocur_top);
+ goto out_pop;
+ }
+
+ switch (btype) {
+ case TYP_DIR2:
+ if (o >= mp->m_dirleafblk)
+ break;
+
+ obfuscate_dir_data_blocks(iocur_top->data, o, c,
+ last == mp->m_dirblkfsbs);
+ break;
+ case TYP_SYMLINK:
+ obfuscate_symlink_blocks(iocur_top->data, c);
+ break;
+ case TYP_ATTR:
+ obfuscate_attr_blocks(iocur_top->data, o, c);
+ break;
+ default:
+ break;
+ }
+ ret = write_buf(iocur_top);
+
+out_pop:
+ pop_cur();
+ return ret;
+}
static int
+process_multi_fsb_objects(
+ xfs_dfiloff_t o,
+ xfs_dfsbno_t s,
+ xfs_dfilblks_t c,
+ typnm_t btype,
+ xfs_dfiloff_t last)
+{
+ if (btype != TYP_DIR2) {
+ print_warning("bad type for multi-fsb object %d", btype);
+ return -EINVAL;
+ }
+
+ return process_single_fsb_objects(o, s, c, btype, last);
+}
+
+/* inode copy routines */
+static int
process_bmbt_reclist(
xfs_bmbt_rec_t *rp,
int numrecs,
@@ -1377,6 +1447,7 @@ process_bmbt_reclist(
xfs_dfiloff_t last;
xfs_agnumber_t agno;
xfs_agblock_t agbno;
+ int error;
if (btype == TYP_DATA)
return 1;
@@ -1438,44 +1509,18 @@ process_bmbt_reclist(
break;
}
- push_cur();
- set_cur(&typtab[btype], XFS_FSB_TO_DADDR(mp, s), c * blkbb,
- DB_RING_IGN, NULL);
- if (iocur_top->data == NULL) {
- print_warning("cannot read %s block %u/%u (%llu)",
- typtab[btype].name, agno, agbno, s);
- if (stop_on_read_error) {
- pop_cur();
- return 0;
- }
- } else {
- if (!dont_obfuscate)
- switch (btype) {
- case TYP_DIR2:
- if (o < mp->m_dirleafblk)
- obfuscate_dir_data_blocks(
- iocur_top->data, o, c,
- last == mp->m_dirblkfsbs);
- break;
-
- case TYP_SYMLINK:
- obfuscate_symlink_blocks(
- iocur_top->data, c);
- break;
-
- case TYP_ATTR:
- obfuscate_attr_blocks(iocur_top->data,
- o, c);
- break;
-
- default: ;
- }
- if (write_buf(iocur_top)) {
- pop_cur();
+ /* single filesystem block objects are trivial to handle */
+ if (btype != TYP_DIR2 || mp->m_dirblkfsbs == 1) {
+ error = process_single_fsb_objects(o, s, c, btype, last);
+ if (error)
return 0;
- }
+ continue;
}
- pop_cur();
+
+ /* multi-extent directory blocks */
+ error = process_multi_fsb_objects(o, s, c, btype, last);
+ if (error)
+ return 0;
}
return 1;
--
1.8.4.rc3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev 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 ` [PATCH 2/5] metadump: support writing discontiguous io cursors Dave Chinner
2014-02-03 15:06 ` Christoph Hellwig
2014-01-23 10:23 ` Dave Chinner [this message]
2014-02-03 15:09 ` [PATCH 3/5] metadump: separate single block objects from multiblock objects 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-4-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