fs: btrfs: Use ktime_get_real_ts for root ctime
PATCH 1/1 fs: btrfs: Use ktime_get_real_ts for root ctime
btrfs_root_item maintains the ctime for root updates. This is not part of vfs_inode.
Since current_time() uses struct inode* as an argument as Linus suggested, this cannot be used to update root times unless, we modify the signature to use inode.
Since btrfs uses nanosecond time granularity, it can also use ktime_get_real_ts directly to obtain timestamp for the root. It is necessary to use the timespec time api here because the same btrfs_set_stack_timespec_*() apis are used for vfs inode times as well. These can be transitioned to using timespec64 when btrfs internally changes to use timespec64 as well.
---
Changes from previous version:
* Separated from the current_time() api series.
* Moved ktime_get_real_ts() outside of spin lock.
fs/btrfs/root-tree.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/root-tree.c +2 -1
@@ -505,8 +505,9 @@ void btrfs_update_root_times(struct btrfs_trans_handle *trans, struct btrfs_root *root) {struct btrfs_root_item *item = &root->root_item; -struct timespec ct =current_fs_time (root->fs_info->sb); +struct timespec ct; +ktime_get_real_ts (&ct);spin_lock (&root->root_item_lock);btrfs_set_root_ctransid (item, trans->transid);btrfs_set_stack_timespec_sec (&item->ctime, ct.tv_sec);
Signature · 1 line
2.7.4
Quoted 15 lines · Deepa Dinamani
btrfs_root_itemmaintains the ctime for root updates. This is not part ofvfs_inode.Since
current_time()uses struct inode* as an argument as Linus suggested, this cannot be used to update root times unless, we modify the signature to use inode.Since btrfs uses nanosecond time granularity, it can also use
ktime_get_real_tsdirectly to obtain timestamp for the root. It is necessary to use the timespec time api here because the same btrfs_set_stack_timespec_*() apis are used for vfs inode times as well. These can be transitioned to using timespec64 when btrfs internally changes to use timespec64 as well.
Quoted 3 lines
Signed-off-by Deepa Dinamani <[email protected]>Cc Chris Mason <[email protected]>Cc David Sterba <[email protected]>
Quoted 29 lines
Cc Josef Bacik <[email protected]>---
Changes from previous version:
* Separated from thecurrent_time()api series.
* Movedktime_get_real_ts()outside of spin lock.
fs/btrfs/root-tree.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)fs/btrfs/root-tree.c +2
-1@@ -505,8 +505,9 @@ void btrfs_update_root_times(struct btrfs_trans_handle *trans, struct btrfs_root *root) {struct btrfs_root_item *item = &root->root_item; -struct timespec ct =current_fs_time (root->fs_info->sb); +struct timespec ct; +ktime_get_real_ts (&ct);spin_lock (&root->root_item_lock);btrfs_set_root_ctransid (item, trans->transid);btrfs_set_stack_timespec_sec (&item->ctime, ct.tv_sec);Signature · 1 line
2.7.4