diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-01-08 01:25:40 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-01-08 01:25:40 +0100 |
commit | dfd1520d3ab98cfa376f2d84ed1e7887d013720d (patch) | |
tree | 9f273984285cc37f5600017f4f835d289608386b /src/import | |
parent | 11689d2a021d95a8447d938180e0962cd9439763 (diff) |
import: also set NOCOW for gpt disk images
Given the write patterns on disk images, we better should turn COW off
for them. In particular as the file systems used inside the disk images
should do their own data integrity checks anyway and we don't need
multiple layers of it.
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/import-gpt.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/import/import-gpt.c b/src/import/import-gpt.c index a85ceee337..d304a399fb 100644 --- a/src/import/import-gpt.c +++ b/src/import/import-gpt.c @@ -20,6 +20,7 @@ ***/ #include <sys/xattr.h> +#include <linux/fs.h> #include <curl/curl.h> #include "hashmap.h" @@ -165,7 +166,7 @@ static void gpt_import_file_success(GptImportFile *f) { f->disk_fd = open(f->final_path, O_RDONLY|O_NOCTTY|O_CLOEXEC); if (f->disk_fd < 0) { - r = log_error_errno(errno, "Failed top open vendor image: %m"); + r = log_error_errno(errno, "Failed to open vendor image: %m"); goto finish; } } @@ -186,6 +187,14 @@ static void gpt_import_file_success(GptImportFile *f) { goto finish; } + /* Turn off COW writing. This should greatly improve + * performance on COW file systems like btrfs, since it + * reduces fragmentation caused by not allowing in-place + * writes. */ + r = chattr_fd(dfd, true, FS_NOCOW_FL); + if (r < 0) + log_warning_errno(errno, "Failed to set file attributes on %s: %m", f->temp_path); + r = copy_bytes(f->disk_fd, dfd, (off_t) -1, true); if (r < 0) { log_error_errno(r, "Failed to make writable copy of image: %m"); |