Set creation/change time (otime/ctime) for offline-created subvolumes and convertd root subvolume - #1157
Conversation
…subvol Before this, btrfs-convert would leave the root subvol of the converted fs with 0 as both otime and ctime, showing "-" when using btrfs subvolume show /path. This patch uses the code from mkfs.btrfs's btrfs_create_tree_root() to set the otime/ctime to the root subvol and generate its UUID right away (instead of having to wait for btrfs_rebuild_uuid_tree(), not necessarily needed but cleaner). This way the timestamp of the filesystem conversion will be available in the "Creation time" field of btrfs subvolume show /path output, while the original ext* "Filesystem created" timestamp is available with stat as the mountpoint's birth time. Assisted-by: Claude:opus-4.6 antigravity-cli-1.1.7 Assisted-by: Gemini:3.1-pro antigravity-cli-1.1.7 Signed-off-by: koraynilay <koray.fra@gmail.com>
…d subvolumes Update common/root-tree-utils.c's btrfs_make_subvolume() to also generate a UUID and set otime and ctime of subvolumes created offline (if it's a normal subvolume). This is essentially the same change as commit 0cdfd08 ("btrfs-progs: convert: set creation/change time (otime/ctime) of root subvol") but that applies to: * mkfs.btrfs' --rootdir and --subvol options * btrfs-convert's ext2_saved subvolume Assisted-by: Gemini:3.1-pro antigravity-cli-1.1.7 Signed-off-by: koraynilay <koray.fra@gmail.com>
adam900710
left a comment
There was a problem hiding this comment.
Only very tiny issues related to headers.
Otherwise looks good to me.
You do not need to refresh the patches, I will change them during merge.
| #include <errno.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include <time.h> |
There was a problem hiding this comment.
No need to include time.h explicitly, it's already included by some other headers.
| */ | ||
|
|
||
| #include "kerncompat.h" | ||
| #include <string.h> |
There was a problem hiding this comment.
No need to include that header explicitly.
There are already users of memset() in the same file, thus it's already included by some other headers.
|
Thanks, btw I added the headers because I checked other files and e.g. |
|
Normally I only add headers when the LSP server is showing errors or unable to complete the function. It's already pretty messy to manage the headers for C, so I tend to not include extra unless it failed to compile. Overall you don't need to bother as long as the project still compiles. |
…subvol Before this, btrfs-convert would leave the root subvol of the converted fs with 0 as both otime and ctime, showing "-" when using btrfs subvolume show /path. This patch uses the code from mkfs.btrfs's btrfs_create_tree_root() to set the otime/ctime to the root subvol and generate its UUID right away (instead of having to wait for btrfs_rebuild_uuid_tree(), not necessarily needed but cleaner). This way the timestamp of the filesystem conversion will be available in the "Creation time" field of btrfs subvolume show /path output, while the original ext* "Filesystem created" timestamp is available with stat as the mountpoint's birth time. Pull-request: #1157 Assisted-by: Claude:opus-4.6 antigravity-cli-1.1.7 Assisted-by: Gemini:3.1-pro antigravity-cli-1.1.7 Signed-off-by: koraynilay <koray.fra@gmail.com> Reviewed-by: Qu Wenruo <wqu@suse.com> [ Remove the duplicated <time.h> header inclusion ] Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
…d subvolumes
Update common/root-tree-utils.c's btrfs_make_subvolume() to also
generate a UUID and set otime and ctime of subvolumes created offline
(if it's a normal subvolume).
This is essentially the same change as commit ("btrfs-progs: convert:
set creation/change time (otime/ctime) of root subvol") but that applies to:
* mkfs.btrfs' --rootdir and --subvol options
* btrfs-convert's ext2_saved subvolume
Pull-request: #1157
Assisted-by: Gemini:3.1-pro antigravity-cli-1.1.7
Signed-off-by: koraynilay <koray.fra@gmail.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
[ Remove the duplicated <string.h> header inclusion ]
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Fix
subvol->otimeandsubvol->ctimenot being set on:btrfs-convertd filesystemmkfs.btrfsusing--rootdirand--subvoloptionsext2_savedsubvolume of abtrfs-convert'd filesystemThanks