From nobody Sun Aug 20 04:28:28 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RT2fj0Nnqz4qgvL; Sun, 20 Aug 2023 04:28:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RT2fh6RJYz4Qbc; Sun, 20 Aug 2023 04:28:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692505708; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HRt0JbaHYx7zaQYoS3Fq7ZhlonnYgwzUgiZqCDZBE1A=; b=CB7F2CTNwfRuP6k8iAZL/iJn4ncT37KExxJFNKSVZIS3VRjkiAqfGitRPBg2kGRM2HphGc 4X+AMjJd+zV5jCGtZU7mE9fxgUaDoKbIyeIVmeeuAtF43QhjaDb+eN3YCYmkVJ8cIXn06a V+gWOq0I/3Txrsne6SFi6to3v5MxuYdMD9vYd8/ajNQvJJlkA3ilWnz0cw87gdi28T+JGS xHjcY9Im2ie29nwDq0Ytbn97AtXbrquv9jwC+rOcWS6we8QBcnAxBc32NUIuCQIecNn+FN tzycZHSFlEZ1/SVWN9XFHZEfEj63AOtDOp4H6IB7sGTNrnVSVtEp9EygBXNO8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692505708; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HRt0JbaHYx7zaQYoS3Fq7ZhlonnYgwzUgiZqCDZBE1A=; b=msQLHl7shNl+HpYIAqeHhk//Sldc2j+ldXa+SnEATelIv687Pw7AwyLFHwcukRbSiLpKvh X0pC5bEy6IO2mnBQc2/cuF4vf+OxrVrf9SNwQ4mXxV3lvjr98f3C18M6ffQERyZbYhASa1 pLjE4tL32OIcvOF0duMgY3UZphiEBlVYYF94yTgIMVLo5pK7u68cSnlbQ7P7aK+TbXFbd0 /PfbempaqWBKeEi5fqVqcSFFZ/oxhQHGy8i58oITGVQgORj4N5C7MfCIqo7XllIcaVeJqQ y+kOED7ly7f5dQckCkA6Qda2l7ZpIGkBCj21cyC5JpMLEinPxVKOe0SW/0oElA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692505708; a=rsa-sha256; cv=none; b=Jj1VSMw1MDic0HCujvBaAXw95NtCwX9MZnowVfk3dchuJaYYCtsnxmLdjhWYFYCrMa22YK /tcJw/sR/Zr4bfioCAgPIk6NxYiTrtIGV2ATJHxUdyAwWBNjAZae7eoQEiG6QQZvtjU+ax G68LAMw9w9MZqa0HgK/XjY8ea4/h4kmLGb+VUTv5pb1HksiJMUcreAFTEhvK5sKycPUkmD OJ5KBVgrlExP0OVSrGxD6r+jetedbZvzrQBphTtnIp3SYh1QLVhtL4fxvhlW6KvABSLcUz kbAH3v2OwptSceUWKnaTTii3SIeVcBRa4vGx/7MWbao/TEVo0ohGXK0QGYO3oA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RT2fh5Rhnz9Gm; Sun, 20 Aug 2023 04:28:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37K4SS1k033807; Sun, 20 Aug 2023 04:28:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37K4SSRW033804; Sun, 20 Aug 2023 04:28:28 GMT (envelope-from git) Date: Sun, 20 Aug 2023 04:28:28 GMT Message-Id: <202308200428.37K4SSRW033804@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kirk McKusick Subject: git: 47048a611dd2 - stable/13 - Set UFS/FFS file type to snapshot before changing its block pointers. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 47048a611dd2606fe93dd59ca9e3f7ec5d756390 Auto-Submitted: auto-generated The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=47048a611dd2606fe93dd59ca9e3f7ec5d756390 commit 47048a611dd2606fe93dd59ca9e3f7ec5d756390 Author: Kirk McKusick AuthorDate: 2023-08-12 18:20:08 +0000 Commit: Kirk McKusick CommitDate: 2023-08-20 04:27:38 +0000 Set UFS/FFS file type to snapshot before changing its block pointers. Reported-by: Peter Holm Tested-by: Peter Holm Sponsored-by: The FreeBSD Foundation (cherry picked from commit 220427da0e9b2c1d8e964120becc17eb7524e46f) --- sys/ufs/ffs/ffs_alloc.c | 1 + sys/ufs/ffs/ffs_snapshot.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index a84202eccc05..933745885755 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -3130,6 +3130,7 @@ ffs_checkcgintegrity(struct fs *fs, fs->fs_cstotal.cs_nifree -= fs->fs_cs(fs, cg).cs_nifree; fs->fs_cs(fs, cg).cs_nifree = 0; fs->fs_maxcluster[cg] = 0; + fs->fs_flags |= FS_NEEDSFSCK; fs->fs_fmod = 1; } diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 5ceca72fd44f..b7844e0564d0 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -368,6 +368,15 @@ restart: goto out; } } + /* + * Change inode to snapshot type file. Before setting its block + * pointers to BLK_SNAP and BLK_NOCOPY in cgaccount, we have to + * set its type to SF_SNAPSHOT so that VOP_REMOVE will know that + * they need to be rolled back before attempting deletion. + */ + ip->i_flags |= SF_SNAPSHOT; + DIP_SET(ip, i_flags, ip->i_flags); + UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); /* * Copy all the cylinder group maps. Although the * filesystem is still active, we hope that only a few @@ -393,12 +402,6 @@ restart: if (error) goto out; } - /* - * Change inode to snapshot type file. - */ - ip->i_flags |= SF_SNAPSHOT; - DIP_SET(ip, i_flags, ip->i_flags); - UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE); /* * Ensure that the snapshot is completely on disk. * Since we have marked it as a snapshot it is safe to