Writing zeroes into the last sector of an object is not going to preallocate it, but just allocates the last sector. This leads to fairly nasty fragmentation. Use fallocate on the whole object instead. On my test setup with XFS this speeds up writes to an unallocate volume from ~73MB/s to ~80MB/s.
This was benchmarked using an O_DIRECT dd call of 1GB size. Signed-off-by: Christoph Hellwig <[email protected]> Index: sheepdog/sheep/store.c =================================================================== --- sheepdog.orig/sheep/store.c 2011-11-10 19:15:46.796295077 +0100 +++ sheepdog/sheep/store.c 2011-11-10 19:25:14.603795482 +0100 @@ -639,19 +640,8 @@ static int store_queue_request_local(str free(buf); buf = NULL; } else { - int size = SECTOR_SIZE; - buf = valloc(size); - if (!buf) { - eprintf("failed to allocate memory\n"); - ret = SD_RES_NO_MEM; - goto out; - } - memset(buf, 0, size); - ret = pwrite64(fd, buf, size, SD_DATA_OBJ_SIZE - size); - free(buf); - buf = NULL; - - if (ret != size) { + ret = posix_fallocate(fd, 0, SD_DATA_OBJ_SIZE); + if (ret == -1) { if (errno == ENOSPC) ret = SD_RES_NO_SPACE; else { -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
