linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Cleanup "fat: propagate 64-bit inode timestamps" patch
@ 2018-08-18  0:34 OGAWA Hirofumi
  2018-08-20 12:39 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: OGAWA Hirofumi @ 2018-08-18  0:34 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Arnd Bergmann, Jeff Layton, linux-kernel

Hi,

Looks like I missed the email to read for a patch
(mmots/broken-out/fat-propagate-64-bit-inode-timestamps.patch).  Well,
so FWIW,

Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

And additionally cleanup patch here (this would be better to be folded
into his patch).

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

[PATCH] Cleanup "fat: propagate 64-bit inode timestamps" patch

- Remove useless temporary variable
- Remove needless long long

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 fs/fat/inode.c |   10 +++-------
 fs/fat/misc.c  |    7 +++----
 2 files changed, 6 insertions(+), 11 deletions(-)

diff -puN fs/fat/inode.c~fat-propagate-64-bit-inode-timestamps-cleanup fs/fat/inode.c
--- linux/fs/fat/inode.c~fat-propagate-64-bit-inode-timestamps-cleanup	2018-08-18 09:23:27.990137305 +0900
+++ linux-hirofumi/fs/fat/inode.c	2018-08-18 09:32:52.629008507 +0900
@@ -509,7 +509,6 @@ static int fat_validate_dir(struct inode
 int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
 {
 	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
-	struct timespec64 ts;
 	int error;
 
 	MSDOS_I(inode)->i_pos = 0;
@@ -559,14 +558,11 @@ int fat_fill_inode(struct inode *inode,
 	inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1))
 			   & ~((loff_t)sbi->cluster_size - 1)) >> 9;
 
-	fat_time_fat2unix(sbi, &ts, de->time, de->date, 0);
-	inode->i_mtime = ts;
+	fat_time_fat2unix(sbi, &inode->i_mtime, de->time, de->date, 0);
 	if (sbi->options.isvfat) {
-		fat_time_fat2unix(sbi, &ts, de->ctime,
+		fat_time_fat2unix(sbi, &inode->i_ctime, de->ctime,
 				  de->cdate, de->ctime_cs);
-		inode->i_ctime = ts;
-		fat_time_fat2unix(sbi, &ts, 0, de->adate, 0);
-		inode->i_atime = ts;
+		fat_time_fat2unix(sbi, &inode->i_atime, 0, de->adate, 0);
 	} else
 		inode->i_ctime = inode->i_atime = inode->i_mtime;
 
diff -puN fs/fat/misc.c~fat-propagate-64-bit-inode-timestamps-cleanup fs/fat/misc.c
--- linux/fs/fat/misc.c~fat-propagate-64-bit-inode-timestamps-cleanup	2018-08-18 09:23:27.992137301 +0900
+++ linux-hirofumi/fs/fat/misc.c	2018-08-18 09:32:52.596008572 +0900
@@ -180,7 +180,7 @@ int fat_chain_add(struct inode *inode, i
 #define IS_LEAP_YEAR(y)	(!((y) & 3) && (y) != YEAR_2100)
 
 /* Linear day numbers of the respective 1sts in non-leap years. */
-static time64_t days_in_year[] = {
+static long days_in_year[] = {
 	/* Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec */
 	0,   0,  31,  59,  90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0,
 };
@@ -191,8 +191,7 @@ void fat_time_fat2unix(struct msdos_sb_i
 {
 	u16 time = le16_to_cpu(__time), date = le16_to_cpu(__date);
 	time64_t second;
-	long day, leap_day, month;
-	long long year;
+	long day, leap_day, month, year;
 
 	year  = date >> 9;
 	month = max(1, (date >> 5) & 0xf);
@@ -207,7 +206,7 @@ void fat_time_fat2unix(struct msdos_sb_i
 	second =  (time & 0x1f) << 1;
 	second += ((time >> 5) & 0x3f) * SECS_PER_MIN;
 	second += (time >> 11) * SECS_PER_HOUR;
-	second += (year * 365 + leap_day
+	second += (time64_t)(year * 365 + leap_day
 		   + days_in_year[month] + day
 		   + DAYS_DELTA) * SECS_PER_DAY;
 
_

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Cleanup "fat: propagate 64-bit inode timestamps" patch
  2018-08-18  0:34 [PATCH] Cleanup "fat: propagate 64-bit inode timestamps" patch OGAWA Hirofumi
@ 2018-08-20 12:39 ` Arnd Bergmann
  2018-08-20 22:23   ` OGAWA Hirofumi
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2018-08-20 12:39 UTC (permalink / raw)
  To: OGAWA Hirofumi; +Cc: Andrew Morton, Jeff Layton, Linux Kernel Mailing List

On Sat, Aug 18, 2018 at 2:34 AM OGAWA Hirofumi
<hirofumi@mail.parknet.co.jp> wrote:
>
> Hi,
>
> Looks like I missed the email to read for a patch
> (mmots/broken-out/fat-propagate-64-bit-inode-timestamps.patch).  Well,
> so FWIW,
>
> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
>
> And additionally cleanup patch here (this would be better to be folded
> into his patch).
>
> Thanks.
> --
> OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
>
> [PATCH] Cleanup "fat: propagate 64-bit inode timestamps" patch
>
> - Remove useless temporary variable
> - Remove needless long long
>
> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

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

>  /* Linear day numbers of the respective 1sts in non-leap years. */
> -static time64_t days_in_year[] = {
> +static long days_in_year[] = {
>         /* Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec */
>         0,   0,  31,  59,  90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0,
>  };

While this is correct, changing it back to a signed 'long' type seems
rather arbitrary. I tried to pick a type that would be the same on 32-bit
and 64-bit architectures, the other choice would have been 'u16',
which saves a few bytes.

A completely different approach would be to just use mktime()
and avoid reimplementing it.

     Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Cleanup "fat: propagate 64-bit inode timestamps" patch
  2018-08-20 12:39 ` Arnd Bergmann
@ 2018-08-20 22:23   ` OGAWA Hirofumi
  0 siblings, 0 replies; 3+ messages in thread
From: OGAWA Hirofumi @ 2018-08-20 22:23 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Andrew Morton, Jeff Layton, Linux Kernel Mailing List

Arnd Bergmann <arnd@arndb.de> writes:

>>  /* Linear day numbers of the respective 1sts in non-leap years. */
>> -static time64_t days_in_year[] = {
>> +static long days_in_year[] = {
>>         /* Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec */
>>         0,   0,  31,  59,  90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0,
>>  };
>
> While this is correct, changing it back to a signed 'long' type seems
> rather arbitrary. I tried to pick a type that would be the same on 32-bit
> and 64-bit architectures, the other choice would have been 'u16',
> which saves a few bytes.

Right. However, "long long" on 32bit arch is not same. In this implement
"long long" works though, Some calculation needs libgcc helper (in
kernel, div64 stuff).  I want to avoid it early than later, and I don't
care saving a few memory in here (I would not care if it was u16).

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-20 22:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-18  0:34 [PATCH] Cleanup "fat: propagate 64-bit inode timestamps" patch OGAWA Hirofumi
2018-08-20 12:39 ` Arnd Bergmann
2018-08-20 22:23   ` OGAWA Hirofumi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).