[Y2038] [PATCH v3 02/24] fs: proc: Delete inode time initializations in proc_alloc_inode()

2016-06-25 Thread Deepa Dinamani
proc uses new_inode_pseudo() to allocate a new inode.
This in turn calls the proc_inode_alloc() callback.
But, at this point, inode is still not initialized
with the super_block pointer which only happens just
before alloc_inode() returns after the call to
inode_init_always().

Also, the inode times are initialized again after the
call to new_inode_pseudo() in proc_inode_alloc().
The assignemet in proc_alloc_inode() is redundant and
also doesn't work after the current_time() api is
changed to take struct inode* instead of
struct *super_block.

This bug was reported after current_time() was used to
assign times in proc_alloc_inode().

Signed-off-by: Deepa Dinamani 
Reported-by: Fengguang Wu  [0-day test robot]
---
 fs/proc/inode.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 6b1843e..606e4cd 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -68,7 +68,6 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
ei->sysctl_entry = NULL;
ei->ns_ops = NULL;
inode = &ei->vfs_inode;
-   inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
return inode;
 }
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 01/24] vfs: Add current_time() api

2016-06-25 Thread Deepa Dinamani
current_fs_time() is used for inode timestamps.

Change the signature of the function to take inode pointer
instead of superblock as per Linus's suggestion.

Also, move the api under vfs as per the discussion on the
thread: https://lkml.org/lkml/2016/6/9/36 . As per Arnd's
suggestion on the thread, changing the function name.

current_fs_time() will be deleted after all the references
to it are replaced by current_time().

There was a bug reported by kbuild test bot with the change
as some of the calls to current_time() were made before the
super_block was initialized. Catch these accidental assignments
as timespec_trunc() does for wrong granularities. This allows
for the function to work right even in these circumstances.
But, adds a warning to make the user aware of the bug.

A coccinelle script was used to identify all the current
.alloc_inode super_block callbacks that updated inode timestamps.
proc filesystem was the only one that was modifying inode times
as part of this callback. The series includes a patch to fix that.

Note that timespec_trunc() will also be moved to fs/inode.c
in a separate patch when this will need to be revamped for
bounds checking purposes.

Signed-off-by: Deepa Dinamani 
---
 fs/inode.c | 23 +++
 include/linux/fs.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/fs/inode.c b/fs/inode.c
index e171f7b..80b6898 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2043,3 +2043,26 @@ void inode_nohighmem(struct inode *inode)
mapping_set_gfp_mask(inode->i_mapping, GFP_USER);
 }
 EXPORT_SYMBOL(inode_nohighmem);
+
+/**
+ * current_time - Return FS time
+ * @inode: inode.
+ *
+ * Return the current time truncated to the time granularity supported by
+ * the fs.
+ *
+ * Note that inode and inode->sb cannot be NULL.
+ * Otherwise, the function warns and returns time without truncation.
+ */
+struct timespec current_time(struct inode *inode)
+{
+   struct timespec now = current_kernel_time();
+
+   if (unlikely(!inode->i_sb)) {
+   WARN(1, "current_time() called with uninitialized super_block 
in the inode");
+   return now;
+   }
+
+   return timespec_trunc(now, inode->i_sb->s_time_gran);
+}
+EXPORT_SYMBOL(current_time);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c4ab2cf..d0d9b38 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1476,6 +1476,7 @@ struct super_block {
 };
 
 extern struct timespec current_fs_time(struct super_block *sb);
+extern struct timespec current_time(struct inode *inode);
 
 static inline struct timespec current_fs_time_sec(struct super_block *sb)
 {
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 06/24] fs: jfs: Replace CURRENT_TIME_SEC by current_time()

2016-06-25 Thread Deepa Dinamani
jfs uses nanosecond granularity for filesystem timestamps.
Only this assignment is not using nanosecond granularity.
Use current_time() to get the right granularity.

Signed-off-by: Deepa Dinamani 
Cc: Dave Kleikamp 
Cc: jfs-discuss...@lists.sourceforge.net
Acked-by: Dave Kleikamp 
---
 fs/jfs/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index 8653cac..b6fd1ff 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -121,7 +121,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, 
unsigned long arg)
 
jfs_set_inode_flags(inode);
inode_unlock(inode);
-   inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
 setflags_out:
mnt_drop_write_file(filp);
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 08/24] fs: ubifs: Replace CURRENT_TIME_SEC with current_time

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe. current_time() will
be transitioned to use 64 bit time along with vfs in a
separate patch.
There is no plan to transition CURRENT_TIME_SEC to use
y2038 safe time interfaces.

current_time() returns timestamps according to the
granularities set in the inode's super_block.
The granularity check to call current_fs_time() or
CURRENT_TIME_SEC is not required.

Use current_time() directly to update inode timestamp.
Use timespec_trunc during file system creation, before
the first inode is created.

Signed-off-by: Deepa Dinamani 
Cc: Artem Bityutskiy 
Cc: Adrian Hunter 
Cc: linux-...@lists.infradead.org
---
 fs/ubifs/dir.c   | 10 +-
 fs/ubifs/file.c  | 12 ++--
 fs/ubifs/ioctl.c |  2 +-
 fs/ubifs/misc.h  | 10 --
 fs/ubifs/sb.c| 14 ++
 fs/ubifs/xattr.c |  6 +++---
 6 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 4b86d3a..6e2dff9 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -106,7 +106,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const 
struct inode *dir,
 
inode_init_owner(inode, dir, mode);
inode->i_mtime = inode->i_atime = inode->i_ctime =
-ubifs_current_time(inode);
+current_time(inode);
inode->i_mapping->nrpages = 0;
 
switch (mode & S_IFMT) {
@@ -529,7 +529,7 @@ static int ubifs_link(struct dentry *old_dentry, struct 
inode *dir,
lock_2_inodes(dir, inode);
inc_nlink(inode);
ihold(inode);
-   inode->i_ctime = ubifs_current_time(inode);
+   inode->i_ctime = current_time(inode);
dir->i_size += sz_change;
dir_ui->ui_size = dir->i_size;
dir->i_mtime = dir->i_ctime = inode->i_ctime;
@@ -586,7 +586,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry 
*dentry)
}
 
lock_2_inodes(dir, inode);
-   inode->i_ctime = ubifs_current_time(dir);
+   inode->i_ctime = current_time(dir);
drop_nlink(inode);
dir->i_size -= sz_change;
dir_ui->ui_size = dir->i_size;
@@ -675,7 +675,7 @@ static int ubifs_rmdir(struct inode *dir, struct dentry 
*dentry)
}
 
