Skip to content

Commit 15eefe2

Browse files
committed
Merge branch 'vfs_timespec64' of https://github.com/deepa-hub/vfs into vfs-timespec64
Pull the timespec64 conversion from Deepa Dinamani: "The series aims to switch vfs timestamps to use struct timespec64. Currently vfs uses struct timespec, which is not y2038 safe. The flag patch applies cleanly. I've not seen the timestamps update logic change often. The series applies cleanly on 4.17-rc6 and linux-next tip (top commit: next-20180517). I'm not sure how to merge this kind of a series with a flag patch. We are targeting 4.18 for this. Let me know if you have other suggestions. 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. I've tried to keep the conversions with the script simple, to aid in the reviews. I've kept all the internal filesystem data structures and function signatures the same. 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." I've pulled it into a branch based on top of the NFS changes that are now in mainline, so I could resolve the non-obvious conflict between the two while merging. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents 93b7f7a + 95582b0 commit 15eefe2

90 files changed

Lines changed: 563 additions & 439 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/firmware/efi/efi-pstore.c‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ static int efi_pstore_close(struct pstore_info *psi)
2828
return 0;
2929
}
3030

31-
static inline u64 generic_id(unsigned long timestamp,
32-
unsigned int part, int count)
31+
static inline u64 generic_id(u64 timestamp, unsigned int part, int count)
3332
{
34-
return ((u64) timestamp * 100 + part) * 1000 + count;
33+
return (timestamp * 100 + part) * 1000 + count;
3534
}
3635

3736
static int efi_pstore_read_func(struct efivar_entry *entry,
@@ -42,15 +41,16 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
4241
int i;
4342
int cnt;
4443
unsigned int part;
45-
unsigned long time, size;
44+
unsigned long size;
45+
u64 time;
4646

4747
if (efi_guidcmp(entry->var.VendorGuid, vendor))
4848
return 0;
4949

5050
for (i = 0; i < DUMP_NAME_LEN; i++)
5151
name[i] = entry->var.VariableName[i];
5252

53-
if (sscanf(name, "dump-type%u-%u-%d-%lu-%c",
53+
if (sscanf(name, "dump-type%u-%u-%d-%llu-%c",
5454
&record->type, &part, &cnt, &time, &data_type) == 5) {
5555
record->id = generic_id(time, part, cnt);
5656
record->part = part;
@@ -62,7 +62,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
6262
else
6363
record->compressed = false;
6464
record->ecc_notice_size = 0;
65-
} else if (sscanf(name, "dump-type%u-%u-%d-%lu",
65+
} else if (sscanf(name, "dump-type%u-%u-%d-%llu",
6666
&record->type, &part, &cnt, &time) == 4) {
6767
record->id = generic_id(time, part, cnt);
6868
record->part = part;
@@ -71,7 +71,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
7171
record->time.tv_nsec = 0;
7272
record->compressed = false;
7373
record->ecc_notice_size = 0;
74-
} else if (sscanf(name, "dump-type%u-%u-%lu",
74+
} else if (sscanf(name, "dump-type%u-%u-%llu",
7575
&record->type, &part, &time) == 3) {
7676
/*
7777
* Check if an old format,
@@ -250,9 +250,10 @@ static int efi_pstore_write(struct pstore_record *record)
250250
/* Since we copy the entire length of name, make sure it is wiped. */
251251
memset(name, 0, sizeof(name));
252252

253-
snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu-%c",
253+
snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lld-%c",
254254
record->type, record->part, record->count,
255-
record->time.tv_sec, record->compressed ? 'C' : 'D');
255+
(long long)record->time.tv_sec,
256+
record->compressed ? 'C' : 'D');
256257

257258
for (i = 0; i < DUMP_NAME_LEN; i++)
258259
efi_name[i] = name[i];
@@ -327,15 +328,15 @@ static int efi_pstore_erase(struct pstore_record *record)
327328
char name[DUMP_NAME_LEN];
328329
int ret;
329330

330-
snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu",
331+
snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lld",
331332
record->type, record->part, record->count,
332-
record->time.tv_sec);
333+
(long long)record->time.tv_sec);
333334
ret = efi_pstore_erase_name(name);
334335
if (ret != -ENOENT)
335336
return ret;
336337

337-
snprintf(name, sizeof(name), "dump-type%u-%u-%lu",
338-
record->type, record->part, record->time.tv_sec);
338+
snprintf(name, sizeof(name), "dump-type%u-%u-%lld",
339+
record->type, record->part, (long long)record->time.tv_sec);
339340
ret = efi_pstore_erase_name(name);
340341

341342
return ret;

‎drivers/staging/lustre/lustre/llite/llite_lib.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,8 +1482,9 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
14821482
}
14831483

14841484
if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
1485-
CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %llu\n",
1486-
LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
1485+
CDEBUG(D_INODE, "setting mtime %llu, ctime %llu, now = %llu\n",
1486+
(unsigned long long)LTIME_S(attr->ia_mtime),
1487+
(unsigned long long)LTIME_S(attr->ia_ctime),
14871488
(s64)ktime_get_real_seconds());
14881489

14891490
if (S_ISREG(inode->i_mode))
@@ -1760,9 +1761,10 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md)
17601761
if (body->mbo_valid & OBD_MD_FLMTIME) {
17611762
if (body->mbo_mtime > LTIME_S(inode->i_mtime)) {
17621763
CDEBUG(D_INODE,
1763-
"setting ino %lu mtime from %lu to %llu\n",
1764-
inode->i_ino, LTIME_S(inode->i_mtime),
1765-
body->mbo_mtime);
1764+
"setting ino %lu mtime from %llu to %llu\n",
1765+
inode->i_ino,
1766+
(unsigned long long)LTIME_S(inode->i_mtime),
1767+
(unsigned long long)body->mbo_mtime);
17661768
LTIME_S(inode->i_mtime) = body->mbo_mtime;
17671769
}
17681770
lli->lli_mtime = body->mbo_mtime;

