diff mbox

[06/12,linux-next] udf: add udf_ajust_time

Message ID 1483736037-25111-7-git-send-email-fabf@skynet.be (mailing list archive)
State New, archived
Headers show

Commit Message

Fabian Frederick Jan. 6, 2017, 8:53 p.m. UTC
Merge timespec affectations

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/udf/inode.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Comments

Jan Kara Jan. 10, 2017, 10:44 a.m. UTC | #1
On Fri 06-01-17 21:53:54, Fabian Frederick wrote:
> Merge timespec affectations
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>

Thanks. I've just renamed the function to udf_trim_crtime() which better
describes what it does.

								Honza

> ---
>  fs/udf/inode.c | 25 +++++++++++--------------
>  1 file changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> index b5893f4..f563e97 100644
> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -1612,6 +1612,14 @@ static int udf_sync_inode(struct inode *inode)
>  	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)
>  {
>  	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->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
>  
> -		if (iinfo->i_crtime.tv_sec > inode->i_atime.tv_sec ||
> -		    (iinfo->i_crtime.tv_sec == inode->i_atime.tv_sec &&
> -		     iinfo->i_crtime.tv_nsec > inode->i_atime.tv_nsec))
> -			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_adjust_time(iinfo, inode->i_atime);
> +		udf_adjust_time(iinfo, inode->i_mtime);
> +		udf_adjust_time(iinfo, inode->i_ctime);
>  
>  		udf_time_to_disk_stamp(&efe->accessTime, inode->i_atime);
>  		udf_time_to_disk_stamp(&efe->modificationTime, inode->i_mtime);
> -- 
> 2.7.4
> 
>
diff mbox

Patch

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index b5893f4..f563e97 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1612,6 +1612,14 @@  static int udf_sync_inode(struct inode *inode)
 	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)
 {
 	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->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
 
-		if (iinfo->i_crtime.tv_sec > inode->i_atime.tv_sec ||
-		    (iinfo->i_crtime.tv_sec == inode->i_atime.tv_sec &&
-		     iinfo->i_crtime.tv_nsec > inode->i_atime.tv_nsec))
-			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_adjust_time(iinfo, inode->i_atime);
+		udf_adjust_time(iinfo, inode->i_mtime);
+		udf_adjust_time(iinfo, inode->i_ctime);
 
 		udf_time_to_disk_stamp(&efe->accessTime, inode->i_atime);
 		udf_time_to_disk_stamp(&efe->modificationTime, inode->i_mtime);