Skip to content

Commit ded9958

Browse files
Christoph Hellwigbrauner
authored andcommitted
btrfs: use vfs_utimes to update file timestamps
Btrfs updates the device node timestamps for block device special files when it stop using the device. Commit 8f96a5b ("btrfs: update the bdev time directly when closing") switch that update from the correct layering to directly call the low-level helper on the bdev inode. This is wrong and got fixed in commit 54fde91 ("btrfs: update device path inode time instead of bd_inode") by updating the file system inode instead of the bdev inode, but this kept the incorrect bypassing of the VFS interfaces and file system ->update_times method. Fix this by using the propet vfs_utimes interface. Fixes: 8f96a5b ("btrfs: update the bdev time directly when closing") Fixes: 54fde91 ("btrfs: update device path inode time instead of bd_inode") Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20251120064859.2911749-5-hch@lst.de Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 0139836 commit ded9958

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

fs/btrfs/volumes.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,14 +2002,11 @@ static int btrfs_add_dev_item(struct btrfs_trans_handle *trans,
20022002
static void update_dev_time(const char *device_path)
20032003
{
20042004
struct path path;
2005-
int ret;
20062005

2007-
ret = kern_path(device_path, LOOKUP_FOLLOW, &path);
2008-
if (ret)
2009-
return;
2010-
2011-
inode_update_time(d_inode(path.dentry), S_MTIME | S_CTIME | S_VERSION);
2012-
path_put(&path);
2006+
if (!kern_path(device_path, LOOKUP_FOLLOW, &path)) {
2007+
vfs_utimes(&path, NULL);
2008+
path_put(&path);
2009+
}
20132010
}
20142011

20152012
static int btrfs_rm_dev_item(struct btrfs_trans_handle *trans,

0 commit comments

Comments
 (0)