lock_2_inodes(dir, inode);
-   inode->i_ctime = ubifs_current_time(dir);
+   inode->i_ctime = current_time(dir);
clear_nlink(inode);
drop_nlink(dir);
dir->i_size -= sz_change;
@@ -1023,7 +1023,7 @@ static int ubifs_rename(struct inode *old_dir, struct 
dentry *old_dentry,
 * Like most other Unix systems, set the @i_ctime for inodes on a
 * rename.
 */
-   time = ubifs_current_time(old_dir);
+   time = current_time(old_dir);
old_inode->i_ctime = time;
 
/* We must adjust parent link count when renaming directories */
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 7bbf420..45e3d71 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1182,7 +1182,7 @@ static int do_truncation(struct ubifs_info *c, struct 
inode *inode,
mutex_lock(&ui->ui_mutex);
ui->ui_size = inode->i_size;
/* Truncation changes inode [mc]time */
-   inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
/* Other attributes may be changed at the same time as well */
do_attr_changes(inode, attr);
err = ubifs_jnl_truncate(c, inode, old_size, new_size);
@@ -1229,7 +1229,7 @@ static int do_setattr(struct ubifs_info *c, struct inode 
*inode,
mutex_lock(&ui->ui_mutex);
if (attr->ia_valid & ATTR_SIZE) {
/* Truncation changes inode [mc]time */
-   inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
/* 'truncate_setsize()' changed @i_size, update @ui_size */
ui->ui_size = inode->i_size;
}
@@ -1406,7 +1406,7 @@ int ubifs_update_time(struct inode *inode, struct 
timespec *time,
  */
 static int update_mctime(struct inode *inode)
 {
-   struct timespec now = ubifs_current_time(inode);
+   struct timespec now = current_time(inode);
struct ubifs_inode *ui = ubifs_inode(inode);
struct ubifs_info *c = inode->i_sb->s_fs_info;
 
@@ -1420,7 +1420,7 @@ static int update_mctime(struct inode *inode)
return err;
 
mutex_lock(&ui->ui_mutex);
-   inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
release = ui->dirty;
mark_inode_dirty_sync(inode);
mutex_unlock(&ui->ui_mutex);
@@ -1498,7 +1498,7 @@ static int ubifs_vm_page_mkwrite(struct vm_area_struct 
*vma,
struct page *page = vmf->page;
struct inode *inode = file_inode(vma->vm_file);
struct ubifs_info *c = inode->i_sb->s_fs_info;
-   struct timespe

[Y2038] [PATCH v3 07/24] fs: ext4: Use current_time() for inode timestamps

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME_SEC and CURRENT_TIME are not y2038 safe.
current_time() will be transitioned to be y2038 safe
along with vfs.

current_time() returns timestamps according to the
granularities set in the super_block.
The granularity check in ext4_current_time() to call
current_time() or CURRENT_TIME_SEC is not required.
Use current_time() directly to obtain timestamps
unconditionally, and remove ext4_current_time().

Quota files are assumed to be on the same filesystem.
Hence, use current_time() for these files as well.

Signed-off-by: Deepa Dinamani 
Cc: "Theodore Ts'o" 
Cc: Andreas Dilger 
Cc: linux-e...@vger.kernel.org
---
 fs/ext4/acl.c |  2 +-
 fs/ext4/ext4.h|  6 --
 fs/ext4/extents.c | 10 +-
 fs/ext4/ialloc.c  |  2 +-
 fs/ext4/inline.c  |  4 ++--
 fs/ext4/inode.c   |  6 +++---
 fs/ext4/ioctl.c   |  8 
 fs/ext4/namei.c   | 24 +---
 fs/ext4/xattr.c   |  2 +-
 9 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index c6601a4..733e2f24 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -197,7 +197,7 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int 
type,
if (error < 0)
return error;
else {
-   inode->i_ctime = ext4_current_time(inode);
+   inode->i_ctime = current_time(inode);
ext4_mark_inode_dirty(handle, inode);
if (error == 0)
acl = NULL;
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b84aa1c..14e5cf4 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1523,12 +1523,6 @@ static inline struct ext4_inode_info *EXT4_I(struct 
inode *inode)
return container_of(inode, struct ext4_inode_info, vfs_inode);
 }
 
-static inline struct timespec ext4_current_time(struct inode *inode)
-{
-   return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
-   current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
-}
-
 static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
 {
return ino == EXT4_ROOT_INO ||
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 2a2eef9..2584317 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4722,7 +4722,7 @@ retry:
map.m_lblk += ret;
map.m_len = len = len - ret;
epos = (loff_t)map.m_lblk << inode->i_blkbits;
-   inode->i_ctime = ext4_current_time(inode);
+   inode->i_ctime = current_time(inode);
if (new_size) {
if (epos > new_size)
epos = new_size;
@@ -4850,7 +4850,7 @@ static long ext4_zero_range(struct file *file, loff_t 
offset,
}
/* Now release the pages and zero block aligned part of pages */
truncate_pagecache_range(inode, start, end - 1);
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
 
ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
 flags, mode);
@@ -4875,7 +4875,7 @@ static long ext4_zero_range(struct file *file, loff_t 
offset,
goto out_dio;
}
 
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
if (new_size) {
ext4_update_inode_size(inode, new_size);
} else {
@@ -5574,7 +5574,7 @@ int ext4_collapse_range(struct inode *inode, loff_t 
offset, loff_t len)
up_write(&EXT4_I(inode)->i_data_sem);
if (IS_SYNC(inode))
ext4_handle_sync(handle);
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
ext4_mark_inode_dirty(handle, inode);
 
 out_stop:
@@ -5684,7 +5684,7 @@ int ext4_insert_range(struct inode *inode, loff_t offset, 
loff_t len)
/* Expand file to avoid data loss if there is error while shifting */
inode->i_size += len;
EXT4_I(inode)->i_disksize += len;
-   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
+   inode->i_mtime = inode->i_ctime = current_time(inode);
ret = ext4_mark_inode_dirty(handle, inode);
if (ret)
goto out_stop;
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 1e4b0b7..8b3d58f 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1039,7 +1039,7 @@ got:
/* This is the optimal IO size (for stat), not the fs block size */
inode->i_blocks = 0;
inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
-  ext4_current_time(inode);
+  current_time(inode

[Y2038] [PATCH v3 09/24] fs: btrfs: Use ktime_get_real_ts for root ctime

2016-06-25 Thread Deepa Dinamani
btrfs_root_item maintains the ctime for root updates.
This is not part of vfs_inode.

Since current_time() uses struct inode* as an argument
as Linus suggested, this cannot be used to update root
times unless, we modify the signature to use inode.

Since btrfs uses nanosecond time granularity, it can also
use ktime_get_real_ts directly to obtain timestamp for
the root. It is necessary to use the timespec time api
here because the same btrfs_set_stack_timespec_*() apis
are used for vfs inode times as well. These can be
transitioned to using timespec64 when btrfs internally
changes to use timespec64 as well.

Signed-off-by: Deepa Dinamani 
Cc: Chris Mason 
Cc: Josef Bacik 
Cc: David Sterba 
Cc: linux-bt...@vger.kernel.org
Acked-by: David Sterba 
---
 fs/btrfs/root-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index f1c3086..161118b 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -496,10 +496,11 @@ 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 = current_fs_time(root->fs_info->sb);
+   struct timespec ct;
 
spin_lock(&root->root_item_lock);
btrfs_set_root_ctransid(item, trans->transid);
+   ktime_get_real_ts(&ct);
btrfs_set_stack_timespec_sec(&item->ctime, ct.tv_sec);
btrfs_set_stack_timespec_nsec(&item->ctime, ct.tv_nsec);
spin_unlock(&root->root_item_lock);
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 04/24] fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe. current_time() will
be transitioned to use 64 bit time along with vfs in a
separate patch.
There is no plan to transistion CURRENT_TIME_SEC to use
y2038 safe time interfaces.

current_time() will also be extended to use superblock
range checking parameters when range checking is introduced.

This works because alloc_super() fills in the the s_time_gran
in super block to NSEC_PER_SEC.

Also note that filesystem specific times like the birthtime,
creation time that were using same interfaces to obtain time
retain same logistics.

Signed-off-by: Deepa Dinamani 
Acked-by: Jan Kara 
---
 fs/affs/amigaffs.c  |  6 +++---
 fs/affs/inode.c |  2 +-
 fs/bfs/dir.c| 14 +++---
 fs/coda/dir.c   |  2 +-
 fs/coda/file.c  |  2 +-
 fs/coda/inode.c |  2 +-
 fs/ext2/acl.c   |  2 +-
 fs/ext2/dir.c   |  6 +++---
 fs/ext2/ialloc.c|  2 +-
 fs/ext2/inode.c |  4 ++--
 fs/ext2/ioctl.c |  4 ++--
 fs/ext2/namei.c |  6 +++---
 fs/ext2/xattr.c |  2 +-
 fs/fat/dir.c|  2 +-
 fs/fat/file.c   |  4 ++--
 fs/fat/inode.c  |  2 +-
 fs/fat/namei_msdos.c| 12 ++--
 fs/fat/namei_vfat.c | 10 +-
 fs/hfs/catalog.c|  8 
 fs/hfs/dir.c|  2 +-
 fs/hfs/inode.c  |  2 +-
 fs/hfsplus/catalog.c|  8 
 fs/hfsplus/dir.c|  6 +++---
 fs/hfsplus/inode.c  |  2 +-
 fs/hfsplus/ioctl.c  |  2 +-
 fs/jffs2/acl.c  |  2 +-
 fs/jffs2/fs.c   |  2 +-
 fs/minix/bitmap.c   |  2 +-
 fs/minix/dir.c  |  6 +++---
 fs/minix/itree_common.c |  4 ++--
 fs/minix/namei.c|  4 ++--
 fs/omfs/dir.c   |  4 ++--
 fs/reiserfs/inode.c |  2 +-
 fs/reiserfs/ioctl.c |  4 ++--
 fs/reiserfs/namei.c | 12 ++--
 fs/reiserfs/stree.c |  8 
 fs/reiserfs/xattr.c |  2 +-
 fs/reiserfs/xattr_acl.c |  2 +-
 fs/sysv/dir.c   |  6 +++---
 fs/sysv/ialloc.c|  2 +-
 fs/sysv/itree.c |  4 ++--
 fs/sysv/namei.c |  4 ++--
 fs/ufs/dir.c|  6 +++---
 fs/ufs/ialloc.c |  2 +-
 fs/ufs/inode.c  |  6 +++---
 fs/ufs/namei.c  |  6 +++---
 46 files changed, 102 insertions(+), 102 deletions(-)

diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index d6c7a51..a9004a0 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -58,7 +58,7 @@ affs_insert_hash(struct inode *dir, struct buffer_head *bh)
mark_buffer_dirty_inode(dir_bh, dir);
affs_brelse(dir_bh);
 
-   dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
+   dir->i_mtime = dir->i_ctime = current_time(dir);
dir->i_version++;
mark_inode_dirty(dir);
 
@@ -112,7 +112,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head 
*rem_bh)
 
affs_brelse(bh);
 
-   dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
+   dir->i_mtime = dir->i_ctime = current_time(dir);
dir->i_version++;
mark_inode_dirty(dir);
 
@@ -313,7 +313,7 @@ affs_remove_header(struct dentry *dentry)
else
clear_nlink(inode);
affs_unlock_link(inode);
-   inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
 
 done:
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 0fdb0f5..ed120ec 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -309,7 +309,7 @@ affs_new_inode(struct inode *dir)
inode->i_gid = current_fsgid();
inode->i_ino = block;
set_nlink(inode, 1);
-   inode->i_mtime   = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_mtime   = inode->i_atime = inode->i_ctime = 
current_time(inode);
atomic_set(&AFFS_I(inode)->i_opencnt, 0);
AFFS_I(inode)->i_blkcnt = 0;
AFFS_I(inode)->i_lc = NULL;
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 34a5bc2..4206419 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -97,7 +97,7 @@ static int bfs_create(struct inode *dir, struct dentry 
*dentry, umode_t mode,
set_bit(ino, info->si_imap);
info->si_freei--;
inode_init_owner(inode, dir, mode);
-   inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
inode->i_blocks = 0;
inode->i_op = &bfs_file_inops;
inode->i_fop = &bfs_file_operations;
@@ -165,7 +165,7 @@ static int bfs_link(struct dentry *old, struct inode *dir,
return err;
}
inc_nlink(inode);
-   inode->i_ctime = CURRENT_TIME_SEC;
+   inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
ihold(inode);
d_instantiate(new, inode);
@@ -194,7 +194,7 @@ static int bfs_unlink(struct inode *dir, struct dentry 
*dentry)
}
de->ino = 0;
mark_buffer_dirty_inode(bh, dir);
-   dir->i_ctime = dir->i_mtime =

[Y2038] [PATCH v3 05/24] fs: Replace current_fs_time() with current_time()

2016-06-25 Thread Deepa Dinamani
current_fs_time() uses struct super_block* as an argument.
As per Linus's suggestion, this is changed to take struct
inode* as a parameter instead. This is because the function
is primarily meant for vfs inode timestamps.
Also the function was renamed as per Arnd's suggestion.

Change all calls to current_fs_time() to use the new
current_time() function instead. current_fs_time() will be
deleted.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/sonypi.c  |  2 +-
 drivers/platform/x86/sony-laptop.c |  2 +-
 fs/attr.c  |  2 +-
 fs/bad_inode.c |  2 +-
 fs/binfmt_misc.c   |  2 +-
 fs/btrfs/file.c|  6 +++---
 fs/btrfs/inode.c   | 20 ++--
 fs/btrfs/ioctl.c   |  8 
 fs/btrfs/transaction.c |  4 ++--
 fs/btrfs/xattr.c   |  2 +-
 fs/ceph/file.c |  4 ++--
 fs/ceph/inode.c|  2 +-
 fs/ceph/xattr.c|  2 +-
 fs/cifs/file.c |  4 ++--
 fs/cifs/inode.c|  8 
 fs/configfs/inode.c|  6 +++---
 fs/debugfs/inode.c |  2 +-
 fs/fat/file.c  |  2 +-
 fs/fuse/dir.c  |  2 +-
 fs/inode.c |  6 +++---
 fs/jfs/namei.c |  2 +-
 fs/kernfs/inode.c  |  2 +-
 fs/locks.c |  2 +-
 fs/nfsd/blocklayout.c  |  2 +-
 fs/ntfs/inode.c|  2 +-
 fs/ntfs/mft.c  |  2 +-
 fs/orangefs/namei.c|  8 
 fs/reiserfs/xattr.c|  4 ++--
 fs/udf/ialloc.c|  2 +-
 fs/udf/inode.c |  4 ++--
 fs/udf/namei.c | 20 ++--
 fs/xfs/xfs_acl.c   |  2 +-
 fs/xfs/xfs_inode.c |  2 +-
 fs/xfs/xfs_iops.c  |  2 +-
 fs/xfs/xfs_trans_inode.c   |  2 +-
 35 files changed, 73 insertions(+), 73 deletions(-)

diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index e496dae..719c5b4 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -934,7 +934,7 @@ static ssize_t sonypi_misc_read(struct file *file, char 
__user *buf,
 
if (ret > 0) {
struct inode *inode = file_inode(file);
-   inode->i_atime = current_fs_time(inode->i_sb);
+   inode->i_atime = current_time(inode);
}
 
return ret;
diff --git a/drivers/platform/x86/sony-laptop.c 
b/drivers/platform/x86/sony-laptop.c
index 1dba359..c890a49 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -4116,7 +4116,7 @@ static ssize_t sonypi_misc_read(struct file *file, char 
__user *buf,
 
if (ret > 0) {
struct inode *inode = file_inode(file);
-   inode->i_atime = current_fs_time(inode->i_sb);
+   inode->i_atime = current_time(inode);
}
 
return ret;
diff --git a/fs/attr.c b/fs/attr.c
index 25b24d0..5c45f98 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -209,7 +209,7 @@ int notify_change(struct dentry * dentry, struct iattr * 
attr, struct inode **de
inode->i_flags &= ~S_NOSEC;
}
 
-   now = current_fs_time(inode->i_sb);
+   now = current_time(inode);
 
attr->ia_ctime = now;
if (!(ia_valid & ATTR_ATIME_SET))
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 3ba385e..3c8ec39 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -173,7 +173,7 @@ void make_bad_inode(struct inode *inode)
 
inode->i_mode = S_IFREG;
inode->i_atime = inode->i_mtime = inode->i_ctime =
-   current_fs_time(inode->i_sb);
+   current_time(inode);
inode->i_op = &bad_inode_ops;   
inode->i_fop = &bad_file_ops;   
 }
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 3a3ced7..722ef54 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -567,7 +567,7 @@ static struct inode *bm_get_inode(struct super_block *sb, 
int mode)
inode->i_ino = get_next_ino();
inode->i_mode = mode;
inode->i_atime = inode->i_mtime = inode->i_ctime =
-   current_fs_time(inode->i_sb);
+   current_time(inode);
}
return inode;
 }
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 8d7c79a..ad98713 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1759,7 +1759,7 @@ static void update_time_for_write(struct inode *inode)
if (IS_NOCMTIME(inode))
return;
 
-   now = current_fs_time(inode->i_sb);
+   now = current_time(inode);
if (!timespec_equal(&inode->i_mtime, &now))
inode->i_mtime = now;
 
@@ -2580,7 +2580,7 @@ out_trans:
goto out_free;
 
inode_inc_iversion(inode);
-   inode->i_mtime =

[Y2038] [PATCH v3 11/24] fs: cifs: Replace CURRENT_TIME by current_time()

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_time() instead.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned change.

Change signature of helper cifs_all_info_to_fattr since it
now needs both super_block and cifs_sb_info.

Note: The inode timestamps read from the server are assumed
to have correct granularity and range.

Signed-off-by: Deepa Dinamani 
Cc: Steve French 
---
 fs/cifs/inode.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 9b3d92e..721809e 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -320,9 +320,9 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct 
super_block *sb)
fattr->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU;
fattr->cf_uid = cifs_sb->mnt_uid;
fattr->cf_gid = cifs_sb->mnt_gid;
-   fattr->cf_atime = CURRENT_TIME;
-   fattr->cf_ctime = CURRENT_TIME;
-   fattr->cf_mtime = CURRENT_TIME;
+   ktime_get_real_ts(&fattr->cf_mtime);
+   fattr->cf_mtime = timespec_trunc(fattr->cf_mtime, sb->s_time_gran);
+   fattr->cf_atime = fattr->cf_ctime = fattr->cf_mtime;
fattr->cf_nlink = 2;
fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL;
 }
@@ -584,9 +584,10 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const 
unsigned char *path,
 /* Fill a cifs_fattr struct with info from FILE_ALL_INFO */
 static void
 cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
-  struct cifs_sb_info *cifs_sb, bool adjust_tz,
+  struct super_block *sb, bool adjust_tz,
   bool symlink)
 {
+   struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
 
memset(fattr, 0, sizeof(*fattr));
@@ -596,8 +597,10 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, 
FILE_ALL_INFO *info,
 
if (info->LastAccessTime)
fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
-   else
-   fattr->cf_atime = CURRENT_TIME;
+   else {
+   ktime_get_real_ts(&fattr->cf_atime);
+   fattr->cf_atime = timespec_trunc(fattr->cf_atime, 
sb->s_time_gran);
+   }
 
fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
@@ -657,7 +660,6 @@ cifs_get_file_info(struct file *filp)
FILE_ALL_INFO find_data;
struct cifs_fattr fattr;
struct inode *inode = file_inode(filp);
-   struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct cifsFileInfo *cfile = filp->private_data;
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
struct TCP_Server_Info *server = tcon->ses->server;
@@ -669,7 +671,7 @@ cifs_get_file_info(struct file *filp)
rc = server->ops->query_file_info(xid, tcon, &cfile->fid, &find_data);
switch (rc) {
case 0:
-   cifs_all_info_to_fattr(&fattr, &find_data, cifs_sb, false,
+   cifs_all_info_to_fattr(&fattr, &find_data, inode->i_sb, false,
   false);
break;
case -EREMOTE:
@@ -751,7 +753,7 @@ cifs_get_inode_info(struct inode **inode, const char 
*full_path,
}
 
if (!rc) {
-   cifs_all_info_to_fattr(&fattr, data, cifs_sb, adjust_tz,
+   cifs_all_info_to_fattr(&fattr, data, sb, adjust_tz,
   symlink);
} else if (rc == -EREMOTE) {
cifs_create_dfs_fattr(&fattr, sb);
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 14/24] fs: f2fs: Use ktime_get_real_seconds for sit_info times

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe.

Replace use of CURRENT_TIME_SEC with ktime_get_real_seconds
in segment timestamps used by GC algorithm including the
segment mtime timestamps.

Signed-off-by: Deepa Dinamani 
Cc: Jaegeuk Kim 
Cc: Changman Lee 
Cc: linux-f2fs-de...@lists.sourceforge.net
---
 fs/f2fs/segment.c | 2 +-
 fs/f2fs/segment.h | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index e3f758d..4af7d5a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2158,7 +2158,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
sit_i->dirty_sentries = 0;
sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
-   sit_i->mounted_time = CURRENT_TIME_SEC.tv_sec;
+   sit_i->mounted_time = ktime_get_real_seconds();
mutex_init(&sit_i->sentry_lock);
return 0;
 }
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 57d450f..94ab338 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -661,8 +661,9 @@ static inline void set_to_next_sit(struct sit_info *sit_i, 
unsigned int start)
 static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
 {
struct sit_info *sit_i = SIT_I(sbi);
-   return sit_i->elapsed_time + CURRENT_TIME_SEC.tv_sec -
-   sit_i->mounted_time;
+   time64_t now = ktime_get_real_seconds();
+
+   return sit_i->elapsed_time + now - sit_i->mounted_time;
 }
 
 static inline void set_summary(struct f2fs_summary *sum, nid_t nid,
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 12/24] fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts()

2016-06-25 Thread Deepa Dinamani
This is in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned patch.

Filesystem times will use current_fs_time() instead of
CURRENT_TIME.
Use ktime_get_real_ts() here as this is not filesystem time.
ktime_get_real_ts() returns the timestamp in ns which can
be used to calculate network time for NTLMv2 authentication
timestamp.

All cifs timestamps currently use timespec internally.
This timestamp can also be transitioned into using
timespec64 when all other timestamps for cifs is transitioned
to use timespec64.

Signed-off-by: Deepa Dinamani 
Cc: Steve French 
---
 fs/cifs/cifsencrypt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 6aeb8d4..b86ce67 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -471,6 +471,7 @@ find_timestamp(struct cifs_ses *ses)
unsigned char *blobptr;
unsigned char *blobend;
struct ntlmssp2_name *attrptr;
+   struct timespec ts;
 
if (!ses->auth_key.len || !ses->auth_key.response)
return 0;
@@ -495,7 +496,8 @@ find_timestamp(struct cifs_ses *ses)
blobptr += attrsize; /* advance attr value */
}
 
-   return cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
+   ktime_get_real_ts(&ts);
+   return cpu_to_le64(cifs_UnixTimeToNT(ts));
 }
 
 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 10/24] fs: udf: Replace CURRENT_TIME with current_time()

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.

CURRENT_TIME macro is also not appropriate for filesystems
as it doesn't use the right granularity for filesystem
timestamps.

Logical Volume Integrity format is described to have the
same timestamp format for "Recording Date and time" as
the other [a,c,m]timestamps.
The function udf_time_to_disk_format() does this conversion.
Hence the timestamp is passed directly to the function and
not truncated. This is as per Arnd's suggestion on the
thread.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. As part of the effort current_time() will be
extended to do range checks.

Signed-off-by: Deepa Dinamani 
Cc: Jan Kara 
Reviewed-by: Jan Kara 
---
 fs/udf/super.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4942549..967ad87 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1986,6 +1986,7 @@ static void udf_open_lvid(struct super_block *sb)
struct buffer_head *bh = sbi->s_lvid_bh;
struct logicalVolIntegrityDesc *lvid;
struct logicalVolIntegrityDescImpUse *lvidiu;
+   struct timespec ts;
 
if (!bh)
return;
@@ -1997,8 +1998,8 @@ static void udf_open_lvid(struct super_block *sb)
mutex_lock(&sbi->s_alloc_mutex);
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
-   udf_time_to_disk_stamp(&lvid->recordingDateAndTime,
-   CURRENT_TIME);
+   ktime_get_real_ts(&ts);
+   udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
 
lvid->descTag.descCRC = cpu_to_le16(
@@ -2019,6 +2020,7 @@ static void udf_close_lvid(struct super_block *sb)
struct buffer_head *bh = sbi->s_lvid_bh;
struct logicalVolIntegrityDesc *lvid;
struct logicalVolIntegrityDescImpUse *lvidiu;
+   struct timespec ts;
 
if (!bh)
return;
@@ -2030,7 +2032,8 @@ static void udf_close_lvid(struct super_block *sb)
mutex_lock(&sbi->s_alloc_mutex);
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
-   udf_time_to_disk_stamp(&lvid->recordingDateAndTime, CURRENT_TIME);
+   ktime_get_real_ts(&ts);
+   udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev))
lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev))
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 13/24] fs: cifs: Replace CURRENT_TIME by get_seconds

