]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: unconditionally free blockmaps when threads complete
authorEric Sandeen <sandeen@sandeen.net>
Mon, 24 Aug 2015 01:52:45 +0000 (11:52 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 24 Aug 2015 01:52:45 +0000 (11:52 +1000)
blkmap_free() doesn't actually free the block map unless it's
inordinately large; this keeps us from constantly freeing
and re-allocating blockmaps for each inode, which makes sense.

However, once the threads which have allocated these structures
exit, we should actually free them; they can grow up to 2MB
for each of the data and attr maps, for each thread, and not
be freed through the normal blkmap_free() test.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
repair/bmap.c
repair/bmap.h
repair/phase3.c
repair/phase4.c

index 26556328c48123490c17d298180fca3aaeb83c4b..abe9f48de4a94544b3ba27cf5568b27d5bf21c7b 100644 (file)
@@ -82,7 +82,8 @@ blkmap_alloc(
  * extents) then free it to release the memory. This prevents us from pinning
  * large tracts of memory due to corrupted fork values or one-off fragmented
  * files. Otherwise we have nothing to do but keep the memory around for the
- * next inode
+ * next inode.
+ * When the thread is done, it should do an unconditional, final free.
  */
 void
 blkmap_free(
@@ -103,6 +104,20 @@ blkmap_free(
        free(blkmap);
 }
 
+void
+blkmap_free_final(void)
+{
+       blkmap_t        *blkmap;
+
+       blkmap = pthread_getspecific(dblkmap_key);
+       pthread_setspecific(dblkmap_key, NULL);
+       free(blkmap);
+
+       blkmap = pthread_getspecific(ablkmap_key);
+       pthread_setspecific(ablkmap_key, NULL);
+       free(blkmap);
+}
+
 /*
  * Get one entry from a block map.
  */
index 973081a69d9ade561f772997681d11f5c203c1b3..501ef6b5dea84699c0a8d3e6005b8ec55394662e 100644 (file)
@@ -58,6 +58,7 @@ extern pthread_key_t ablkmap_key;
 
 blkmap_t       *blkmap_alloc(xfs_extnum_t nex, int whichfork);
 void           blkmap_free(blkmap_t *blkmap);
+void           blkmap_free_final(void);
 
 int            blkmap_set_ext(blkmap_t **blkmapp, xfs_fileoff_t o,
                               xfs_fsblock_t b, xfs_filblks_t c);
index 20786af338f457dd8e921aa2ed7e17f38ce9f11b..76c9440367fd47f59c3c5cb1e56dacac9a38dbbc 100644 (file)
@@ -27,6 +27,7 @@
 #include "err_protos.h"
 #include "dinode.h"
 #include "progress.h"
+#include "bmap.h"
 
 static void
 process_agi_unlinked(
@@ -75,6 +76,7 @@ process_ag_func(
        wait_for_inode_prefetch(arg);
        do_log(_("        - agno = %d\n"), agno);
        process_aginodes(wq->mp, arg, agno, 1, 0, 1);
+       blkmap_free_final();
        cleanup_inode_prefetch(arg);
 }
 
index e0571e87431e78c475e91409ef38de63ecdebe7d..1a7d7b5f57b96ff312955fc2ec2adcba1384391c 100644 (file)
@@ -138,6 +138,7 @@ process_ag_func(
        wait_for_inode_prefetch(arg);
        do_log(_("        - agno = %d\n"), agno);
        process_aginodes(wq->mp, arg, agno, 0, 1, 0);
+       blkmap_free_final();
        cleanup_inode_prefetch(arg);
 
        /*