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 83B2569FE6 for ; Thu, 21 Jan 2021 16:48:32 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 723C913BE3 for ; Thu, 21 Jan 2021 16:48:02 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id B3BE313BD8 for ; Thu, 21 Jan 2021 16:48:00 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 81A0A460B6 for ; Thu, 21 Jan 2021 16:48:00 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Thu, 21 Jan 2021 16:47:59 +0100 Message-Id: <20210121154759.7421-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.265 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [zfspoolplugin.pm] Subject: [pve-devel] [PATCH storage] add workaround for zfs rollback bug 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: Thu, 21 Jan 2021 15:48:32 -0000 as described in the zfs bug https://github.com/openzfs/zfs/issues/10931 the kernel keeps around cached data from mmaps after a rollback, thus having invalid data in files that were allegedly rolled back to workaround this (until a real fix comes along), we unmount the subvol, invalidating the kernel cache anyway the dataset gets mounted on the next 'activate_volume' again Signed-off-by: Dominik Csapak --- PVE/Storage/ZFSPoolPlugin.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm index 3054331..105d802 100644 --- a/PVE/Storage/ZFSPoolPlugin.pm +++ b/PVE/Storage/ZFSPoolPlugin.pm @@ -467,9 +467,18 @@ sub volume_snapshot_delete { sub volume_snapshot_rollback { my ($class, $scfg, $storeid, $volname, $snap) = @_; - my $vname = ($class->parse_volname($volname))[1]; + my (undef, $vname, undef, undef, undef, undef, $format) = $class->parse_volname($volname); + + my $msg = $class->zfs_request($scfg, undef, 'rollback', "$scfg->{pool}/$vname\@$snap"); + + # we have to unmount rollbacked subvols, to invalidate wrong kernel + # caches, they get mounted in activate volume again + # see zfs bug #10931 https://github.com/openzfs/zfs/issues/10931 + if ($format eq 'subvol') { + $class->zfs_request($scfg, undef, 'unmount', "$scfg->{pool}/$vname"); + } - $class->zfs_request($scfg, undef, 'rollback', "$scfg->{pool}/$vname\@$snap"); + return $msg; } sub volume_rollback_is_possible { -- 2.20.1