mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
vfs/y2038: inode timestamps conversion to timespec64
This is a late set of changes from Deepa Dinamani doing an automated
treewide conversion of the inode and iattr structures from 'timespec'
to 'timespec64', to push the conversion from the VFS layer into the
individual file systems.
There were no conflicts between this and the contents of linux-next
until just before the merge window, when we saw multiple problems:
- A minor conflict with my own y2038 fixes, which I could address
by adding another patch on top here.
- One semantic conflict with late changes to the NFS tree. I addressed
this by merging Deepa's original branch on top of the changes that
now got merged into mainline and making sure the merge commit includes
the necessary changes as produced by coccinelle.
- A trivial conflict against the removal of staging/lustre.
- Multiple conflicts against the VFS changes in the overlayfs tree.
These are still part of linux-next, but apparently this is no longer
intended for 4.18 [1], so I am ignoring that part.
As Deepa writes:
The series aims to switch vfs timestamps to use struct timespec64.
Currently vfs uses struct timespec, which is not y2038 safe.
The series involves the following:
1. Add vfs helper functions for supporting struct timepec64 timestamps.
2. Cast prints of vfs timestamps to avoid warnings after the switch.
3. Simplify code using vfs timestamps so that the actual
replacement becomes easy.
4. Convert vfs timestamps to use struct timespec64 using a script.
This is a flag day patch.
Next steps:
1. Convert APIs that can handle timespec64, instead of converting
timestamps at the boundaries.
2. Update internal data structures to avoid timestamp conversions.
Thomas Gleixner adds:
I think there is no point to drag that out for the next merge window.
The whole thing needs to be done in one go for the core changes which
means that you're going to play that catchup game forever. Let's get
over with it towards the end of the merge window.
[1] https://www.spinics.net/lists/linux-fsdevel/msg128294.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABAgAGBQJbInZAAAoJEGCrR//JCVInReoQAIlVIIMt5ZX6wmaKbrjy9Itf
MfgbFihQ/djLnuSPVQ3nztcxF0d66BKHZ9puVjz6+mIHqfDvJTRwZs9nU+sOF/T1
g78fRkM1cxq6ZCkGYAbzyjyo5aC4PnSMP/NQLmwqvi0MXqqrbDoq5ZdP9DHJw39h
L9lD8FM/P7T29Fgp9tq/pT5l9X8VU8+s5KQG1uhB5hii4VL6pD6JyLElDita7rg+
Z7/V7jkxIGEUWF7vGaiR1QTFzEtpUA/exDf9cnsf51OGtK/LJfQ0oiZPPuq3oA/E
LSbt8YQQObc+dvfnGxwgxEg1k5WP5ekj/Wdibv/+rQKgGyLOTz6Q4xK6r8F2ahxs
nyZQBdXqHhJYyKr1H1reUH3mrSgQbE5U5R1i3My0xV2dSn+vtK5vgF21v2Ku3A1G
wJratdtF/kVBzSEQUhsYTw14Un+xhBLRWzcq0cELonqxaKvRQK9r92KHLIWNE7/v
c0TmhFbkZA+zR8HdsaL3iYf1+0W/eYy8PcvepyldKNeW2pVk3CyvdTfY2Z87G2XK
tIkK+BUWbG3drEGG3hxZ3757Ln3a9qWyC5ruD3mBVkuug/wekbI8PykYJS7Mx4s/
WNXl0dAL0Eeu1M8uEJejRAe1Q3eXoMWZbvCYZc+wAm92pATfHVcKwPOh8P7NHlfy
A3HkjIBrKW5AgQDxfgvm
=CZX2
-----END PGP SIGNATURE-----
Merge tag 'vfs-timespec64' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground
Pull inode timestamps conversion to timespec64 from Arnd Bergmann:
"This is a late set of changes from Deepa Dinamani doing an automated
treewide conversion of the inode and iattr structures from 'timespec'
to 'timespec64', to push the conversion from the VFS layer into the
individual file systems.
As Deepa writes:
'The series aims to switch vfs timestamps to use struct timespec64.
Currently vfs uses struct timespec, which is not y2038 safe.
The series involves the following:
1. Add vfs helper functions for supporting struct timepec64
timestamps.
2. Cast prints of vfs timestamps to avoid warnings after the switch.
3. Simplify code using vfs timestamps so that the actual replacement
becomes easy.
4. Convert vfs timestamps to use struct timespec64 using a script.
This is a flag day patch.
Next steps:
1. Convert APIs that can handle timespec64, instead of converting
timestamps at the boundaries.
2. Update internal data structures to avoid timestamp conversions'
Thomas Gleixner adds:
'I think there is no point to drag that out for the next merge
window. The whole thing needs to be done in one go for the core
changes which means that you're going to play that catchup game
forever. Let's get over with it towards the end of the merge window'"
* tag 'vfs-timespec64' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground:
pstore: Remove bogus format string definition
vfs: change inode times to use struct timespec64
pstore: Convert internal records to timespec64
udf: Simplify calls to udf_disk_stamp_to_time
fs: nfs: get rid of memcpys for inode times
ceph: make inode time prints to be long long
lustre: Use long long type to print inode time
fs: add timespec64_truncate()
This commit is contained in:
commit
7a932516f5
85 changed files with 539 additions and 424 deletions
|
|
@ -124,8 +124,8 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
|
|||
iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
|
||||
else
|
||||
iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime =
|
||||
iinfo->i_crtime = current_time(inode);
|
||||
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
|
||||
iinfo->i_crtime = timespec64_to_timespec(inode->i_mtime);
|
||||
if (unlikely(insert_inode_locked(inode) < 0)) {
|
||||
make_bad_inode(inode);
|
||||
iput(inode);
|
||||
|
|
|
|||
|
|
@ -1271,6 +1271,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
|
|||
struct udf_inode_info *iinfo = UDF_I(inode);
|
||||
struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
|
||||
struct kernel_lb_addr *iloc = &iinfo->i_location;
|
||||
struct timespec ts;
|
||||
unsigned int link_count;
|
||||
unsigned int indirections = 0;
|
||||
int bs = inode->i_sb->s_blocksize;
|
||||
|
|
@ -1443,15 +1444,12 @@ reread:
|
|||
inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
|
||||
(inode->i_sb->s_blocksize_bits - 9);
|
||||
|
||||
if (!udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime))
|
||||
inode->i_atime = sbi->s_record_time;
|
||||
|
||||
if (!udf_disk_stamp_to_time(&inode->i_mtime,
|
||||
fe->modificationTime))
|
||||
inode->i_mtime = sbi->s_record_time;
|
||||
|
||||
if (!udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime))
|
||||
inode->i_ctime = sbi->s_record_time;
|
||||
udf_disk_stamp_to_time(&ts, fe->accessTime);
|
||||
inode->i_atime = timespec_to_timespec64(ts);
|
||||
udf_disk_stamp_to_time(&ts, fe->modificationTime);
|
||||
inode->i_mtime = timespec_to_timespec64(ts);
|
||||
udf_disk_stamp_to_time(&ts, fe->attrTime);
|
||||
inode->i_ctime = timespec_to_timespec64(ts);
|
||||
|
||||
iinfo->i_unique = le64_to_cpu(fe->uniqueID);
|
||||
iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
|
||||
|
|
@ -1461,18 +1459,13 @@ reread:
|
|||
inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
|
||||
(inode->i_sb->s_blocksize_bits - 9);
|
||||
|
||||
if (!udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime))
|
||||
inode->i_atime = sbi->s_record_time;
|
||||
|
||||
if (!udf_disk_stamp_to_time(&inode->i_mtime,
|
||||
efe->modificationTime))
|
||||
inode->i_mtime = sbi->s_record_time;
|
||||
|
||||
if (!udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime))
|
||||
iinfo->i_crtime = sbi->s_record_time;
|
||||
|
||||
if (!udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime))
|
||||
inode->i_ctime = sbi->s_record_time;
|
||||
udf_disk_stamp_to_time(&ts, efe->accessTime);
|
||||
inode->i_atime = timespec_to_timespec64(ts);
|
||||
udf_disk_stamp_to_time(&ts, efe->modificationTime);
|
||||
inode->i_mtime = timespec_to_timespec64(ts);
|
||||
udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime);
|
||||
udf_disk_stamp_to_time(&ts, efe->attrTime);
|
||||
inode->i_ctime = timespec_to_timespec64(ts);
|
||||
|
||||
iinfo->i_unique = le64_to_cpu(efe->uniqueID);
|
||||
iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
|
||||
|
|
@ -1722,9 +1715,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
|
|||
inode->i_sb->s_blocksize - sizeof(struct fileEntry));
|
||||
fe->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
|
||||
|
||||
udf_time_to_disk_stamp(&fe->accessTime, inode->i_atime);
|
||||
udf_time_to_disk_stamp(&fe->modificationTime, inode->i_mtime);
|
||||
udf_time_to_disk_stamp(&fe->attrTime, inode->i_ctime);
|
||||
udf_time_to_disk_stamp(&fe->accessTime,
|
||||
timespec64_to_timespec(inode->i_atime));
|
||||
udf_time_to_disk_stamp(&fe->modificationTime,
|
||||
timespec64_to_timespec(inode->i_mtime));
|
||||
udf_time_to_disk_stamp(&fe->attrTime,
|
||||
timespec64_to_timespec(inode->i_ctime));
|
||||
memset(&(fe->impIdent), 0, sizeof(struct regid));
|
||||
strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER);
|
||||
fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
|
||||
|
|
@ -1743,14 +1739,17 @@ static int udf_update_inode(struct inode *inode, int do_sync)
|
|||
efe->objectSize = cpu_to_le64(inode->i_size);
|
||||
efe->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
|
||||
|
||||
udf_adjust_time(iinfo, inode->i_atime);
|
||||
udf_adjust_time(iinfo, inode->i_mtime);
|
||||
udf_adjust_time(iinfo, inode->i_ctime);
|
||||
udf_adjust_time(iinfo, timespec64_to_timespec(inode->i_atime));
|
||||
udf_adjust_time(iinfo, timespec64_to_timespec(inode->i_mtime));
|
||||
udf_adjust_time(iinfo, timespec64_to_timespec(inode->i_ctime));
|
||||
|
||||
udf_time_to_disk_stamp(&efe->accessTime, inode->i_atime);
|
||||
udf_time_to_disk_stamp(&efe->modificationTime, inode->i_mtime);
|
||||
udf_time_to_disk_stamp(&efe->accessTime,
|
||||
timespec64_to_timespec(inode->i_atime));
|
||||
udf_time_to_disk_stamp(&efe->modificationTime,
|
||||
timespec64_to_timespec(inode->i_mtime));
|
||||
udf_time_to_disk_stamp(&efe->createTime, iinfo->i_crtime);
|
||||
udf_time_to_disk_stamp(&efe->attrTime, inode->i_ctime);
|
||||
udf_time_to_disk_stamp(&efe->attrTime,
|
||||
timespec64_to_timespec(inode->i_ctime));
|
||||
|
||||
memset(&(efe->impIdent), 0, sizeof(efe->impIdent));
|
||||
strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER);
|
||||
|
|
|
|||
|
|
@ -862,6 +862,9 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
|
|||
struct buffer_head *bh;
|
||||
uint16_t ident;
|
||||
int ret = -ENOMEM;
|
||||
#ifdef UDFFS_DEBUG
|
||||
struct timestamp *ts;
|
||||
#endif
|
||||
|
||||
outstr = kmalloc(128, GFP_NOFS);
|
||||
if (!outstr)
|
||||
|
|
@ -880,15 +883,15 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
|
|||
|
||||
pvoldesc = (struct primaryVolDesc *)bh->b_data;
|
||||
|
||||
if (udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
|
||||
pvoldesc->recordingDateAndTime)) {
|
||||
udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
|
||||
pvoldesc->recordingDateAndTime);
|
||||
#ifdef UDFFS_DEBUG
|
||||
struct timestamp *ts = &pvoldesc->recordingDateAndTime;
|
||||
udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
|
||||
le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
|
||||
ts->minute, le16_to_cpu(ts->typeAndTimezone));
|
||||
ts = &pvoldesc->recordingDateAndTime;
|
||||
udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
|
||||
le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
|
||||
ts->minute, le16_to_cpu(ts->typeAndTimezone));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
ret = udf_dstrCS0toChar(sb, outstr, 31, pvoldesc->volIdent, 32);
|
||||
if (ret < 0)
|
||||
|
|
|
|||
|
|
@ -253,8 +253,8 @@ extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
|
|||
extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
|
||||
|
||||
/* udftime.c */
|
||||
extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
|
||||
extern void udf_disk_stamp_to_time(struct timespec *dest,
|
||||
struct timestamp src);
|
||||
extern struct timestamp *udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
|
||||
extern void udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
|
||||
|
||||
#endif /* __UDF_DECL_H */
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
#include <linux/kernel.h>
|
||||
#include <linux/time.h>
|
||||
|
||||
struct timespec *
|
||||
void
|
||||
udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
|
||||
{
|
||||
u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone);
|
||||
|
|
@ -67,10 +67,9 @@ udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
|
|||
* recorded with bogus sub-second values.
|
||||
*/
|
||||
dest->tv_nsec %= NSEC_PER_SEC;
|
||||
return dest;
|
||||
}
|
||||
|
||||
struct timestamp *
|
||||
void
|
||||
udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
|
||||
{
|
||||
long seconds;
|
||||
|
|
@ -79,9 +78,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
|
|||
|
||||
offset = -sys_tz.tz_minuteswest;
|
||||
|
||||
if (!dest)
|
||||
return NULL;
|
||||
|
||||
dest->typeAndTimezone = cpu_to_le16(0x1000 | (offset & 0x0FFF));
|
||||
|
||||
seconds = ts.tv_sec + offset * 60;
|
||||
|
|
@ -97,7 +93,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
|
|||
dest->centiseconds * 10000) / 100;
|
||||
dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
|
||||
dest->hundredsOfMicroseconds * 100);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
|||
Loading…
Reference in a new issue