2016-06-25 Thread Deepa Dinamani
This is in preparation for the change that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned patch.

Filesystems will use current_time() instead of
CURRENT_TIME.
Use ktime_get_real_seconds() here as this is not filesystem
time.
Only the seconds portion of the timestamp is necessary for
timezone calculation using server time.

Assume that the difference between server and client times
lie in the range INT_MIN..INT_MAX. This is valid because
this is the difference between current times between server
and client, and the largest timezone difference is in the
range of one day.

All cifs timestamps currently use timespec internally.
This timestamp can also be transitioned into using
timespec64 when all other timestamps for cifs is transitioned
to use timespec64.

Signed-off-by: Deepa Dinamani 
Cc: Steve French 
---
 fs/cifs/cifssmb.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index d47197e..6c666a3 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -478,14 +478,14 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, 
NEGOTIATE_RSP *pSMBr)
 * this requirement.
 */
int val, seconds, remain, result;
-   struct timespec ts, utc;
-   utc = CURRENT_TIME;
+   struct timespec ts;
+   unsigned long utc = ktime_get_real_seconds();
ts = cnvrtDosUnixTm(rsp->SrvTime.Date,
rsp->SrvTime.Time, 0);
cifs_dbg(FYI, "SrvTime %d sec since 1970 (utc: %d) diff: %d\n",
-(int)ts.tv_sec, (int)utc.tv_sec,
-(int)(utc.tv_sec - ts.tv_sec));
-   val = (int)(utc.tv_sec - ts.tv_sec);
+(int)ts.tv_sec, (int)utc,
+(int)(utc - ts.tv_sec));
+   val = (int)(utc - ts.tv_sec);
seconds = abs(val);
result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
remain = seconds % MIN_TZ_ADJ;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 15/24] drivers: staging: lustre: Replace CURRENT_TIME with current_time()

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_time() instead.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. As part of the effort current_time() will be
extended to do range checks. Hence, it is necessary for all
file system timestamps to use current_time().

