From: Jens Axboe Date: Thu, 4 Dec 2008 13:30:13 +0000 (+0100) Subject: smalloc: unlink pool file in add_pool() X-Git-Tag: fio-1.24~38 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=443bb114d963a99082eef916025268a5a107092b;ds=sidebyside 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 --- diff --git a/smalloc.c b/smalloc.c index 7f3c10b1..fc6ac526 100644 --- a/smalloc.c +++ b/smalloc.c @@ -224,7 +224,13 @@ static int add_pool(struct pool *pool, unsigned int alloc_size) 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 @@ void sinit(void) 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);