diff mbox series

fs: clarify the rerurn value check for inode_needs_update_time

Message ID 20221011020212.131100-1-joseph.qi@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series fs: clarify the rerurn value check for inode_needs_update_time | expand

Commit Message

Joseph Qi Oct. 11, 2022, 2:02 a.m. UTC
inode_needs_update_time() can only returns >0 or 0, which means inode
needs sync or not.
So cleanup the callers return value check, and also cleanup redundant
check in the function before return.

Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
---
 fs/inode.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Jan Kara Oct. 11, 2022, 4:02 p.m. UTC | #1
On Tue 11-10-22 10:02:12, Joseph Qi wrote:
> inode_needs_update_time() can only returns >0 or 0, which means inode
> needs sync or not.
> So cleanup the callers return value check, and also cleanup redundant
> check in the function before return.
> 
> Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>

OK, makes sense. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/inode.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index b608528efd3a..d8f4ba98549a 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -2071,9 +2071,6 @@ static int inode_needs_update_time(struct inode *inode, struct timespec64 *now)
>  	if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode))
>  		sync_it |= S_VERSION;
>  
> -	if (!sync_it)
> -		return 0;
> -
>  	return sync_it;
>  }
>  
> @@ -2113,7 +2110,7 @@ int file_update_time(struct file *file)
>  	struct timespec64 now = current_time(inode);
>  
>  	ret = inode_needs_update_time(inode, &now);
> -	if (ret <= 0)
> +	if (!ret)
>  		return ret;
>  
>  	return __file_update_time(file, &now, ret);
> @@ -2153,7 +2150,7 @@ static int file_modified_flags(struct file *file, int flags)
>  		return 0;
>  
>  	ret = inode_needs_update_time(inode, &now);
> -	if (ret <= 0)
> +	if (!ret)
>  		return ret;
>  	if (flags & IOCB_NOWAIT)
>  		return -EAGAIN;
> -- 
> 2.24.4
>
diff mbox series

Patch

diff --git a/fs/inode.c b/fs/inode.c
index b608528efd3a..d8f4ba98549a 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2071,9 +2071,6 @@  static int inode_needs_update_time(struct inode *inode, struct timespec64 *now)
 	if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode))
 		sync_it |= S_VERSION;
 
-	if (!sync_it)
-		return 0;
-
 	return sync_it;
 }
 
@@ -2113,7 +2110,7 @@  int file_update_time(struct file *file)
 	struct timespec64 now = current_time(inode);
 
 	ret = inode_needs_update_time(inode, &now);
-	if (ret <= 0)
+	if (!ret)
 		return ret;
 
 	return __file_update_time(file, &now, ret);
@@ -2153,7 +2150,7 @@  static int file_modified_flags(struct file *file, int flags)
 		return 0;
 
 	ret = inode_needs_update_time(inode, &now);
-	if (ret <= 0)
+	if (!ret)
 		return ret;
 	if (flags & IOCB_NOWAIT)
 		return -EAGAIN;