Skip to contentSkip to conversation

exfat: use local UTC offset when EXFAT_TZ_VALID isn't set

PATCH In review Chung-Chiang Cheng 3 participants 7 messages Sep 9, 2021 – Oct 5, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exfat: use local UTC offset when EXFAT_TZ_VALID isn't set

EXFAT_TZ_VALID is corresponding to OffsetValid field in exfat specification [1]. If this bit isn't set, timestamps should be treated as having the same UTC offset as the current local time.

This patch uses the existing mount option 'time_offset' as fat does. If time_offset isn't set, local UTC offset in sys_tz will be used as the default value.

---
 fs/exfat/exfat_fs.h | 1 +
 fs/exfat/misc.c     | 8 +++++++-
 fs/exfat/super.c    | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)
fs/exfat/exfat_fs.h +1 -0
index 1d6da61157c9..b57fdd94ad01 100644
@@ -204,6 +204,7 @@ struct exfat_mount_options {
 	/* on error: continue, panic, remount-ro */
 	enum exfat_error_mode errors;
 	unsigned utf8:1, /* Use of UTF-8 character set */
+		 tz_set:1, /* Filesystem timestamps' offset set */
 		 discard:1; /* Issue discard requests on deletions */
 	int time_offset; /* Offset of timestamps from UTC (in minutes) */
 };
fs/exfat/misc.c +7 -1
index d34e6193258d..349e3fe64ea2 100644
@@ -73,6 +73,12 @@ static void exfat_adjust_tz(struct timespec64 *ts, u8 tz_off)
 		ts->tv_sec += TIMEZONE_SEC(0x80 - tz_off);
 }
 
+static inline int exfat_tz_offset(struct exfat_sb_info *sbi)
+{
+	return (sbi->options.tz_set ? -sbi->options.time_offset :
+			sys_tz.tz_minuteswest) * SECS_PER_MIN;
+}
+
 /* Convert a EXFAT time/date pair to a UNIX date (seconds since 1 1 70). */
 void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
 		u8 tz, __le16 time, __le16 date, u8 time_cs)
@@ -96,7 +102,7 @@ void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
 		exfat_adjust_tz(ts, tz & ~EXFAT_TZ_VALID);
 	else
 		/* Convert from local time to UTC using time_offset. */
-		ts->tv_sec -= sbi->options.time_offset * SECS_PER_MIN;
+		ts->tv_sec += exfat_tz_offset(sbi);
 }
 
 /* Convert linear UNIX date to a EXFAT time/date pair. */
fs/exfat/super.c +2 -1
index 5539ffc20d16..caeea375e4fa 100644
@@ -173,7 +173,7 @@ static int exfat_show_options(struct seq_file *m, struct dentry *root)
 		seq_puts(m, ",errors=remount-ro");
 	if (opts->discard)
 		seq_puts(m, ",discard");
-	if (opts->time_offset)
+	if (opts->tz_set)
 		seq_printf(m, ",time_offset=%d", opts->time_offset);
 	return 0;
 }
@@ -303,6 +303,7 @@ static int exfat_parse_param(struct fs_context *fc, struct fs_parameter *param)
 		 */
 		if (result.int_32 < -24 * 60 || result.int_32 > 24 * 60)
 			return -EINVAL;
+		opts->tz_set = 1;
 		opts->time_offset = result.int_32;
 		break;
 	case Opt_utf8:
Signature · 1 line
2.25.1
maintainer
#1 lore raw

2021-09-09 15:55 GMT+09:00, Chung-Chiang Cheng <[email protected]>:

Quoted 11 lines

EXFAT_TZ_VALID is corresponding to OffsetValid field in exfat specification [1]. If this bit isn't set, timestamps should be treated as having the same UTC offset as the current local time.

This patch uses the existing mount option 'time_offset' as fat does. If time_offset isn't set, local UTC offset in sys_tz will be used as the default value.

Link: [1]
https://docs.microsoft.com/en-us/windows/win32/fileio/exfat-specification#74102-offsetvalid-field

Please read this discussion:
https://patchwork.kernel.org/project/linux-fsdevel/patch/[email protected]/

Thanks!

maintainer
#2 lore raw

Hello, Namjae,

