Re: [PATCH v2 06/24] fs: ext4: Use current_time() for inode timestamps
From: Deepa Dinamani
Date: Fri Jun 24 2016 - 19:08:57 EST
>> @@ -3727,6 +3727,7 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>> };
>> u8 new_file_type;
>> int retval;
>> + struct timespec ctime;
>>
>> if ((ext4_encrypted_inode(old_dir) ||
>> ext4_encrypted_inode(new_dir)) &&
>> @@ -3829,8 +3830,9 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>> * Like most other Unix systems, set the ctime for inodes on a
>> * rename.
>> */
>> - old.inode->i_ctime = ext4_current_time(old.inode);
>> - new.inode->i_ctime = ext4_current_time(new.inode);
>> + ctime = current_time(old.inode);
>> + old.inode->i_ctime = ctime;
>> + new.inode->i_ctime = ctime;
>> ext4_mark_inode_dirty(handle, old.inode);
>> ext4_mark_inode_dirty(handle, new.inode);
>>
>
> Adding a local variable here looks like it is going to cause us trouble when we
> change the return type of current_time() to timespec64.
>
> I'd write this as
>
> new.inode->i_ctime = old.inode->i_ctime;
>
> instead.
This should be fine.
There are already instances that use local timespecs for inode time assignments.
These can be changed this way:
+ ctime = vfs_time_to_timespec(current_time(old.inode));
+ old.inode->i_ctime = timespec_to_vfs_time(ctime);
+ new.inode->i_ctime = timespec_to_vfs_time(ctime);
This could be a little inefficient, but only temporary.
The local variable can be changed to timespec64 when the macros are deleted.
I'm trying to make minimal changes.
-Deepa