xfs
[Top] [All Lists]

[PATCH 3/3] xfsdump: refuse restore of V4 format unless FS has projid32b

To: Eric Sandeen <sandeen@xxxxxxxxxx>
Subject: [PATCH 3/3] xfsdump: refuse restore of V4 format unless FS has projid32bit set
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Fri, 12 Oct 2012 16:42:27 -0500
Cc: xfs-oss <xfs@xxxxxxxxxxx>
In-reply-to: <50788C50.40600@xxxxxxxxxx>
References: <50788C50.40600@xxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
Restoring a dump w/ the top 16 bits of a 32-bit project ID
set will fail to restore the full ID unless the projid32 feature
flag is set on the filesystem.

So if the target fs is xfs, fail the restore if we have a version
4 dump (only used currently if dumped from a projid32 fs) and
the target xfs filesystem does not have that feature set.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

p.s. i'd rather go by whether the contents of the dump have any
> 16 bit project ids than by the feature flag, but I don't see
a way to do that.

diff --git a/restore/content.c b/restore/content.c
index edd00ed..fb15779 100644
--- a/restore/content.c
+++ b/restore/content.c
@@ -36,6 +36,7 @@
 #include <pthread.h>
 
 #include "types.h"
+#include "fs.h"
 #include "timeutil.h"
 #include "util.h"
 #include "cldmgr.h"
@@ -2021,6 +2022,8 @@ content_stream_restore( ix_t thrdix )
                bool_t resumepr;
                ix_t level;
                uuid_t *baseidp;
+               uuid_t fsuuid;
+               __u32 fsflags = 0;
 
                rv = Media_mfile_next( Mediap,
                                       PURP_SEARCH,
@@ -2160,6 +2163,29 @@ content_stream_restore( ix_t thrdix )
                        Media_end( Mediap );
                        return mlog_exit(EXIT_ERROR, RV_COMPAT);
                }
+
+               /* if dump format supports 32 bit project IDs and target fs
+                * is XFS, make sure the target fs supports it as well
+                */
+               if ( persp->a.dstdirisxfspr &&
+                    grhdrp->gh_version >= GLOBAL_HDR_VERSION_4) {
+                       rval = fs_getinfo(persp->a.dstdir, &fsuuid, &fsflags);
+                       if ( rval ) {
+                               mlog( MLOG_NORMAL | MLOG_WARNING, _(
+                                       "could not query filesystem features "
+                                       "for %s\n"),
+                                       persp->a.dstdir);
+                       }
+                       if (!(fsflags & XFS_FSOP_GEOM_FLAGS_PROJID32)) {
+                               mlog( MLOG_NORMAL | MLOG_ERROR, _(
+                                       "dump version >= %d requires projid32 "
+                                       "feature on target filesystem\n"),
+                                       GLOBAL_HDR_VERSION_4);
+                               Media_end( Mediap );
+                               return mlog_exit(EXIT_ERROR, RV_COMPAT);
+                       }
+               }
+
                strncpyterm( persp->s.dumplab,
                             grhdrp->gh_dumplabel,
                             sizeof( persp->s.dumplab ));

<Prev in Thread] Current Thread [Next in Thread>