I found an important difference between the code we first wrote and the code that has changed since our initial patch review. This difference seems to cause compatibility issues when reading saved timestamps without timezone. (In our initial patch review, there were concerns about possible compatibility issues.) I think the code that reads timestamps without timezone should go back to the concept we wrote in the first place like reported patch.
It could be an answer of another timestamp issue.

Could you please let me know what you think?

Thanks.

Quoted 29 lines

-----Original Message-----
From: Namjae Jeon [mailto:[email protected]]
Sent: Friday, September 10, 2021 10:01 AM
To: Chung-Chiang Cheng <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH] exfat: use local UTC offset when EXFAT_TZ_VALID isn't set

2021-09-09 15:55 GMT+09:00, Chung-Chiang Cheng <[email protected]>:

Quoted 8 lines

EXFAT_TZ_VALID is corresponding to OffsetValid field in exfat specification [1]. If this bit isn't set, timestamps should be treated as having the same UTC offset as the current local time.

This patch uses the existing mount option 'time_offset' as fat does. If time_offset isn't set, local UTC offset in sys_tz will be used as the default value.

Quoted 6 lines

Link: [1]
https://protect2.fireeye.com/v1/url?k=cba4edf5-943fd4c8-cba566ba-0cc47
a31309a-e70aa065be678729&q=1&e=225feff2-841f-404c-9a2e-c12064b232d0&u= https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Ffileio%2F exfat-specification%2374102-offsetvalid-field

Please read this discussion:
https://patchwork.kernel.org/project/linux-
fsdevel/patch/[email protected]/

Thanks!

maintainer
#3 lore raw

2021-10-01 22:19 GMT+09:00, Sungjong Seo <[email protected]>:

Quoted 1 line

Hello, Namjae,

Hi Sungjong,

Quoted 8 lines

I found an important difference between the code we first wrote and the code that has changed since our initial patch review. This difference seems to cause compatibility issues when reading saved timestamps without timezone. (In our initial patch review, there were concerns about possible compatibility issues.)
I think the code that reads timestamps without timezone should go back to the concept we wrote in the first place like reported patch.

Are you talking about using sys_tz?

Quoted 1 line

It could be an answer of another timestamp issue.

What is another timestamp issue ?

Quoted 36 lines

Could you please let me know what you think?

Thanks.

Quoted 30 lines

-----Original Message-----
From: Namjae Jeon [mailto:[email protected]]
Sent: Friday, September 10, 2021 10:01 AM
To: Chung-Chiang Cheng <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH] exfat: use local UTC offset when EXFAT_TZ_VALID isn't
set

2021-09-09 15:55 GMT+09:00, Chung-Chiang Cheng <[email protected]>:

Quoted 8 lines

EXFAT_TZ_VALID is corresponding to OffsetValid field in exfat specification [1]. If this bit isn't set, timestamps should be treated as having the same UTC offset as the current local time.

This patch uses the existing mount option 'time_offset' as fat does. If time_offset isn't set, local UTC offset in sys_tz will be used as the default value.

Quoted 6 lines

Link: [1]
https://protect2.fireeye.com/v1/url?k=cba4edf5-943fd4c8-cba566ba-0cc47
a31309a-e70aa065be678729&q=1&e=225feff2-841f-404c-9a2e-c12064b232d0&u= https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Ffileio%2F exfat-specification%2374102-offsetvalid-field

Please read this discussion:
https://patchwork.kernel.org/project/linux-
fsdevel/patch/[email protected]/

Thanks!

maintainer
#4 lore raw
Quoted 7 lines

2021-10-01 22:19 GMT+09:00, Sungjong Seo <[email protected]>:

Quoted 1 line

Hello, Namjae,

Hi Sungjong,

Quoted 4 lines

I found an important difference between the code we first wrote and the code that has changed since our initial patch review. This difference seems to cause compatibility issues when reading saved

Quoted 6 lines

timestamps without timezone.

Quoted 4 lines

(In our initial patch review, there were concerns about possible compatibility issues.) I think the code that reads timestamps without timezone should go back to the concept we wrote in the first place like reported patch.

Are you talking about using sys_tz?

Yes, exactly, a part like below.

+static inline int exfat_tz_offset(struct exfat_sb_info *sbi) {
+ return (sbi->options.tz_set ? -sbi->options.time_offset :
+ sys_tz.tz_minuteswest) * SECS_PER_MIN; }
+

