dedupe: don't add extent items unless we use them
authorJens Axboe <axboe@fb.com>
Wed, 24 Sep 2014 14:21:15 +0000 (08:21 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 24 Sep 2014 14:21:15 +0000 (08:21 -0600)
Only used for collision_check and debug output, so save memory
if those aren't enabled.

Signed-off-by: Jens Axboe <axboe@fb.com>
t/dedupe.c

index e51e444e7b82f441d67d0d7dab9600dd09e3f081..7acb090a63e4a0a080f083b715a7c7d9df9ba3c2 100644 (file)
@@ -134,11 +134,18 @@ static int read_block(int fd, void *buf, off_t offset)
 
 static void add_item(struct chunk *c, struct item *i)
 {
-       struct extent *e;
+       /*      
+        * Save some memory and don't add extent items, if we don't
+        * use them.
+        */
+       if (dump_output || collision_check) {
+               struct extent *e;
+
+               e = malloc(sizeof(*e));
+               e->offset = i->offset;
+               flist_add_tail(&e->list, &c->extent_list);
+       }
 
-       e = malloc(sizeof(*e));
-       e->offset = i->offset;
-       flist_add_tail(&e->list, &c->extent_list);
        c->count++;
 }