smalloc: unlink pool file in add_pool()

Don't defer until cleanup time, since we may not clean up if fio
crashes or is killed in other ways.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/smalloc.c b/smalloc.c
index 7f3c10b..fc6ac52 100644
--- a/smalloc.c
+++ b/smalloc.c
@@ -224,7 +224,13 @@
 		goto out_unlink;
 #endif
 
+	/*
+	 * Unlink pool file now. It wont get deleted until the fd is closed,
+	 * which happens both for cleanup or unexpected quit. This way we
+	 * don't leave temp files around in case of a crash.
+	 */
 	pool->fd = fd;
+	unlink(pool->file);
 
 	nr_pools++;
 	return 0;
@@ -252,7 +258,10 @@
 
 static void cleanup_pool(struct pool *pool)
 {
-	unlink(pool->file);
+	/*
+	 * This will also remove the temporary file we used as a backing
+	 * store, it was already unlinked
+	 */
 	close(pool->fd);
 	munmap(pool->map, pool->mmap_size);