From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id ECCE21FF15F
	for <inbox@lore.proxmox.com>; Mon, 26 Aug 2024 22:46:38 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 623661A266;
	Mon, 26 Aug 2024 22:47:03 +0200 (CEST)
Date: Mon, 26 Aug 2024 16:46:10 -0400
To: PVE Devel <pve-devel@lists.proxmox.com>
MIME-Version: 1.0
Message-ID: <mailman.425.1724705222.302.pve-devel@lists.proxmox.com>
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Post: <mailto:pve-devel@lists.proxmox.com>
From: Joshua Huber via pve-devel <pve-devel@lists.proxmox.com>
Precedence: list
Cc: Joshua Huber <jhuber@blockbridge.com>
X-Mailman-Version: 2.1.29
X-BeenThere: pve-devel@lists.proxmox.com
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
Subject: [pve-devel] orphaned cfs lock when interrupting qm disk import
Content-Type: multipart/mixed; boundary="===============5086982583436267290=="
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

--===============5086982583436267290==
Content-Type: message/rfc822
Content-Disposition: inline

Return-Path: <jhuber@blockbridge.com>
X-Original-To: pve-devel@lists.proxmox.com
Delivered-To: pve-devel@lists.proxmox.com
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) server-digest SHA256)
	(No client certificate requested)
	by lists.proxmox.com (Postfix) with ESMTPS id 64840C6B83
	for <pve-devel@lists.proxmox.com>; Mon, 26 Aug 2024 22:47:02 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 353361A292
	for <pve-devel@lists.proxmox.com>; Mon, 26 Aug 2024 22:46:32 +0200 (CEST)
Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 <pve-devel@lists.proxmox.com>; Mon, 26 Aug 2024 22:46:31 +0200 (CEST)
Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2f504652853so24206041fa.0
        for <pve-devel@lists.proxmox.com>; Mon, 26 Aug 2024 13:46:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=blockbridge.com; s=google; t=1724705184; x=1725309984; darn=lists.proxmox.com;
        h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
         :date:message-id:reply-to;
        bh=LKPgNxUbihk6Zj/GKTfqR5B0O+D+DV5qjLxI0K6KBog=;
        b=bdVei2walFO8XQcMUdnHwZPF73w3f9m17BTetDZS+fyrqJ7l2Rcte5vF/QClRXyVBk
         bo4upVOzT9Pj11Rhk9aBz0Dv9vNmuykMtyuFZnujMeMqV+oRxGMrMraratGOSxHuk4u+
         eDPm9JTUO3COov0/DNrw20ussJxg7sBn8BcAGHJhhLmB+JypVc3gPBLcn4xUuBEuBIkd
         KFnbEl2FPy2//ZmxmYboopIFXwWVyY51dTlH0ZdPwOgzQ+sQ7UG9OpqWI9Gqw4Fr6G1M
         V/LQtM00cCs9wQkLdOs8VCvXjNG+Pte/9ibBimJj5hjio3gK3pGQ6ZdfxuGDJ4ndGojR
         Qp3A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1724705184; x=1725309984;
        h=to:subject:message-id:date:from:mime-version:x-gm-message-state
         :from:to:cc:subject:date:message-id:reply-to;
        bh=LKPgNxUbihk6Zj/GKTfqR5B0O+D+DV5qjLxI0K6KBog=;
        b=OWBPo5K0507+271OM+6htrCooWScMmLE7FtdXM/i7wMb6ZSTThzgx6ac2ekbQzEk5A
         eHQhZGdGUiwQh5AXazlqVVYA06wUH4SJkrgjz8/7bWdXX3eWGrqQlDWM0uu9W8+Wivmw
         UijD8HTolz8684BQI+y0yIBgMdJyyTfwIuPM/w50D5VOLdsPtIMlb1wOuu4I/vK3ZwNe
         DiZh/TYBwRDCBTOMa+JMSd1DZf3YAOY8RBqbENqr44zMq8ZWmXvcPoLs+s6rHOucRgXw
         6IHuYk86hYmWzDLGmAA988MReRO1AHEIENLQN2LLN9RWQDzpvVsI9Y3gtTSVryTxro5I
         M1EQ==
X-Gm-Message-State: AOJu0YxOXdSrTQYBNpsvYfpKbEbmDuDF7IbLMCH2ANf7+xRNUjn1NcPe
	rFJYUSEc71hplm7igAXIbA0FwZP13o1WYUYr1XPvUHXR5nV80PRyOPnj5qr8oEQJtqDJ16vWG7C
	HMEV4mvQyd18lHYz7G9qNrboyyORwnz0WURU8cbDbwHFliRiy
X-Google-Smtp-Source: AGHT+IFF3hkKuuU0R2zSUGBz6O/Y+coD5ViWsySKVyJ9XEr8kkOqXK2U5rTaKtz8yDW5n0E1eGVy+OU9DdJVL5+XZc8=
X-Received: by 2002:a05:651c:1a0a:b0:2ef:22ed:3818 with SMTP id
 38308e7fff4ca-2f514e56966mr3311181fa.32.1724705183401; Mon, 26 Aug 2024
 13:46:23 -0700 (PDT)
MIME-Version: 1.0
From: Joshua Huber <jhuber@blockbridge.com>
Date: Mon, 26 Aug 2024 16:46:10 -0400
Message-ID: <CA+uqL00=49RuhJjjsJZfwZURWYBqf_TdkqCGtB6PM1055pO0yQ@mail.gmail.com>
Subject: orphaned cfs lock when interrupting qm disk import
To: PVE Devel <pve-devel@lists.proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
	BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
	DKIM_SIGNED               0.1 Message has a DKIM or DK signature, not necessarily valid
	DKIM_VALID               -0.1 Message has at least one valid DKIM or DK signature
	DKIM_VALID_AU            -0.1 Message has a valid DKIM or DK signature from author's domain
	DKIM_VALID_EF            -0.1 Message has a valid DKIM or DK signature from envelope-from domain
	DMARC_PASS               -0.1 DMARC pass policy
	HTML_MESSAGE            0.001 HTML included in message
	RCVD_IN_DNSWL_NONE     -0.0001 Sender listed at https://www.dnswl.org/, no trust
	SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
	SPF_PASS               -0.001 SPF: sender matches SPF record
	T_SCC_BODY_TEXT_LINE    -0.01 -
Content-Type: text/plain; charset="UTF-8"
X-Content-Filtered-By: Mailman/MimeDel 2.1.29

Hi everyone,

Say you've just kicked off a long-running "qm disk import ..." command and
notice that an incorrect flag was specified. Ok, cancel the operation with
control-C, fix the flag and re-execute the import command...

However, when using shared storage you'll (at least for the next 120
seconds) bump up against an orphaned cfs lock directory. One could manually
remove the directory from /etc/pve/priv/locks, but it seems a little risky.
(and a bad habit to get into)

So this got me thinking... could we trap SIGINT and more gracefully fail
the operation? It seems like this would allow the cfs_lock function to
clean up after itself. This seems like it'd be a nice CLI QOL improvement.

However, I'm not familiar with the history of the cfs-lock mechanism, why
it's used for shared storage backends, and what other invalid PVE states
might be avoided as a side-effect of serializing storage operations.
Allowing concurrent operations could result in disk numbering collisions,
but I'm not sure what else. (apart from storage-specific limitations.)

The README in the pve-cluster repo was helpful but a bit limited in scope.
Could anyone shed some more light on this for me?

Thanks in advance,
Josh

--===============5086982583436267290==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

--===============5086982583436267290==--