Skip to content

Commit

Permalink
Merge tag 'vfs-timespec64' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/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()
  • Loading branch information
torvalds committed Jun 14, 2018
2 parents dc594c3 + e264abe commit 7a93251
Show file tree
Hide file tree
Showing 85 changed files with 539 additions and 424 deletions.
27 changes: 14 additions & 13 deletions drivers/firmware/efi/efi-pstore.c
Expand Up @@ -28,10 +28,9 @@ static int efi_pstore_close(struct pstore_info *psi)
return 0;
}

static inline u64 generic_id(unsigned long timestamp,
unsigned int part, int count)
static inline u64 generic_id(u64 timestamp, unsigned int part, int count)
{
return ((u64) timestamp * 100 + part) * 1000 + count;
return (timestamp * 100 + part) * 1000 + count;
}

static int efi_pstore_read_func(struct efivar_entry *entry,
Expand All @@ -42,15 +41,16 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
int i;
int cnt;
unsigned int part;
unsigned long time, size;
unsigned long size;
u64 time;

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

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

if (sscanf(name, "dump-type%u-%u-%d-%lu-%c",
if (sscanf(name, "dump-type%u-%u-%d-%llu-%c",
&record->type, &part, &cnt, &time, &data_type) == 5) {
record->id = generic_id(time, part, cnt);
record->part = part;
Expand All @@ -62,7 +62,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
else
record->compressed = false;
record->ecc_notice_size = 0;
} else if (sscanf(name, "dump-type%u-%u-%d-%lu",
} else if (sscanf(name, "dump-type%u-%u-%d-%llu",
&record->type, &part, &cnt, &time) == 4) {
record->id = generic_id(time, part, cnt);
record->part = part;
Expand All @@ -71,7 +71,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
record->time.tv_nsec = 0;
record->compressed = false;
record->ecc_notice_size = 0;
} else if (sscanf(name, "dump-type%u-%u-%lu",
} else if (sscanf(name, "dump-type%u-%u-%llu",
&record->type, &part, &time) == 3) {
/*
* Check if an old format,
Expand Down Expand Up @@ -250,9 +250,10 @@ static int efi_pstore_write(struct pstore_record *record)
/* Since we copy the entire length of name, make sure it is wiped. */
memset(name, 0, sizeof(name));

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

for (i = 0; i < DUMP_NAME_LEN; i++)
efi_name[i] = name[i];
Expand Down Expand Up @@ -327,15 +328,15 @@ static int efi_pstore_erase(struct pstore_record *record)
char name[DUMP_NAME_LEN];
int ret;

snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu",
snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lld",
record->type, record->part, record->count,
record->time.tv_sec);
(long long)record->time.tv_sec);
ret = efi_pstore_erase_name(name);
if (ret != -ENOENT)
return ret;

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

return ret;
Expand Down
15 changes: 12 additions & 3 deletions drivers/tty/tty_io.c
Expand Up @@ -867,8 +867,13 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
i = -EIO;
tty_ldisc_deref(ld);

if (i > 0)
tty_update_time(&inode->i_atime);
if (i > 0) {
struct timespec ts;

ts = timespec64_to_timespec(inode->i_atime);
tty_update_time(&ts);
inode->i_atime = timespec_to_timespec64(ts);
}

return i;
}
Expand Down Expand Up @@ -969,7 +974,11 @@ static inline ssize_t do_tty_write(
cond_resched();
}
if (written) {
tty_update_time(&file_inode(file)->i_mtime);
struct timespec ts;

ts = timespec64_to_timespec(file_inode(file)->i_mtime);
tty_update_time(&ts);
file_inode(file)->i_mtime = timespec_to_timespec64(ts);
ret = written;
}
out:
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/function/f_fs.c
Expand Up @@ -1308,7 +1308,7 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
inode = new_inode(sb);

if (likely(inode)) {
struct timespec ts = current_time(inode);
struct timespec64 ts = current_time(inode);

inode->i_ino = get_next_ino();
inode->i_mode = perms->mode;
Expand Down
7 changes: 5 additions & 2 deletions fs/adfs/inode.c
Expand Up @@ -199,7 +199,7 @@ adfs_adfs2unix_time(struct timespec *tv, struct inode *inode)
return;

cur_time:
*tv = current_time(inode);
*tv = timespec64_to_timespec(current_time(inode));
return;

too_early:
Expand Down Expand Up @@ -242,6 +242,7 @@ adfs_unix2adfs_time(struct inode *inode, unsigned int secs)
struct inode *
adfs_iget(struct super_block *sb, struct object_info *obj)
{
struct timespec ts;
struct inode *inode;

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

inode->i_mode = adfs_atts2mode(sb, inode);
adfs_adfs2unix_time(&inode->i_mtime, inode);
ts = timespec64_to_timespec(inode->i_mtime);
adfs_adfs2unix_time(&ts, inode);
inode->i_mtime = timespec_to_timespec64(ts);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;

Expand Down
2 changes: 1 addition & 1 deletion fs/afs/fsclient.c
Expand Up @@ -72,7 +72,7 @@ void afs_update_inode_from_status(struct afs_vnode *vnode,
const afs_dataversion_t *expected_version,
u8 flags)
{
struct timespec t;
struct timespec64 t;
umode_t mode;

t.tv_sec = status->mtime_client;
Expand Down
14 changes: 7 additions & 7 deletions fs/attr.c
Expand Up @@ -183,14 +183,14 @@ void setattr_copy(struct inode *inode, const struct iattr *attr)
if (ia_valid & ATTR_GID)
inode->i_gid = attr->ia_gid;
if (ia_valid & ATTR_ATIME)
inode->i_atime = timespec_trunc(attr->ia_atime,
inode->i_sb->s_time_gran);
inode->i_atime = timespec64_trunc(attr->ia_atime,
inode->i_sb->s_time_gran);
if (ia_valid & ATTR_MTIME)
inode->i_mtime = timespec_trunc(attr->ia_mtime,
inode->i_sb->s_time_gran);
inode->i_mtime = timespec64_trunc(attr->ia_mtime,
inode->i_sb->s_time_gran);
if (ia_valid & ATTR_CTIME)
inode->i_ctime = timespec_trunc(attr->ia_ctime,
inode->i_sb->s_time_gran);
inode->i_ctime = timespec64_trunc(attr->ia_ctime,
inode->i_sb->s_time_gran);
if (ia_valid & ATTR_MODE) {
umode_t mode = attr->ia_mode;

Expand Down Expand Up @@ -227,7 +227,7 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
struct inode *inode = dentry->d_inode;
umode_t mode = inode->i_mode;
int error;
struct timespec now;
struct timespec64 now;
unsigned int ia_valid = attr->ia_valid;

WARN_ON_ONCE(!inode_is_locked(inode));
Expand Down
2 changes: 1 addition & 1 deletion fs/bad_inode.c
Expand Up @@ -126,7 +126,7 @@ static int bad_inode_fiemap(struct inode *inode,
return -EIO;
}

static int bad_inode_update_time(struct inode *inode, struct timespec *time,
static int bad_inode_update_time(struct inode *inode, struct timespec64 *time,
int flags)
{
return -EIO;
Expand Down
6 changes: 3 additions & 3 deletions fs/btrfs/file.c
Expand Up @@ -1842,16 +1842,16 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)

static void update_time_for_write(struct inode *inode)
{
struct timespec now;
struct timespec64 now;

if (IS_NOCMTIME(inode))
return;

now = current_time(inode);
if (!timespec_equal(&inode->i_mtime, &now))
if (!timespec64_equal(&inode->i_mtime, &now))
inode->i_mtime = now;

if (!timespec_equal(&inode->i_ctime, &now))
if (!timespec64_equal(&inode->i_ctime, &now))
inode->i_ctime = now;

if (IS_I_VERSION(inode))
Expand Down
8 changes: 4 additions & 4 deletions fs/btrfs/inode.c
Expand Up @@ -5745,7 +5745,7 @@ static struct inode *new_simple_dir(struct super_block *s,
inode->i_mtime = current_time(inode);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
BTRFS_I(inode)->i_otime = inode->i_mtime;
BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime);

return inode;
}
Expand Down Expand Up @@ -6094,7 +6094,7 @@ static int btrfs_dirty_inode(struct inode *inode)
* This is a copy of file_update_time. We need this so we can return error on
* ENOSPC for updating the inode in the case of file write and mmap writes.
*/
static int btrfs_update_time(struct inode *inode, struct timespec *now,
static int btrfs_update_time(struct inode *inode, struct timespec64 *now,
int flags)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
Expand Down Expand Up @@ -6349,7 +6349,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
inode->i_mtime = current_time(inode);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
BTRFS_I(inode)->i_otime = inode->i_mtime;
BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime);

inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
struct btrfs_inode_item);
Expand Down Expand Up @@ -9435,7 +9435,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
struct btrfs_root *dest = BTRFS_I(new_dir)->root;
struct inode *new_inode = new_dentry->d_inode;
struct inode *old_inode = old_dentry->d_inode;
struct timespec ctime = current_time(old_inode);
struct timespec64 ctime = current_time(old_inode);
struct dentry *parent;
u64 old_ino = btrfs_ino(BTRFS_I(old_inode));
u64 new_ino = btrfs_ino(BTRFS_I(new_inode));
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/ioctl.c
Expand Up @@ -562,7 +562,7 @@ static noinline int create_subvol(struct inode *dir,
struct btrfs_root *root = BTRFS_I(dir)->root;
struct btrfs_root *new_root;
struct btrfs_block_rsv block_rsv;
struct timespec cur_time = current_time(dir);
struct timespec64 cur_time = current_time(dir);
struct inode *inode;
int ret;
int err;
Expand Down Expand Up @@ -5395,7 +5395,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_root_item *root_item = &root->root_item;
struct btrfs_trans_handle *trans;
struct timespec ct = current_time(inode);
struct timespec64 ct = current_time(inode);
int ret = 0;
int received_uuid_changed;

Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/root-tree.c
Expand Up @@ -485,9 +485,9 @@ void btrfs_update_root_times(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
struct btrfs_root_item *item = &root->root_item;
struct timespec ct;
struct timespec64 ct;

ktime_get_real_ts(&ct);
ktime_get_real_ts64(&ct);
spin_lock(&root->root_item_lock);
btrfs_set_root_ctransid(item, trans->transid);
btrfs_set_stack_timespec_sec(&item->ctime, ct.tv_sec);
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/transaction.c
Expand Up @@ -1422,7 +1422,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
struct dentry *dentry;
struct extent_buffer *tmp;
struct extent_buffer *old;
struct timespec cur_time;
struct timespec64 cur_time;
int ret = 0;
u64 to_reserve = 0;
u64 index = 0;
Expand Down
12 changes: 7 additions & 5 deletions fs/ceph/addr.c
Expand Up @@ -574,6 +574,7 @@ static u64 get_writepages_data_length(struct inode *inode,
*/
static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
{
struct timespec ts;
struct inode *inode;
struct ceph_inode_info *ci;
struct ceph_fs_client *fsc;
Expand Down Expand Up @@ -624,11 +625,12 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
set_bdi_congested(inode_to_bdi(inode), BLK_RW_ASYNC);

set_page_writeback(page);
ts = timespec64_to_timespec(inode->i_mtime);
err = ceph_osdc_writepages(&fsc->client->osdc, ceph_vino(inode),
&ci->i_layout, snapc, page_off, len,
ceph_wbc.truncate_seq,
ceph_wbc.truncate_size,
&inode->i_mtime, &page, 1);
&ts, &page, 1);
if (err < 0) {
struct writeback_control tmp_wbc;
if (!wbc)
Expand Down Expand Up @@ -1132,7 +1134,7 @@ static int ceph_writepages_start(struct address_space *mapping,
pages = NULL;
}

req->r_mtime = inode->i_mtime;
req->r_mtime = timespec64_to_timespec(inode->i_mtime);
rc = ceph_osdc_start_request(&fsc->client->osdc, req, true);
BUG_ON(rc);
req = NULL;
Expand Down Expand Up @@ -1732,7 +1734,7 @@ int ceph_uninline_data(struct file *filp, struct page *locked_page)
goto out;
}

req->r_mtime = inode->i_mtime;
req->r_mtime = timespec64_to_timespec(inode->i_mtime);
err = ceph_osdc_start_request(&fsc->client->osdc, req, false);
if (!err)
err = ceph_osdc_wait_request(&fsc->client->osdc, req);
Expand Down Expand Up @@ -1774,7 +1776,7 @@ int ceph_uninline_data(struct file *filp, struct page *locked_page)
goto out_put;
}

req->r_mtime = inode->i_mtime;
req->r_mtime = timespec64_to_timespec(inode->i_mtime);
err = ceph_osdc_start_request(&fsc->client->osdc, req, false);
if (!err)
err = ceph_osdc_wait_request(&fsc->client->osdc, req);
Expand Down Expand Up @@ -1935,7 +1937,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci,
0, false, true);
err = ceph_osdc_start_request(&fsc->client->osdc, rd_req, false);

wr_req->r_mtime = ci->vfs_inode.i_mtime;
wr_req->r_mtime = timespec64_to_timespec(ci->vfs_inode.i_mtime);
err2 = ceph_osdc_start_request(&fsc->client->osdc, wr_req, false);

if (!err)
Expand Down
4 changes: 2 additions & 2 deletions fs/ceph/cache.c
Expand Up @@ -130,7 +130,7 @@ static enum fscache_checkaux ceph_fscache_inode_check_aux(

memset(&aux, 0, sizeof(aux));
aux.version = ci->i_version;
aux.mtime = inode->i_mtime;
aux.mtime = timespec64_to_timespec(inode->i_mtime);

if (memcmp(data, &aux, sizeof(aux)) != 0)
return FSCACHE_CHECKAUX_OBSOLETE;
Expand Down Expand Up @@ -163,7 +163,7 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)
if (!ci->fscache) {
memset(&aux, 0, sizeof(aux));
aux.version = ci->i_version;
aux.mtime = inode->i_mtime;
aux.mtime = timespec64_to_timespec(inode->i_mtime);
ci->fscache = fscache_acquire_cookie(fsc->fscache,
&ceph_fscache_inode_object_def,
&ci->i_vino, sizeof(ci->i_vino),
Expand Down
6 changes: 3 additions & 3 deletions fs/ceph/caps.c
Expand Up @@ -1360,9 +1360,9 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
arg.xattr_buf = NULL;
}

arg.mtime = inode->i_mtime;
arg.atime = inode->i_atime;
arg.ctime = inode->i_ctime;
arg.mtime = timespec64_to_timespec(inode->i_mtime);
arg.atime = timespec64_to_timespec(inode->i_atime);
arg.ctime = timespec64_to_timespec(inode->i_ctime);

arg.op = op;
arg.caps = cap->implemented;
Expand Down

0 comments on commit 7a93251

Please sign in to comment.