‎drivers/staging/lustre/lustre/llite/namei.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,9 @@ void ll_update_times(struct ptlrpc_request *request, struct inode *inode)
844844
LASSERT(body);
845845
if (body->mbo_valid & OBD_MD_FLMTIME &&
846846
body->mbo_mtime > LTIME_S(inode->i_mtime)) {
847-
CDEBUG(D_INODE, "setting fid " DFID " mtime from %lu to %llu\n",
848-
PFID(ll_inode2fid(inode)), LTIME_S(inode->i_mtime),
847+
CDEBUG(D_INODE, "setting fid " DFID " mtime from %llu to %llu\n",
848+
PFID(ll_inode2fid(inode)),
849+
(unsigned long long)LTIME_S(inode->i_mtime),
849850
body->mbo_mtime);
850851
LTIME_S(inode->i_mtime) = body->mbo_mtime;
851852
}

‎drivers/staging/lustre/lustre/lmv/lmv_obd.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,11 +3031,12 @@ static int lmv_merge_attr(struct obd_export *exp,
30313031
for (i = 0; i < lsm->lsm_md_stripe_count; i++) {
30323032
struct inode *inode = lsm->lsm_md_oinfo[i].lmo_root;
30333033

3034-
CDEBUG(D_INFO, "" DFID " size %llu, blocks %llu nlink %u, atime %lu ctime %lu, mtime %lu.\n",
3034+
CDEBUG(D_INFO, "" DFID " size %llu, blocks %llu nlink %u, atime %llu ctime %llu, mtime %llu.\n",
30353035
PFID(&lsm->lsm_md_oinfo[i].lmo_fid),
30363036
i_size_read(inode), (unsigned long long)inode->i_blocks,
3037-
inode->i_nlink, LTIME_S(inode->i_atime),
3038-
LTIME_S(inode->i_ctime), LTIME_S(inode->i_mtime));
3037+
inode->i_nlink, (unsigned long long)LTIME_S(inode->i_atime),
3038+
(unsigned long long)LTIME_S(inode->i_ctime),
3039+
(unsigned long long)LTIME_S(inode->i_mtime));
30393040

30403041
/* for slave stripe, it needs to subtract nlink for . and .. */
30413042
if (i)

‎drivers/staging/lustre/lustre/mdc/mdc_reint.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data,
129129
}
130130

131131
if (op_data->op_attr.ia_valid & (ATTR_MTIME | ATTR_CTIME))
132-
CDEBUG(D_INODE, "setting mtime %ld, ctime %ld\n",
133-
LTIME_S(op_data->op_attr.ia_mtime),
134-
LTIME_S(op_data->op_attr.ia_ctime));
132+
CDEBUG(D_INODE, "setting mtime %lld, ctime %lld\n",
133+
(long long)LTIME_S(op_data->op_attr.ia_mtime),
134+
(long long)LTIME_S(op_data->op_attr.ia_ctime));
135135
mdc_setattr_pack(req, op_data, ea, ealen);
136136

137137
ptlrpc_request_set_replen(req);

‎drivers/staging/lustre/lustre/obdclass/obdo.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, u32 valid)
6060
u32 newvalid = 0;
6161

6262
if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
63-
CDEBUG(D_INODE, "valid %x, new time %lu/%lu\n",
64-
valid, LTIME_S(src->i_mtime),
65-
LTIME_S(src->i_ctime));
63+
CDEBUG(D_INODE, "valid %x, new time %llu/%llu\n",
64+
valid, (long long)LTIME_S(src->i_mtime),
65+
(long long)LTIME_S(src->i_ctime));
6666

6767
if (valid & OBD_MD_FLATIME) {
6868
dst->o_atime = LTIME_S(src->i_atime);

‎drivers/tty/tty_io.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,13 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
867867
i = -EIO;
868868
tty_ldisc_deref(ld);
869869

870-
if (i > 0)
871-
tty_update_time(&inode->i_atime);
870+
if (i > 0) {
871+
struct timespec ts;
872+
873+
ts = timespec64_to_timespec(inode->i_atime);
874+
tty_update_time(&ts);
875+
inode->i_atime = timespec_to_timespec64(ts);
876+
}
872877

873878
return i;
874879
}
@@ -969,7 +974,11 @@ static inline ssize_t do_tty_write(
969974
cond_resched();
970975
}
971976
if (written) {
972-
tty_update_time(&file_inode(file)->i_mtime);
977+
struct timespec ts;
978+
979+
ts = timespec64_to_timespec(file_inode(file)->i_mtime);
980+
tty_update_time(&ts);
981+
file_inode(file)->i_mtime = timespec_to_timespec64(ts);
973982
ret = written;
974983
}
975984
out:

‎drivers/usb/gadget/function/f_fs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
12971297
inode = new_inode(sb);
12981298

12991299
if (likely(inode)) {
1300-
struct timespec ts = current_time(inode);
1300+
struct timespec64 ts = current_time(inode);
13011301

13021302
inode->i_ino = get_next_ino();
13031303
inode->i_mode = perms->mode;

‎fs/adfs/inode.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ adfs_adfs2unix_time(struct timespec *tv, struct inode *inode)
199199
return;
200200

201201
cur_time:
202-
*tv = current_time(inode);
202+
*tv = timespec64_to_timespec(current_time(inode));
203203
return;
204204

205205
too_early:
@@ -242,6 +242,7 @@ adfs_unix2adfs_time(struct inode *inode, unsigned int secs)
242242
struct inode *
243243
adfs_iget(struct super_block *sb, struct object_info *obj)
244244
{
245+
struct timespec ts;
245246
struct inode *inode;
246247

247248
inode = new_inode(sb);
@@ -270,7 +271,9 @@ adfs_iget(struct super_block *sb, struct object_info *obj)
270271
ADFS_I(inode)->stamped = ((obj->loadaddr & 0xfff00000) == 0xfff00000);
271272

272273
inode->i_mode = adfs_atts2mode(sb, inode);
273-
adfs_adfs2unix_time(&inode->i_mtime, inode);
274+
ts = timespec64_to_timespec(inode->i_mtime);
275+
adfs_adfs2unix_time(&ts, inode);
276+
inode->i_mtime = timespec_to_timespec64(ts);
274277
inode->i_atime = inode->i_mtime;
275278
inode->i_ctime = inode->i_mtime;
276279

‎fs/afs/fsclient.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void afs_update_inode_from_status(struct afs_vnode *vnode,
7272
const afs_dataversion_t *expected_version,
7373
u8 flags)
7474
{
75-
struct timespec t;
75+
struct timespec64 t;
7676
umode_t mode;
7777

7878
t.tv_sec = status->mtime_client;

0 commit comments

Comments
 (0)