Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1494443 > unrolled thread

[PATCH] fs: btrfs: Use ktime_get_real_ts for root ctime

Started byDeepa Dinamani <deepa.kernel@gmail.com>
First post2016-10-01 19:30 +0200
Last post2016-10-02 01:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] fs: btrfs: Use ktime_get_real_ts for root ctime Deepa Dinamani <deepa.kernel@gmail.com> - 2016-10-01 19:30 +0200
    Re: [PATCH] fs: btrfs: Use ktime_get_real_ts for root ctime David Sterba <dsterba@suse.cz> - 2016-10-02 01:10 +0200

#1494443 — [PATCH] fs: btrfs: Use ktime_get_real_ts for root ctime

FromDeepa Dinamani <deepa.kernel@gmail.com>
Date2016-10-01 19:30 +0200
Subject[PATCH] fs: btrfs: Use ktime_get_real_ts for root ctime
Message-ID<snwgO-3bv-19@gated-at.bofh.it>
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.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: Chris Mason <clm@fb.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Josef Bacik <jbacik@fb.com>
Cc: linux-btrfs@vger.kernel.org
---
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(-)

diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index 0912960..17e5a5f 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -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);
-- 
2.7.4

[toc] | [next] | [standalone]


#1494504

FromDavid Sterba <dsterba@suse.cz>
Date2016-10-02 01:10 +0200
Message-ID<snBzP-6Ug-3@gated-at.bofh.it>
In reply to#1494443
On Sat, Oct 01, 2016 at 10:23:34AM -0700, Deepa Dinamani wrote:
> 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.
> 
> Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
> Cc: Chris Mason <clm@fb.com>
> Cc: David Sterba <dsterba@suse.com>

Acked-by: David Sterba <dsterba@suse.com>

> Cc: Josef Bacik <jbacik@fb.com>
> Cc: linux-btrfs@vger.kernel.org
> ---
> 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(-)
> 
> diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
> index 0912960..17e5a5f 100644
> --- a/fs/btrfs/root-tree.c
> +++ b/fs/btrfs/root-tree.c
> @@ -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);
> -- 
> 2.7.4
> 
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web