From: wkendall@sgi.com
To: xfs@oss.sgi.com
Subject: [PATCH v2 9/9] xfsrestore: check for compatible xfsrestore
Date: Fri, 05 Nov 2010 11:35:09 -0500 [thread overview]
Message-ID: <20101105163644.761748638@sgi.com> (raw)
In-Reply-To: 20101105163500.747192954@sgi.com
[-- Attachment #1: check_compatible_restore --]
[-- Type: text/plain, Size: 6939 bytes --]
When resuming a restore or doing a cumulative restore, xfsrestore
reads state information left around by the previous invocation.
This patch adds logic to determine whether or not restore is
able to make sense of the sense information.
The xfsrestore man page has also been updated to make the user
aware of the requirement to use a compatible restore and
system when resuming restores.
Signed-off-by: Bill Kendall <wkendall@sgi.com>
---
man/man8/xfsrestore.8 | 26 +++++++++++---
restore/content.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 108 insertions(+), 10 deletions(-)
Index: xfsdump-kernel.org/man/man8/xfsrestore.8
===================================================================
--- xfsdump-kernel.org.orig/man/man8/xfsrestore.8
+++ xfsdump-kernel.org/man/man8/xfsrestore.8
@@ -61,6 +61,18 @@ The deltas must be applied in the order
Each delta applied must have been produced with the previously applied
delta as its base.
.P
+.I xfsrestore
+keeps state information in the
+.IR xfsrestorehousekeepingdir ,
+to inform subsequent invocations when used in
+cumulative mode, or in the event a restore is interrupted.
+To ensure that the state information can be processed,
+a compatible version of
+.I xfsrestore
+must be used for each subsequent invocation. Additionally,
+each invocation must run on a system of the same endianness
+and page size.
+.P
The options to
.I xfsrestore
are:
@@ -78,11 +90,11 @@ option allows the operator to specify an
in which
.I xfsrestore
creates the
-.I xfsrestorehousekeeping
-directory.
-When performing a cumulative (\f3\-r\f1 option) restore,
-each successive invocation of \f2xfsrestore\f1 must specify the same alternate
+.I xfsrestorehousekeepingdir
directory.
+When performing a cumulative (\f3\-r\f1 option) restore or
+resuming (\f3\-R\f1 option) a restore, each successive invocation
+must specify the same alternate directory.
.TP 5
\f3\-b\f1 \f2blocksize\f1
Specifies the blocksize, in bytes, to be used for the restore.
@@ -205,7 +217,11 @@ Source tape drive is a QIC tape. QIC ta
blocksize, for which \f2xfsrestore\f1 must make special allowances.
.TP 5
\f3\-r\f1
-Selects the cumulative mode of operation.
+Selects the cumulative mode of operation. The
+.B \-a
+and
+.I destination
+options must be the same for each invocation.
.TP 5
\f3\-s\f1 \f2subtree\f1
Specifies a subtree to restore.
Index: xfsdump-kernel.org/restore/content.c
===================================================================
--- xfsdump-kernel.org.orig/restore/content.c
+++ xfsdump-kernel.org/restore/content.c
@@ -71,6 +71,13 @@
/* structure definitions used locally ****************************************/
+#define HOUSEKEEPING_MAGIC 0x686b6d61
+ /* "hkma" - see the housekeeping_magic field of pers_t below.
+ */
+#define HOUSEKEEPING_VERSION 1
+ /* see the housekeeping_version field of pers_t below.
+ */
+
#define WRITE_TRIES_MAX 3
/* retry loop tuning for write(2) workaround
*/
@@ -358,12 +365,43 @@ struct stream_context {
typedef struct stream_context stream_context_t;
-/* persistent state file header - two parts: accumulation state
- * which spans several sessions, and session state. each has a valid
- * bit, and no fields are valid until the valid bit is set.
- * all elements defined such that a bzero results in a valid initial state.
+/* persistent state file header - on-disk format information plus
+ * accumulation state (which spans several sessions) and session state.
+ * the latter two have a valid bit, and their fields are not valid until
+ * the valid bit is set. all elements defined such that a bzero results
+ * in a valid initial state.
*/
struct pers {
+ /* on-disk format information used to verify that xfsrestore
+ * can make sense of the data in xfsrestorehousekeepingdir
+ * when running in cumulative mode or when resuming a restore.
+ *
+ * for backwards/forwards compatibility, this struct must be
+ * the first field! also any changes to the struct must address
+ * compatibility with other xfsrestore versions.
+ */
+ struct {
+ size32_t housekeeping_magic;
+ /* used to determine if this struct has been
+ * initialized, and whether the machine's
+ * endianness is the same as the previous
+ * invocation. (data written to xfsrestore's
+ * state directory is not converted to an
+ * endian-neutral format since it only persists
+ * for the life of one or more restore sessions.)
+ */
+ size32_t housekeeping_version;
+ /* version of the data structures used in the
+ * state files in housekeepingdir. this must be
+ * bumped whenever the on-disk format changes.
+ */
+ size64_t pagesize;
+ /* headers in the persistent state files
+ * are aligned on page size boundaries, so
+ * this cannot change betweeen invocations.
+ */
+ } v;
+
/* command line arguments from first session, and session
* history.
*/
@@ -1301,6 +1339,49 @@ content_init( intgen_t argc, char *argv[
strerror( errno ));
return BOOL_FALSE;
}
+
+ /* but first setup or verify the on-disk format information
+ */
+ if ( ! persp->a.valpr ) {
+ /* this is the first restore session
+ */
+ persp->v.housekeeping_magic = HOUSEKEEPING_MAGIC;
+ persp->v.housekeeping_version = HOUSEKEEPING_VERSION;
+ persp->v.pagesize = pgsz;
+
+ } else {
+ /* cumulative or resuming a restore, verify the header
+ */
+ if ( persp->v.housekeeping_magic != HOUSEKEEPING_MAGIC ) {
+ mlog( MLOG_NORMAL | MLOG_ERROR, _(
+ "%s format corrupt or wrong endianness "
+ "(0x%x, expected 0x%x)\n"),
+ hkdirname,
+ persp->v.housekeeping_magic,
+ HOUSEKEEPING_MAGIC );
+ return BOOL_FALSE;
+ }
+ if ( persp->v.housekeeping_version != HOUSEKEEPING_VERSION ) {
+ mlog( MLOG_NORMAL | MLOG_ERROR, _(
+ "%s format version differs from previous "
+ "restore (%u, expected %u)\n"),
+ hkdirname,
+ persp->v.housekeeping_version,
+ HOUSEKEEPING_VERSION );
+ return BOOL_FALSE;
+ }
+ if ( persp->v.pagesize != pgsz ) {
+ mlog( MLOG_NORMAL | MLOG_ERROR, _(
+ "%s format differs from previous "
+ "restore due to page size change "
+ "(was %lu, now %lu)\n"),
+ hkdirname,
+ persp->v.pagesize,
+ pgsz );
+ return BOOL_FALSE;
+ }
+ }
+
if ( ! persp->a.valpr ) {
if ( ! dstdir ) {
mlog( MLOG_NORMAL | MLOG_ERROR, _(
@@ -1565,7 +1646,8 @@ content_init( intgen_t argc, char *argv[
stpgcnt = 0;
newstpgcnt = ( stsz + pgmask ) / pgsz;
descpgcnt = 0;
- memset( ( void * )persp, 0, sizeof( pers_t ));
+ memset( ( void * )&persp->a, 0,
+ sizeof( pers_t ) - offsetofmember( pers_t, a ));
} else if ( ! persp->s.valpr ) {
stpgcnt = persp->a.stpgcnt;
newstpgcnt = stpgcnt;
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2010-11-05 16:35 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-05 16:35 [PATCH v2 0/9] xfsrestore dirent limitations and scaling issues wkendall
2010-11-05 16:35 ` [PATCH v2 1/9] xfsrestore: turn off NODECHK wkendall
2010-11-12 23:23 ` Alex Elder
2010-11-05 16:35 ` [PATCH v2 2/9] xfsrestore: change nrh_t from 32 to 64 bits wkendall
2010-11-12 23:24 ` Alex Elder
2010-11-05 16:35 ` [PATCH v2 3/9] xfsrestore: cache path lookups wkendall
2010-11-12 23:25 ` Alex Elder
2010-11-05 16:35 ` [PATCH v2 4/9] xfsrestore: mmap dirent names for faster lookups wkendall
2010-11-12 23:25 ` Alex Elder
2010-11-15 21:51 ` Bill Kendall
2010-11-05 16:35 ` [PATCH v2 5/9] xfsrestore: cleanup node allocation wkendall
2010-11-15 20:38 ` Alex Elder
2010-11-15 21:36 ` Bill Kendall
2010-11-05 16:35 ` [PATCH v2 6/9] xfsrestore: fix node table setup wkendall
2010-11-15 20:38 ` Alex Elder
2010-11-15 21:30 ` Bill Kendall
2010-11-05 16:35 ` [PATCH v2 7/9] xfsrestore: make node lookup more efficient wkendall
2010-11-15 20:38 ` Alex Elder
2010-11-15 22:06 ` Bill Kendall
2010-11-05 16:35 ` [PATCH v2 8/9] xfsrestore: remove nix_t wkendall
2010-11-12 23:25 ` Alex Elder
2010-11-05 16:35 ` wkendall [this message]
2010-11-12 23:25 ` [PATCH v2 9/9] xfsrestore: check for compatible xfsrestore Alex Elder
2010-11-12 23:25 ` [PATCH v2 0/9] xfsrestore dirent limitations and scaling issues Alex Elder
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=20101105163644.761748638@sgi.com \
--to=wkendall@sgi.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