Quoted 3 lines
Quoted 2 lines

It could be an answer of another timestamp issue.

What is another timestamp issue ?

What I'm saying is "timestamp incompatibilities in exfat-fs" from Reiner <[email protected]> I think it might be the same issue with this.

Quoted 38 lines
Quoted 38 lines

Could you please let me know what you think?

Thanks.

Quoted 31 lines

-----Original Message-----
From: Namjae Jeon [mailto:[email protected]]
Sent: Friday, September 10, 2021 10:01 AM
To: Chung-Chiang Cheng <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH] exfat: use local UTC offset when EXFAT_TZ_VALID isn't set

2021-09-09 15:55 GMT+09:00, Chung-Chiang Cheng <[email protected]>:

Quoted 8 lines

EXFAT_TZ_VALID is corresponding to OffsetValid field in exfat specification [1]. If this bit isn't set, timestamps should be treated as having the same UTC offset as the current local time.

This patch uses the existing mount option 'time_offset' as fat does. If time_offset isn't set, local UTC offset in sys_tz will be used as the default value.

Quoted 8 lines

Link: [1]
https://protect2.fireeye.com/v1/url?k=cba4edf5-943fd4c8-cba566ba-0c
c47 a31309a-e70aa065be678729&q=1&e=225feff2-841f-404c-9a2e-c12064b232d0 &u= https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Ffileio %2F exfat-specification%2374102-offsetvalid-field

Please read this discussion:
https://patchwork.kernel.org/project/linux-
fsdevel/patch/[email protected]/

Thanks!

maintainer
#5 lore raw

2021-10-05 13:05 GMT+09:00, Sungjong Seo <[email protected]>:

Quoted 7 lines
Quoted 7 lines

2021-10-01 22:19 GMT+09:00, Sungjong Seo <[email protected]>:

Quoted 1 line

Hello, Namjae,

Hi Sungjong,

Quoted 4 lines

I found an important difference between the code we first wrote and the code that has changed since our initial patch review. This difference seems to cause compatibility issues when reading saved

Quoted 7 lines
Quoted 6 lines

timestamps without timezone.

Quoted 4 lines

(In our initial patch review, there were concerns about possible compatibility issues.) I think the code that reads timestamps without timezone should go back to the concept we wrote in the first place like reported patch.

Are you talking about using sys_tz?

Yes, exactly, a part like below.

Have you read discussion about this before ?
Let me know what I am missing something.

Quoted 7 lines
fs/exfat/misc.c +4 -0
+static inline int exfat_tz_offset(struct exfat_sb_info *sbi) {
+	return (sbi->options.tz_set ? -sbi->options.time_offset :
+			sys_tz.tz_minuteswest) * SECS_PER_MIN; }
+
Quoted 2 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

It could be an answer of another timestamp issue.

What is another timestamp issue ?

What I'm saying is "timestamp incompatibilities in exfat-fs" from Reiner <[email protected]>
I think it might be the same issue with this.

Have you checked fuse-exfat patch he shared ? It was exfat timezone support. I am not sure how it is related to sys_tz...

Thanks!

Quoted 41 lines
Quoted 39 lines
Quoted 39 lines

Could you please let me know what you think?

Thanks.

Quoted 31 lines

-----Original Message-----
From: Namjae Jeon [mailto:[email protected]]
Sent: Friday, September 10, 2021 10:01 AM
To: Chung-Chiang Cheng <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH] exfat: use local UTC offset when EXFAT_TZ_VALID isn't set

2021-09-09 15:55 GMT+09:00, Chung-Chiang Cheng <[email protected]>:

Quoted 8 lines

EXFAT_TZ_VALID is corresponding to OffsetValid field in exfat specification [1]. If this bit isn't set, timestamps should be treated as having the same UTC offset as the current local time.

This patch uses the existing mount option 'time_offset' as fat does. If time_offset isn't set, local UTC offset in sys_tz will be used as the default value.

Quoted 8 lines

Link: [1]
https://protect2.fireeye.com/v1/url?k=cba4edf5-943fd4c8-cba566ba-0c
c47 a31309a-e70aa065be678729&q=1&e=225feff2-841f-404c-9a2e-c12064b232d0 &u= https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Ffileio %2F exfat-specification%2374102-offsetvalid-field