Also change format string for prints so that these are valid
when vfs is transitioned to use 64 bit timestamps.

Signed-off-by: Deepa Dinamani 
Cc: Greg Kroah-Hartman 
Cc: lustre-de...@lists.lustre.org
Acked-by: James Simmons 
---
 drivers/staging/lustre/lustre/llite/llite_lib.c  | 16 
 drivers/staging/lustre/lustre/llite/namei.c  |  4 ++--
 drivers/staging/lustre/lustre/mdc/mdc_reint.c|  6 +++---
 .../staging/lustre/lustre/obdclass/linux/linux-obdo.c|  6 +++---
 drivers/staging/lustre/lustre/obdclass/obdo.c|  6 +++---
 drivers/staging/lustre/lustre/osc/osc_io.c   |  2 +-
 6 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 546063e..71a5b25 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1201,23 +1201,23 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr 
*attr, bool hsm_import)
 
/* We mark all of the fields "set" so MDS/OST does not re-set them */
if (attr->ia_valid & ATTR_CTIME) {
-   attr->ia_ctime = CURRENT_TIME;
+   attr->ia_ctime = current_time(inode);
attr->ia_valid |= ATTR_CTIME_SET;
}
if (!(attr->ia_valid & ATTR_ATIME_SET) &&
(attr->ia_valid & ATTR_ATIME)) {
-   attr->ia_atime = CURRENT_TIME;
+   attr->ia_atime = current_time(inode);
attr->ia_valid |= ATTR_ATIME_SET;
}
if (!(attr->ia_valid & ATTR_MTIME_SET) &&
(attr->ia_valid & ATTR_MTIME)) {
-   attr->ia_mtime = CURRENT_TIME;
+   attr->ia_mtime = current_time(inode);
attr->ia_valid |= ATTR_MTIME_SET;
}
 
