db5d2a4b77
where there is no good reason to keep them separate. It's a pain during rebase if there are multiple patches changing the same code over and over again. This was especially bad for the backup-related patches. If the history of patches really is needed, it can be extracted via git. Additionally, compilation with partial application of patches was broken since a long time, because one of the master key changes became part of an earlier patch during a past rebase. If only the same files were changed by a subsequent patch and the changes felt to belong together (obvious for later bug fixes, but also done for features e.g. adding master key support for PBS), the patches were squashed together. The PBS namespace support patch was split into the individual parts it changes, i.e. PBS block driver, pbs-restore binary and QMP backup infrastructure, and squashed into the respective patches. No code change is intended, git diff in the submodule should not show any difference between applying all patches before this commit and applying all patches after this commit. The query-proxmox-support QMP function has been left as part of the "PVE-Backup: Proxmox backup patches for QEMU" patch, because it's currently only used there. If it ever is used elsewhere too, it can be split out from there. The recent alloc-track and BQL-related savevm-async changes have been left separate for now, because it's not 100% clear they are the best approach yet. This depends on what upstream decides about the BQL stuff and whether and what kind of issues with the changes pop up. The qemu-img dd snapshot patch has been re-ordered to after the other qemu-img dd patches. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
135 lines
4.9 KiB
Diff
135 lines
4.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
|
Date: Mon, 6 Apr 2020 12:16:50 +0200
|
|
Subject: [PATCH] PVE: [Up+Config] file-posix: make locking optiono on create
|
|
|
|
Otherwise creating images on nfs/cifs can be problematic.
|
|
|
|
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
|
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
|
---
|
|
block/file-posix.c | 59 ++++++++++++++++++++++++++++++--------------
|
|
qapi/block-core.json | 3 ++-
|
|
2 files changed, 42 insertions(+), 20 deletions(-)
|
|
|
|
diff --git a/block/file-posix.c b/block/file-posix.c
|
|
index 9681bd0434..044890822d 100644
|
|
--- a/block/file-posix.c
|
|
+++ b/block/file-posix.c
|
|
@@ -2483,6 +2483,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
|
int fd;
|
|
uint64_t perm, shared;
|
|
int result = 0;
|
|
+ bool locked = false;
|
|
|
|
/* Validate options and set default values */
|
|
assert(options->driver == BLOCKDEV_DRIVER_FILE);
|
|
@@ -2523,19 +2524,22 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
|
perm = BLK_PERM_WRITE | BLK_PERM_RESIZE;
|
|
shared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
|
|
|
|
- /* Step one: Take locks */
|
|
- result = raw_apply_lock_bytes(NULL, fd, perm, ~shared, false, errp);
|
|
- if (result < 0) {
|
|
- goto out_close;
|
|
- }
|
|
+ if (file_opts->locking != ON_OFF_AUTO_OFF) {
|
|
+ /* Step one: Take locks */
|
|
+ result = raw_apply_lock_bytes(NULL, fd, perm, ~shared, false, errp);
|
|
+ if (result < 0) {
|
|
+ goto out_close;
|
|
+ }
|
|
+ locked = true;
|
|
|
|
- /* Step two: Check that nobody else has taken conflicting locks */
|
|
- result = raw_check_lock_bytes(fd, perm, shared, errp);
|
|
- if (result < 0) {
|
|
- error_append_hint(errp,
|
|
- "Is another process using the image [%s]?\n",
|
|
- file_opts->filename);
|
|
- goto out_unlock;
|
|
+ /* Step two: Check that nobody else has taken conflicting locks */
|
|
+ result = raw_check_lock_bytes(fd, perm, shared, errp);
|
|
+ if (result < 0) {
|
|
+ error_append_hint(errp,
|
|
+ "Is another process using the image [%s]?\n",
|
|
+ file_opts->filename);
|
|
+ goto out_unlock;
|
|
+ }
|
|
}
|
|
|
|
/* Clear the file by truncating it to 0 */
|
|
@@ -2589,13 +2593,15 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
|
}
|
|
|
|
out_unlock:
|
|
- raw_apply_lock_bytes(NULL, fd, 0, 0, true, &local_err);
|
|
- if (local_err) {
|
|
- /* The above call should not fail, and if it does, that does
|
|
- * not mean the whole creation operation has failed. So
|
|
- * report it the user for their convenience, but do not report
|
|
- * it to the caller. */
|
|
- warn_report_err(local_err);
|
|
+ if (locked) {
|
|
+ raw_apply_lock_bytes(NULL, fd, 0, 0, true, &local_err);
|
|
+ if (local_err) {
|
|
+ /* The above call should not fail, and if it does, that does
|
|
+ * not mean the whole creation operation has failed. So
|
|
+ * report it the user for their convenience, but do not report
|
|
+ * it to the caller. */
|
|
+ warn_report_err(local_err);
|
|
+ }
|
|
}
|
|
|
|
out_close:
|
|
@@ -2619,6 +2625,7 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
|
PreallocMode prealloc;
|
|
char *buf = NULL;
|
|
Error *local_err = NULL;
|
|
+ OnOffAuto locking;
|
|
|
|
/* Skip file: protocol prefix */
|
|
strstart(filename, "file:", &filename);
|
|
@@ -2641,6 +2648,18 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
|
return -EINVAL;
|
|
}
|
|
|
|
+ locking = qapi_enum_parse(&OnOffAuto_lookup,
|
|
+ qemu_opt_get(opts, "locking"),
|
|
+ ON_OFF_AUTO_AUTO, &local_err);
|
|
+ if (local_err) {
|
|
+ error_propagate(errp, local_err);
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ if (locking == ON_OFF_AUTO_AUTO) {
|
|
+ locking = ON_OFF_AUTO_OFF;
|
|
+ }
|
|
+
|
|
options = (BlockdevCreateOptions) {
|
|
.driver = BLOCKDEV_DRIVER_FILE,
|
|
.u.file = {
|
|
@@ -2652,6 +2671,8 @@ raw_co_create_opts(BlockDriver *drv, const char *filename,
|
|
.nocow = nocow,
|
|
.has_extent_size_hint = has_extent_size_hint,
|
|
.extent_size_hint = extent_size_hint,
|
|
+ .has_locking = true,
|
|
+ .locking = locking,
|
|
},
|
|
};
|
|
return raw_co_create(&options, errp);
|
|
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
|
index 3c945c1f93..542add004b 100644
|
|
--- a/qapi/block-core.json
|
|
+++ b/qapi/block-core.json
|
|
@@ -4740,7 +4740,8 @@
|
|
'size': 'size',
|
|
'*preallocation': 'PreallocMode',
|
|
'*nocow': 'bool',
|
|
- '*extent-size-hint': 'size'} }
|
|
+ '*extent-size-hint': 'size',
|
|
+ '*locking': 'OnOffAuto' } }
|
|
|
|
##
|
|
# @BlockdevCreateOptionsGluster:
|