Please read this discussion:
https://patchwork.kernel.org/project/linux-
fsdevel/patch/[email protected]/

Thanks!

maintainer
#6 lore raw
Quoted 8 lines

2021-10-05 13:05 GMT+09:00, Sungjong Seo <[email protected]>:

Quoted 7 lines
Quoted 7 lines

2021-10-01 22:19 GMT+09:00, Sungjong Seo <[email protected]>:

Quoted 1 line

Hello, Namjae,

Hi Sungjong,

Quoted 4 lines

I found an important difference between the code we first wrote and the code that has changed since our initial patch review. This difference seems to cause compatibility issues when reading saved

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines

timestamps without timezone.

Quoted 4 lines

(In our initial patch review, there were concerns about possible compatibility issues.) I think the code that reads timestamps without timezone should go back to the concept we wrote in the first place like reported patch.

Are you talking about using sys_tz?

Yes, exactly, a part like below.

Have you read discussion about this before ?

Of course. That's why I wrote the expression "go back".
As you know, there was the discussion of local time conversion method for reading timestamps that have no OffsetValid bit.
that is, whether to use sys_tz or not was the main topic.

And I understand that the current exFAT implementation doesn't use sys_tz and depends entirely on time_offset.(UTC if time_offset is not set)

Quoted 1 line

Let me know what I am missing something.

No, there is nothing you are missing.
I thought compatibility issues regarding sys_tz could be serious because I misunderstood that other compatibility issues were reported. :(

I am just concerned that most system daemons mount exfat-fs without time_offset option, which could be reported as a compatibility issue.

However, to discuss this more, it would be nice to see the trend of how many issues regarding sys_tz will be reported.

Quoted 9 lines
Quoted 9 lines
fs/exfat/misc.c +4 -0
+static inline int exfat_tz_offset(struct exfat_sb_info *sbi) {
+	return (sbi->options.tz_set ? -sbi->options.time_offset :
+			sys_tz.tz_minuteswest) * SECS_PER_MIN; }
+
Quoted 3 lines
Quoted 3 lines

It could be an answer of another timestamp issue.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

What is another timestamp issue ?

What I'm saying is "timestamp incompatibilities in exfat-fs" from Reiner <[email protected]> I think it might be the same issue with this.

Have you checked fuse-exfat patch he shared ? It was exfat timezone support.
I am not sure how it is related to sys_tz...

As I mentioned above, I misunderstood. :)
I mistakenly thought that the code that handles timestamp without OffsetValid bit was added as well.

Thanks!

Quoted 50 lines

Thanks!

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

Could you please let me know what you think?

Thanks.

Quoted 9 lines

-----Original Message-----
From: Namjae Jeon [mailto:[email protected]]
Sent: Friday, September 10, 2021 10:01 AM
To: Chung-Chiang Cheng <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH] exfat: use local UTC offset when EXFAT_TZ_VALID isn't set

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

2021-09-09 15:55 GMT+09:00, Chung-Chiang Cheng

<[email protected]>:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

EXFAT_TZ_VALID is corresponding to OffsetValid field in exfat specification [1]. If this bit isn't set, timestamps should be treated as having the same UTC offset as the current local time.

This patch uses the existing mount option 'time_offset' as fat

does.

Quoted 25 lines
Quoted 23 lines
Quoted 23 lines
Quoted 21 lines
Quoted 12 lines

If time_offset isn't set, local UTC offset in sys_tz will be used as the default value.

Link: [1]
https://protect2.fireeye.com/v1/url?k=cba4edf5-943fd4c8-cba566ba
-0c
c47 a31309a-e70aa065be678729&q=1&e=225feff2-841f-404c-9a2e-c12064b23 2d0
&u= https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Ffil eio %2F exfat-specification%2374102-offsetvalid-field

Quoted 1 line

Please read this discussion:

https://protect2.fireeye.com/v1/url?k=9bbcab7c-c4279381-9bbd2033-0
00babff317b-88ee581b44536876&q=1&e=b0d8a44b-4821-44a8-860a-4d3116c b634d&u=https%3A%2F%2Fpatchwork.kernel.org%2Fproject%2Flinux- fsdevel/patch/[email protected]/

Thanks!