if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
-   CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %llu\n",
-  LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
+   CDEBUG(D_INODE, "setting mtime %llu, ctime %llu, now = %llu\n",
+  (long long)LTIME_S(attr->ia_mtime), (long 
long)LTIME_S(attr->ia_ctime),
   (s64)ktime_get_real_seconds());
 
/* We always do an MDS RPC, even if we're only changing the size;
@@ -1503,9 +1503,9 @@ void ll_update_inode(struct inode *inode, struct 
lustre_md *md)
}
if (body->valid & OBD_MD_FLMTIME) {
if (body->mtime > LTIME_S(inode->i_mtime)) {
-   CDEBUG(D_INODE, "setting ino %lu mtime from %lu to 
%llu\n",
-  inode->i_ino, LTIME_S(inode->i_mtime),
-  body->mtime);
+   CDEBUG(D_INODE, "setting ino %lu mtime from %llu to 
%llu\n",
+  inode->i_ino, (unsigned long 
long)LTIME_S(inode->i_mtime),
+  (unsigned long long)body->mtime);
LTIME_S(inode->i_mtime) = body->mtime;
}
lli->lli_mtime = body->mtime;
diff --git a/drivers/staging/lustre/lustre/llite/namei.c 
b/drivers/staging/lustre/lustre/llite/namei.c
index 3664bfd..2c823fe 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -725,8 +725,8 @@ static void ll_update_times(struct ptlrpc_request *request,
LASSERT(body);
if (body->valid & OBD_MD_FLMTIME &&
body->mtime > LTIME_S(inode->i_mtime)) {
-   CDEBUG(D_INODE, "setting fid "DFID" mtime from %lu to %llu\n",
-  PFID(ll_inode2fid(inode)), LTIME_S(inode->i_mtime),
+   CDEBUG(D_INODE, "setting fid "DFID" mtime from %llu to %llu\n",
+  PFID(ll_inode2fid(inode)), (unsigned long 
long)LTIME_S(inode->i_mtime),
   body->mtime);
LTIME_S(inode->i_mtime) = body->mtime;
}
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c 
b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
index 5dba2c8..f78819e 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c
@@ -139,9 +139,9 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data 
*op_data,
rpc_lock = obd->u.cli.cl_rpc_lock;
 
if (op_data->op_attr.ia_valid & (ATTR_MTIME | ATTR_CTIME))
-   CDEBUG(D_INODE, "setting mtime %ld, ctime %ld\n",
-  LTIME_S(op_data->op_attr.ia_m

[Y2038] [PATCH v3 16/24] fs: ocfs2: Use time64_t to represent orphan scan times

2016-06-25 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Use time64_t which is y2038 safe to represent orphan
scan times.
time64_t is sufficient here as only the seconds delta
times are relevant.

Also use appropriate time functions that return time in
time64_t format. Time functions now return monotonic
time instead of real time as only delta scan times are
relevant and these values are not persistent across
reboots.

The format string for the debug print is still using long
as this is only the time elapsed since the last scan and
long is sufficient to represent this value.

Signed-off-by: Deepa Dinamani 
Cc: Mark Fasheh 
Cc: Joel Becker 
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/journal.c | 4 ++--
 fs/ocfs2/ocfs2.h   | 2 +-
 fs/ocfs2/super.c   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index bc0e21e..ab68933 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1949,7 +1949,7 @@ static void ocfs2_queue_orphan_scan(struct ocfs2_super 
*osb)
 */
