* [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling
@ 2018-06-21 16:04 Arnd Bergmann
2018-06-21 16:04 ` [PATCH 2/2] [v2] btrfs: use timespec64 for i_otime Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Arnd Bergmann @ 2018-06-21 16:04 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba
Cc: Arnd Bergmann, Qu Wenruo, Nikolay Borisov, Anand Jain, Liu Bo,
linux-btrfs, linux-kernel
The transaction times were changed to ktime_get_real_seconds to avoid
the y2038 overflow, but they still have a minor problem when they go
backwards or jump due to settimeofday() or leap seconds.
This changes the transaction handling to instead use ktime_get_seconds(),
which returns a CLOCK_MONOTONIC timestamp that has neither of those
problems.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: Rebased on top of an earlier patch by Allen Pais, which
also obsoleted the original patch 2/3
---
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/transaction.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index f3224e23d5fa..bf0717f2824d 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1819,7 +1819,7 @@ static int transaction_kthread(void *arg)
goto sleep;
}
- now = ktime_get_real_seconds();
+ now = ktime_get_seconds();
if (cur->state < TRANS_STATE_BLOCKED &&
!test_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags) &&
(now < cur->start_time ||
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 56c8bab0b816..ebe50dfb8947 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -241,7 +241,7 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info,
refcount_set(&cur_trans->use_count, 2);
atomic_set(&cur_trans->pending_ordered, 0);
cur_trans->flags = 0;
- cur_trans->start_time = ktime_get_real_seconds();
+ cur_trans->start_time = ktime_get_seconds();
memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs));
--
2.9.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] [v2] btrfs: use timespec64 for i_otime
2018-06-21 16:04 [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling Arnd Bergmann
@ 2018-06-21 16:04 ` Arnd Bergmann
2018-06-21 16:09 ` Nikolay Borisov
2018-06-21 16:06 ` [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling Nikolay Borisov
2018-06-21 17:24 ` David Sterba
2 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2018-06-21 16:04 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba
Cc: Arnd Bergmann, Omar Sandoval, Nikolay Borisov, Liu Bo,
linux-btrfs, linux-kernel
While the regular inode timestamps all use timespec64 now, the
i_otime field is btrfs specific and still needs to be converted
to correctly represent times beyond 2038.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: no changes
---
fs/btrfs/btrfs_inode.h | 2 +-
fs/btrfs/inode.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 7e075343daa5..1343ac57b438 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -178,7 +178,7 @@ struct btrfs_inode {
struct btrfs_delayed_node *delayed_node;
/* File creation time. */
- struct timespec i_otime;
+ struct timespec64 i_otime;
/* Hook into fs_info->delayed_iputs */
struct list_head delayed_iput;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e9482f0db9d0..22dcc8afd38f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5745,7 +5745,7 @@ static struct inode *new_simple_dir(struct super_block *s,
inode->i_mtime = current_time(inode);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
- BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime);
+ BTRFS_I(inode)->i_otime = inode->i_mtime;
return inode;
}
@@ -6349,7 +6349,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
inode->i_mtime = current_time(inode);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
- BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime);
+ BTRFS_I(inode)->i_otime = inode->i_mtime;
inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
struct btrfs_inode_item);
--
2.9.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling
2018-06-21 16:04 [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling Arnd Bergmann
2018-06-21 16:04 ` [PATCH 2/2] [v2] btrfs: use timespec64 for i_otime Arnd Bergmann
@ 2018-06-21 16:06 ` Nikolay Borisov
2018-06-21 17:24 ` David Sterba
2 siblings, 0 replies; 5+ messages in thread
From: Nikolay Borisov @ 2018-06-21 16:06 UTC (permalink / raw)
To: Arnd Bergmann, Chris Mason, Josef Bacik, David Sterba
Cc: Qu Wenruo, Anand Jain, Liu Bo, linux-btrfs, linux-kernel
On 21.06.2018 19:04, Arnd Bergmann wrote:
> The transaction times were changed to ktime_get_real_seconds to avoid
> the y2038 overflow, but they still have a minor problem when they go
> backwards or jump due to settimeofday() or leap seconds.
>
> This changes the transaction handling to instead use ktime_get_seconds(),
> which returns a CLOCK_MONOTONIC timestamp that has neither of those
> problems.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> v2: Rebased on top of an earlier patch by Allen Pais, which
> also obsoleted the original patch 2/3
> ---
> fs/btrfs/disk-io.c | 2 +-
> fs/btrfs/transaction.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index f3224e23d5fa..bf0717f2824d 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -1819,7 +1819,7 @@ static int transaction_kthread(void *arg)
> goto sleep;
> }
>
> - now = ktime_get_real_seconds();
> + now = ktime_get_seconds();
> if (cur->state < TRANS_STATE_BLOCKED &&
> !test_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags) &&
> (now < cur->start_time ||
> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> index 56c8bab0b816..ebe50dfb8947 100644
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -241,7 +241,7 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info,
> refcount_set(&cur_trans->use_count, 2);
> atomic_set(&cur_trans->pending_ordered, 0);
> cur_trans->flags = 0;
> - cur_trans->start_time = ktime_get_real_seconds();
> + cur_trans->start_time = ktime_get_seconds();
>
> memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs));
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] [v2] btrfs: use timespec64 for i_otime
2018-06-21 16:04 ` [PATCH 2/2] [v2] btrfs: use timespec64 for i_otime Arnd Bergmann
@ 2018-06-21 16:09 ` Nikolay Borisov
0 siblings, 0 replies; 5+ messages in thread
From: Nikolay Borisov @ 2018-06-21 16:09 UTC (permalink / raw)
To: Arnd Bergmann, Chris Mason, Josef Bacik, David Sterba
Cc: Omar Sandoval, Liu Bo, linux-btrfs, linux-kernel
On 21.06.2018 19:04, Arnd Bergmann wrote:
> While the regular inode timestamps all use timespec64 now, the
> i_otime field is btrfs specific and still needs to be converted
> to correctly represent times beyond 2038.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> v2: no changes
> ---
> fs/btrfs/btrfs_inode.h | 2 +-
> fs/btrfs/inode.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
> index 7e075343daa5..1343ac57b438 100644
> --- a/fs/btrfs/btrfs_inode.h
> +++ b/fs/btrfs/btrfs_inode.h
> @@ -178,7 +178,7 @@ struct btrfs_inode {
> struct btrfs_delayed_node *delayed_node;
>
> /* File creation time. */
> - struct timespec i_otime;
> + struct timespec64 i_otime;
>
> /* Hook into fs_info->delayed_iputs */
> struct list_head delayed_iput;
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index e9482f0db9d0..22dcc8afd38f 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -5745,7 +5745,7 @@ static struct inode *new_simple_dir(struct super_block *s,
> inode->i_mtime = current_time(inode);
> inode->i_atime = inode->i_mtime;
> inode->i_ctime = inode->i_mtime;
> - BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime);
> + BTRFS_I(inode)->i_otime = inode->i_mtime;
>
> return inode;
> }
> @@ -6349,7 +6349,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
> inode->i_mtime = current_time(inode);
> inode->i_atime = inode->i_mtime;
> inode->i_ctime = inode->i_mtime;
> - BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime);
> + BTRFS_I(inode)->i_otime = inode->i_mtime;
>
> inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
> struct btrfs_inode_item);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling
2018-06-21 16:04 [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling Arnd Bergmann
2018-06-21 16:04 ` [PATCH 2/2] [v2] btrfs: use timespec64 for i_otime Arnd Bergmann
2018-06-21 16:06 ` [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling Nikolay Borisov
@ 2018-06-21 17:24 ` David Sterba
2 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2018-06-21 17:24 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Chris Mason, Josef Bacik, David Sterba, Qu Wenruo,
Nikolay Borisov, Anand Jain, Liu Bo, linux-btrfs, linux-kernel
On Thu, Jun 21, 2018 at 06:04:05PM +0200, Arnd Bergmann wrote:
> The transaction times were changed to ktime_get_real_seconds to avoid
> the y2038 overflow, but they still have a minor problem when they go
> backwards or jump due to settimeofday() or leap seconds.
>
> This changes the transaction handling to instead use ktime_get_seconds(),
> which returns a CLOCK_MONOTONIC timestamp that has neither of those
> problems.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: Rebased on top of an earlier patch by Allen Pais, which
> also obsoleted the original patch 2/3
1 and 2 added to patch queue, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-21 17:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-21 16:04 [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling Arnd Bergmann
2018-06-21 16:04 ` [PATCH 2/2] [v2] btrfs: use timespec64 for i_otime Arnd Bergmann
2018-06-21 16:09 ` Nikolay Borisov
2018-06-21 16:06 ` [PATCH 1/2] [v2] btrfs: use monotonic time for transaction handling Nikolay Borisov
2018-06-21 17:24 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®