From 58ca80a77a4b82867922bc7c6ea0a26771a38135 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Dec 06 2018 14:13:54 +0000 Subject: Write the COW header after allocating the file The header was being overwritten when fallocate was not supported, causing backups to fail on the new agent. I would be interested to know how it was working on newer kernels. Resolves: #165 --- diff --git a/src/dattobd.c b/src/dattobd.c index 2065182..e568661 100644 --- a/src/dattobd.c +++ b/src/dattobd.c @@ -2032,9 +2032,6 @@ static int cow_init(char *path, uint64_t elements, unsigned long sect_size, unsi if(uuid) memcpy(cm->uuid, uuid, COW_UUID_SIZE); else generate_random_uuid(cm->uuid); - ret = __cow_write_header_dirty(cm); - if(ret) goto error; - LOG_DEBUG("allocating cow manager array (%lu sections)", cm->total_sects); cm->sects = kzalloc((cm->total_sects) * sizeof(struct cow_section), GFP_KERNEL | __GFP_NOWARN); if(!cm->sects){ @@ -2052,6 +2049,9 @@ static int cow_init(char *path, uint64_t elements, unsigned long sect_size, unsi ret = file_allocate(cm->filp, 0, file_max); if(ret) goto error; + ret = __cow_write_header_dirty(cm); + if(ret) goto error; + *cm_out = cm; return 0;