seqno++;
os->os_count++;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
 unlock:
ocfs2_orphan_scan_unlock(osb, seqno);
 out:
@@ -2006,7 +2006,7 @@ void ocfs2_orphan_scan_start(struct ocfs2_super *osb)
struct ocfs2_orphan_scan *os;
 
os = &osb->osb_orphan_scan;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE);
else {
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index e63af7d..7e5958b 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -224,7 +224,7 @@ struct ocfs2_orphan_scan {
struct ocfs2_super  *os_osb;
struct ocfs2_lock_res   os_lockres; /* lock to synchronize scans */
struct delayed_work os_orphan_scan_work;
-   struct timespec os_scantime;  /* time this node ran the scan */
+   time64_tos_scantime;  /* time this node ran the scan */
u32 os_count;  /* tracks node specific scans */
u32 os_seqno;   /* tracks cluster wide scans */
atomic_tos_state;  /* ACTIVE or INACTIVE */
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 3971146..6992c00 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -337,7 +337,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char 
*buf, int len)
out += snprintf(buf + out, len - out, "Disabled\n");
else
out += snprintf(buf + out, len - out, "%lu seconds ago\n",
-   (get_seconds() - os->os_scantime.tv_sec));
+   (unsigned long)(ktime_get_seconds() - 
os->os_scantime));
 
out += snprintf(buf + out, len - out, "%10s => %3s  %10s\n",
"Slots", "Num", "RecoGen");
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 03/24] fs: Replace CURRENT_TIME with current_time() for inode timestamps

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_time() instead.

CURRENT_TIME is also not y2038 safe.

This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. As part of the effort current_time() will be
extended to do range checks. Hence, it is necessary for all
file system timestamps to use current_time(). Also,
current_time() will be transitioned along with vfs to be
y2038 safe.

Note that whenever a single call to current_time() is used
to change timestamps in different inodes, it is because they
share the same time granularity.

Signed-off-by: Deepa Dinamani 
Acked-by: Felipe Balbi 
Acked-by: Steven Whitehouse 
Acked-by: Ryusuke Konishi 
Acked-by: David Sterba 
---
 arch/powerpc/platforms/cell/spufs/inode.c |  2 +-
 arch/s390/hypfs/inode.c   |  4 ++--
 drivers/infiniband/hw/qib/qib_fs.c|  2 +-
 drivers/misc/ibmasm/ibmasmfs.c|  2 +-
 drivers/oprofile/oprofilefs.c |  2 +-
 drivers/usb/core/devio.c  | 18 +-
 drivers/usb/gadget/function/f_fs.c|  8 
 drivers/usb/gadget/legacy/inode.c |  2 +-
 fs/9p/vfs_inode.c |  2 +-
 fs/adfs/inode.c   |  2 +-
 fs/autofs4/inode.c|  2 +-
 fs/autofs4/root.c |  6 +++---
 fs/btrfs/inode.c  |  2 +-
 fs/devpts/inode.c |  6 +++---
 fs/efivarfs/inode.c   |  2 +-
 fs/exofs/dir.c|  6 +++---
 fs/exofs/inode.c  |  4 ++--
 fs/exofs/namei.c  |  6 +++---
 fs/ext2/super.c   |  2 +-
 fs/ext4/super.c   |  2 +-
 fs/f2fs/dir.c |  8 
 fs/f2fs/file.c|  8 
 fs/f2fs/inline.c  |  2 +-
 fs/f2fs/namei.c   | 12 ++--
 fs/f2fs/xattr.c   |  2 +-
 fs/fuse/control.c |  2 +-
 fs/gfs2/bmap.c|  8 
 fs/gfs2/dir.c | 12 ++--
 fs/gfs2/inode.c   |  8 
 fs/gfs2/quota.c   |  2 +-
 fs/gfs2/xattr.c   |  8 
 fs/hugetlbfs/inode.c  | 10 +-
 fs/jfs/acl.c  |  2 +-
 fs/jfs/inode.c|  2 +-
 fs/jfs/jfs_inode.c|  2 +-
 fs/jfs/namei.c| 22 +++---
 fs/jfs/super.c|  2 +-
 fs/jfs/xattr.c|  2 +-
 fs/libfs.c| 14 +++---
 fs/logfs/dir.c|  6 +++---
 fs/logfs/file.c   |  2 +-
 fs/logfs/inode.c  |  4 ++--
 fs/logfs/readwrite.c  |  4 ++--
 fs/nilfs2/dir.c   |  6 +++---
 fs/nilfs2/inode.c |  4 ++--
 fs/nilfs2/ioctl.c |  2 +-
 fs/nilfs2/namei.c |  6 +++---
 fs/nsfs.c |  2 +-
 fs/ocfs2/acl.c|  2 +-
 fs/ocfs2/alloc.c  |  2 +-
 fs/ocfs2/aops.c   |  2 +-
 fs/ocfs2/dir.c|  4 ++--
 fs/ocfs2/dlmfs/dlmfs.c|  4 ++--
 fs/ocfs2/file.c   | 12 ++--
 fs/ocfs2/move_extents.c   |  2 +-
 fs/ocfs2/namei.c  | 16 +---
 fs/ocfs2/refcounttree.c   |  4 ++--
 fs/ocfs2/xattr.c  |  2 +-
 fs/omfs/inode.c   |  2 +-
 fs/openpromfs/inode.c |  2 +-
 fs/orangefs/file.c|  2 +-
 fs/orangefs/inode.c   |  2 +-
 fs/orangefs/namei.c   |  2 +-
 fs/pipe.c |  2 +-
 fs/posix_acl.c|  2 +-
 fs/proc/base.c|  2 +-
 fs/proc/inode.c   |  2 +-
 fs/proc/proc_sysctl.c |  2 +-
 fs/proc/self.c|  2 +-
 fs/proc/thread_self.c |  2 +-
 fs/pstore/inode.c |  2 +-
 fs/ramfs/inode.c  |  6 +++---
 fs/reiserfs/super.c   |  2 +-
 fs/tracefs/inode.c|  2 +-
 fs/ufs/ialloc.c   |  6 --
 ipc/mqueue.c  | 18 +-
 kernel/bpf/inode.c|  2 +-
 mm/shmem.c

