diff mbox series

[2/3] btrfs: use 64-bit timestamps for struct btrfs_dev_replace_item

Message ID 20180620143448.44388-2-arnd@arndb.de
State New
Headers show
Series [1/3] btrfs: use monotonic time for transaction handling | expand

Commit Message

Arnd Bergmann June 20, 2018, 2:34 p.m. UTC
The structure already has 64-bit fields for the timestamps, but
calling get_seconds() may truncate and risk overflow on 32-bit
architectures.

This changes the dev-replace code to use ktime_get_real_seconds()
instead, which always returns 64-bit timestamps.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 fs/btrfs/dev-replace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

-- 
2.9.0

Comments

David Sterba June 20, 2018, 2:36 p.m. UTC | #1
On Wed, Jun 20, 2018 at 04:34:33PM +0200, Arnd Bergmann wrote:
> The structure already has 64-bit fields for the timestamps, but

> calling get_seconds() may truncate and risk overflow on 32-bit

> architectures.

> 

> This changes the dev-replace code to use ktime_get_real_seconds()

> instead, which always returns 64-bit timestamps.

> 

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Thanks but there's a patch already fixng that, sent a few days ago

https://patchwork.kernel.org/patch/10473195/

and added to patch queue for the next dev cycle as it does not appear to
urgent for 4.18.
Arnd Bergmann June 20, 2018, 3:15 p.m. UTC | #2
On Wed, Jun 20, 2018 at 4:36 PM, David Sterba <dsterba@suse.cz> wrote:
> On Wed, Jun 20, 2018 at 04:34:33PM +0200, Arnd Bergmann wrote:

>> The structure already has 64-bit fields for the timestamps, but

>> calling get_seconds() may truncate and risk overflow on 32-bit

>> architectures.

>>

>> This changes the dev-replace code to use ktime_get_real_seconds()

>> instead, which always returns 64-bit timestamps.

>>

>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

>

> Thanks but there's a patch already fixng that, sent a few days ago

>

> https://patchwork.kernel.org/patch/10473195/

>

> and added to patch queue for the next dev cycle as it does not appear to

> urgent for 4.18.


Ok, sounds good.
I had missed that Allen has independently sent out some of the
same patches that I created in the last weeks.

Allen, do you have more patches pending? I have sent out most of what
I did (around 80 patches I think), with just ext4, ceph, nfs and xfs pending
at the moment. It seems we also sent identical patches for procfs and
I have something pending for ceph that duplicates another patch you did.

      Arnd
diff mbox series

Patch

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index e2ba0419297a..1b30c38d05c9 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -465,7 +465,7 @@  int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
 	 * go to the tgtdev as well (refer to btrfs_map_block()).
 	 */
 	dev_replace->replace_state = BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED;
-	dev_replace->time_started = get_seconds();
+	dev_replace->time_started = ktime_get_real_seconds();
 	dev_replace->cursor_left = 0;
 	dev_replace->committed_cursor_left = 0;
 	dev_replace->cursor_left_last_write_of_item = 0;
@@ -618,7 +618,7 @@  static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 			  : BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED;
 	dev_replace->tgtdev = NULL;
 	dev_replace->srcdev = NULL;
-	dev_replace->time_stopped = get_seconds();
+	dev_replace->time_stopped = ktime_get_real_seconds();
 	dev_replace->item_needs_writeback = 1;
 
 	/* replace old device with new one in mapping tree */
@@ -807,7 +807,7 @@  int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
 		break;
 	}
 	dev_replace->replace_state = BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED;
-	dev_replace->time_stopped = get_seconds();
+	dev_replace->time_stopped = ktime_get_real_seconds();
 	dev_replace->item_needs_writeback = 1;
 	btrfs_dev_replace_write_unlock(dev_replace);
 	btrfs_scrub_cancel(fs_info);
@@ -848,7 +848,7 @@  void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info)
 	case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:
 		dev_replace->replace_state =
 			BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED;
-		dev_replace->time_stopped = get_seconds();
+		dev_replace->time_stopped = ktime_get_real_seconds();
 		dev_replace->item_needs_writeback = 1;
 		btrfs_info(fs_info, "suspending dev_replace for unmount");
 		break;