]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: update target inode's ctime on unlink
authorJeff Layton <jlayton@kernel.org>
Mon, 12 Aug 2024 16:30:52 +0000 (12:30 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:10:32 +0000 (15:10 +0200)
[ Upstream commit 3bc2ac2f8f0b78a13140fc72022771efe0c9b778 ]

Unlink changes the link count on the target inode. POSIX mandates that
the ctime must also change when this occurs.

According to https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html:

"Upon successful completion, unlink() shall mark for update the last data
 modification and last file status change timestamps of the parent
 directory. Also, if the file's link count is not 0, the last file status
 change timestamp of the file shall be marked for update."

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: David Sterba <dsterba@suse.com>
[ add link to the opengroup docs ]
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/inode.c

index f7807f36c8e3fe7ed0042d769b5f1b9142965a3d..eb12ba64ac7a7aa10928c1b38fc8e0bf45731e30 100644 (file)
@@ -4199,6 +4199,7 @@ err:
 
        btrfs_i_size_write(dir, dir->vfs_inode.i_size - name_len * 2);
        inode_inc_iversion(&inode->vfs_inode);
+       inode_set_ctime_current(&inode->vfs_inode);
        inode_inc_iversion(&dir->vfs_inode);
        inode->vfs_inode.i_ctime = dir->vfs_inode.i_mtime =
                dir->vfs_inode.i_ctime = current_time(&inode->vfs_inode);