[Y2038] [PATCH v3 17/24] fs: ocfs2: Replace CURRENT_TIME with ktime_get_real_seconds()

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.

Use y2038 safe ktime_get_real_seconds() here for timestamps.

struct heartbeat_block's hb_seq and deletetion time are already
64 bits wide and accommodate times beyond y2038.

Signed-off-by: Deepa Dinamani 
Cc: Mark Fasheh 
Cc: Joel Becker 
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/cluster/heartbeat.c | 2 +-
 fs/ocfs2/inode.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 636abcb..9158c98 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -741,7 +741,7 @@ static inline void o2hb_prepare_block(struct o2hb_region 
*reg,
hb_block = (struct o2hb_disk_heartbeat_block *)slot->ds_raw_block;
memset(hb_block, 0, reg->hr_block_bytes);
/* TODO: time stuff */
-   cputime = CURRENT_TIME.tv_sec;
+   cputime = ktime_get_real_seconds();
if (!cputime)
cputime = 1;
 
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index c56a767..382401d 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -703,7 +703,7 @@ static int ocfs2_remove_inode(struct inode *inode,
goto bail_commit;
}
 
-   di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec);
+   di->i_dtime = cpu_to_le64(ktime_get_real_seconds());
di->i_flags &= cpu_to_le32(~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL));
ocfs2_journal_dirty(handle, di_bh);
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 18/24] audit: Use timespec64 to represent audit timestamps

2016-06-25 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani 
Cc: Paul Moore 
Cc: Eric Paris 
Cc: linux-au...@redhat.com
Acked-by: Paul Moore 
Acked-by: Richard Guy Briggs 
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c| 10 +-
 kernel/audit.h|  2 +-
 kernel/auditsc.c  |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 961a417..2f6a1123 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -335,7 +335,7 @@ static inline void audit_ptrace(struct task_struct *t)
/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial);
+ struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -510,7 +510,7 @@ static inline void __audit_seccomp(unsigned long syscall, 
long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial)
+ struct timespec64 *t, unsigned int *serial)
 {
return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index 22bb4f2..6c2f405 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1325,10 +1325,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-   *t = CURRENT_TIME;
+   ktime_get_real_ts64(t);
*serial = audit_serial();
}
 }
@@ -1370,7 +1370,7 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 int type)
 {
struct audit_buffer *ab = NULL;
-   struct timespec t;
+   struct timespec64   t;
unsigned intuninitialized_var(serial);
int reserve = 5; /* Allow atomic callers to go up to five
entries over the normal backlog limit */
@@ -1422,8 +1422,8 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 
audit_get_stamp(ab->ctx, &t, &serial);
 
-   audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-t.tv_sec, t.tv_nsec/100, serial);
+   audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+(unsigned long long)t.tv_sec, t.tv_nsec/100, 
serial);
return ab;
 }
 
diff --git a/kernel/audit.h b/kernel/audit.h
index cbbe6bb..029d674 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -111,7 +111,7 @@ struct audit_context {
enum audit_statestate, current_state;
unsigned intserial; /* serial number for record */
int major;  /* syscall number */
-   struct timespec ctime;  /* time of syscall entry */
+   struct timespec64   ctime;  /* time of syscall entry */
unsigned long   argv[4];/* syscall arguments */
longreturn_code;/* syscall return code */
u64 prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index fb1a3df..591c726 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1527,7 +1527,7 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
return;
 
context->serial = 0;
-   context->ctime  = CURRENT_TIME;
+   ktime_get_real_ts64(&context->ctime);
context->in_syscall = 1;
context->current_state  = state;
context->ppid   = 0;
@@ -1936,13 +1936,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx->in_syscall)
return 0;
-- 
1.9.1

__

[Y2038] [PATCH v3 20/24] block: Replace CURRENT_TIME with ktime_get_real_ts

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.
The macro will be deleted and all the references to it
will be replaced by ktime_get_* apis.

struct timespec is also not y2038 safe.
Retain timespec for timestamp representation here as ceph
uses it internally everywhere.
These references will be changed to use struct timespec64
in a separate patch.

Signed-off-by: Deepa Dinamani 
Cc: Ilya Dryomov 
Cc: Sage Weil 
Cc: Alex Elder 
Cc: ceph-de...@vger.kernel.org
---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 4506620..14867ab 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1888,7 +1888,7 @@ static void rbd_osd_req_format_write(struct 
rbd_obj_request *obj_request)
 {
struct ceph_osd_request *osd_req = obj_request->osd_req;
 
-   osd_req->r_mtime = CURRENT_TIME;
+   ktime_get_real_ts(&osd_req->r_mtime);
osd_req->r_data_offset = obj_request->offset;
 }
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 23/24] time: Delete current_fs_time() function

2016-06-25 Thread Deepa Dinamani
All uses of the current_fs_time() function have been
replaced by other time interfaces.

And, its use cases can be fulfilled by current_time()
or ktime_get_* variants.

Signed-off-by: Deepa Dinamani 
Cc: John Stultz 
Cc: Thomas Gleixner 
---
 include/linux/fs.h |  1 -
 kernel/time/time.c | 14 --
 2 files changed, 15 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index d0d9b38..5befa38 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1475,7 +1475,6 @@ struct super_block {
struct list_heads_inodes_wb;/* writeback inodes */
 };
 
-extern struct timespec current_fs_time(struct super_block *sb);
 extern struct timespec current_time(struct inode *inode);
 
 static inline struct timespec current_fs_time_sec(struct super_block *sb)
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 667b933..1ef0b4d 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -230,20 +230,6 @@ SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
 }
 
-/**
- * current_fs_time - Return FS time
- * @sb: Superblock.
- *
- * Return the current time truncated to the time granularity supported by
- * the fs.
- */
-struct timespec current_fs_time(struct super_block *sb)
-{
-   struct timespec now = current_kernel_time();
-   return timespec_trunc(now, sb->s_time_gran);
-}
-EXPORT_SYMBOL(current_fs_time);
-
 /*
  * Convert jiffies to milliseconds and back.
  *
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 19/24] fs: nfs: Make nfs boot time y2038 safe

2016-06-25 Thread Deepa Dinamani
boot_time is represented as a struct timespec.
struct timespec and CURRENT_TIME are not y2038 safe.
Overall, the plan is to use timespec64 and ktime_t for
all internal kernel representation of timestamps.
CURRENT_TIME will also be removed.

boot_time is used to construct the nfs client boot verifier.

Use ktime_t to represent boot_time and ktime_get_real() for
the boot_time value.

Following Trond's request https://lkml.org/lkml/2016/6/9/22 ,
use ktime_t instead of converting to struct timespec64.

Use higher and lower 32 bit parts of ktime_t for the boot
verifier.

Use the lower 32 bit part of ktime_t for the authsys_parms
stamp field.

Signed-off-by: Deepa Dinamani 
Cc: Trond Myklebust 
Cc: Anna Schumaker 
Cc: linux-...@vger.kernel.org
---
 fs/nfs/client.c   |  2 +-
 fs/nfs/netns.h|  2 +-
 fs/nfs/nfs4proc.c | 10 ++
 fs/nfs/nfs4xdr.c  |  2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 4849d0f..92798bb 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1078,7 +1078,7 @@ void nfs_clients_init(struct net *net)
idr_init(&nn->cb_ident_idr);
 #endif
spin_lock_init(&nn->nfs_client_lock);
-   nn->boot_time = CURRENT_TIME;
+   nn->boot_time = ktime_get_real();
 }
 
 #ifdef CONFIG_PROC_FS
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index f0e06e4..fbce0d8 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -29,7 +29,7 @@ struct nfs_net {
int cb_users[NFS4_MAX_MINOR_VERSION + 1];
 #endif
spinlock_t nfs_client_lock;
-   struct timespec boot_time;
+   ktime_t boot_time;
 #ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfsfs;
 #endif
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 406dd3e..8d9b5a9 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5062,12 +5062,14 @@ static void nfs4_init_boot_verifier(const struct 
nfs_client *clp,
if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) {
/* An impossible timestamp guarantees this value
 * will never match a generated boot time. */
