From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 09083B902 for ; Tue, 12 Sep 2023 13:55:28 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E6821125FC for ; Tue, 12 Sep 2023 13:55:27 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 12 Sep 2023 13:55:27 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E5F9E45F46 for ; Tue, 12 Sep 2023 13:55:26 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 12 Sep 2023 13:55:01 +0200 Message-Id: <20230912115501.149923-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.080 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu] fix #4710: vma create: don't use O_DIRECT for tmpfs X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Sep 2023 11:55:28 -0000 The implementation of the helper is_path_tmpfs() is similar to the existing (in upstream) qemu_fd_getfs() function in util/mmap-alloc.c, which unfortunately only takes an existing fd. Signed-off-by: Fiona Ebner --- ...VE-Backup-add-vma-backup-format-code.patch | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch index 857d22d..d5fa0ba 100644 --- a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch +++ b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch @@ -16,10 +16,10 @@ Signed-off-by: Fiona Ebner block/meson.build | 2 + meson.build | 5 + vma-reader.c | 867 ++++++++++++++++++++++++++++++++++++++++++++ - vma-writer.c | 793 ++++++++++++++++++++++++++++++++++++++++ + vma-writer.c | 818 +++++++++++++++++++++++++++++++++++++++++ vma.c | 900 ++++++++++++++++++++++++++++++++++++++++++++++ vma.h | 150 ++++++++ - 6 files changed, 2717 insertions(+) + 6 files changed, 2742 insertions(+) create mode 100644 vma-reader.c create mode 100644 vma-writer.c create mode 100644 vma.c @@ -936,10 +936,10 @@ index 0000000000..81a891c6b1 + diff --git a/vma-writer.c b/vma-writer.c new file mode 100644 -index 0000000000..ac7da237d0 +index 0000000000..5caf80b9f5 --- /dev/null +++ b/vma-writer.c -@@ -0,0 +1,793 @@ +@@ -0,0 +1,818 @@ +/* + * VMA: Virtual Machine Archive + * @@ -955,6 +955,8 @@ index 0000000000..ac7da237d0 + +#include "qemu/osdep.h" +#include ++#include ++#include +#include + +#include "vma.h" @@ -963,6 +965,7 @@ index 0000000000..ac7da237d0 +#include "qemu/main-loop.h" +#include "qemu/coroutine.h" +#include "qemu/cutils.h" ++#include "qemu/error-report.h" +#include "qemu/memalign.h" + +#define DEBUG_VMA 0 @@ -1198,6 +1201,23 @@ index 0000000000..ac7da237d0 + return (done == bytes) ? bytes : -1; +} + ++static bool is_path_tmpfs(const char *path) { ++ struct statfs fs; ++ int ret; ++ ++ do { ++ ret = statfs(path, &fs); ++ } while (ret != 0 && errno == EINTR); ++ ++ if (ret != 0) { ++ warn_report("statfs call for %s failed, assuming not tmpfs - %s\n", ++ path, strerror(errno)); ++ return false; ++ } ++ ++ return fs.f_type == TMPFS_MAGIC; ++} ++ +VmaWriter *vma_writer_create(const char *filename, uuid_t uuid, Error **errp) +{ + const char *p; @@ -1247,8 +1267,13 @@ index 0000000000..ac7da237d0 + } + /* try to use O_NONBLOCK */ + fcntl(vmaw->fd, F_SETFL, fcntl(vmaw->fd, F_GETFL)|O_NONBLOCK); -+ } else { -+ oflags = O_NONBLOCK|O_DIRECT|O_WRONLY|O_EXCL; ++ } else { ++ gchar *dirname = g_path_get_dirname(filename); ++ oflags = O_NONBLOCK|O_WRONLY|O_EXCL; ++ if (!is_path_tmpfs(dirname)) { ++ oflags |= O_DIRECT; ++ } ++ g_free(dirname); + vmaw->fd = qemu_create(filename, oflags, 0644, errp); + } + -- 2.39.2