From: Jeff Layton Date: Mon, 12 Aug 2024 16:30:52 +0000 (-0400) Subject: btrfs: update target inode's ctime on unlink X-Git-Tag: v5.10.227~512 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f08589057f323442b7fb7c5b9eb4dc0453efea59;p=thirdparty%2Fkernel%2Fstable.git btrfs: update target inode's ctime on unlink [ 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 Reviewed-by: David Sterba [ add link to the opengroup docs ] Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index cd3156a9a268d..24598acb9a314 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3704,6 +3704,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);