-   verf[0] = 0;
-   verf[1] = cpu_to_be32(NSEC_PER_SEC + 1);
+   verf[0] = cpu_to_be32(U32_MAX);
+   verf[1] = cpu_to_be32(U32_MAX);
} else {
struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
-   verf[0] = cpu_to_be32(nn->boot_time.tv_sec);
-   verf[1] = cpu_to_be32(nn->boot_time.tv_nsec);
+   u64 ns = ktime_to_ns(nn->boot_time);
+
+   verf[0] = cpu_to_be32(ns >> 32);
+   verf[1] = cpu_to_be32(ns);
}
memcpy(bootverf->data, verf, sizeof(bootverf->data));
 }
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 661e753..5944be0 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1850,7 +1850,7 @@ static void encode_create_session(struct xdr_stream *xdr,
*p++ = cpu_to_be32(RPC_AUTH_UNIX);  /* auth_sys */
 
/* authsys_parms rfc1831 */
-   *p++ = cpu_to_be32(nn->boot_time.tv_nsec);  /* stamp */
+   *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
*p++ = cpu_to_be32(0);  /* UID */
*p++ = cpu_to_be32(0);  /* GID */
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 21/24] libceph: Replace CURRENT_TIME with ktime_get_real_ts

2016-06-25 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.
The macro will be deleted and all the references to it
will be replaced by ktime_get_* apis.

struct timespec is also not y2038 safe.
Retain timespec for timestamp representation here as ceph
uses it internally everywhere.
These references will be changed to use struct timespec64
in a separate patch.

Signed-off-by: Deepa Dinamani 
Cc: "Yan, Zheng" 
Cc: Sage Weil 
Cc: Ilya Dryomov 
Cc: ceph-de...@vger.kernel.org
---
 net/ceph/messenger.c  | 6 --
 net/ceph/osd_client.c | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index a550289..1825eed 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1366,8 +1366,9 @@ static void prepare_write_keepalive(struct 
ceph_connection *con)
dout("prepare_write_keepalive %p\n", con);
con_out_kvec_reset(con);
if (con->peer_features & CEPH_FEATURE_MSGR_KEEPALIVE2) {
-   struct timespec now = CURRENT_TIME;
+   struct timespec now;
 
+   ktime_get_real_ts(&now);
con_out_kvec_add(con, sizeof(tag_keepalive2), &tag_keepalive2);
ceph_encode_timespec(&con->out_temp_keepalive2, &now);
con_out_kvec_add(con, sizeof(con->out_temp_keepalive2),
@@ -3149,8 +3150,9 @@ bool ceph_con_keepalive_expired(struct ceph_connection 
*con,
 {
if (interval > 0 &&
(con->peer_features & CEPH_FEATURE_MSGR_KEEPALIVE2)) {
-   struct timespec now = CURRENT_TIME;
+   struct timespec now;
struct timespec ts;
+   ktime_get_real_ts(&now);
jiffies_to_timespec(interval, &ts);
ts = timespec_add(con->last_keepalive_ack, ts);
return timespec_compare(&now, &ts) >= 0;
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 8946959..44eb2d0 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -3567,7 +3567,7 @@ ceph_osdc_watch(struct ceph_osd_client *osdc,
ceph_oid_copy(&lreq->t.base_oid, oid);
ceph_oloc_copy(&lreq->t.base_oloc, oloc);
lreq->t.flags = CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK;
-   lreq->mtime = CURRENT_TIME;
+   ktime_get_real_ts(&lreq->mtime);
 
lreq->reg_req = alloc_linger_request(lreq);
if (!lreq->reg_req) {
@@ -3625,7 +3625,7 @@ int ceph_osdc_unwatch(struct ceph_osd_client *osdc,
ceph_oid_copy(&req->r_base_oid, &lreq->t.base_oid);
ceph_oloc_copy(&req->r_base_oloc, &lreq->t.base_oloc);
req->r_flags = CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK;
-   req->r_mtime = CURRENT_TIME;
+   ktime_get_real_ts(&req->r_mtime);
osd_req_op_watch_init(req, 0, lreq->linger_id,
  CEPH_OSD_WATCH_OP_UNWATCH);
 
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 22/24] fs: ceph: Replace current_fs_time for request stamp

2016-06-25 Thread Deepa Dinamani
The current_fs_time() api is being changed to use vfs
struct inode* as an argument instead of struct super_block*.

Set the new mds client request r_stamp field using
ktime_get_real_ts() instead of using current_fs_time().

Also, since r_stamp is used as mtime on the server, use
timespec_trunc() to truncate the timestamp, using the right
granularity from the superblock.

This api will be transitioned to be y2038 safe along
with vfs.

Signed-off-by: Deepa Dinamani 
Cc: "Yan, Zheng" 
Cc: Sage Weil 
Cc: Ilya Dryomov 
Cc: ceph-de...@vger.kernel.org
---
 fs/ceph/mds_client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 2103b82..c6cae7a 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1697,6 +1697,7 @@ struct ceph_mds_request *
 ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode)
 {
struct ceph_mds_request *req = kzalloc(sizeof(*req), GFP_NOFS);
+   struct timespec ts;
 
if (!req)
return ERR_PTR(-ENOMEM);
@@ -1715,7 +1716,8 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, 
int op, int mode)
init_completion(&req->r_safe_completion);
INIT_LIST_HEAD(&req->r_unsafe_item);
 
-   req->r_stamp = current_fs_time(mdsc->fsc->sb);
+   ktime_get_real_ts(&ts);
+   req->r_stamp = timespec_trunc(ts, mdsc->fsc->sb->s_time_gran);
 
req->r_op = op;
req->r_direct_mode = mode;
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH v3 24/24] time: Delete CURRENT_TIME_SEC

2016-06-25 Thread Deepa Dinamani
All uses of CURRENT_TIME_SEC macro have been replaced by
other time functions.  This macro is also not y2038 safe.
And, all its use cases can be fulfilled by y2038 safe
ktime_get_* variants.

Signed-off-by: Deepa Dinamani 
Cc: John Stultz 
Cc: Thomas Gleixner 
Acked-by: John Stultz 
---
 include/linux/time.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/time.h b/include/linux/time.h
index 4cea09d..9c3f345 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -152,7 +152,6 @@ static inline bool timespec_inject_offset_valid(const 
struct timespec *ts)
 }
 
 #define CURRENT_TIME   (current_kernel_time())
-#define CURRENT_TIME_SEC   ((struct timespec) { get_seconds(), 0 })
 
 /* Some architectures do not supply their own clocksource.
  * This is mainly the case in architectures that get their
-- 
1.9.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038