Description
Describe the feature would like to see added to OpenZFS
In a .zfs/snapshot
directory, it would be useful if snapshot subdirectories had their mtime
attribute set to the snapshot creation timestamp.
How will this feature improve OpenZFS?
If mtime
were set, then with ls -l
one could quickly see snapshot timestamps. "When was this snapshot created" is the most important fact about a snapshot. When I need to restore, I generally want to restore the newest snapshot. When I'm running out of disk space, I want to destroy the oldest snapshot. I'd like to use ls -l
to see and sort by timestamp, rather than zfs list -t snapshot -s creation -o name <fs>
.
Additional context
Currently (e.g zfs 2.1.5) the snapshot directory timestamps are not set usefully. E.g. here are the directory's timestamps for a recently created snapshot. None of them equal the snapshot's 'creation' property:
root@server /var/lib/postgresql/12/main/.zfs/snapshot # stat autosnap_2023-07-26_09:00:13_hourly
File: autosnap_2023-07-26_09:00:13_hourly
Size: 23 Blocks: 17 IO Block: 1536 directory
Device: b3h/179d Inode: 281474976611565 Links: 19
Access: (0700/drwx------) Uid: ( 114/postgres) Gid: ( 120/ postgres)
Access: 2023-06-20 05:12:10.393136304 -0700
Modify: 2023-04-23 22:08:07.119052048 -0700
Change: 2023-04-23 22:08:07.119052048 -0700
Birth: 2022-07-06 07:51:09.067191634 -0700
root@server /var/lib/postgresql/12/main/.zfs/snapshot # zfs get creation tank/var/lib/postgresql/12/main@autosnap_2023-07-26_09:00:13_hourly
NAME PROPERTY VALUE SOURCE
tank/var/lib/postgresql/12/main@autosnap_2023-07-26_09:00:13_hourly creation Wed Jul 26 2:00 2023 -
root@server /var/lib/postgresql/12/main/.zfs/snapshot # date
Wed Jul 26 02:59:54 PDT 2023