diff mbox

[RFC,v2b,3/5] fs: btrfs: Use vfs_time accessors

Message ID 1455270349-3187-4-git-send-email-deepa.kernel@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Deepa Dinamani Feb. 12, 2016, 9:45 a.m. UTC
This is in preparation for changing VFS inode timestamps to
use 64 bit time.
The VFS inode timestamps are not y2038 safe as they use
struct timespec. These will be changed to use struct timespec64
instead and that is y2038 safe.
But, since the above data type conversion will break the
end file systems, use vfs_time functions to access inode times.

Note that the btrfs_update_time() has not been changed in this
patch. This will need to be updated along with vfs time
data type changes. This is because the function signature is
decided by the VFS layer since it is a VFS inode operations
callback.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
---
 fs/btrfs/file.c  | 14 +++++++++-----
 fs/btrfs/inode.c |  4 ++--
 2 files changed, 11 insertions(+), 7 deletions(-)

Comments

Arnd Bergmann Feb. 12, 2016, 1:57 p.m. UTC | #1
On Friday 12 February 2016 01:45:47 Deepa Dinamani wrote:
> +       ts = vfs_time_to_timespec(inode->i_mtime);
> +       if (!timespec_equal(&ts, &now))
> +               inode->i_mtime = timespec_to_vfs_time(now);
> +
> +       ts = vfs_time_to_timespec(inode->i_mtime);
> +       if (!timespec_equal(&ts, &now))
> +               inode->i_ctime = timespec_to_vfs_time(now);
> 

The second one needs to be fs_time_to_timespec(inode->i_ctime), not i_mtime.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Deepa Dinamani Feb. 13, 2016, 7:01 a.m. UTC | #2
On Fri, Feb 12, 2016 at 5:57 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Friday 12 February 2016 01:45:47 Deepa Dinamani wrote:
>> +       ts = vfs_time_to_timespec(inode->i_mtime);
>> +       if (!timespec_equal(&ts, &now))
>> +               inode->i_mtime = timespec_to_vfs_time(now);
>> +
>> +       ts = vfs_time_to_timespec(inode->i_mtime);
>> +       if (!timespec_equal(&ts, &now))
>> +               inode->i_ctime = timespec_to_vfs_time(now);
>>
>
> The second one needs to be fs_time_to_timespec(inode->i_ctime), not i_mtime.


Yes, you are correct.
I will wait for some consensus on the proposal to figure out which
version to post again.

Thanks,
-Deepa
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 610f569..3bccb97 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1733,16 +1733,20 @@  out:
 static void update_time_for_write(struct inode *inode)
 {
 	struct timespec now;
+	struct timespec ts;
 
 	if (IS_NOCMTIME(inode))
 		return;
 
-	now = current_fs_time(inode->i_sb);
-	if (!timespec_equal(&inode->i_mtime, &now))
-		inode->i_mtime = now;
+	now = vfs_time_to_timespec(current_fs_time(inode->i_sb));
 
-	if (!timespec_equal(&inode->i_ctime, &now))
-		inode->i_ctime = now;
+	ts = vfs_time_to_timespec(inode->i_mtime);
+	if (!timespec_equal(&ts, &now))
+		inode->i_mtime = timespec_to_vfs_time(now);
+
+	ts = vfs_time_to_timespec(inode->i_mtime);
+	if (!timespec_equal(&ts, &now))
+		inode->i_ctime = timespec_to_vfs_time(now);
 
 	if (IS_I_VERSION(inode))
 		inode_inc_iversion(inode);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 59c0e22..5b93cf8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5592,7 +5592,7 @@  static struct inode *new_simple_dir(struct super_block *s,
 	inode->i_mtime = current_fs_time(inode->i_sb);
 	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 = vfs_time_to_timespec(inode->i_mtime);
 
 	return inode;
 }
@@ -6164,7 +6164,7 @@  static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
 	inode->i_mtime = current_fs_time(inode->i_sb);
 	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 = vfs_time_to_timespec(inode->i_mtime);
 
 	inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
 				  struct btrfs_inode_item);