diff mbox series

[2/6] ext4: use 64-bit timestamps for mmp_time

Message ID 20180620153322.54221-2-arnd@arndb.de
State Accepted
Commit af123b3718592a66a24716ed4724dc214220492b
Headers show
Series [1/6] ext4: sysfs: print ext4_super_block fields as little-endian | expand

Commit Message

Arnd Bergmann June 20, 2018, 3:32 p.m. UTC
The mmp_time field is 64 bits wide, which is good, but calling
get_seconds() results in a 32-bit value on 32-bit architectures. Using
ktime_get_real_seconds() instead returns 64 bits everywhere.

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

---
 fs/ext4/mmp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.9.0

Comments

Andreas Dilger June 21, 2018, 5:20 p.m. UTC | #1
On Jun 20, 2018, at 9:32 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> 

> The mmp_time field is 64 bits wide, which is good, but calling

> get_seconds() results in a 32-bit value on 32-bit architectures. Using

> ktime_get_real_seconds() instead returns 64 bits everywhere.

> 

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


Reviewed-by: Andreas Dilger <adilger@dilger.ca>


> ---

> fs/ext4/mmp.c | 6 +++---

> 1 file changed, 3 insertions(+), 3 deletions(-)

> 

> diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c

> index 27b9a76a0dfa..39da4eb48361 100644

> --- a/fs/ext4/mmp.c

> +++ b/fs/ext4/mmp.c

> @@ -147,7 +147,7 @@ static int kmmpd(void *data)

> 

> 	mmp_block = le64_to_cpu(es->s_mmp_block);

> 	mmp = (struct mmp_struct *)(bh->b_data);

> -	mmp->mmp_time = cpu_to_le64(get_seconds());

> +	mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds());

> 	/*

> 	 * Start with the higher mmp_check_interval and reduce it if

> 	 * the MMP block is being updated on time.

> @@ -165,7 +165,7 @@ static int kmmpd(void *data)

> 			seq = 1;

> 

> 		mmp->mmp_seq = cpu_to_le32(seq);

> -		mmp->mmp_time = cpu_to_le64(get_seconds());

> +		mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds());

> 		last_update_time = jiffies;

> 

> 		retval = write_mmp_block(sb, bh);

> @@ -244,7 +244,7 @@ static int kmmpd(void *data)

> 	 * Unmount seems to be clean.

> 	 */

> 	mmp->mmp_seq = cpu_to_le32(EXT4_MMP_SEQ_CLEAN);

> -	mmp->mmp_time = cpu_to_le64(get_seconds());

> +	mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds());

> 

> 	retval = write_mmp_block(sb, bh);

> 

> --

> 2.9.0

> 



Cheers, Andreas
Jan Kara June 22, 2018, 7:38 a.m. UTC | #2
On Wed 20-06-18 17:32:59, Arnd Bergmann wrote:
> The mmp_time field is 64 bits wide, which is good, but calling

> get_seconds() results in a 32-bit value on 32-bit architectures. Using

> ktime_get_real_seconds() instead returns 64 bits everywhere.

> 

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


Looks good.

Reviewed-by: Jan Kara <jack@suse.cz>


								Honza

> ---

>  fs/ext4/mmp.c | 6 +++---

>  1 file changed, 3 insertions(+), 3 deletions(-)

> 

> diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c

> index 27b9a76a0dfa..39da4eb48361 100644

> --- a/fs/ext4/mmp.c

> +++ b/fs/ext4/mmp.c

> @@ -147,7 +147,7 @@ static int kmmpd(void *data)

>  

>  	mmp_block = le64_to_cpu(es->s_mmp_block);

>  	mmp = (struct mmp_struct *)(bh->b_data);

> -	mmp->mmp_time = cpu_to_le64(get_seconds());

> +	mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds());

>  	/*

>  	 * Start with the higher mmp_check_interval and reduce it if

>  	 * the MMP block is being updated on time.

> @@ -165,7 +165,7 @@ static int kmmpd(void *data)

>  			seq = 1;

>  

>  		mmp->mmp_seq = cpu_to_le32(seq);

> -		mmp->mmp_time = cpu_to_le64(get_seconds());

> +		mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds());

>  		last_update_time = jiffies;

>  

>  		retval = write_mmp_block(sb, bh);

> @@ -244,7 +244,7 @@ static int kmmpd(void *data)

>  	 * Unmount seems to be clean.

>  	 */

>  	mmp->mmp_seq = cpu_to_le32(EXT4_MMP_SEQ_CLEAN);

> -	mmp->mmp_time = cpu_to_le64(get_seconds());

> +	mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds());

>  

>  	retval = write_mmp_block(sb, bh);

>  

> -- 

> 2.9.0

> 

> 

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR
diff mbox series

Patch

diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
index 27b9a76a0dfa..39da4eb48361 100644
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -147,7 +147,7 @@  static int kmmpd(void *data)
 
 	mmp_block = le64_to_cpu(es->s_mmp_block);
 	mmp = (struct mmp_struct *)(bh->b_data);
-	mmp->mmp_time = cpu_to_le64(get_seconds());
+	mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds());
 	/*
 	 * Start with the higher mmp_check_interval and reduce it if
 	 * the MMP block is being updated on time.
@@ -165,7 +165,7 @@  static int kmmpd(void *data)
 			seq = 1;
 
 		mmp->mmp_seq = cpu_to_le32(seq);
-		mmp->mmp_time = cpu_to_le64(get_seconds());
+		mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds());
 		last_update_time = jiffies;
 
 		retval = write_mmp_block(sb, bh);
@@ -244,7 +244,7 @@  static int kmmpd(void *data)
 	 * Unmount seems to be clean.
 	 */
 	mmp->mmp_seq = cpu_to_le32(EXT4_MMP_SEQ_CLEAN);
-	mmp->mmp_time = cpu_to_le64(get_seconds());
+	mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds());
 
 	retval = write_mmp_block(sb, bh);