]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - copy/xfs_copy.c
xfs: print specific dqblk that failed verifiers
[thirdparty/xfsprogs-dev.git] / copy / xfs_copy.c
index 22ded6b12b4b8b7b21fae2b465e0ba2d6691b111..0b80613f4e64ba6759fb590d87ae0ef526eb30e6 100644 (file)
@@ -28,7 +28,7 @@
 #define        rounddown(x, y) (((x)/(y))*(y))
 #define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0)
 
-extern int     platform_check_ismounted(char *, char *, struct stat64 *, int);
+extern int     platform_check_ismounted(char *, char *, struct stat *, int);
 
 int            logfd;
 char           *logfile_name;
@@ -43,7 +43,7 @@ unsigned int  source_sectorsize;      /* source disk sectorsize */
 
 xfs_agblock_t  first_agbno;
 
-__uint64_t     barcount[11];
+uint64_t       barcount[11];
 
 unsigned int   num_targets;
 target_control *target;
@@ -162,7 +162,7 @@ check_errors(void)
                        if (target[i].err_type == 0)
                                do_log(_("write error"));
                        else
-                               do_log(_("lseek64 error"));
+                               do_log(_("lseek error"));
                        do_log(_(" at offset %lld\n"), target[i].position);
                }
        }
@@ -192,7 +192,7 @@ do_write(
                buf = &w_buf;
 
        if (target[args->id].position != buf->position)  {
-               if (lseek64(args->fd, buf->position, SEEK_SET) < 0)  {
+               if (lseek(args->fd, buf->position, SEEK_SET) < 0)  {
                        error = target[args->id].err_type = 1;
                } else  {
                        target[args->id].position = buf->position;
@@ -263,7 +263,7 @@ handler(int sig)
                                                target[i].position);
                                } else  {
                                        do_warn(
-               _("%s:  lseek64 error on target %d \"%s\" at offset %lld\n"),
+               _("%s:  lseek error on target %d \"%s\" at offset %lld\n"),
                                                progname, i, target[i].name,
                                                target[i].position);
                                }
@@ -313,7 +313,7 @@ usage(void)
 }
 
 void
-init_bar(__uint64_t source_blocks)
+init_bar(uint64_t source_blocks)
 {
        int     i;
 
@@ -322,7 +322,7 @@ init_bar(__uint64_t source_blocks)
 }
 
 int
-bump_bar(int tenths, __uint64_t numblocks)
+bump_bar(int tenths, uint64_t numblocks)
 {
        static char *bar[11] = {
                " 0% ",
@@ -388,9 +388,9 @@ read_wbuf(int fd, wbuf *buf, xfs_mount_t *mp)
        }
 
        if (source_position != buf->position)  {
-               lres = lseek64(fd, buf->position, SEEK_SET);
+               lres = lseek(fd, buf->position, SEEK_SET);
                if (lres < 0LL)  {
-                       do_warn(_("%s:  lseek64 failure at offset %lld\n"),
+                       do_warn(_("%s:  lseek failure at offset %lld\n"),
                                progname, source_position);
                        die_perror();
                }
@@ -476,6 +476,7 @@ void
 write_wbuf(void)
 {
        int             i;
+       int             badness = 0;
 
        /* verify target threads */
        for (i = 0; i < num_targets; i++)
@@ -486,6 +487,17 @@ write_wbuf(void)
        for (i = 0; i < num_targets; i++)
                if (target[i].state != INACTIVE)
                        pthread_mutex_unlock(&targ[i].wait);    /* wake up */
+               else
+                       badness++;
+
+       /*
+        * If all the targets are inactive then there won't be any io
+        * threads left to release mainwait.  We're screwed, so bail out.
+        */
+       if (badness == num_targets) {
+               check_errors();
+               exit(1);
+       }
 
        signal_maskfunc(SIGCHLD, SIG_UNBLOCK);
        pthread_mutex_lock(&mainwait);
@@ -534,8 +546,8 @@ main(int argc, char **argv)
        xfs_off_t       pos;
        size_t          length;
        int             c;
-       __uint64_t      size, sizeb;
-       __uint64_t      numblocks = 0;
+       uint64_t        size, sizeb;
+       uint64_t        numblocks = 0;
        int             wblocks = 0;
        int             num_threads = 0;
        struct dioattr  d;
@@ -562,7 +574,7 @@ main(int argc, char **argv)
        extern int      optind;
        libxfs_init_t   xargs;
        thread_args     *tcarg;
-       struct stat64   statbuf;
+       struct stat     statbuf;
 
        progname = basename(argv[0]);
 
@@ -643,7 +655,7 @@ main(int argc, char **argv)
                die_perror();
        }
 
-       if (fstat64(source_fd, &statbuf) < 0)  {
+       if (fstat(source_fd, &statbuf) < 0)  {
                do_log(_("%s:  couldn't stat source \"%s\"\n"),
                        progname, source_name);
                die_perror();
@@ -794,7 +806,7 @@ main(int argc, char **argv)
        for (i = 0; i < num_targets; i++)  {
                int     write_last_block = 0;
 
-               if (stat64(target[i].name, &statbuf) < 0)  {
+               if (stat(target[i].name, &statbuf) < 0)  {
                        /* ok, assume it's a file and create it */
 
                        do_out(_("Creating file %s\n"), target[i].name);
@@ -834,7 +846,7 @@ main(int argc, char **argv)
                if (write_last_block)  {
                        /* ensure regular files are correctly sized */
 
-                       if (ftruncate64(target[i].fd, mp->m_sb.sb_dblocks *
+                       if (ftruncate(target[i].fd, mp->m_sb.sb_dblocks *
                                                source_blocksize))  {
                                do_log(_("%s:  cannot grow data section.\n"),
                                        progname);
@@ -862,7 +874,7 @@ main(int argc, char **argv)
 
                        off = mp->m_sb.sb_dblocks * source_blocksize;
                        off -= sizeof(lb);
-                       if (pwrite64(target[i].fd, lb, sizeof(lb), off) < 0)  {
+                       if (pwrite(target[i].fd, lb, sizeof(lb), off) < 0)  {
                                do_log(_("%s:  failed to write last block\n"),
                                        progname);
                                do_log(_("\tIs target \"%s\" too small?\n"),
@@ -951,8 +963,8 @@ main(int argc, char **argv)
        num_ags = mp->m_sb.sb_agcount;
 
        init_bar(mp->m_sb.sb_blocksize / BBSIZE
-                       * ((__uint64_t)mp->m_sb.sb_dblocks
-                           - (__uint64_t)mp->m_sb.sb_fdblocks + 10 * num_ags));
+                       * ((uint64_t)mp->m_sb.sb_dblocks
+                           - (uint64_t)mp->m_sb.sb_fdblocks + 10 * num_ags));
 
        kids = num_targets;
 
@@ -1128,7 +1140,8 @@ main(int argc, char **argv)
                                 ((char *) btree_buf.data +
                                  pos - btree_buf.position);
 
-                       ASSERT(be32_to_cpu(block->bb_magic) == XFS_ABTB_MAGIC);
+                       ASSERT(be32_to_cpu(block->bb_magic) == XFS_ABTB_MAGIC ||
+                              be32_to_cpu(block->bb_magic) == XFS_ABTB_CRC_MAGIC);
                }
 
                /*
@@ -1202,6 +1215,7 @@ main(int argc, char **argv)
 
        check_errors();
        libxfs_umount(mp);
+       libxfs_destroy();
 
        return 0;
 }