udf: Factor out trimming of crtime

Factor out trimming of crtime field.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Fabian Frederick 2017-01-06 21:53:54 +01:00 committed by Jan Kara
parent d50c4dd527
commit 7ed0fbd7e3
1 changed files with 11 additions and 14 deletions

View File

@ -1612,6 +1612,14 @@ static int udf_sync_inode(struct inode *inode)
return udf_update_inode(inode, 1); return udf_update_inode(inode, 1);
} }
static void udf_adjust_time(struct udf_inode_info *iinfo, struct timespec time)
{
if (iinfo->i_crtime.tv_sec > time.tv_sec ||
(iinfo->i_crtime.tv_sec == time.tv_sec &&
iinfo->i_crtime.tv_nsec > time.tv_nsec))
iinfo->i_crtime = time;
}
static int udf_update_inode(struct inode *inode, int do_sync) static int udf_update_inode(struct inode *inode, int do_sync)
{ {
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
@ -1738,20 +1746,9 @@ static int udf_update_inode(struct inode *inode, int do_sync)
efe->objectSize = cpu_to_le64(inode->i_size); efe->objectSize = cpu_to_le64(inode->i_size);
efe->logicalBlocksRecorded = cpu_to_le64(lb_recorded); efe->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
if (iinfo->i_crtime.tv_sec > inode->i_atime.tv_sec || udf_adjust_time(iinfo, inode->i_atime);
(iinfo->i_crtime.tv_sec == inode->i_atime.tv_sec && udf_adjust_time(iinfo, inode->i_mtime);
iinfo->i_crtime.tv_nsec > inode->i_atime.tv_nsec)) udf_adjust_time(iinfo, inode->i_ctime);
iinfo->i_crtime = inode->i_atime;
if (iinfo->i_crtime.tv_sec > inode->i_mtime.tv_sec ||
(iinfo->i_crtime.tv_sec == inode->i_mtime.tv_sec &&
iinfo->i_crtime.tv_nsec > inode->i_mtime.tv_nsec))
iinfo->i_crtime = inode->i_mtime;
if (iinfo->i_crtime.tv_sec > inode->i_ctime.tv_sec ||
(iinfo->i_crtime.tv_sec == inode->i_ctime.tv_sec &&
iinfo->i_crtime.tv_nsec > inode->i_ctime.tv_nsec))
iinfo->i_crtime = inode->i_ctime;
udf_time_to_disk_stamp(&efe->accessTime, inode->i_atime); udf_time_to_disk_stamp(&efe->accessTime, inode->i_atime);
udf_time_to_disk_stamp(&efe->modificationTime, inode->i_mtime); udf_time_to_disk_stamp(&efe->modificationTime, inode->i_mtime);