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.
***/
#include <sys/xattr.h>
***/
#include <sys/xattr.h>
#include <curl/curl.h>
#include "hashmap.h"
#include <curl/curl.h>
#include "hashmap.h"
f->disk_fd = open(f->final_path, O_RDONLY|O_NOCTTY|O_CLOEXEC);
if (f->disk_fd < 0) {
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");
+ /* 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");
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");